Example #1
0
 public function testEntityErrors()
 {
     $post = new \SpotTest\Entity\Post(['title' => 'My Awesome Post', 'body' => '<p>Body</p>']);
     $postErrors = ['title' => ['Title cannot contain the word awesome']];
     // Has NO errors
     $this->assertTrue(!$post->hasErrors());
     // Set errors
     $post->errors($postErrors);
     // Has errors
     $this->assertTrue($post->hasErrors());
     // Full error array
     $this->assertEquals($postErrors, $post->errors());
     // Errors for one key only
     $this->assertEquals($postErrors['title'], $post->errors('title'));
 }