Skip to content

Commit

Permalink
✅ BASE #129 new PHPUnit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Jul 24, 2020
1 parent d9b423b commit 2d8f965
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TFormDinGenericField
*/
public function __construct($adiantiObj
,string $id
,string $label
,$label
,$boolRequired = false
,string $value=null
,string $placeholder =null)
Expand Down Expand Up @@ -95,12 +95,13 @@ public function getAdiantiObj(){
protected function setLabelTxt($label){
$this->labelTxt = $label;
}
protected function getLabelTxt(){
public function getLabelTxt(){
return $this->labelTxt;
}

protected function setLabel($label,$boolRequired){
public function setLabel($label,$boolRequired){
if(!empty($label)){
$this->setLabelTxt($label);
$formDinLabelField = new TFormDinLabelField($label,$boolRequired);
$label = $formDinLabelField->getAdiantiObj();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?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.
*/

require_once __DIR__.'/../../../mockFormAdianti.php';

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

class TFormDinGenericFieldTest extends TestCase
{

private $classTest;

/**
* Prepares the environment before running a test.
*/
protected function setUp(): void {
parent::setUp();
$id = 'id1';
$adiantiObj = new TText($id);
$this->classTest = new TFormDinGenericField($adiantiObj,$id,'Texto1');
}

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

public function test_instanceOff()
{
$adiantiObj = $this->classTest->getAdiantiObj();
$this->assertInstanceOf(TText::class, $adiantiObj);
}

public function testSetAdiantiObj_failNullLavel()
{
$this->expectNotToPerformAssertions();

$id = 'id1';
$adiantiObj = new TText($id);
$classTest = new TFormDinGenericField($adiantiObj,$id,null);
}

public function testsetLabel()
{
$labelTxtEsperado = 'kkk';
$this->classTest->setLabel($labelTxtEsperado,true);
$labelAdiantiObj = $this->classTest->getLabel();
$label = $this->classTest->getLabelTxt();
$this->assertInstanceOf(TLabel::class, $labelAdiantiObj);
$this->assertEquals($labelTxtEsperado, $label);
}
}

0 comments on commit 2d8f965

Please sign in to comment.