コード例 #1
0
 /**
  * Test hasError on associated records
  *
  * @return void
  */
 public function testHasErrorAssociated()
 {
     $this->_setupTables();
     $row = new Article(['title' => 'My title', 'user' => new Entity(['username' => 'Mark'])]);
     $row->errors('title', []);
     $row->errors('body', 'Gotta have one');
     $row->user->errors('username', ['Required']);
     $context = new EntityContext($this->request, ['entity' => $row, 'table' => 'Articles']);
     $this->assertTrue($context->hasError('user.username'));
     $this->assertFalse($context->hasError('user.nope'));
     $this->assertFalse($context->hasError('no.nope'));
 }