コード例 #1
0
ファイル: ModelTest.php プロジェクト: rajanishtimes/basicyii
 public function testIsAttributeRequired()
 {
     $singer = new Singer();
     $this->assertFalse($singer->isAttributeRequired('firstName'));
     $this->assertTrue($singer->isAttributeRequired('lastName'));
 }
コード例 #2
0
ファイル: ModelTest.php プロジェクト: aivavic/yii2
 public function testIsAttributeRequired()
 {
     $singer = new Singer();
     $this->assertFalse($singer->isAttributeRequired('firstName'));
     $this->assertTrue($singer->isAttributeRequired('lastName'));
     // attribute is not marked as required when a conditional validation is applied using `$when`.
     // the condition should not be applied because this info may be retrieved before model is loaded with data
     $singer->firstName = 'qiang';
     $this->assertFalse($singer->isAttributeRequired('test'));
     $singer->firstName = 'cebe';
     $this->assertFalse($singer->isAttributeRequired('test'));
 }