diff options
author | LEDfan <tobia@ledfan.be> | 2016-01-17 18:05:05 +0300 |
---|---|---|
committer | LEDfan <tobia@ledfan.be> | 2016-01-17 18:05:05 +0300 |
commit | 1327b3479c6453511d54371ebbd9e569ff73a6a1 (patch) | |
tree | a77dc5a6885782c7e5ddfd5218a882dc638d4a35 /tests/integration | |
parent | 8adfd8e5162328af17fd1a9c0168c0f58ad2e717 (diff) |
Add extra tests -> DB is full covered now
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/db/IqRosterTest.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/integration/db/IqRosterTest.php b/tests/integration/db/IqRosterTest.php new file mode 100644 index 0000000..8ce890f --- /dev/null +++ b/tests/integration/db/IqRosterTest.php @@ -0,0 +1,54 @@ +<?php +namespace OCA\OJSXC\Db; + +use PHPUnit_Framework_TestCase; +use Sabre\Xml\Writer; + +class IqRosterTest extends PHPUnit_Framework_TestCase { + + public function testIqRoster() { + $expected = '<body xmlns="http://jabber.org/protocol/httpbind"><iq to="john@localhost" type="result" id="4434"><query xmlns="jabber:iq:roster"><item jid="test@test.be" name="Test Test"></item><item jid="test2@test.be" name="Test2 Test"></item></query></iq></body>'; + + $writer = new Writer(); + $writer->openMemory(); + $writer->startElement('body'); + $writer->writeAttribute('xmlns', 'http://jabber.org/protocol/httpbind'); + + $iqRoster = new IQRoster(); + $iqRoster->setType('result'); + $iqRoster->setTo('john@localhost'); + $iqRoster->setQid(4434); + $iqRoster->addItem('test@test.be', 'Test Test'); + $iqRoster->addItem('test2@test.be', 'Test2 Test'); + + $this->assertEquals($iqRoster->getType(), 'result'); + $this->assertEquals($iqRoster->getTo(), 'john@localhost'); + $this->assertEquals($iqRoster->getQid(), 4434); + $this->assertEquals($iqRoster->getItems(), [ + [ + "name" => "item", + "attributes" => [ + "jid" => "test@test.be", + "name" => "Test Test" + ], + "value" => '' + ], + [ + "name" => "item", + "attributes" => [ + "jid" => "test2@test.be", + "name" => "Test2 Test" + ], + "value" => '' + ], + ]); + + $writer->write($iqRoster); // needed to test the xmlSerialize function + + $writer->endElement(); + $result = $writer->outputMemory(); + + $this->assertEquals($expected, $result); + } + +} |