public function testCreatesSuitableTableDataGatewayObjectWhenInstantiated() { $mapper = new ZFExt_Model_EntryMapper($this->_tableGateway); $this->assertTrue($mapper->_getGateway() instanceof Zend_Db_Table_Abstract); }
public function testSavingNewEntryAddsItToIdentityMap() { $author = new ZFExt_Model_Author(array('id' => 2, 'username' => 'joe_bloggs', 'fullname' => 'Joe Bloggs', 'email' => '*****@*****.**', 'url' => 'http://www.example.com')); $entry = new ZFExt_Model_Entry(array('title' => 'My Title', 'content' => 'My Content', 'published_date' => '2009-08-17T17:30:00Z', 'author' => $author)); // set mock expectation on calling Zend_Db_Table::insert() $insertionData = array('title' => 'My Title', 'content' => 'My Content', 'published_date' => '2009-08-17T17:30:00Z', 'author_id' => 2, "id" => NULL); $this->_tableGateway->expects($this->once())->method('insert')->with($this->equalTo($insertionData))->will($this->returnValue(123)); $mapper = new ZFExt_Model_EntryMapper($this->_tableGateway); $mapper->save($entry); $result = $mapper->find(123); $this->assertSame($result, $entry); }