Exemplo n.º 1
0
 public function testDataNulls()
 {
     $data = ['title' => 'A Post', 'body' => 'A Body', 'status' => 0, 'author_id' => 1];
     $post = new \SpotTest\Entity\Post($data);
     $post->status = null;
     $this->assertTrue($post->isModified('status'));
     $post->status = 1;
     $this->assertTrue($post->isModified('status'));
     $post->data(['status' => null]);
     $this->assertTrue($post->isModified('status'));
     $post->title = '';
     $this->assertTrue($post->isModified('title'));
     $this->title = null;
     $this->assertTrue($post->isModified('title'));
     $this->title = 'A Post';
     $post->data(['title' => null]);
     $this->assertTrue($post->isModified('title'));
 }
Exemplo n.º 2
0
 public function testRelationsAreNotReturnedWithData()
 {
     $post = new \SpotTest\Entity\Post(['title' => 'A Post', 'body' => 'A Body', 'status' => 0, 'data' => ['posts' => 'are cool', 'another field' => 'to serialize'], 'date_created' => new \DateTime()]);
     $author = new \SpotTest\Entity\Author(['email' => '*****@*****.**', 'password' => 'password']);
     $post->author = $author;
     $data = $post->data();
     $this->assertFalse(isset($data['author']));
     $array = $post->toArray();
     $this->assertFalse(isset($array['author']));
 }