From 4e1922e1060f5d54c7ecc661aed121b9f94b15dd Mon Sep 17 00:00:00 2001 From: sualko Date: Wed, 26 Jul 2017 15:55:48 +0200 Subject: run php-cs-fixer --- tests/integration/DbLockTest.php | 21 +++++++----- tests/integration/MemLockTest.php | 17 +++++----- tests/integration/db/IqRosterTest.php | 12 +++---- tests/integration/db/MessageMapperTest.php | 40 ++++++++++++---------- tests/integration/db/PresenceMapperTest.php | 51 ++++++++++++++++++----------- tests/integration/db/PresenceTest.php | 29 +++++++++------- tests/integration/db/StanzaMapperTest.php | 35 +++++++++++--------- 7 files changed, 118 insertions(+), 87 deletions(-) (limited to 'tests/integration') diff --git a/tests/integration/DbLockTest.php b/tests/integration/DbLockTest.php index d157b48..d344c9f 100644 --- a/tests/integration/DbLockTest.php +++ b/tests/integration/DbLockTest.php @@ -8,7 +8,8 @@ use OCA\OJSXC\DbLock; $time = 0; -function time() { +function time() +{ global $time; return $time; } @@ -16,7 +17,8 @@ function time() { /** * @group DB */ -class DbLockTest extends TestCase { +class DbLockTest extends TestCase +{ /** * @var \OCA\OJSXC\DbLock @@ -39,7 +41,8 @@ class DbLockTest extends TestCase { */ private $container; - public function setUp() { + public function setUp() + { parent::setUp(); $app = new Application(); $this->container = $app->getContainer(); @@ -51,7 +54,8 @@ class DbLockTest extends TestCase { * Tests the setLock and stillLocked function by setting up and lock * and then setting a new lock. */ - public function testLock() { + public function testLock() + { global $time; $time = 4; $this->dbLock = new DbLock( @@ -86,20 +90,19 @@ class DbLockTest extends TestCase { $this->assertEquals($result[0]['configkey'], 'longpolling'); $this->assertEquals($result[0]['configvalue'], '5'); $this->assertTrue($this->dbLock2->stillLocked()); - } - private function fetchLocks() { + private function fetchLocks() + { $stmt = $this->con->executeQuery("SELECT * FROM `*PREFIX*preferences` WHERE `appid`='ojsxc' AND `configkey`='longpolling'"); $reuslt = []; - while($row = $stmt->fetch()){ + while ($row = $stmt->fetch()) { $result[] = $row; } return $result; } - -} \ No newline at end of file +} diff --git a/tests/integration/MemLockTest.php b/tests/integration/MemLockTest.php index 3ab1c16..f29df59 100644 --- a/tests/integration/MemLockTest.php +++ b/tests/integration/MemLockTest.php @@ -13,7 +13,8 @@ use OCA\OJSXC\MemLock; /** * @group DB */ -class MemLockTest extends TestCase { +class MemLockTest extends TestCase +{ /** * @var \OCA\OJSXC\MemLock @@ -37,7 +38,8 @@ class MemLockTest extends TestCase { public static $time; - public function setUp() { + public function setUp() + { parent::setUp(); $app = new Application(); $this->container = $app->getContainer(); @@ -46,14 +48,14 @@ class MemLockTest extends TestCase { if ($version[0] === 8 && $version[1] == 0) { $this->markTestSkipped(); } - } /** * Tests the setLock and stillLocked function by setting up and lock * and then setting a new lock. */ - public function testLock() { + public function testLock() + { global $time; $time = 4; $cache = $this->container->getServer()->getMemCacheFactory(); @@ -87,11 +89,10 @@ class MemLockTest extends TestCase { $this->assertTrue($this->memLock2->stillLocked()); $result = $this->fetchLock(); $this->assertEquals('5', $result); - } - private function fetchLock() { + private function fetchLock() + { return $this->memCache->get('-john-ojxsc-lock'); } - -} \ No newline at end of file +} diff --git a/tests/integration/db/IqRosterTest.php b/tests/integration/db/IqRosterTest.php index f2613c7..beb60bb 100644 --- a/tests/integration/db/IqRosterTest.php +++ b/tests/integration/db/IqRosterTest.php @@ -4,12 +4,13 @@ namespace OCA\OJSXC\Db; use Sabre\Xml\Writer; use OCA\OJSXC\Utility\TestCase; -class IqRosterTest extends TestCase { - - public function testIqRoster() { +class IqRosterTest extends TestCase +{ + public function testIqRoster() + { $expected = ''; - $writer = new Writer(); + $writer = new Writer(); $writer->openMemory(); $writer->startElement('body'); $writer->writeAttribute('xmlns', 'http://jabber.org/protocol/httpbind'); @@ -24,7 +25,7 @@ class IqRosterTest extends TestCase { $this->assertEquals($iqRoster->getType(), 'result'); $this->assertEquals($iqRoster->getTo(), 'john@localhost'); $this->assertEquals($iqRoster->getQid(), 4434); - $this->assertEquals($iqRoster->getItems(), [ + $this->assertEquals($iqRoster->getItems(), [ [ "name" => "item", "attributes" => [ @@ -52,5 +53,4 @@ class IqRosterTest extends TestCase { $this->assertEquals($expected, $result); } - } diff --git a/tests/integration/db/MessageMapperTest.php b/tests/integration/db/MessageMapperTest.php index e4d3a9a..3aa1ce6 100644 --- a/tests/integration/db/MessageMapperTest.php +++ b/tests/integration/db/MessageMapperTest.php @@ -5,7 +5,8 @@ namespace OCA\OJSXC\Db; use OCA\OJSXC\Utility\MapperTestUtility; use OCP\AppFramework\Db\DoesNotExistException; -function uniqid() { +function uniqid() +{ return 4; // chosen by fair dice roll. // guaranteed to be unique. } @@ -13,20 +14,23 @@ function uniqid() { /** * @group DB */ -class MessageMapperTest extends MapperTestUtility { +class MessageMapperTest extends MapperTestUtility +{ /** * @var StanzaMapper */ protected $mapper; - protected function setUp() { + protected function setUp() + { $this->entityName = 'OCA\OJSXC\Db\Message'; $this->mapperName = 'MessageMapper'; parent::setUp(); } - public function insertProvider() { + public function insertProvider() + { return [ [ 'john@localhost', @@ -42,7 +46,8 @@ class MessageMapperTest extends MapperTestUtility { /** * @dataProvider insertProvider */ - public function testInsert($from, $to, $data, $type, $msg, $expectedStanza) { + public function testInsert($from, $to, $data, $type, $msg, $expectedStanza) + { $stanza = new Message(); $stanza->setFrom($from); $stanza->setTo($to); @@ -61,22 +66,24 @@ class MessageMapperTest extends MapperTestUtility { $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. + $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() { + public function testFindByToNotFound() + { $this->mapper->findByTo('test'); } /** * @expectedException \OCP\AppFramework\Db\DoesNotExistException */ - public function testFindByToNotFound2() { + public function testFindByToNotFound2() + { $stanza = new Message(); $stanza->setFrom('john@localhost'); $stanza->setTo('john@localhost'); @@ -88,7 +95,8 @@ class MessageMapperTest extends MapperTestUtility { $this->mapper->findByTo('test'); } - public function testFindByToFound() { + public function testFindByToFound() + { $stanza1 = new Message(); $stanza1->setFrom('jan@localhost'); $stanza1->setTo('john@localhost'); @@ -113,15 +121,13 @@ class MessageMapperTest extends MapperTestUtility { // check findByTo $result = $this->mapper->findByTo('john@localhost'); $this->assertCount(1, $result); - $this->assertEquals('Messageabc', $result[0]->getStanza()); + $this->assertEquals('Messageabc', $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', $result[0]->getStanza()); - + $this->assertEquals($stanza2->getTo(), $result[0]->getTo()); + $this->assertEquals('Message', $result[0]->getStanza()); } - -} \ No newline at end of file +} diff --git a/tests/integration/db/PresenceMapperTest.php b/tests/integration/db/PresenceMapperTest.php index 4be8a0e..11968c1 100644 --- a/tests/integration/db/PresenceMapperTest.php +++ b/tests/integration/db/PresenceMapperTest.php @@ -8,7 +8,8 @@ use OCA\OJSXC\Utility\MapperTestUtility; $time = 0; -function time() { +function time() +{ global $time; return $time; } @@ -17,7 +18,8 @@ function time() { /** * @group DB */ -class PresenceMapperTest extends MapperTestUtility { +class PresenceMapperTest extends MapperTestUtility +{ /** * @var PresenceMapper @@ -29,7 +31,8 @@ class PresenceMapperTest extends MapperTestUtility { */ protected $newContentContainer; - protected function setUp() { + protected function setUp() + { $this->entityName = 'OCA\OJSXC\Db\Presence'; $this->mapperName = 'PresenceMapper'; parent::setUp(); @@ -43,7 +46,8 @@ class PresenceMapperTest extends MapperTestUtility { /** * @return array */ - public function presenceIfNotExitsProvider() { + public function presenceIfNotExitsProvider() + { $input1 = new PresenceEntity(); $input1->setPresence('online'); $input1->setUserid('admin'); @@ -90,7 +94,8 @@ class PresenceMapperTest extends MapperTestUtility { * @param PresenceEntity[] $inputs * @param array $expected */ - public function testSetPresenceIfNotExists($inputs, $expected) { + public function testSetPresenceIfNotExists($inputs, $expected) + { foreach ($inputs as $input) { $this->mapper->setPresence($input); } @@ -102,7 +107,8 @@ class PresenceMapperTest extends MapperTestUtility { /** * @return array */ - public function presenceIfExitsProvider() { + public function presenceIfExitsProvider() + { $input1 = new PresenceEntity(); $input1->setPresence('online'); $input1->setUserid('admin'); @@ -158,7 +164,8 @@ class PresenceMapperTest extends MapperTestUtility { * @param PresenceEntity[] $inputs * @param array $expected */ - public function testSetPresenceIfExists($inputs, $expected) { + public function testSetPresenceIfExists($inputs, $expected) + { foreach ($inputs as $input) { $this->mapper->setPresence($input); } @@ -168,7 +175,8 @@ class PresenceMapperTest extends MapperTestUtility { $this->assertArrayDbResultsEqual($expected, $result, ['userid', 'presence', 'last_active']); } - public function getPresenceProvider() { + public function getPresenceProvider() + { $input1 = new PresenceEntity(); $input1->setPresence('online'); $input1->setUserid('admin'); @@ -221,7 +229,8 @@ class PresenceMapperTest extends MapperTestUtility { * @param $inputs * @param $expected */ - public function testGetPresence($inputs, $expected) { + public function testGetPresence($inputs, $expected) + { foreach ($inputs as $input) { $this->mapper->setPresence($input); } @@ -231,7 +240,8 @@ class PresenceMapperTest extends MapperTestUtility { $this->assertObjectDbResultsEqual($expected, $result, ['userid', 'presence', 'lastActive', 'to', 'from']); } - public function getConnectedUsersProvider() { + public function getConnectedUsersProvider() + { $input1 = new PresenceEntity(); $input1->setPresence('online'); $input1->setUserid('admin'); @@ -273,7 +283,8 @@ class PresenceMapperTest extends MapperTestUtility { /** * @dataProvider getConnectedUsersProvider */ - public function testGetConnectedUsers($inputs, $expected) { + public function testGetConnectedUsers($inputs, $expected) + { foreach ($inputs as $input) { $this->mapper->setPresence($input); } @@ -286,7 +297,8 @@ class PresenceMapperTest extends MapperTestUtility { $this->assertEquals($expected, $result); } - public function updatePresenceProvider() { + public function updatePresenceProvider() + { $input1 = new PresenceEntity(); $input1->setPresence('online'); $input1->setUserid('admin'); @@ -370,8 +382,8 @@ class PresenceMapperTest extends MapperTestUtility { * @param int $expNewContentCount * @param array $expStanzasToSend */ - public function testUpdatePresence($inputs, $expInput, $expConnectedUsers, $expNewContent, $expNewContentCount, $expStanzasToSend) { - + public function testUpdatePresence($inputs, $expInput, $expConnectedUsers, $expNewContent, $expNewContentCount, $expStanzasToSend) + { global $time; $time = 1000; foreach ($inputs as $input) { @@ -396,10 +408,10 @@ class PresenceMapperTest extends MapperTestUtility { $stanzasToSend = $this->fetchAllAsArray('*PREFIX*ojsxc_stanzas'); $this->assertArrayDbResultsEqual($expStanzasToSend, $stanzasToSend, ['to', 'from', 'stanza']); - } - public function setActiveProvider() { + public function setActiveProvider() + { $input1 = new PresenceEntity(); $input1->setPresence('online'); $input1->setUserid('admin'); @@ -452,7 +464,8 @@ class PresenceMapperTest extends MapperTestUtility { /** * @dataProvider setActiveProvider */ - public function testSetActive($inputs, $expected) { + public function testSetActive($inputs, $expected) + { global $time; foreach ($inputs as $input) { @@ -466,7 +479,5 @@ class PresenceMapperTest extends MapperTestUtility { $result = $this->fetchAllAsArray(); $this->assertArrayDbResultsEqual($expected, $result, ['userid', 'last_active', 'presence']); - } - -} \ No newline at end of file +} diff --git a/tests/integration/db/PresenceTest.php b/tests/integration/db/PresenceTest.php index b92af60..7c7bfa0 100644 --- a/tests/integration/db/PresenceTest.php +++ b/tests/integration/db/PresenceTest.php @@ -8,13 +8,14 @@ use Sabre\Xml\LibXMLException; use Sabre\Xml\ParseException; use OCA\OJSXC\Utility\TestCase; -class PresenceTest extends TestCase{ - - private function generateFactoryData($xml, $from, $to, $presence, $userId) { +class PresenceTest extends TestCase +{ + private function generateFactoryData($xml, $from, $to, $presence, $userId) + { $reader = new Reader(); $reader->xml($xml); $reader->elementMap = [ - '{jabber:client}presence' => function(Reader $reader) use ($userId) { + '{jabber:client}presence' => function (Reader $reader) use ($userId) { return Presence::createFromXml($reader, $userId); } ]; @@ -30,10 +31,10 @@ class PresenceTest extends TestCase{ $userId, $expected ]; - } - public function factoryProvider() { + public function factoryProvider() + { return [ $this->generateFactoryData("", null, null, 'unavailable', 'admin'), $this->generateFactoryData("", null, null, 'unavailable', 'admin'), @@ -52,7 +53,8 @@ class PresenceTest extends TestCase{ /** * @dataProvider factoryProvider */ - public function testFactory($reader, $userid, Presence $expectedElement) { + public function testFactory($reader, $userid, Presence $expectedElement) + { $result = $reader->parse(); $result = $result['value']; $this->assertEquals($expectedElement->getTo(), $result->getTo()); @@ -62,8 +64,9 @@ class PresenceTest extends TestCase{ } - private function generateSerializeData($to, $from, $presence, $expected) { - $writer = new Writer(); + private function generateSerializeData($to, $from, $presence, $expected) + { + $writer = new Writer(); $writer->openMemory(); $writer->startElement('body'); $writer->writeAttribute('xmlns', 'http://jabber.org/protocol/httpbind'); @@ -82,7 +85,8 @@ class PresenceTest extends TestCase{ $presence ]; } - public function serializeProvider() { + public function serializeProvider() + { return [ $this->generateSerializeData('admin@own.dev', 'derp@own.dev', 'chat', 'chat'), $this->generateSerializeData('admin@own.dev', 'derp@own.dev', 'online', ''), @@ -97,7 +101,8 @@ class PresenceTest extends TestCase{ /** * @dataProvider serializeProvider */ - public function testSerialize(Writer $writer, Presence $presenceEntity, $expected, $to, $from, $presence) { + public function testSerialize(Writer $writer, Presence $presenceEntity, $expected, $to, $from, $presence) + { $writer->write($presenceEntity); $writer->endElement(); $result = $writer->outputMemory(); @@ -107,4 +112,4 @@ class PresenceTest extends TestCase{ $this->assertEquals($presence, $presenceEntity->getPresence()); $this->assertSabreXmlEqualsXml($expected, $result); } -} \ No newline at end of file +} diff --git a/tests/integration/db/StanzaMapperTest.php b/tests/integration/db/StanzaMapperTest.php index b4385b5..a2c09b0 100644 --- a/tests/integration/db/StanzaMapperTest.php +++ b/tests/integration/db/StanzaMapperTest.php @@ -8,20 +8,23 @@ use OCP\AppFramework\Db\DoesNotExistException; /** * @group DB */ -class StanzaMapperTest extends MapperTestUtility { +class StanzaMapperTest extends MapperTestUtility +{ /** * @var StanzaMapper */ protected $mapper; - protected function setUp() { + protected function setUp() + { $this->entityName = 'OCA\OJSXC\Db\Stanza'; $this->mapperName = 'StanzaMapper'; parent::setUp(); } - public function insertProvider() { + public function insertProvider() + { return [ [ 'john@localhost', @@ -34,7 +37,8 @@ class StanzaMapperTest extends MapperTestUtility { /** * @dataProvider insertProvider */ - public function testInsert($from, $to, $data) { + public function testInsert($from, $to, $data) + { $stanza = new Stanza(); $stanza->setFrom($from); $stanza->setTo($to); @@ -50,21 +54,23 @@ class StanzaMapperTest extends MapperTestUtility { $this->assertCount(1, $result); $this->assertEquals($stanza->getFrom(), $result[0]->getFrom()); - $this->assertEquals($stanza->getTo(), $result[0]->getTo()); - $this->assertEquals($stanza->getStanza(), $result[0]->getStanza()); + $this->assertEquals($stanza->getTo(), $result[0]->getTo()); + $this->assertEquals($stanza->getStanza(), $result[0]->getStanza()); } /** * @expectedException \OCP\AppFramework\Db\DoesNotExistException */ - public function testFindByToNotFound() { + public function testFindByToNotFound() + { $this->mapper->findByTo('test'); } /** * @expectedException \OCP\AppFramework\Db\DoesNotExistException */ - public function testFindByToNotFound2() { + public function testFindByToNotFound2() + { $stanza = new Stanza(); $stanza->setFrom('john@localhost'); $stanza->setTo('john@localhost'); @@ -74,7 +80,8 @@ class StanzaMapperTest extends MapperTestUtility { $this->mapper->findByTo('test'); } - public function testFindByToFound() { + public function testFindByToFound() + { $stanza1 = new Stanza(); $stanza1->setFrom('jan@localhost'); $stanza1->setTo('john@localhost'); @@ -95,15 +102,13 @@ class StanzaMapperTest extends MapperTestUtility { // check findByTo $result = $this->mapper->findByTo('john@localhost'); $this->assertCount(1, $result); - $this->assertEquals($stanza1->getStanza(), $result[0]->getStanza()); + $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()); - + $this->assertEquals($stanza2->getTo(), $result[0]->getTo()); + $this->assertEquals($stanza2->getStanza(), $result[0]->getStanza()); } - -} \ No newline at end of file +} -- cgit v1.2.3