From d6ebf7d851dde1b2bbfbd895a2c2de43cda3e4df Mon Sep 17 00:00:00 2001 From: LEDfan Date: Sun, 17 Jan 2016 11:38:09 +0100 Subject: Install dependencies in travis + extra test --- tests/integration/db/StanzaMapperTest.php | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'tests/integration') diff --git a/tests/integration/db/StanzaMapperTest.php b/tests/integration/db/StanzaMapperTest.php index 22ca394..b4385b5 100644 --- a/tests/integration/db/StanzaMapperTest.php +++ b/tests/integration/db/StanzaMapperTest.php @@ -3,6 +3,7 @@ namespace OCA\OJSXC\Db; use OCA\OJSXC\Utility\MapperTestUtility; +use OCP\AppFramework\Db\DoesNotExistException; /** * @group DB @@ -53,6 +54,56 @@ class StanzaMapperTest extends MapperTestUtility { $this->assertEquals($stanza->getStanza(), $result[0]->getStanza()); } + /** + * @expectedException \OCP\AppFramework\Db\DoesNotExistException + */ + public function testFindByToNotFound() { + $this->mapper->findByTo('test'); + } + + /** + * @expectedException \OCP\AppFramework\Db\DoesNotExistException + */ + public function testFindByToNotFound2() { + $stanza = new Stanza(); + $stanza->setFrom('john@localhost'); + $stanza->setTo('john@localhost'); + $stanza->setStanza('abcd'); + $this->mapper->insert($stanza); + + $this->mapper->findByTo('test'); + } + + public function testFindByToFound() { + $stanza1 = new Stanza(); + $stanza1->setFrom('jan@localhost'); + $stanza1->setTo('john@localhost'); + $stanza1->setStanza('abcd1'); + $this->mapper->insert($stanza1); + $stanza2 = new Stanza(); + $stanza2->setFrom('thomas@localhost'); + $stanza2->setTo('jan@localhost'); + $stanza2->setStanza('abcd2'); + $this->mapper->insert($stanza2); + + + // check if two elements are inserted + $result = $this->fetchAll(); + $this->assertCount(2, $result); + + // check findByTo + $result = $this->mapper->findByTo('john@localhost'); + $this->assertCount(1, $result); + $this->assertEquals($stanza1->getStanza(), $result[0]->getStanza()); + + // check if element is deleted + $result = $this->fetchAll(); + $this->assertCount(1, $result); + $this->assertEquals($stanza2->getFrom(), $result[0]->getFrom()); + $this->assertEquals($stanza2->getTo(), $result[0]->getTo()); + $this->assertEquals($stanza2->getStanza(), $result[0]->getStanza()); + + } } \ No newline at end of file -- cgit v1.2.3