Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLEDfan <tobia@ledfan.be>2016-01-17 17:01:39 +0300
committerLEDfan <tobia@ledfan.be>2016-01-17 17:01:39 +0300
commit8adfd8e5162328af17fd1a9c0168c0f58ad2e717 (patch)
treec1172b11a307f0b19040ab1aa3b8e724e4a20b7a
parent82350784ccf3a1bbe31be8d2679835399af30e56 (diff)
Fix travis for HHVM
-rw-r--r--.travis.yml7
-rw-r--r--phpunit.integration.xml5
-rw-r--r--phpunit.xml9
-rw-r--r--tests/integration/db/MessageMapperTest.php127
4 files changed, 144 insertions, 4 deletions
diff --git a/.travis.yml b/.travis.yml
index 15d32ab..1fa36e9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,7 +38,12 @@ install:
- cd ..
- ocdev setup core --dir owncloud --branch $BRANCH --no-history
- mv jsxc.chat owncloud/apps/ojsxc
- - phpenv config-add owncloud/apps/ojsxc/tests/travis/php.ini
+ - |
+ if [[ $TRAVIS_PHP_VERSION = "hhv"* ]]; then
+ cat owncloud/apps/ojsxc/tests/travis/php.ini >> /etc/hhvm/php.ini
+ else
+ phpenv config-add owncloud/apps/ojsxc/tests/travis/php.ini
+ fi
- cd owncloud
- ./occ maintenance:install --database-name oc_autotest --database-user oc_autotest --database-pass --admin-user admin --admin-pass admin --database $DB
- ./occ app:enable ojsxc
diff --git a/phpunit.integration.xml b/phpunit.integration.xml
index ab9eb95..ada7e30 100644
--- a/phpunit.integration.xml
+++ b/phpunit.integration.xml
@@ -4,4 +4,9 @@
<directory>./tests/integration</directory>
</testsuite>
</testsuites>
+ <filter>
+ <whitelist processUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">lib/db</directory>
+ </whitelist>
+ </filter>
</phpunit> \ No newline at end of file
diff --git a/phpunit.xml b/phpunit.xml
index 8cb6251..5f669ce 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -5,8 +5,11 @@
</testsuite>
</testsuites>
<filter>
- <whitelist processUncoveredFilesFromWhitelist="true">
- <directory suffix=".php">lib</directory>
- </whitelist>
+ <whitelist processUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">lib</directory>
+ <exclude>
+ <directory suffix=".php">lib/db</directory>
+ </exclude>
+ </whitelist>
</filter>
</phpunit> \ No newline at end of file
diff --git a/tests/integration/db/MessageMapperTest.php b/tests/integration/db/MessageMapperTest.php
new file mode 100644
index 0000000..83c7ab8
--- /dev/null
+++ b/tests/integration/db/MessageMapperTest.php
@@ -0,0 +1,127 @@
+<?php
+
+namespace OCA\OJSXC\Db;
+
+use OCA\OJSXC\Utility\MapperTestUtility;
+use OCP\AppFramework\Db\DoesNotExistException;
+
+function uniqid() {
+ return 4; // chosen by fair dice roll.
+ // guaranteed to be unique.
+}
+
+/**
+ * @group DB
+ */
+class MessageMapperTest extends MapperTestUtility {
+
+ /**
+ * @var StanzaMapper
+ */
+ protected $mapper;
+
+ protected function setUp() {
+ $this->entityName = 'OCA\OJSXC\Db\Message';
+ $this->mapperName = 'MessageMapper';
+ parent::setUp();
+ }
+
+ public function insertProvider() {
+ return [
+ [
+ 'john@localhost',
+ 'thomas@localhost',
+ 'abcd',
+ 'test',
+ 'Test Message',
+ '<message to="thomas@localhost" from="john@localhost" type="test" xmlns="jabber:client" id="4-msg">Test Message</message>'
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider insertProvider
+ */
+ public function testInsert($from, $to, $data, $type, $msg, $expectedStanza) {
+ $stanza = new Message();
+ $stanza->setFrom($from);
+ $stanza->setTo($to);
+ $stanza->setStanza($data);
+ $stanza->setType($type);
+ $stanza->setValues($msg);
+
+ $this->assertEquals($stanza->getFrom(), $from);
+ $this->assertEquals($stanza->getTo(), $to);
+ $this->assertEquals($stanza->getStanza(), $data);
+ $this->assertEquals($stanza->getType(), $type);
+
+ $this->mapper->insert($stanza);
+
+ $result = $this->fetchAll();
+
+ $this->assertCount(1, $result);
+ $this->assertEquals($stanza->getFrom(), $result[0]->getFrom());
+ $this->assertEquals($stanza->getTo(), $result[0]->getTo());
+ $this->assertEquals($expectedStanza, $result[0]->getStanza());
+ $this->assertEquals(null, $result[0]->getType()); // type is saved into the XML string, not the DB.
+ }
+
+ /**
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
+ */
+ public function testFindByToNotFound() {
+ $this->mapper->findByTo('test');
+ }
+
+ /**
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
+ */
+ public function testFindByToNotFound2() {
+ $stanza = new Message();
+ $stanza->setFrom('john@localhost');
+ $stanza->setTo('john@localhost');
+ $stanza->setStanza('abcd');
+ $stanza->setType('test');
+ $stanza->setValues('message abc');
+ $this->mapper->insert($stanza);
+
+ $this->mapper->findByTo('test');
+ }
+
+ public function testFindByToFound() {
+ $stanza1 = new Message();
+ $stanza1->setFrom('jan@localhost');
+ $stanza1->setTo('john@localhost');
+ $stanza1->setStanza('abcd1');
+ $stanza1->setType('test');
+ $stanza1->setValues('Messageabc');
+ $this->mapper->insert($stanza1);
+
+ $stanza2 = new Message();
+ $stanza2->setFrom('thomas@localhost');
+ $stanza2->setTo('jan@localhost');
+ $stanza2->setStanza('abcd2');
+ $stanza2->setType('test2');
+ $stanza2->setValues('Message');
+ $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('<message to="john@localhost" from="jan@localhost" type="test" xmlns="jabber:client" id="4-msg">Messageabc</message>', $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('<message to="jan@localhost" from="thomas@localhost" type="test2" xmlns="jabber:client" id="4-msg">Message</message>', $result[0]->getStanza());
+
+ }
+
+} \ No newline at end of file