"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/framework/validators/ValidatorTest.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).

ValidatorTest.php  (yii2-2.0.35):ValidatorTest.php  (yii2-2.0.36)
skipping to change at line 74 skipping to change at line 74
'boolean', 'boolean',
$model, $model,
['attr_test1', 'attr_test2'], ['attr_test1', 'attr_test2'],
['on' => ['a', 'b'], 'except' => ['c', 'd', 'e']] ['on' => ['a', 'b'], 'except' => ['c', 'd', 'e']]
); );
$this->assertInstanceOf(BooleanValidator::className(), $val); $this->assertInstanceOf(BooleanValidator::className(), $val);
$this->assertSame(['a', 'b'], $val->on); $this->assertSame(['a', 'b'], $val->on);
$this->assertSame(['c', 'd', 'e'], $val->except); $this->assertSame(['c', 'd', 'e'], $val->except);
$val = TestValidator::createValidator('inlineVal', $model, ['val_attr_a' ], ['params' => ['foo' => 'bar']]); $val = TestValidator::createValidator('inlineVal', $model, ['val_attr_a' ], ['params' => ['foo' => 'bar']]);
$this->assertInstanceOf(InlineValidator::className(), $val); $this->assertInstanceOf(InlineValidator::className(), $val);
$this->assertSame('inlineVal', $val->method); $this->assertSame('inlineVal', $val->method[1]);
$this->assertSame(['foo' => 'bar'], $val->params); $this->assertSame(['foo' => 'bar'], $val->params);
} }
/** /**
* @see https://github.com/yiisoft/yii2/issues/14370 * @see https://github.com/yiisoft/yii2/issues/14370
*/ */
public function testCreateBuiltInValidatorWithSameNameFunction() public function testCreateBuiltInValidatorWithSameNameFunction()
{ {
$model = new ValidatorTestFunctionModel(); $model = new ValidatorTestFunctionModel();
skipping to change at line 205 skipping to change at line 205
$this->expectExceptionMessage(TestValidator::className() . ' does not su pport validateValue().'); $this->expectExceptionMessage(TestValidator::className() . ' does not su pport validateValue().');
$val = new TestValidator(); $val = new TestValidator();
$val->validate('abc'); $val->validate('abc');
} }
public function testValidateAttribute() public function testValidateAttribute()
{ {
// Access to validator in inline validation (https://github.com/yiisoft/ yii2/issues/6242) // Access to validator in inline validation (https://github.com/yiisoft/ yii2/issues/6242)
$model = new FakedValidationModel(); $model = new FakedValidationModel();
$model->val_attr_a = 'a';
$val = Validator::createValidator('inlineVal', $model, ['val_attr_a'], [ 'params' => ['foo' => 'bar']]); $val = Validator::createValidator('inlineVal', $model, ['val_attr_a'], [ 'params' => ['foo' => 'bar']]);
$val->validateAttribute($model, 'val_attr_a'); $val->validateAttribute($model, 'val_attr_a');
$args = $model->getInlineValArgs(); $args = $model->getInlineValArgs();
$this->assertCount(3, $args); $this->assertCount(4, $args);
$this->assertEquals('val_attr_a', $args[0]); $this->assertEquals('val_attr_a', $args[0]);
$this->assertEquals('a', $args[3]);
$this->assertEquals(['foo' => 'bar'], $args[1]); $this->assertEquals(['foo' => 'bar'], $args[1]);
$this->assertInstanceOf(InlineValidator::className(), $args[2]); $this->assertInstanceOf(InlineValidator::className(), $args[2]);
} }
public function testClientValidateAttribute() public function testClientValidateAttribute()
{ {
$val = new TestValidator(); $val = new TestValidator();
$this->assertNull( $this->assertNull(
$val->clientValidateAttribute($this->getTestModel(), 'attr_runMe1', []) $val->clientValidateAttribute($this->getTestModel(), 'attr_runMe1', [])
); //todo pass a view instead of array ); //todo pass a view instead of array
// Access to validator in inline validation (https://github.com/yiisoft/ yii2/issues/6242) // Access to validator in inline validation (https://github.com/yiisoft/ yii2/issues/6242)
$model = new FakedValidationModel(); $model = new FakedValidationModel();
$val = Validator::createValidator('inlineVal', $model, ['val_attr_a'], [ 'params' => ['foo' => 'bar']]); $val = Validator::createValidator('inlineVal', $model, ['val_attr_a'], [ 'params' => ['foo' => 'bar']]);
$val->clientValidate = 'clientInlineVal'; $val->clientValidate = 'clientInlineVal';
$args = $val->clientValidateAttribute($model, 'val_attr_a', null); $args = $val->clientValidateAttribute($model, 'val_attr_a', null);
$this->assertCount(3, $args); $this->assertCount(4, $args);
$this->assertEquals('val_attr_a', $args[0]); $this->assertEquals('val_attr_a', $args[0]);
$this->assertEquals(['foo' => 'bar'], $args[1]); $this->assertEquals(['foo' => 'bar'], $args[1]);
$this->assertInstanceOf(InlineValidator::className(), $args[2]); $this->assertInstanceOf(InlineValidator::className(), $args[2]);
} }
public function testIsActive() public function testIsActive()
{ {
$val = new TestValidator(); $val = new TestValidator();
$this->assertTrue($val->isActive('scenA')); $this->assertTrue($val->isActive('scenA'));
$this->assertTrue($val->isActive('scenB')); $this->assertTrue($val->isActive('scenB'));
 End of changes. 5 change blocks. 
3 lines changed or deleted 5 lines changed or added

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