public function testEntitySetDataConstruct() { $mapper = test_spot_mapper(); $post = new Entity_Post(array('title' => 'My Awesome Post', 'body' => '<p>Body</p>')); $data = $post->data(); ksort($data); $testData = array('id' => null, 'title' => 'My Awesome Post', 'body' => '<p>Body</p>', 'status' => 0, 'date_created' => null); ksort($testData); $this->assertEquals($testData, $data); }
public function testDataNulls() { $data = array('title' => 'A Post', 'body' => 'A Body', 'status' => 0, 'author_id' => 1); $post = new Entity_Post($data); $post->status = null; $this->assertTrue($post->isModified('status')); $post->status = 1; $this->assertTrue($post->isModified('status')); $post->data(array('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(array('title' => null)); $this->assertTrue($post->isModified('title')); }