"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/framework/validators/EachValidatorTest.php" between
yii2-2.0.35.tar.gz and yii2-2.0.36.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

EachValidatorTest.php  (yii2-2.0.35):EachValidatorTest.php  (yii2-2.0.36)
skipping to change at line 15 skipping to change at line 15
* @license http://www.yiiframework.com/license/ * @license http://www.yiiframework.com/license/
*/ */
namespace yiiunit\framework\validators; namespace yiiunit\framework\validators;
use yii\validators\EachValidator; use yii\validators\EachValidator;
use yiiunit\data\base\ArrayAccessObject; use yiiunit\data\base\ArrayAccessObject;
use yiiunit\data\base\Speaker; use yiiunit\data\base\Speaker;
use yiiunit\data\validators\models\FakedValidationModel; use yiiunit\data\validators\models\FakedValidationModel;
use yiiunit\data\validators\models\ValidatorTestTypedPropModel; use yiiunit\data\validators\models\ValidatorTestTypedPropModel;
use yiiunit\data\validators\models\ValidatorTestEachAndInlineMethodModel;
use yiiunit\TestCase; use yiiunit\TestCase;
/** /**
* @group validators * @group validators
*/ */
class EachValidatorTest extends TestCase class EachValidatorTest extends TestCase
{ {
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
skipping to change at line 241 skipping to change at line 242
$model = new Speaker(); $model = new Speaker();
$model->customLabel = ['invalid_ip']; $model->customLabel = ['invalid_ip'];
$validator = new EachValidator(['rule' => ['ip']]); $validator = new EachValidator(['rule' => ['ip']]);
$validator->validateAttribute($model, 'customLabel'); $validator->validateAttribute($model, 'customLabel');
$validator->validateAttribute($model, 'firstName'); $validator->validateAttribute($model, 'firstName');
$this->assertEquals('This is the custom label must be a valid IP address .', $model->getFirstError('customLabel')); $this->assertEquals('This is the custom label must be a valid IP address .', $model->getFirstError('customLabel'));
$this->assertEquals('First Name is invalid.', $model->getFirstError('fir stName')); $this->assertEquals('First Name is invalid.', $model->getFirstError('fir stName'));
} }
* @see https://github.com/yiisoft/yii2/issues/18051
public function testCustomMethod()
$model = new Speaker();
$model->firstName = ['a', 'b'];
$validator = new EachValidator(['rule' => ['customValidatingMethod']]);
$validator->validateAttribute($model, 'firstName');
$this->assertEquals('Custom method error', $model->getFirstError('firstN
// make sure each value of attribute array is checked separately
$this->assertEquals(['a', 'b'], $model->getCheckedValues());
// make sure original array is restored at the end
$this->assertEquals(['a', 'b'], $model->firstName);
public function testAnonymousMethod()
$model = new ValidatorTestEachAndInlineMethodModel();
} }
 End of changes. 2 change blocks. 
0 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)