Skip to content

Commit

Permalink
added test that fails yiisoft#14413
Browse files Browse the repository at this point in the history
  • Loading branch information
cebe committed Jul 15, 2017
1 parent 59002a9 commit aba0b4a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/framework/validators/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace yiiunit\framework\validators;

use yii\base\DynamicModel;
use yii\validators\BooleanValidator;
use yii\validators\InlineValidator;
use yii\validators\NumberValidator;
Expand Down Expand Up @@ -270,4 +271,24 @@ public function testGetActiveValidatorsForSafeAttributes()
}
$this->assertTrue($isFound);
}

/**
* Make sure attribute names are calculated dynamically
* https://github.com/yiisoft/yii2/issues/13979
* https://github.com/yiisoft/yii2/pull/14413
*/
public function testAttributeNamesDynamic()
{
$model = new DynamicModel(['email1' => 'invalid', 'email2' => 'invalid']);
$validator = new TestValidator();
$validator->enableErrorOnValidateAttribute();

$validator->attributes = ['email1'];
$model->getValidators()->append($validator);
$this->assertFalse($model->validate());

$validator->attributes = ['email2'];
$model->getValidators()->append($validator);
$this->assertFalse($model->validate());
}
}

0 comments on commit aba0b4a

Please sign in to comment.