diff options
author | LEDfan <tobia@ledfan.be> | 2016-01-17 19:00:01 +0300 |
---|---|---|
committer | LEDfan <tobia@ledfan.be> | 2016-01-17 19:00:01 +0300 |
commit | 76b64582e7e01f2ffabbc50aadb1d9d62dc9a42f (patch) | |
tree | 263d4e442080059d77ea60badbde64933b03d230 /tests/unit | |
parent | 1327b3479c6453511d54371ebbd9e569ff73a6a1 (diff) |
add xmppresponse
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/http/XMPPResponseTest.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/unit/http/XMPPResponseTest.php b/tests/unit/http/XMPPResponseTest.php new file mode 100644 index 0000000..e906ef9 --- /dev/null +++ b/tests/unit/http/XMPPResponseTest.php @@ -0,0 +1,66 @@ +<?php + +namespace OCA\OJSXC\Db { + function uniqid() { + return 4; // chosen by fair dice roll. + // guaranteed to be unique. + } +} + +namespace OCA\OJSXC\Http { + + use OCA\OJSXC\Db\Message; + use OCA\OJSXC\Db\Stanza; + use PHPUnit_Framework_TestCase; + + + class IqRosterTest extends PHPUnit_Framework_TestCase { + + public function writingProvider() { + $stanza1 = new Stanza(); + $stanza1->setFrom('test@test.be'); + $stanza1->setTo('test.be'); + $stanza1->setStanza('abc'); + + $stanza2 = new Message(); + $stanza2->setFrom('test@test.be'); + $stanza2->setTo('test.be'); + $stanza2->setStanza('abc'); + $stanza2->setType('testtype'); + $stanza2->setValues('abcvalue'); + + return [ + [ + [null], + '<body xmlns="http://jabber.org/protocol/httpbind"/>' + ], + [ + [$stanza1], + '<body xmlns="http://jabber.org/protocol/httpbind">abc</body>' + ], + [ + [$stanza1, $stanza2], + '<body xmlns="http://jabber.org/protocol/httpbind">abc<message to="test.be" from="test@test.be" type="testtype" xmlns="jabber:client" id="4-msg">abcvalue</message></body>' + ], + [ + [$stanza1, null, $stanza2], + '<body xmlns="http://jabber.org/protocol/httpbind">abc<message to="test.be" from="test@test.be" type="testtype" xmlns="jabber:client" id="4-msg">abcvalue</message></body>' + ], + ]; + } + + /** + * @dataProvider writingProvider + */ + public function testWriting($stanzas, $expected) { + $response = new XMPPResponse(); + foreach ($stanzas as $stanza) { + $response->write($stanza); + } + $result = $response->render(); + $this->assertEquals($result, $expected); + } + + } + +}
\ No newline at end of file |