diff options
author | LEDfan <tobia@ledfan.be> | 2016-01-17 13:38:09 +0300 |
---|---|---|
committer | LEDfan <tobia@ledfan.be> | 2016-01-17 13:38:09 +0300 |
commit | d6ebf7d851dde1b2bbfbd895a2c2de43cda3e4df (patch) | |
tree | 7c432a5a4472c2495a43deef10cd162474d6aeee /tests | |
parent | b77b8e1381c49910ccd82965c8038b6815d75af8 (diff) |
Install dependencies in travis + extra test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/db/StanzaMapperTest.php | 51 |
1 files changed, 51 insertions, 0 deletions
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 |