/** * @expectedException \InvalidArgumentException */ public function testAttachUnPersistedDocument() { $oDocument = new Document(); $oDocument->setTitle('Foobar'); $oDocument->setInfo('Foobar, Foobar, Foobar'); $oPurchase = new Purchase(); $oPurchase->setEmail('*****@*****.**'); $oPurchase->setDocument($oDocument); }
/** * Method tests adding a duplicate title. */ public function testDuplicateTitle() { $oDocument = new Document(); $oDocument->setTitle('Foobar'); $oDocument->setInfo('Foobar, Foobar, Foobar'); $iID = $this->oDao->insert($oDocument); $this->assertNotNull($iID); $this->assertGreaterThan(1, $iID); $oPersistDoc = $this->oDao->find($iID); $this->assertInstanceOf('\\Application\\Model\\Document', $oPersistDoc); $oDocument2 = new Document(); $oDocument2->setTitle('Foobar'); $oDocument2->setInfo('Foobar, Foobar, Foobar'); try { $this->oDao->insert($oDocument2); } catch (InvalidQueryException $oEx) { $this->assertContains(' Duplicate entry', $oEx->getMessage()); } finally { //Clean up the db after testing $this->oDao->delete($oPersistDoc); } }