Skip to content

Commit

Permalink
🔨 BASE #107 PHPUnit e novos metodos
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Jul 12, 2020
1 parent c5e098b commit ee12a8b
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 34 deletions.
100 changes: 66 additions & 34 deletions appexemplo_v1.0/app/lib/widget/FormDin5/webform/TFormDinGrid.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ public function __construct( $strName
$bootgrid->width = '100%';
$this->setAdiantiObj($bootgrid);
$this->setId($strName);
if($boolDataTable){
$this->adiantiObj->datatable = 'true';
}
if(!$boolDefaultClick){
$this->adiantiObj->disableDefaultClick();
}
$this->setAction($action);

$this->setTitle($title);
$this->setKey($key);
}

public function validateDeprecated($strHeigh,$strWidth)
Expand All @@ -163,7 +153,7 @@ public function validateDeprecated($strHeigh,$strWidth)

public function setAdiantiObj( $bootgrid )
{
if( !($bootgrid instanceof BootstrapFormBuilder) ){
if( !($bootgrid instanceof BootstrapDatagridWrapper) ){
throw new InvalidArgumentException(TFormDinMessage::ERROR_FD5_OBJ_BOOTGRID);
}
$this->adiantiObj = $bootgrid;
Expand All @@ -176,27 +166,6 @@ public function getAdiantiObj(){
return $this->adiantiObj;
}

/**
* Coluna do Grid Padronizado em BoorStrap
* Reconstruido FormDin 4 Sobre o Adianti 7.1
*
* @param string $name = Name of the column in the database
* @param string $label = Text label that will be shown in the header
* @param string $align = Column align (left, center, right)
* @param string $width = Column Width (pixels)
* @return TDataGridColumn
*/
public function addColumn(string $name
, string $label
, string $align='left'
, string $width = NULL){
$action = $this->getAction();
$formDinGridColumn = new TFormDinGridColumn($action, $name, $label,$align,$width);
$column = $formDinGridColumn->getAdiantiObj();
$this->adiantiObj->addColumn($column);
return $column;
}

public function getAction(){
return $this->action;
}
Expand All @@ -205,11 +174,15 @@ public function setAction($action){
$this->action = $action;
}

public function getIdGrid(){
public function getId(){
return $this->idGrid;
}

public function setIdGrid(string $idGrid){
public function setId(string $idGrid){
if(empty($idGrid)){
throw new InvalidArgumentException(TFormDinMessage::ERROR_EMPTY_INPUT);
}
$this->getAdiantiObj()->setId($idGrid);
$this->idGrid = $idGrid;
}

Expand All @@ -229,6 +202,65 @@ public function setKey(string $key){
$this->key = $key;
}

public function enableDataTable(){
$this->getAdiantiObj()->datatable = 'true';
}

public function disableDataTable(){
$this->getAdiantiObj()->datatable = 'false';
}

/**
* Coluna do Grid Padronizado em BoorStrap
* Reconstruido FormDin 4 Sobre o Adianti 7.1
*
* @param string $name = Name of the column in the database
* @param string $label = Text label that will be shown in the header
* @param string $align = Column align (left, center, right)
* @param string $width = Column Width (pixels)
* @return TDataGridColumn
*/
public function addColumn(string $name
, string $label
, string $align='left'
, string $width = NULL){
$action = $this->getAction();
$formDinGridColumn = new TFormDinGridColumn($action, $name, $label,$align,$width);
$column = $formDinGridColumn->getAdiantiObj();
$this->adiantiObj->addColumn($column);
return $column;
}

//---------------------------------------------------------------------------------------
/**
* coluna tipo checkbox. Irá criar no gride uma coluno do tipo checkbox. Quando é feito o POST
* será criado uma nova variavel com valor de strName
*
*
* @param string $strName - Nome do variavel no POST
* @param string $strTitle - Titulo que aparece no grid
* @param string $strKeyField - Valor que será passado no POST
* @param string $strDescField - Descrição do campo, valor que irá aparecer o gride
* @param boolean $boolReadOnly
* @param boolean $boolAllowCheckAll - TRUE = pode selecionar todos , FALSE = não permite multiplas seleções
* @return TGridCheckColumn
*/
public function addCheckColumn( $strName
, $strTitle = null
, $strKeyField
, $strDescField = null
, $boolReadOnly = null
, $boolAllowCheckAll = null )
{
if ( !$strKeyField )
{
$strKeyField = strtoupper( $strName );
}
$this->getAdiantiObj()->disableDefaultClick(); //IMPORTANTE DESATIVAR
$col = new TGridCheckColumn( $strName, $strTitle, $strKeyField, $strDescField, $boolReadOnly, $boolAllowCheckAll );
$this->columns[ strtolower( $strName )] = $col;
return $col;
}


//------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/*
* ----------------------------------------------------------------------------
* Formdin 5 Framework
* SourceCode https://github.com/bjverde/formDin5
* @author Reinaldo A. Barrêto Junior
*
* É uma reconstrução do FormDin 4 Sobre o Adianti 7.X
* ----------------------------------------------------------------------------
* This file is part of Formdin Framework.
*
* Formdin Framework is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License version 3
* along with this program; if not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc., 51 Franklin Street,
* Fifth Floor, Boston, MA 02110-1301, USA.
* ----------------------------------------------------------------------------
* Este arquivo é parte do Framework Formdin.
*
* O Framework Formdin é um software livre; você pode redistribuí-lo e/ou
* modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
* do Software Livre (FSF).
*
* Este programa é distribuí1do na esperança que possa ser útil, mas SEM NENHUMA
* GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
* APLICAÇÃO EM PARTICULAR. Veja a Licen?a Pública Geral GNU/LGPL em portugu?s
* para maiores detalhes.
*
* Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
* "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
* ou escreva para a Fundação do Software Livre (FSF) Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
*/

$path = __DIR__.'/../../../../../';
//require_once $path.'tests/initTest.php';

use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Error\Warning;

class TFormDinGridTest extends TestCase
{

private $classTest;

/**
* Prepares the environment before running a test.
*/
protected function setUp(): void {
parent::setUp();
$this->classTest = new TFormDinGrid('grid');
}

/**
* Cleans up the environment after running a test.
*/
protected function tearDown(): void {
$this->classTest = null;
parent::tearDown();
}


public function testConstruct_Height()
{
$this->expectException(InvalidArgumentException::class);
$grid = new TFormDinGrid('grid',null,null,700);
}
public function testConstruct_Width()
{
$this->expectException(InvalidArgumentException::class);
$grid = new TFormDinGrid('grid',null,null,null,700);
}

}

0 comments on commit ee12a8b

Please sign in to comment.