mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-28 04:58:46 +02:00
N°6414 Validator refactoring
New AbstractValidator class, with new method Validate All existing validators are now children of AbstractRegexpValidator Handle validators JS counterparts in renderers : only regexp validators are implemented client side
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2023 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Sources\Form\Validator;
|
||||
|
||||
use Combodo\iTop\Form\Field\StringField;
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
|
||||
class ValidatorTest extends ItopTestCase
|
||||
{
|
||||
public function testMandatoryValidator()
|
||||
{
|
||||
$oField = new StringField('test');
|
||||
$oField->SetMandatory(true);
|
||||
$oField->SetCurrentValue('there is a value !');
|
||||
|
||||
$bIsMandatoryFieldValidWithExistingValue = $oField->Validate();
|
||||
$this->assertTrue($bIsMandatoryFieldValidWithExistingValue);
|
||||
|
||||
$oField->SetCurrentValue(null);
|
||||
$bIsMandatoryFieldValidWithNoValue = $oField->Validate();
|
||||
$this->assertFalse($bIsMandatoryFieldValidWithNoValue);
|
||||
$this->assertNotEmpty($oField->GetErrorMessages());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user