diff options
Diffstat (limited to 'tests/lib')
351 files changed, 7025 insertions, 6393 deletions
diff --git a/tests/lib/APITest.php b/tests/lib/APITest.php index bf6902fde65..7027d64eceb 100644 --- a/tests/lib/APITest.php +++ b/tests/lib/APITest.php @@ -17,7 +17,7 @@ class APITest extends \Test\TestCase { /** * @param string $message */ - function buildResponse($shipped, $data, $code, $message=null) { + public function buildResponse($shipped, $data, $code, $message=null) { $resp = new \OC\OCS\Result($data, $code, $message); $resp->addHeader('KEY', 'VALUE'); return [ @@ -32,7 +32,7 @@ class APITest extends \Test\TestCase { /** * @param \OC\OCS\Result $result */ - function checkResult($result, $success) { + public function checkResult($result, $success) { // Check response is of correct type $this->assertInstanceOf(\OC\OCS\Result::class, $result); // Check if it succeeded @@ -79,7 +79,7 @@ class APITest extends \Test\TestCase { $request ->expects($this->once()) ->method('getScriptName') - ->will($this->returnValue($scriptName)); + ->willReturn($scriptName); $this->assertEquals($expected, $this->invokePrivate(new \OC_API, 'isV2', [$request])); } diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php index 988fd64001d..afd807a44b4 100644 --- a/tests/lib/Accounts/AccountPropertyTest.php +++ b/tests/lib/Accounts/AccountPropertyTest.php @@ -33,7 +33,6 @@ use Test\TestCase; * @package Test\Accounts */ class AccountPropertyTest extends TestCase { - public function testConstructor() { $accountProperty = new AccountProperty( IAccountManager::PROPERTY_WEBSITE, @@ -97,6 +96,4 @@ class AccountPropertyTest extends TestCase { 'verified' => IAccountManager::VERIFIED ], $accountProperty->jsonSerialize()); } - - } diff --git a/tests/lib/Accounts/AccountTest.php b/tests/lib/Accounts/AccountTest.php index 6d0e187c433..11b13637bd0 100644 --- a/tests/lib/Accounts/AccountTest.php +++ b/tests/lib/Accounts/AccountTest.php @@ -35,7 +35,6 @@ use Test\TestCase; * @package Test\Accounts */ class AccountTest extends TestCase { - public function testConstructor() { $user = $this->createMock(IUser::class); $account = new Account($user); @@ -108,5 +107,4 @@ class AccountTest extends TestCase { $this->assertEquals($properties, $account->jsonSerialize()); } - } diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php index 958b6fd4738..76abeb5b495 100644 --- a/tests/lib/Accounts/AccountsManagerTest.php +++ b/tests/lib/Accounts/AccountsManagerTest.php @@ -21,7 +21,6 @@ namespace Test\Accounts; - use OC\Accounts\Account; use OC\Accounts\AccountManager; use OCP\Accounts\IAccountManager; @@ -81,7 +80,6 @@ class AccountsManagerTest extends TestCase { ->setConstructorArgs([$this->connection, $this->eventDispatcher, $this->jobList, $this->logger]) ->setMethods($mockedMethods) ->getMock(); - } /** @@ -163,10 +161,9 @@ class AccountsManagerTest extends TestCase { ->with($askUser, $expectedData); } - if(empty($expectedData)) { + if (empty($expectedData)) { $accountManager->expects($this->never())->method('addMissingDefaultValues'); - - } else { + } else { $accountManager->expects($this->once())->method('addMissingDefaultValues')->with($expectedData) ->willReturn($expectedData); } @@ -216,7 +213,6 @@ class AccountsManagerTest extends TestCase { } public function testAddMissingDefaultValues() { - $accountManager = $this->getInstance(); $input = [ @@ -235,7 +231,6 @@ class AccountsManagerTest extends TestCase { } private function addDummyValuesToTable($uid, $data) { - $query = $this->connection->getQueryBuilder(); $query->insert($this->table) ->values( @@ -295,5 +290,4 @@ class AccountsManagerTest extends TestCase { ->willReturn($data); $this->assertEquals($expected, $accountManager->getAccount($user)); } - } diff --git a/tests/lib/Accounts/HooksTest.php b/tests/lib/Accounts/HooksTest.php index 0d6ce3241d6..a0360404d72 100644 --- a/tests/lib/Accounts/HooksTest.php +++ b/tests/lib/Accounts/HooksTest.php @@ -21,7 +21,6 @@ namespace Test\Accounts; - use OC\Accounts\AccountManager; use OC\Accounts\Hooks; use OCP\ILogger; @@ -34,7 +33,7 @@ use Test\TestCase; * @package Test\Accounts * @group DB */ -class HooksTest extends TestCase { +class HooksTest extends TestCase { /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject */ private $logger; @@ -90,7 +89,6 @@ class HooksTest extends TestCase { } $this->hooks->changeUserHook($params); - } public function dataTestChangeUserHook() { @@ -152,5 +150,4 @@ class HooksTest extends TestCase { $result = $this->invokePrivate($hooks, 'getAccountManager'); $this->assertInstanceOf(AccountManager::class, $result); } - } diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php index b52b12a7e8c..77c0607916a 100644 --- a/tests/lib/Activity/ManagerTest.php +++ b/tests/lib/Activity/ManagerTest.php @@ -19,7 +19,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * -*/ + */ namespace Test\Activity; @@ -61,7 +61,7 @@ class ManagerTest extends TestCase { $this->assertSame([], self::invokePrivate($this->activityManager, 'getConsumers')); - $this->activityManager->registerConsumer(function() { + $this->activityManager->registerConsumer(function () { return new NoOpConsumer(); }); @@ -79,7 +79,7 @@ class ManagerTest extends TestCase { public function testGetConsumersInvalidConsumer() { $this->expectException(\InvalidArgumentException::class); - $this->activityManager->registerConsumer(function() { + $this->activityManager->registerConsumer(function () { return new \stdClass(); }); @@ -240,7 +240,7 @@ class ManagerTest extends TestCase { $consumer->expects($this->once()) ->method('receive') ->with($event) - ->willReturnCallback(function(\OCP\Activity\IEvent $event) use ($expected) { + ->willReturnCallback(function (\OCP\Activity\IEvent $event) use ($expected) { $this->assertLessThanOrEqual(time() + 2, $event->getTimestamp(), 'Timestamp not set correctly'); $this->assertGreaterThanOrEqual(time() - 2, $event->getTimestamp(), 'Timestamp not set correctly'); $this->assertSame($expected, $event->getAuthor(), 'Author name not set correctly'); @@ -270,7 +270,7 @@ class ManagerTest extends TestCase { ->getMock(); $consumer->expects($this->once()) ->method('receive') - ->willReturnCallback(function(\OCP\Activity\IEvent $event) { + ->willReturnCallback(function (\OCP\Activity\IEvent $event) { $this->assertSame('test_app', $event->getApp(), 'App not set correctly'); $this->assertSame('test_type', $event->getType(), 'Type not set correctly'); $this->assertSame('test_affected', $event->getAffectedUser(), 'Affected user not set correctly'); @@ -294,8 +294,6 @@ class ManagerTest extends TestCase { } class NoOpConsumer implements \OCP\Activity\IConsumer { - public function receive(\OCP\Activity\IEvent $event) { - } } diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php index 80ddcbbd354..bdcf2837fa5 100644 --- a/tests/lib/AllConfigTest.php +++ b/tests/lib/AllConfigTest.php @@ -23,13 +23,13 @@ class AllConfigTest extends \Test\TestCase { protected $connection; protected function getConfig($systemConfig = null, $connection = null) { - if($this->connection === null) { + if ($this->connection === null) { $this->connection = \OC::$server->getDatabaseConnection(); } - if($connection === null) { + if ($connection === null) { $connection = $this->connection; } - if($systemConfig === null) { + if ($systemConfig === null) { $systemConfig = $this->getMockBuilder('\OC\SystemConfig') ->disableOriginalConstructor() ->getMock(); @@ -44,14 +44,14 @@ class AllConfigTest extends \Test\TestCase { $this->connection->executeUpdate( 'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' . '`configkey`, `configvalue`) VALUES (?, ?, ?, ?)', - array('userDelete', 'appDelete', 'keyDelete', 'valueDelete') + ['userDelete', 'appDelete', 'keyDelete', 'valueDelete'] ); $config->deleteUserValue('userDelete', 'appDelete', 'keyDelete'); $result = $this->connection->executeQuery( 'SELECT COUNT(*) AS `count` FROM `*PREFIX*preferences` WHERE `userid` = ?', - array('userDelete') + ['userDelete'] )->fetch(); $actualCount = $result['count']; @@ -64,28 +64,28 @@ class AllConfigTest extends \Test\TestCase { $config->setUserValue('userSet', 'appSet', 'keySet', 'valueSet'); - $result = $this->connection->executeQuery($selectAllSQL, array('userSet'))->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAll(); $this->assertEquals(1, count($result)); - $this->assertEquals(array( + $this->assertEquals([ 'userid' => 'userSet', 'appid' => 'appSet', 'configkey' => 'keySet', 'configvalue' => 'valueSet' - ), $result[0]); + ], $result[0]); // test if the method overwrites existing database entries $config->setUserValue('userSet', 'appSet', 'keySet', 'valueSet2'); - $result = $this->connection->executeQuery($selectAllSQL, array('userSet'))->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userSet'])->fetchAll(); $this->assertEquals(1, count($result)); - $this->assertEquals(array( + $this->assertEquals([ 'userid' => 'userSet', 'appid' => 'appSet', 'configkey' => 'keySet', 'configvalue' => 'valueSet2' - ), $result[0]); + ], $result[0]); // cleanup - it therefore relies on the successful execution of the previous test $config->deleteUserValue('userSet', 'appSet', 'keySet'); @@ -98,28 +98,28 @@ class AllConfigTest extends \Test\TestCase { $config->setUserValue('userPreCond', 'appPreCond', 'keyPreCond', 'valuePreCond'); - $result = $this->connection->executeQuery($selectAllSQL, array('userPreCond'))->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond'])->fetchAll(); $this->assertEquals(1, count($result)); - $this->assertEquals(array( + $this->assertEquals([ 'userid' => 'userPreCond', 'appid' => 'appPreCond', 'configkey' => 'keyPreCond', 'configvalue' => 'valuePreCond' - ), $result[0]); + ], $result[0]); // test if the method overwrites existing database entries with valid precond $config->setUserValue('userPreCond', 'appPreCond', 'keyPreCond', 'valuePreCond2', 'valuePreCond'); - $result = $this->connection->executeQuery($selectAllSQL, array('userPreCond'))->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond'])->fetchAll(); $this->assertEquals(1, count($result)); - $this->assertEquals(array( + $this->assertEquals([ 'userid' => 'userPreCond', 'appid' => 'appPreCond', 'configkey' => 'keyPreCond', 'configvalue' => 'valuePreCond2' - ), $result[0]); + ], $result[0]); // cleanup $config->deleteUserValue('userPreCond', 'appPreCond', 'keyPreCond'); @@ -155,28 +155,28 @@ class AllConfigTest extends \Test\TestCase { $config->setUserValue('userPreCond1', 'appPreCond', 'keyPreCond', 'valuePreCond'); - $result = $this->connection->executeQuery($selectAllSQL, array('userPreCond1'))->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAll(); $this->assertEquals(1, count($result)); - $this->assertEquals(array( + $this->assertEquals([ 'userid' => 'userPreCond1', 'appid' => 'appPreCond', 'configkey' => 'keyPreCond', 'configvalue' => 'valuePreCond' - ), $result[0]); + ], $result[0]); // test if the method overwrites existing database entries with valid precond $config->setUserValue('userPreCond1', 'appPreCond', 'keyPreCond', 'valuePreCond2', 'valuePreCond3'); - $result = $this->connection->executeQuery($selectAllSQL, array('userPreCond1'))->fetchAll(); + $result = $this->connection->executeQuery($selectAllSQL, ['userPreCond1'])->fetchAll(); $this->assertEquals(1, count($result)); - $this->assertEquals(array( + $this->assertEquals([ 'userid' => 'userPreCond1', 'appid' => 'appPreCond', 'configkey' => 'keyPreCond', 'configvalue' => 'valuePreCond' - ), $result[0]); + ], $result[0]); // cleanup $config->deleteUserValue('userPreCond1', 'appPreCond', 'keyPreCond'); @@ -190,15 +190,15 @@ class AllConfigTest extends \Test\TestCase { ->disableOriginalConstructor()->getMock(); $resultMock->expects($this->once()) ->method('fetchColumn') - ->will($this->returnValue('valueSetUnchanged')); + ->willReturn('valueSetUnchanged'); $connectionMock = $this->createMock(IDBConnection::class); $connectionMock->expects($this->once()) ->method('executeQuery') ->with($this->equalTo('SELECT `configvalue` FROM `*PREFIX*preferences` '. 'WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?'), - $this->equalTo(array('userSetUnchanged', 'appSetUnchanged', 'keySetUnchanged'))) - ->will($this->returnValue($resultMock)); + $this->equalTo(['userSetUnchanged', 'appSetUnchanged', 'keySetUnchanged'])) + ->willReturn($resultMock); $connectionMock->expects($this->never()) ->method('executeUpdate'); @@ -218,19 +218,19 @@ class AllConfigTest extends \Test\TestCase { $result = $this->connection->executeQuery( 'SELECT `userid`, `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?', - array('userGet') + ['userGet'] )->fetchAll(); $this->assertEquals(1, count($result)); - $this->assertEquals(array( + $this->assertEquals([ 'userid' => 'userGet', 'appid' => 'appGet', 'configkey' => 'keyGet', 'configvalue' => 'valueGet' - ), $result[0]); + ], $result[0]); // drop data from database - but the config option should be cached in the config object - $this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences` WHERE `userid` = ?', array('userGet')); + $this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences` WHERE `userid` = ?', ['userGet']); // testing the caching mechanism $value = $config->getUserValue('userGet', 'appGet', 'keyGet'); @@ -239,7 +239,7 @@ class AllConfigTest extends \Test\TestCase { $result = $this->connection->executeQuery( 'SELECT `userid`, `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?', - array('userGet') + ['userGet'] )->fetchAll(); $this->assertEquals(0, count($result)); @@ -249,15 +249,15 @@ class AllConfigTest extends \Test\TestCase { $config = $this->getConfig(); // preparation - add something to the database - $data = array( - array('userFetch', 'appFetch1', 'keyFetch1', 'value1'), - array('userFetch', 'appFetch1', 'keyFetch2', 'value2'), - array('userFetch', 'appFetch2', 'keyFetch3', 'value3'), - array('userFetch', 'appFetch1', 'keyFetch4', 'value4'), - array('userFetch', 'appFetch4', 'keyFetch1', 'value5'), - array('userFetch', 'appFetch5', 'keyFetch1', 'value6'), - array('userFetch2', 'appFetch', 'keyFetch1', 'value7') - ); + $data = [ + ['userFetch', 'appFetch1', 'keyFetch1', 'value1'], + ['userFetch', 'appFetch1', 'keyFetch2', 'value2'], + ['userFetch', 'appFetch2', 'keyFetch3', 'value3'], + ['userFetch', 'appFetch1', 'keyFetch4', 'value4'], + ['userFetch', 'appFetch4', 'keyFetch1', 'value5'], + ['userFetch', 'appFetch5', 'keyFetch1', 'value6'], + ['userFetch2', 'appFetch', 'keyFetch1', 'value7'] + ]; foreach ($data as $entry) { $this->connection->executeUpdate( 'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' . @@ -267,10 +267,10 @@ class AllConfigTest extends \Test\TestCase { } $value = $config->getUserKeys('userFetch', 'appFetch1'); - $this->assertEquals(array('keyFetch1', 'keyFetch2', 'keyFetch4'), $value); + $this->assertEquals(['keyFetch1', 'keyFetch2', 'keyFetch4'], $value); $value = $config->getUserKeys('userFetch2', 'appFetch'); - $this->assertEquals(array('keyFetch1'), $value); + $this->assertEquals(['keyFetch1'], $value); // cleanup $this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`'); @@ -288,15 +288,15 @@ class AllConfigTest extends \Test\TestCase { $config = $this->getConfig(); // preparation - add something to the database - $data = array( - array('userFetch1', 'appFetch2', 'keyFetch1', 'value1'), - array('userFetch2', 'appFetch2', 'keyFetch1', 'value2'), - array('userFetch3', 'appFetch2', 'keyFetch1', 3), - array('userFetch4', 'appFetch2', 'keyFetch1', 'value4'), - array('userFetch5', 'appFetch2', 'keyFetch1', 'value5'), - array('userFetch6', 'appFetch2', 'keyFetch1', 'value6'), - array('userFetch7', 'appFetch2', 'keyFetch1', 'value7') - ); + $data = [ + ['userFetch1', 'appFetch2', 'keyFetch1', 'value1'], + ['userFetch2', 'appFetch2', 'keyFetch1', 'value2'], + ['userFetch3', 'appFetch2', 'keyFetch1', 3], + ['userFetch4', 'appFetch2', 'keyFetch1', 'value4'], + ['userFetch5', 'appFetch2', 'keyFetch1', 'value5'], + ['userFetch6', 'appFetch2', 'keyFetch1', 'value6'], + ['userFetch7', 'appFetch2', 'keyFetch1', 'value7'] + ]; foreach ($data as $entry) { $this->connection->executeUpdate( 'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' . @@ -306,20 +306,20 @@ class AllConfigTest extends \Test\TestCase { } $value = $config->getUserValueForUsers('appFetch2', 'keyFetch1', - array('userFetch1', 'userFetch2', 'userFetch3', 'userFetch5')); - $this->assertEquals(array( - 'userFetch1' => 'value1', - 'userFetch2' => 'value2', - 'userFetch3' => 3, - 'userFetch5' => 'value5' - ), $value); + ['userFetch1', 'userFetch2', 'userFetch3', 'userFetch5']); + $this->assertEquals([ + 'userFetch1' => 'value1', + 'userFetch2' => 'value2', + 'userFetch3' => 3, + 'userFetch5' => 'value5' + ], $value); $value = $config->getUserValueForUsers('appFetch2', 'keyFetch1', - array('userFetch1', 'userFetch4', 'userFetch9')); - $this->assertEquals(array( + ['userFetch1', 'userFetch4', 'userFetch9']); + $this->assertEquals([ 'userFetch1' => 'value1', 'userFetch4' => 'value4' - ), $value, 'userFetch9 is an non-existent user and should not be shown.'); + ], $value, 'userFetch9 is an non-existent user and should not be shown.'); // cleanup $this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`'); @@ -329,15 +329,15 @@ class AllConfigTest extends \Test\TestCase { $config = $this->getConfig(); // preparation - add something to the database - $data = array( - array('userFetch3', 'appFetch1', 'keyFetch1', 'value1'), - array('userFetch3', 'appFetch1', 'keyFetch2', 'value2'), - array('userFetch3', 'appFetch2', 'keyFetch3', 'value3'), - array('userFetch3', 'appFetch1', 'keyFetch4', 'value4'), - array('userFetch3', 'appFetch4', 'keyFetch1', 'value5'), - array('userFetch3', 'appFetch5', 'keyFetch1', 'value6'), - array('userFetch4', 'appFetch2', 'keyFetch1', 'value7') - ); + $data = [ + ['userFetch3', 'appFetch1', 'keyFetch1', 'value1'], + ['userFetch3', 'appFetch1', 'keyFetch2', 'value2'], + ['userFetch3', 'appFetch2', 'keyFetch3', 'value3'], + ['userFetch3', 'appFetch1', 'keyFetch4', 'value4'], + ['userFetch3', 'appFetch4', 'keyFetch1', 'value5'], + ['userFetch3', 'appFetch5', 'keyFetch1', 'value6'], + ['userFetch4', 'appFetch2', 'keyFetch1', 'value7'] + ]; foreach ($data as $entry) { $this->connection->executeUpdate( 'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' . @@ -363,15 +363,15 @@ class AllConfigTest extends \Test\TestCase { $config = $this->getConfig(); // preparation - add something to the database - $data = array( - array('userFetch5', 'appFetch1', 'keyFetch1', 'value1'), - array('userFetch5', 'appFetch1', 'keyFetch2', 'value2'), - array('userFetch5', 'appFetch2', 'keyFetch3', 'value3'), - array('userFetch5', 'appFetch1', 'keyFetch4', 'value4'), - array('userFetch5', 'appFetch4', 'keyFetch1', 'value5'), - array('userFetch5', 'appFetch5', 'keyFetch1', 'value6'), - array('userFetch6', 'appFetch2', 'keyFetch1', 'value7') - ); + $data = [ + ['userFetch5', 'appFetch1', 'keyFetch1', 'value1'], + ['userFetch5', 'appFetch1', 'keyFetch2', 'value2'], + ['userFetch5', 'appFetch2', 'keyFetch3', 'value3'], + ['userFetch5', 'appFetch1', 'keyFetch4', 'value4'], + ['userFetch5', 'appFetch4', 'keyFetch1', 'value5'], + ['userFetch5', 'appFetch5', 'keyFetch1', 'value6'], + ['userFetch6', 'appFetch2', 'keyFetch1', 'value7'] + ]; foreach ($data as $entry) { $this->connection->executeUpdate( 'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' . @@ -411,18 +411,18 @@ class AllConfigTest extends \Test\TestCase { ->method('getValue') ->with($this->equalTo('dbtype'), $this->equalTo('sqlite')) - ->will($this->returnValue(\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite'))); + ->willReturn(\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite')); $config = $this->getConfig($systemConfig); // preparation - add something to the database - $data = array( - array('user1', 'appFetch9', 'keyFetch9', 'value9'), - array('user2', 'appFetch9', 'keyFetch9', 'value9'), - array('user3', 'appFetch9', 'keyFetch9', 'value8'), - array('user4', 'appFetch9', 'keyFetch8', 'value9'), - array('user5', 'appFetch8', 'keyFetch9', 'value9'), - array('user6', 'appFetch9', 'keyFetch9', 'value9'), - ); + $data = [ + ['user1', 'appFetch9', 'keyFetch9', 'value9'], + ['user2', 'appFetch9', 'keyFetch9', 'value9'], + ['user3', 'appFetch9', 'keyFetch9', 'value8'], + ['user4', 'appFetch9', 'keyFetch8', 'value9'], + ['user5', 'appFetch8', 'keyFetch9', 'value9'], + ['user6', 'appFetch9', 'keyFetch9', 'value9'], + ]; foreach ($data as $entry) { $this->connection->executeUpdate( 'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' . @@ -432,10 +432,9 @@ class AllConfigTest extends \Test\TestCase { } $value = $config->getUsersForUserValue('appFetch9', 'keyFetch9', 'value9'); - $this->assertEquals(array('user1', 'user2', 'user6'), $value); + $this->assertEquals(['user1', 'user2', 'user6'], $value); // cleanup $this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`'); } - } diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index 0e895b5f999..5b6fedb1cc2 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> @@ -35,29 +37,29 @@ class AppManagerTest extends TestCase { * @return AppConfig|MockObject */ protected function getAppConfig() { - $appConfig = array(); + $appConfig = []; $config = $this->createMock(AppConfig::class); $config->expects($this->any()) ->method('getValue') - ->will($this->returnCallback(function ($app, $key, $default) use (&$appConfig) { + ->willReturnCallback(function ($app, $key, $default) use (&$appConfig) { return (isset($appConfig[$app]) and isset($appConfig[$app][$key])) ? $appConfig[$app][$key] : $default; - })); + }); $config->expects($this->any()) ->method('setValue') - ->will($this->returnCallback(function ($app, $key, $value) use (&$appConfig) { + ->willReturnCallback(function ($app, $key, $value) use (&$appConfig) { if (!isset($appConfig[$app])) { - $appConfig[$app] = array(); + $appConfig[$app] = []; } $appConfig[$app][$key] = $value; - })); + }); $config->expects($this->any()) ->method('getValues') - ->will($this->returnCallback(function ($app, $key) use (&$appConfig) { + ->willReturnCallback(function ($app, $key) use (&$appConfig) { if ($app) { return $appConfig[$app]; } else { - $values = array(); + $values = []; foreach ($appConfig as $appid => $appData) { if (isset($appData[$key])) { $values[$appid] = $appData[$key]; @@ -65,7 +67,7 @@ class AppManagerTest extends TestCase { } return $values; } - })); + }); return $config; } @@ -336,6 +338,35 @@ class AppManagerTest extends TestCase { $this->assertEquals(\OC::$SERVERROOT . '/apps/files', $this->manager->getAppPath('files')); } + public function testGetAppPathSymlink() { + $fakeAppDirname = sha1(uniqid('test', true)); + $fakeAppPath = sys_get_temp_dir() . '/' . $fakeAppDirname; + $fakeAppLink = \OC::$SERVERROOT . '/' . $fakeAppDirname; + + mkdir($fakeAppPath); + if (symlink($fakeAppPath, $fakeAppLink) === false) { + $this->markTestSkipped('Failed to create symlink'); + } + + // Use the symlink as the app path + \OC::$APPSROOTS[] = [ + 'path' => $fakeAppLink, + 'url' => \OC::$WEBROOT . '/' . $fakeAppDirname, + 'writable' => false, + ]; + + $fakeTestAppPath = $fakeAppPath . '/' . 'test-test-app'; + mkdir($fakeTestAppPath); + + $generatedAppPath = $this->manager->getAppPath('test-test-app'); + + rmdir($fakeTestAppPath); + unlink($fakeAppLink); + rmdir($fakeAppPath); + + $this->assertEquals($fakeAppLink . '/test-test-app', $generatedAppPath); + } + public function testGetAppPathFail() { $this->expectException(AppPathNotFoundException::class); $this->manager->getAppPath('testnotexisting'); @@ -346,7 +377,7 @@ class AppManagerTest extends TestCase { $this->groupManager->expects($this->once()) ->method('getUserGroupIds') ->with($user) - ->will($this->returnValue(array('foo', 'bar'))); + ->willReturn(['foo', 'bar']); $this->appConfig->setValue('test', 'enabled', '["foo"]'); $this->assertTrue($this->manager->isEnabledForUser('test', $user)); @@ -357,7 +388,7 @@ class AppManagerTest extends TestCase { $this->groupManager->expects($this->once()) ->method('getUserGroupIds') ->with($user) - ->will($this->returnValue(array('bar'))); + ->willReturn(['bar']); $this->appConfig->setValue('test', 'enabled', '["foo"]'); $this->assertFalse($this->manager->isEnabledForUser('test', $user)); @@ -373,11 +404,11 @@ class AppManagerTest extends TestCase { $this->userSession->expects($this->once()) ->method('getUser') - ->will($this->returnValue($user)); + ->willReturn($user); $this->groupManager->expects($this->once()) ->method('getUserGroupIds') ->with($user) - ->will($this->returnValue(array('foo', 'bar'))); + ->willReturn(['foo', 'bar']); $this->appConfig->setValue('test', 'enabled', '["foo"]'); $this->assertTrue($this->manager->isEnabledForUser('test')); @@ -410,7 +441,7 @@ class AppManagerTest extends TestCase { $this->groupManager->expects($this->any()) ->method('getUserGroupIds') ->with($user) - ->will($this->returnValue(array('foo', 'bar'))); + ->willReturn(['foo', 'bar']); $this->appConfig->setValue('test1', 'enabled', 'yes'); $this->appConfig->setValue('test2', 'enabled', 'no'); @@ -462,11 +493,11 @@ class AppManagerTest extends TestCase { $manager->expects($this->any()) ->method('getAppInfo') - ->will($this->returnCallback( - function($appId) use ($appInfos) { + ->willReturnCallback( + function ($appId) use ($appInfos) { return $appInfos[$appId]; } - )); + ); $this->appConfig->setValue('test1', 'enabled', 'yes'); $this->appConfig->setValue('test1', 'installed_version', '1.0.0'); @@ -511,11 +542,11 @@ class AppManagerTest extends TestCase { $manager->expects($this->any()) ->method('getAppInfo') - ->will($this->returnCallback( - function($appId) use ($appInfos) { + ->willReturnCallback( + function ($appId) use ($appInfos) { return $appInfos[$appId]; } - )); + ); $this->appConfig->setValue('test1', 'enabled', 'yes'); $this->appConfig->setValue('test2', 'enabled', 'yes'); @@ -532,7 +563,7 @@ class AppManagerTest extends TestCase { $group = $this->createMock(IGroup::class); $group->expects($this->any()) ->method('getGID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $this->appConfig->setValue('test1', 'enabled', 'yes'); $this->appConfig->setValue('test2', 'enabled', 'no'); diff --git a/tests/lib/App/AppStore/Bundles/BundleBase.php b/tests/lib/App/AppStore/Bundles/BundleBase.php index 2c566b0ea0a..dc7e1920896 100644 --- a/tests/lib/App/AppStore/Bundles/BundleBase.php +++ b/tests/lib/App/AppStore/Bundles/BundleBase.php @@ -41,9 +41,9 @@ abstract class BundleBase extends TestCase { parent::setUp(); $this->l10n = $this->createMock(IL10N::class); $this->l10n->method('t') - ->will($this->returnCallback(function ($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); - })); + }); } public function testGetIdentifier() { diff --git a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php index b4d30b4bf50..5964220958c 100644 --- a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php +++ b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php @@ -78,5 +78,4 @@ class BundleFetcherTest extends TestCase { $this->bundleFetcher->getBundleByIdentifier('NotExistingBundle'); } - } diff --git a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php index 1c5d2a480e9..db96b3e46aa 100644 --- a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php +++ b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php @@ -30,14 +30,11 @@ class EducationBundleTest extends BundleBase { $this->bundleIdentifier = 'EducationBundle'; $this->bundleName = 'Education Edition'; $this->bundleAppIds = [ - 'zenodo', 'dashboard', 'circles', 'groupfolders', 'announcementcenter', - 'admin_notifications', 'quota_warning', - 'orcid', 'user_saml', ]; } diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php index 38e813dc251..50b0fd04dfc 100644 --- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php @@ -38,7 +38,7 @@ use OCP\ILogger; use PHPUnit_Framework_MockObject_MockObject; use Test\TestCase; -class AppFetcherTest extends TestCase { +class AppFetcherTest extends TestCase { /** @var IAppData|PHPUnit_Framework_MockObject_MockObject */ protected $appData; /** @var IClientService|PHPUnit_Framework_MockObject_MockObject */ @@ -54,54 +54,54 @@ class AppFetcherTest extends TestCase { /** @var AppFetcher */ protected $fetcher; /** @var string */ - static $responseJson = <<<'EOD' + public static $responseJson = <<<'EOD' [{"id":"direct_menu","categories":["customization"],"userDocs":"","adminDocs":"","developerDocs":"","issueTracker":"https://github.com/juliushaertl/direct_menu/issues","website":"","created":"2016-10-01T09:16:06.030994Z","lastModified":"2016-10-06T14:01:05.584192Z","releases":[{"version":"0.9.2","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/juliushaertl/direct_menu/releases/download/v0.9.2/direct_menu.tar.gz","created":"2016-10-06T14:01:05.578297Z","licenses":["agpl"],"lastModified":"2016-10-06T14:01:05.643813Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"ERBS9G5bZ3vwCizz2Ht5DehsVJmb63bzF3aYcH7xjbDVMPagOFWdUAiLDwTeZR1n\ni4gdZ73J/IjHQQJoOPwtCjgbZgLPFqL5x13CLUO9mb/33dZe/+gqEDc/3AuJ4TlA\nXUdLxHRb1bwIlJOwuSr/E24452VG20WUhLXBoM0Zm7WcMxvJWo2zAWnuqnLX3dy9\ncPB4PX+6JU2lUMINj8OYQmM1QnqvjG8YV0cYHbBbnSicOGwXEnni7mojsC8T0cn7\nYEJ2O2iO9hh3fvFEXUzDcL7tDQ5bZqm63Oa991bsAJxFo/RbzeJRh//DcOrd8Ufn\nu2SqRhwybS8j4YvfjAL9RPdRfPLwf6X2gx/Y6QFrKHH0QMI/9J/ZFyoUQcqKbsHV\n85O+yuWoqVmza71tkp4n9PuMdprCinaVvHbHbNGUf2SIh9BWuEQuVvvnvB+ZW8XY\n+Cl+unzk3WgOgT0iY3uEmsQcrLIo4DSKhcNgD1NS13fR/JTSavvmOqBarUMFZfVC\nbkR1DTBCyDjdpNBidpa3/26675dz5IT5Zedp4BBBREQzX08cIhJx5mgqDdX3CU09\nuWtzoaLi71/1BWTFAN+Y9VyfZ8/Z3Pg3vKedRJ565mztIj0geL3riEsC5YnPS0+C\n+a3B9sDiiOa101EORzX3lrPqL7reEPdCxrIwN+hKFBQ=","translations":{}}],"screenshots":[{"url":"https://bitgrid.net/~jus/direct_menu_nc.png"}],"translations":{"en":{"name":"Direct Menu","summary":"Provide easy access to all apps in the header.","description":"Provide easy access to all apps in the header."}},"isFeatured":false,"authors":[{"name":"Julius Härtl","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIEBjCCAu4CAhADMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYwOTE0MTI1MDU0WhcNMjYxMjIxMTI1MDU0WjAWMRQwEgYD\r\nVQQDDAtkaXJlY3RfbWVudTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB\r\nAMkzWsAkKP/40ktvJMpnr0IJNVoPOR0hvh24igcDskL1WKiD2eiRUenj5LE0Nvn+\r\nsiGmWsAqRVpdiz+Y8ghQqQMzKi43IrRN0AxlCrHWrSqBZT3wIAUcFz4RzEoFxc1N\r\nUZzWma6ljukGnvt4V1ZyT+H/cjqxUkBhh/y9SS0jUen1a1grND6Rw54X46V2dlCu\r\nFH+pLsfPJJGw+QLeTGHn7dqdv18cYMAlWDCzPixVnNiCXHZcUtKMmstU2xU4R2e6\r\nzimp2rgkE4TNHrafpjH8xGdNi2FG5Dmokob/L5Q2r8jyNaW7UsFfrvLTRj371b3/\r\n2FhhxoGUvDzaG2An02Exwm52LJfdTVMHAMPZub5poHfy5vAEdZGPQ/m02l8ZK/Y2\r\n7yT807GlfPMXfdfjCxR6wNtmv7rvBDdrUZmIRNJfpFSdvlH/+MOTWnabyfQv2K4Q\r\nBIwltX6Elh0lh4ntvt1ZVtvFv+PL1Dc7QLV+w19+/LJA0mnsh7GIFYKFlbA65gA0\r\nc/w+uqDy0+5MxkR9WGPpd79KRA1tKWTis4Ny1lApK5y3zIsVGa3DfBHXcwqkWHbV\r\nwIpyuyyDsFtC1b9LTFONX7iU9cbNk5C5GTM331MdA2kLcD/D5k42GNTBSca7MkPx\r\nFx/ETSn0Ct167el30symf2AxvXjw+mBYPN71rVTMDwe9AgMBAAEwDQYJKoZIhvcN\r\nAQELBQADggEBAC0fJKnbEhXA8M283jA9GxABxLyTBcQyVVNnz2L/bYYNi81Y9iZv\r\n+U0S3qaIfoqNcV9FTKAutbsKvWyolnI7MRRK6feNuFfoP2jKubM1CnawpyT/RF2Q\r\ne/zxnB1EmeI2X5D2xceJDLB7Fy5W0EGrLixRIdFaSUommWFUm9E2hSIaNlziSBdc\r\n1J/mOQeNYO5zg5ouEt1rzQW4Mhh1I2uNQmGe4ip+Jl/2LAv3FZuu4NrSEcoXH3ro\r\nG2dF9Gtu4GiQ5fuaJknaxlgXHovfqeZwZJX9o4M+Ug81AqiY7XjdiaCPdh0Tthcx\r\n2OmWZo7UBREWenjKyFZZ/iKoqH5sdenBtpo=\r\n-----END CERTIFICATE-----"},{"id":"apporder","categories":["customization"],"userDocs":"","adminDocs":"","developerDocs":"","issueTracker":"https://github.com/juliushaertl/apporder/issues","website":"","created":"2016-10-01T09:16:47.111889Z","lastModified":"2016-10-12T19:50:16.038821Z","releases":[{"version":"0.3.3","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/juliushaertl/apporder/releases/download/0.3.3/apporder.tar.gz","created":"2016-10-12T19:14:10.802359Z","licenses":["agpl"],"lastModified":"2016-10-12T19:50:16.104357Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"nhlT9lhrmBxIsqh/e3RLm2NDw/U8ZvvoMyYQTLMM3H19DQmVcPYPYC9QWVTsowUzXblVaOXVGylbpKma9yOlOAqJtF3qyXecLl4+tA/Awb6BBhKPgHFdcLDAL5yy1K7/uei3SgEojMlJoI9vEK5I1C5YTh43yNH+//Im6MAuNYFUTlMXK426zdOe6ogpCI5GlYdXopqYANxcpT+WXWET6DDSM5Ev+MYwMcSAY4r8+tvARRU4ZAenRgjkBT6R5z6cD76emRax14tbV6vkjjwRcO+dQtM0tFPbd+5fsNInbauv50VzIMgjA6RnKTOI17gRsSdGlsV4vZn2aIxEPWauu6T/UohMvAE9HMn13vtbpPBSFwJAktj6yHASYGzupNQLprA0+OdyALoLZPpQAKNEXA42a4EVISBKu0EmduHJlUPeqhnIGkkGgVNWS8AWqzP2nFoPdXBgUWateiMcBTHxgEKDac5YmNc9lsXpzf1OxBaXHBhGYKuXPwIfyH3jTWb1OdwixJEuRe9dl63T9qOTRre8QWns/bMqKLibGfMtFhVB21ARJayBuX70eVvabG/2N7Y5t1zUlFygIKu51tvo3AVCRDdRrFWDvkAjxzIz5FIdALVZ+DReFYu/r4WF/w3V9rInFuEDSwb/OH4r8sQycs07tSlMyA74Y3FpjKTBxso=","translations":{}},{"version":"0.3.2","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/juliushaertl/apporder/releases/download/0.3.2/apporder.tar.gz","created":"2016-10-06T14:00:51.532409Z","licenses":["agpl"],"lastModified":"2016-10-06T14:00:51.598455Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"gRVFOtj9414ZNSdRH/qNB2SwVZUQh+gaFnNLFjjXjJ1MdRMCISzvwb+QU1qYuK/y\nuL8K0pn1+fFQf8A3VsC2pb6yaLQ5U9C3Guf886Flf4qtYw1P8UWRA9yOJ+6Md+PH\n6pTEiDIdm4xbmM0KkBhsE5kL8dvLIq4EwwcAh2Qq8fjytzAk1YiP+KrTaYrVwskM\nDmm0lgP4NVnjRBTX9myW6tr6N3w0tq2jJ/+a/vEDJv+5ozKJx8N5gbJNdrtI4k7I\nyaQNWJ7cngtAHmUREeoBggV5uJayDceu83PPQR6N9/WVyNyZjw1Q8/Q6e/NyiXT2\no8mGv5tHl3DBOVuv8v7gBQgDh6ppp12M81aiCZymn2XIgjw50VQ+K15KHnLHuFFw\nwuHZVcoQ7b6oR4K4TURSfPFUeNgGS4R9v6gjg1RUcSm1Pnryc6pYnh10AUY8dk6q\n1CZ6Upt6SScP2ZEGWsFwVjjQhY/ZJmNfnhaGoFOZ5L9CnzyNCkGXFg0rL36i6djb\naqFy/z+Brnklng5ct6XWoP7uDt5BaHznQj1NHSfHn0GUQ0N968zWm9vQvy+dyXyC\nxR7vKeu2ppZ2ydoeQ9CVwfhOEsGs5OvrpapQdh9KbUHcX7b7ql01J7/P6dFuNuHe\n+7/y4ex3sEVg5YBmDtF8iZ6d7zsHd6peL1s1EsLnenQ=","translations":{}}],"screenshots":[{"url":"https://bitgrid.net/~jus/apporder-nc.gif"}],"translations":{"en":{"name":"AppOrder","summary":"Sort apps in the menu with drag and drop","description":"\nEnable sorting for icons inside the app menu. The order will be saved for each\nuser individually. Administrators can define a custom default order.\nAppOrder works with the default owncloud menu as well as with the direct_menu\napp.\n\n## Set a default order for all new users\n\nGo to the Admin settings > Additional settings and drag the icons under App order.\n\n## Use first app as default app\n\nYou can easily let Nextcloud redirect your user to the first app in their\npersonal order by changing the following parameter in your config/config.php:\n\n'defaultapp' => 'apporder',\n\nUsers will now get redirected to the first app of the default order or to the\nfirst app of the user order.\n "}},"isFeatured":false,"authors":[{"name":"Julius Härtl","mail":"jus@bitgrid.net","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIEAzCCAusCAhAEMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYwOTE0MTI1MjQ4WhcNMjYxMjIxMTI1MjQ4WjATMREwDwYD\r\nVQQDDAhhcHBvcmRlcjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKVK\r\nKn5jivCu+eRfe5BECjDOzNaGHlpiegb49Hf4nh0W7DqcoLHip5c1O2BcEYdH6rkw\r\n20WclvjoQpgavG5aFXzXzur6eKTT5TpgY5oZTLoWjbx4e+fKdhyDPTpqNZzs1pxz\r\nsZLDL/ElpbSErE0s+QK/pzP11WNPylAkI9AKSyDMO3Mbllg8I8Bt+bT7LJKYOO/T\r\nLhv9m0anLZ4HrdfimhVIoMiu3RpyRigk8titXZA94+F8Fbf7ZQ9f14Y/v3+rfJFQ\r\nii9cDoox5uUrjplH2LrMr5BodfCfydLu4uVpPWYkdccgvcZ1sugjvNXyCQgdzQDK\r\npOpiwVkkiQFaQJYbGSDblFWPl/cLtA/P/qS7s8tWyTQuc1rYlEpCHG/fG8ZFkSVK\r\n9eCMGxK908VB4IU2DHZHOHi7JvtOz8X/Ak6pIIFdARoW3rfKlrz6DD4T9jEgYq0n\r\nRe7YwCKEIU3liZJ+qG6LCa+rMlp/7sCzAmqBhaaaJyX4nnZCa2Q2cNZpItEAdwVc\r\nqxLYL1FiNFMSeeYhzJJoq5iMC3vp2LScUJJNoXZj9zv+uqTNGHr+bimchR2rHUBo\r\nPzDLFJmat03KdWcMYxcK5mxJNGHpgyqM7gySlbppY/cgAospE8/ygU2FlFWIC9N0\r\neDaY+T8QA1msnzsfMhYuOI8CRYigan1agGOMDgGxAgMBAAEwDQYJKoZIhvcNAQEL\r\nBQADggEBAGsECd+meXHg1rr8Wb6qrkDz/uxkY1J+pa5WxnkVcB6QrF3+HDtLMvYm\r\nTTS02ffLLyATNTOALZFSy4fh4At4SrNzl8dUaapgqk1T8f+y1FhfpZrEBsarrq+2\r\nCSKtBro2jcnxzI3BvHdQcx4RAGo8sUzaqKBmsy+JmAqpCSk8f1zHR94x4Akp7n44\r\n8Ha7u1GcHMPzSeScRMGJX/x06B45cLVGHH5GF2Bu/8JaCSEAsgETCMkc/XFMYrRd\r\nTu+WGOL2Ee5U4k4XFdzeSLODWby08iU+Gx3bXTR6WIvXCYeIVsCPKK/luvfGkiSR\r\nCpW1GUIA1cyulT4uyHf9g6BMdYVOsFQ=\r\n-----END CERTIFICATE-----"},{"id":"twofactor_totp","categories":["tools"],"userDocs":"","adminDocs":"","developerDocs":"","issueTracker":"","website":"","created":"2016-10-08T14:13:54.356716Z","lastModified":"2016-10-12T14:38:56.186269Z","releases":[{"version":"0.4.1","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.4.0 <7.1.0","platformVersionSpec":">=10.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/ChristophWurst/twofactor_totp/releases/download/0.4.1/twofactor_totp.tar.gz","created":"2016-10-12T14:38:56.174612Z","licenses":["agpl"],"lastModified":"2016-10-12T14:38:56.248223Z","isNightly":false,"rawPhpVersionSpec":">=5.4 <=7.0","rawPlatformVersionSpec":">=10 <=11","signature":"bnwWxmHEn8xkoWbtwhC1kIrJ0dQfAI3PUtU62k+Tru/BHt1G2aVxqO8bCdghojZ7\nzdFMlIJw4kekYFsVfLk8jzjUTZKVbNVKCdkHrVTQ0bUUryMAMLqGQ3PSRI5NX6D5\nFpkvwO1coYwU0XVWF8KAS0meX0ztSkT3Mv96LLrxr8F8SrB/MGmKIE4WTjt1fAIa\nZLAVEUo/3sNFTGLYBtL3wjctrkZvJltP8abeRfls9FkRHu+rN7R3uLFzk42uZn3X\nWpt5BBmlYm5ORbnJ2ApsxEkMNK+rOy8GIePaz5277ozTNrOnO04id1FXnS9mIsKD\n20nRzjekZH+nneQYoCTfnEFg2QXpW+a+zINbqCD5hivEU8utdpDAHFpNjIJdjXcS\n8MiCA/yvtwRnfqJ5Fy9BxJ6Gt05/GPUqT8DS7P1I1N+qxhsvFEdxhrm2yIOhif8o\nh7ro5ls+d3OQ8i3i4vdZm821Ytxdu/DQBHiVoOBarvFWwWAv2zd2VAvpTmk6J5yv\n3y+csRqpEJYd9fcVMPsTu7WBRRrpBsAqdAHJcZEwak2kz1kdOgSf8FIzP1z6Q71d\nMl2RKcPeutMHHSLiGIN/h7fM5aSs49wGgGZmfz28fHVd7/U0HFSMYmkT/GMq5tMP\nIyc+QZAN4qbX8G0k/QSTkK/L4lOT2hQiQqiSqmWItMk=","translations":{}}],"screenshots":[],"translations":{"en":{"name":"Two Factor TOTP Provider","summary":"A Two-Factor-Auth Provider for TOTP (e.g. Google Authenticator)","description":"A Two-Factor-Auth Provider for TOTP (e.g. Google Authenticator)"}},"isFeatured":true,"authors":[{"name":"Christoph Wurst","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIECTCCAvECAhASMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYxMDEyMDkzNDMxWhcNMjcwMTE4MDkzNDMxWjAZMRcwFQYD\r\nVQQDDA50d29mYWN0b3JfdG90cDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC\r\nggIBALC1K94104L/nOtmTygx7QNjUcnHs3yrn71mw4pMxTlonXOnMTpwxsfL1Hhu\r\n/5GMSgupTbQPlevSl6J86UMs455/sPShd6ifmAuhb8VFaAsjpizjs0RMaUg1sjmF\r\nuV18PD9FXLourx51V/c4MG5kpavlV+bLUrVMAjbsJY2+k30tCC/XkP5u8jUWmM/T\r\n5REChn7/obPgaeddhuJoILYhKEW3VNrR8Fm9SYiviB3FLhM7URDZ97IBnXYqbvbT\r\nZnvq+E74Zc7HgYwQwrjU/AqQAInhNpAR4ZM6CkWWWWaL96O1q3lCfKJNaxqC0Kg/\r\nkGn/pxYkl9062jtMUz60s9OPDyuisfyl68UyM68Ozyz4SMRLmDVbewOqQAwmAbtz\r\n8p9AQrX3Pr9tXhARR4pDSsQz1z+8ExEd6EKbhMyiTtHtZQ1Vm9qfoR52snpznb5N\r\ne4TcT2qHAkOWV9+a9ESXmQz2bNjgThxEl5edTVY9m4t248lK5aBTGq5ZKGULNHSQ\r\nGGpr/ftMFpII45tSvadexUvzcR/BHt3QwBAlPmA4rWtjmOMuJGDGk+mKw4pUgtT8\r\nKvUMPQpnrbXSjKctxb3V5Ppg0UGntlSG71aVdxY1raLvKSmYeoMxUTnNeS6UYAF6\r\nI3FiuPnrjVFsZa2gwZfG8NmUPVPdv1O/IvLbToXvyieo8MbZAgMBAAEwDQYJKoZI\r\nhvcNAQELBQADggEBAEb6ajdng0bnNRuqL/GbmDC2hyy3exqPoZB/P5u0nZZzDZ18\r\nLFgiWr8DOYvS+9i6kdwWscMwNJsLEUQ2rdrAi+fGr6dlazn3sCCXrskLURKn5qCU\r\nfIFZbr2bGjSg93JGnvNorfsdJkwpFW2Z9gOwMwa9tAzSkR9CsSdOeYrmdtBdodAR\r\ndIu2MkhxAZk9FZfnFkjTaAXcBHafJce7H/IEjHDEoIkFp5KnAQLHsJb4n8JeXmi9\r\nVMgQ6yUWNuzOQMZpMIV7RMOUZHvxiX/ZWUFzXNYX0GYub6p4O2uh3LJE+xXyDf77\r\nRBO7PLY3m4TXCeKesxZlkoGke+lnq7B8tkADdPI=\r\n-----END CERTIFICATE-----"},{"id":"contacts","categories":["office","organization","social"],"userDocs":"https://docs.nextcloud.com/server/11/user_manual/pim/contacts.html","adminDocs":"https://docs.nextcloud.com/server/11/admin_manual/configuration_server/occ_command.html?highlight=occ%20commands#dav-label","developerDocs":"https://github.com/nextcloud/contacts#building-the-app","issueTracker":"https://github.com/nextcloud/contacts/issues","website":"https://github.com/nextcloud/contacts#readme","created":"2016-10-30T14:00:58.922766Z","lastModified":"2016-11-22T22:08:01.904319Z","releases":[{"version":"1.5.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/contacts/releases/download/v1.5.0/contacts.tar.gz","created":"2016-11-22T22:08:01.861942Z","licenses":["agpl"],"lastModified":"2016-11-22T22:08:02.306939Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"ZqqhqtbHcNB+rzGCQ7FDIjjvHjit+dhAE1UhFgiXApkx3tmPP4nJOBAGNjHe+2Ao\nVcTIX2SrWEfieRrA4Gp+0k7pUPWag1Z0T1OVOwO4cmS1AVFyGIOE1bRvDhMfsWTU\n4CI4oXaKBFAY6mtnf7VJ7EeIdNqhImkohyWDQ88NiPRLM1XNkJJk6AvZBcT0fvCv\no145X4dLpbixSXsN99QFNJ/oXvK+9tBGwTd5i/WnNFY90vcNRLia8aRo7SA0YJRx\nLnxnj2HMqwTTDQEKE+1elYKWsqQ2DeqwScP97UIKe5bZXnrwOi9kH9PDmR4abtzd\nlHL8E1Wgw25ePDeHG7APrx0tVOJy1bP+g8vcarpGynWZoizDkBvYZD+xtxizpBXC\nJsDOSzczApptY6dnOtv0Vat8oh/Z/F99gBUahEu4WZ16ZgR1nj40PDK1Snl18Cgk\nMe1EZcde8SLEpTbCWYIfIw/O9Fkp5cWD/dAqoiO6g+gNxSZ/gGp57qoGfFxn7d/x\nH3aH8GljatAFjrwItw1JzR0THt0ukkOK+bw/pfCslk10sjHMitmz/GXa4qMS91DZ\nBKLUd0dSfQUQzkfwcojImbzJRvca4/DYe3mfG7+RCH0tDL6t72dKL9joB++u5R1u\nVZPgkToexlXcKWpiDB8H2/SEShKr4udAOjR5de9CYWM=","translations":{}}],"screenshots":[{"url":"https://raw.githubusercontent.com/nextcloud/screenshots/master/apps/Contacts/contacts.png"}],"translations":{"en":{"name":"Contacts","summary":"The new and improved app for your Contacts.","description":"The new and improved app for your Contacts."}},"isFeatured":true,"authors":[{"name":"Alexander Weidinger","mail":"","homepage":""},{"name":"Jan-Christoph Borchardt","mail":"","homepage":""},{"name":"Hendrik Leppelsack","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIEAzCCAusCAhATMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYxMDEyMjAzNzIyWhcNMjcwMTE4MjAzNzIyWjATMREwDwYD\r\nVQQDDAhjb250YWN0czCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANzx\r\n/zJF+5/s4lOJLWIlfKQgTy+UpvIpiUXCgrsHsDZTx+hjQAhIWukH88a+7NVAL7Ys\r\nkQNC0Tlm755FJi/T6EdR7edOwIRdo2ZwakOWLZXd209+6cCd2UloHL0bgnbWepTl\r\nR/4YgbLg/G+FVKCfkEiYc3PuDZ3EVrcwQFcg7h74X9ne6CHH0Z1WQLydxJuVEb2n\r\nX9I+nIRpPHcVostkSiUmzHR7C5TjTIo2PzzgnCU6GC0iBa6z6dDYfz24QEp/b8UA\r\nZaLhjkyKghVGMnoF/s9KPgH4NM8pvvtadQN8pxlOPju4wbmKPUrsXo4ujurDXbbc\r\nYkzNt8ojobGwdTXoyDogAsGZLQd2FQksWpRvY+I3zVPokBfPMdUPLllG5VcV0VA5\r\nDRK+h2ms+XmspdBvGonjF+XdbFm9hEmDoFmoi9aU6C6AdofjmG/e9+pw/20dXUWk\r\nmMorWwXQ5yLmIn5LnpRXrOuK7CS28VRhBYuVNMlsyKhzU0rophbsD9OFXxYLjr6s\r\n7UPNwZ5h+kjXZDBKD89QctBSViT8RhLe8nulRIm0iJn1sb9hca/CF63KmsFzENfK\r\nQeM6MO0H34PB84iNyz5AX1OIy+1wHD4Wrzt9O/i2LkWK6tBhL69aZiBqdLXWKffj\r\nARDCxxIfews51EZFyHzwsw65I97y46aBKxY382q7AgMBAAEwDQYJKoZIhvcNAQEL\r\nBQADggEBACLypX0spxAVAwQIS9dlC9bh1X/XdW2nAvSju2taUTBzbp074SnW6niI\r\nbnY4ihYs4yOuGvzXxnp/OlvWH7qhOIchJUq/XPcEFMa7P03XjVpcNnD3k0zQWlZb\r\ntGonX9EUOeLZKdqI4fkrCkMLScfjgJzoHGYQrm8vlIg0IVuRLCKd5+x4bS7KagbG\r\niuPit2pjkw3nWz0JRHneRXz/BNoAWBnJiV7JMF2xwBAHN4ghTM8NSJzrGTurmpMI\r\nGld7yCP47xNPaAZEC66odcClvNtJ2Clgp8739jD6uJJCqcKDejeef0VU1PG7AXId\r\n52bVrGMxJwOuL1393vKxGH0PHDzcB1M=\r\n-----END CERTIFICATE-----"},{"id":"mail","categories":["tools"],"userDocs":"","adminDocs":"https://github.com/nextcloud/mail#readme","developerDocs":"","issueTracker":"","website":"","created":"2016-10-19T19:41:41.710285Z","lastModified":"2016-10-19T19:57:33.689238Z","releases":[{"version":"0.6.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.4.0 <7.1.0","platformVersionSpec":">=10.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/mail/releases/download/v0.6.0/mail.tar.gz","created":"2016-10-19T19:57:33.676730Z","licenses":["agpl"],"lastModified":"2016-10-19T19:57:33.834580Z","isNightly":false,"rawPhpVersionSpec":">=5.4 <=7.0","rawPlatformVersionSpec":">=10 <=11","signature":"VbMsvDpt+gSPeFM8LrZXEK10rk8kkLlgCcblgqNdCSeGZeVpwDAYv3CccVSLa0+l\nlTSqQ0VIoH+OIU6vIQNBKHmSCzTplk7OrY0+L5FajXx8LnBaOh892GfGSlEt1neN\nKyM0i0uOjO/xpCP/NoUlgkz6hnmYY5XEdN6DTsJtJ/XZhDQ45IYuIkMkHE/eFehS\n0JnOagIz+PSipeBY2Ry+tV8YbRa7bC1JAvZzlod0dyI015AHZESeitRUY+MwMWkt\nN/me7g7/Kev0wggIQQZm9aYcw63GMk/1VHUPB7Y0ESW9tx2nR5+KwTDn/Jy4DGf1\nrg8h0t5I+aPhHOBLrpczH0qaZWY2lsVZWq8KWjJI9aR9P0v2f2aXixXzD/Cuz1cK\nhvhKWkOSla4D+/FxeyHGjQvdXMG8gXm0ZmTimKChCoVuCbncDd8pzkdyNoGXcvuk\nsP8OrkQFooL4E7S4BWfdSiN/a8jUITJQkuXp/OVrVGeCupLWJh7qegUw6DvoqyGy\nD4c6b+qYn68kx3CLaPPiz+tFAZQZQdj7+Kx/lohso8yTnVSiGYrMj4IvvCbpsQjg\nWF3WSqF/K/tTnPYTWb9NUPSihTbVNv6AXOfTsPEp/ba2YSS5DjvjVjkr5vhR9eg1\nikQ3Cw6lW3vaA4LVCC+hFkMRnI4N0bo5qQavP3PnZPc=","translations":{"en":{"changelog":"### Added\n- Alias support\n [#1523](https://github.com/owncloud/mail/pull/1523) @tahaalibra\n- New incoming messages are prefetched\n [#1631](https://github.com/owncloud/mail/pull/1631) @ChristophWurst\n- Custom app folder support\n [#1627](https://github.com/owncloud/mail/pull/1627) @juliushaertl\n- Improved search\n [#1609](https://github.com/owncloud/mail/pull/1609) @ChristophWurst\n- Scroll to refresh\n [#1595](https://github.com/owncloud/mail/pull/1593) @ChristophWurst\n- Shortcuts to star and mark messages as unread\n [#1590](https://github.com/owncloud/mail/pull/1590) @ChristophWurst\n- Shortcuts to select previous/next messsage\n [#1557](https://github.com/owncloud/mail/pull/1557) @ChristophWurst\n\n## Changed\n- Minimum server is Nextcloud 10/ownCloud 9.1\n [#84](https://github.com/nextcloud/mail/pull/84) @ChristophWurst\n- Use session storage instead of local storage for client-side cache\n [#1612](https://github.com/owncloud/mail/pull/1612) @ChristophWurst\n- When deleting the current message, the next one is selected immediatelly\n [#1585](https://github.com/owncloud/mail/pull/1585) @ChristophWurst\n\n## Fixed\n- Client error while composing a new message\n [#1609](https://github.com/owncloud/mail/pull/1609) @ChristophWurst\n- Delay app start until page has finished loading\n [#1634](https://github.com/owncloud/mail/pull/1634) @ChristophWurst\n- Auto-redirection of HTML mail links\n [#1603](https://github.com/owncloud/mail/pull/1603) @ChristophWurst\n- Update folder counters when reading/deleting messages\n [#1585](https://github.com/owncloud/mail/pull/1585)"}}}],"screenshots":[],"translations":{"en":{"name":"Mail","summary":"Easy to use email client which connects to your mail server via IMAP and SMTP.","description":"Easy to use email client which connects to your mail server via IMAP and SMTP."}},"isFeatured":false,"authors":[{"name":"Christoph Wurst, Thomas Müller, Jan-Christoph Borchardt, Steffen Lindner & many more …","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\nMIID/zCCAucCAhAVMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\ndXRob3JpdHkwHhcNMTYxMDE5MTkzMDM0WhcNMjcwMTI1MTkzMDM0WjAPMQ0wCwYD\nVQQDDARtYWlsMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp++RuliQ\nlBeeiPtP0ecBn00OaU1UCpft/NVI5pnSiT9nU4l2kc5IvKjA8UxDB3gWfYTOeBFh\ntUHQ2P6UKCmHZT9sApHhqLu2n0V+YhlFIViuaxndSID/M414cl56xOYQusV3Pcae\no2dOSeRRzLab3tEaVHlkBSFkGmAwPZItsmTklvV3h1sUysDicYgfXPCkf7K+JgWA\nBP7vsWC8B7MDRhcB3enYv5tTcpsyvtGX7bb1oTIWVypcmKsGYfTX12VNBxKzNBIG\n8pwdb8Xo0o14TytWsWN7mSHf1XbwfwYMjDWOlMqiRc+mcoKMBH41TfM/CXslSivI\nsyvxasEaFdlj8lmKPENdzw1OfYRs43usIf4szwyt4rb8ocXfDipnY3P2hccN6YcZ\nl8y8Vsr69ASluDj2A2Pl5vH6xp6tNybZRnN5G6sghhaYaLNDU/TdMyYzz4AY33Ra\nHSaMypfcXjd76Aj8jZvcwk1BH+ZsvFqNK7ZKCb7WVcMH8KRcU1sxZ4rp9vviM2fL\nL7EVtznm3bSI9jjHXbiwq7RvNRRy+F6YRpAdWGwTU8uUkDabPFi41FikYyzNWauK\nJhlDJXl514XjKyMVBjAZYVr5gZZkO1J7C4XzLFbC5UzYNSzW5Iwx/1j5OeYJRxh6\n5rhiUwR+COT1wdVsl6khMC8MfBR4unSd338CAwEAATANBgkqhkiG9w0BAQsFAAOC\nAQEATBvpqz75PUOFPy7Tsj9bJPaKOlvBSklHH7s43fDDmQbJwswXarZi3gNdKf8D\nyO/ACZvO8ANWAWL/WahkOyQtKOYzffaABGcEIP7636jzBdKtgwSGzW3fMwDghG10\nqBr2dE6ruOEdSpuZxgMgh2EulgknZUXaHAMI2HjjtAMOBScLQVjOgUqiOHmICrXy\nZETmzhx0BXDt5enJYs8R2KMYJNIme1easQRYmWKliXogNY09W7ifT9FHtVW1HX+K\nxRS4JXbapjolkxyGSpP+iYSgItVnYzl6o9KZResR4yDsBv7G/8fpV4GQU9IS3zLD\nPiZOosVHWJdpUKCw9V4P1prGTQ==\n-----END CERTIFICATE-----"},{"id":"audioplayer","categories":["multimedia"],"userDocs":"https://github.com/rello/audioplayer/wiki#user-documentation","adminDocs":"https://github.com/rello/audioplayer/wiki#admin-documentation","developerDocs":"","issueTracker":"https://github.com/rello/audioplayer/issues","website":"https://github.com/rello/audioplayer","created":"2016-09-16T05:44:24.857567Z","lastModified":"2016-11-17T22:34:34.637028Z","releases":[{"version":"1.3.1","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.4.0","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/Rello/audioplayer/releases/download/1.3.1/audioplayer-1.3.1.tar.gz","created":"2016-11-17T22:34:34.215350Z","licenses":["agpl"],"lastModified":"2016-11-17T22:34:34.867778Z","isNightly":false,"rawPhpVersionSpec":">=5.4","rawPlatformVersionSpec":">=9 <=11","signature":"p6Zz0IEFrxvw6y/3jHgGWWCxR6qpMzvU2HKfxcIVsK6sJnoRUhWLeAXwZ432fH2a S2llj+IGS9OvW+5VQElrXgPtEjDK1BT00DRJnp5RFCRlUv0LNoedJMzx6B6AHqPP JBufk3cG1O/CO0M0L1ITGSmSOzfKvWTRo3lxVGF792NyBaP/SyZCkH1N1TzBQzUi Ywl3+HiglPcXbHjtJm/arnKorbJWVKoaN93xFuaBapd2ozQSpi0fE0uGRsici+U7 HNa1M5WFE1rzUJoufE0E9246At07rFY1e+TdNEq8IlLgCXg5vGCKkEyuWpWno6aX LfRaIiT9x39UTAwNvuDKS0c+n4uWDYPsGfKhDx9N7CXpUrthfXVEWRzZEXG7as10 6ANvrRPJemSZH8FUSrdJhD7k12qa9R825y7mIG68Li8P71V92EOxFfo9tNXqXwBt VuDGxBqByFVPqSCj5I8hrzJzQl2Xt40g8+8ZcSF96RMg/pM+bwRMTv+mz0V+vQQ4 DWjqnWVPalaJ1PPD5/QFFErtXuNRbyxKZ6BMWxfJlLM9Kz66P75K+8fYaSwz+2KG NxY7I3svzS2K9LGH3fBLUy1t3Hl+c3zGFq/ll1MJrf9NswV4yxt2WmISfM/KDww8 yELkGs2cRzbw2tCvnmYlJJhIqRLkyFAbDzWRH/XdVx4=","translations":{"en":{"changelog":"2016-11-17\n- fix: one-click-play for wav not working\n- fix: wrong sql statement for PostgreSQL [#90](https://github.com/rello/audioplayer/issues/90)"}}},{"version":"1.3.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.4.0","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/Rello/audioplayer/releases/download/1.3.0/audioplayer-1.3.0.tar.gz","created":"2016-11-15T18:11:19.539636Z","licenses":["agpl"],"lastModified":"2016-11-15T18:11:19.592881Z","isNightly":false,"rawPhpVersionSpec":">=5.4","rawPlatformVersionSpec":">=9 <=11","signature":"lbp7wd3JhMHW5mC8kVnQFvcwzf3aTIhYhq3ak/C/vfDXJDIPFuQ1odVRWtaHXEKQ XmKYIoTobV1TAU5q9G0O0Kds73T/XtHG4ATLxMZE8RsUWNSj5v3H4YDub6A0uoX6 rzyLEYV6SGEtdPFMwLcUjDExKpzAzKpgxcd9uyz2NhcHJEO8FJmirn34bm69//TO vjjiMW4zpL+dho+7LQbOX+L1SmwmdBqwypE9zzeuIuhUWDEQtImHAvjIO6Temajm lX0H5JaowJa8kvP6Jkh3KAvsHQ4sJklvWTPGcv0gboN+o6CmjWNOb+3LeSH0nhe6 BmiPloUDJcPQwq2gQejH2pY+qJEdRcULSKS09/dRbE3gOSlG36FThN0INpv6uNP4 qVIiYs3/SEHMmlS5CHvJDt2S2XN9LT9IX7QPeuS/0CMcuopaG/+cdC4KscVCq4D4 bllgew9asiBqix8iV8C4oerYOiC5vWcgBrZhGShoJT1Qq+NKz+H10dFgjFCAZuPj nVagJkbXmf2NdcvpSC7qsufhyEZyCSp+I7QEYsbo1PW3aUU35Syt47lgeVFX0hVQ jC1wMIhEW5Rm2nCkRSZkRupKDQ+N6uWuB0lykeMV2ShcDvvUZrhN3c49sooWgigB yIqKryzM4fLErjjNHdYgwCq6bbgPDLK3ic9b3B4rF3E=","translations":{"en":{"changelog":"2016-11-15\n- fix: handling of temporary scanner files [#68](https://github.com/rello/audioplayer/issues/68)\n- fix: simpler analysis of incorrect files in scanner [#57](https://github.com/rello/audioplayer/issues/57)\n- fix: album sorted correctly by artist and album [#80](https://github.com/rello/audioplayer/issues/80)\n- fix: neutral cover for unknown album [#16](https://github.com/rello/audioplayer/issues/16)\n- fix: error message from ID3 editor shown in front-end [#77](https://github.com/rello/audioplayer/issues/77)\n- enhancement: occ support for library scan and reset [#72](https://github.com/rello/audioplayer/issues/72)\n- enhancement: select a dedicated folder for scanning in personal settings [#79](https://github.com/rello/audioplayer/issues/79)\n- enhancement: exclude folders from scanning via .noaudio file [#79](https://github.com/rello/audioplayer/issues/79)\n- enhancement: significantly reduce database reads during scanning [#79](https://github.com/rello/audioplayer/issues/79)\n- enhancement: cleanup of classes; move from \\OC\\Files\\View to \\OCP\\Files\\IRootFolder [#72](https://github.com/rello/audioplayer/issues/72)"}}},{"version":"1.2.2","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.4.0","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/Rello/audioplayer/releases/download/1.2.2/audioplayer-1.2.2.tar.gz","created":"2016-10-06T21:21:05.414691Z","licenses":["agpl"],"lastModified":"2016-10-06T21:21:05.483224Z","isNightly":false,"rawPhpVersionSpec":">=5.4","rawPlatformVersionSpec":">=9 <=11","signature":"toeS45z50Lm0djgrQokOTN7gA8a113IZtiKKiLsGUKWrCV/6AKJBmEFcSun6rhLH\nbz/RtIdFKwQql6O3E0m1Zch2y1A8aLWHzFTO+5orLCVi7y15SshrJYbb9aI5Pj3i\nSR7+kMHGS8uNx2uIn3B4mO6UYF8AzCfp+ule18DOjnpu86KWvEOGtFXsQkLtgepp\nbJhOGWW/uOVIos/T1xPP4GCmtVmgn7U3b9q0pMYRH7ONXEiNsfQxDrR66EZH3Jfo\nlVyM9UvQmMKoDSdBUlvLlhCEGJGqFOD7hFntLYloI4oXv9uGqcagaJVh3TkEysY2\nMbBZpVhch5zRJ/HGlZOvmEzZ8Inxkk3iap+JmJ5/gZTefwfKUyYHALsILlh820U2\nNA/1B5A015XH5a5uflGE/tnlPtrOeecIN4mg+1njo2RG89HJWJNHM2ZDO4SkXjSR\njgygmAS5aR5+KKifiA/pwjhLozDWPU4lNzsj3Foz3bx3Okopy7eq83LORqieT4Jp\nFvP64q/45LOSRBWIWLitYzRzZp7HYywMsnz12WpxtqxIjO7+7y/ByeWWOBNU1IJC\nK2D+035ZGWZr0CxDJte33WOISwjVoSwrcov++O3BQW8lM5IkcDNcJFyzNPKAXcQU\nPUXmQpYurHoIw6odAYcbrG6iOiSesuNOf2kQWbjV3/c=","translations":{"en":{"changelog":"2016-09-18\n- fix: icon issues with alternative apps folder [#65](https://github.com/rello/audioplayer/issues/65)"}}}],"screenshots":[{"url":"https://github.com/rello/screenshots/raw/master/audioplayer_main.png"},{"url":"https://github.com/rello/screenshots/raw/master/audioplayer_lists.png"},{"url":"https://github.com/rello/screenshots/raw/master/audioplayer_share.png"}],"translations":{"en":{"name":"Audio Player","summary":"Audio Player for ownCloud and Nextcloud","description":"Audio Player for MP3, MP4, Ogg, and Wave with a lot of flexibility for all your needs."}},"isFeatured":false,"authors":[{"name":"Marcel Scherello","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIEBjCCAu4CAhAIMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYwOTE1MjExMjA4WhcNMjYxMjIyMjExMjA4WjAWMRQwEgYD\r\nVQQDDAthdWRpb3BsYXllcjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB\r\nALyC+iLscLs62NeNmUXEBmg+xMuUtDmZKr+xzJWtl6SSNRz+8K1JygvUIXFJ3RIL\r\nCYA3xyq8/wyZH1gNrLKyz5eTeYawG+eT3ges/FT6MWGUbZoRrBrikVcLC94QzxTH\r\nxOl8Dn+SCV/2bhcvPTQdhK+dqtvGilOtjHa40iMrk9gSdlKVys5CK/xdlEp8uiMa\r\nkz1WENn8MVCCJV58bAUbaCupDWXR9CCoSsw8XinNsCenZ2B2XlnmbM44280w0ojs\r\n72rfQRgj3yDG+ZUUyUOuxIuodu8liXYciLf0ph6t/f/qoSmctbBdsR5Fl1Upj1Ac\r\nqeHb5Yf/B3Vi6Mn3XfDx0H2EHk1v9Dhzxay+v9BHUzyIX2iH/q+7TE0/Jzo5AwBW\r\nvFKWXvG7wXaALcHYZf5v/M93IE0iCHsv2EsZKQPBnzXVGmp4DwFSP4po1B7hcog1\r\ngAMaellAzzvUAizgCovN6Qct3qDEANYniPlvtnlcaQGonajW4N019kFQRHLIzPFR\r\njab5iUMMwSnT8FhZO2ZOWuWhJven+gXjxC8mfMVgBfZnAVgydNfx9rN+KzTc88ke\r\nobUdZ0OOeBzA7pIxGEFg9V6KTEEWZ+qH048vxXz4HI9B1I+2wQLBrZl8CvweEZ5U\r\n5ID8XrrE/UaNZ1CvLKtCgB24gj/m1Elkh7wA3gEcEo2JAgMBAAEwDQYJKoZIhvcN\r\nAQELBQADggEBACtgUp+FCmjWIkQUuWSdzKWdO+IH4v9wBIrF9mo0OLIakFyDYyM5\r\nLlkYZXbplGXd4cfn3ruIqJNzlIb4xa5CU0bM4TMbD4oOSlLMKM/EamKPHI3bzr++\r\nzi7mQDFxmAE6FWSMBgKKUb4tqLc5oBap8e12tPEZl/UR6d9iUB2ltvrm3T3vrjjl\r\n2Worm0eYBNqnagXmX5+wS11AQqeJemGqRy5e1yXRlTgB0IJhH0dCsFNwifEigutp\r\nFNvGFVBn4r5qCiChEoq+rCXHRjPi/eCfbW21XeLFDiLxapcZyc85JIcA7znUYoFe\r\nP7Y/ekMscwWhLbF91OaQlcWpRtEMyde/DaI=\r\n-----END CERTIFICATE-----"},{"id":"calendar","categories":["organization"],"userDocs":"https://docs.nextcloud.com/server/10/user_manual/pim/calendar.html","adminDocs":"","developerDocs":"","issueTracker":"https://github.com/nextcloud/calendar/issues","website":"https://github.com/nextcloud/calendar/","created":"2016-10-01T12:40:39.060903Z","lastModified":"2016-11-22T20:31:13.029921Z","releases":[{"version":"1.4.1","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/calendar/releases/download/v1.4.1/calendar.tar.gz","created":"2016-11-22T20:31:13.020268Z","licenses":["agpl"],"lastModified":"2016-11-22T20:31:13.087340Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"nThwe9CJBCan9nuDLdhfBiQyPhmum6Aa0UcYsIDdhGMw+C2acf81KhEmBJuTTWxo\nWGby6WcrcJJmeuCW+ePU91ju7Pd76RirprhVXIEceIDzSCxin+K0oZCZ1IGVIJjP\nIkVehTsLuCeTBbjvz1b3k5QFyhUhvd32Xt7k5d7VARyI4OqnqYYNBtH9vvgeRrFw\nAxsQr4o4axof6i3iykLg6WfWarYArY4dIuu5DkPuGPWf2bbgjwWEra4sQejhOs7G\nsk1xcsfYv2NpArIbpw/wnATdjiax+Gjz1URMD3NgL5ky0ecuZmNvN25QErg3nlVr\nhh1FBfA5pvCJbkJ6nr5bU4bKaffwDX1nr5h77FS5zzn0Pyd7ZIExmVmNtaeJfnfV\n5vnclapzXMNU+R6t/ATJQd1srvSJhyljQapzsqnrjNMEUojOEvqqygJp0KwNVPqs\n3g9XGSoOnO+WULWBeISW7UVOg8BOF8pwvHIU2++bSzOdpypW0Eq6p2DPWO6qL/H1\neFLKrUg3EvnTjvknbBxMB55h9jNJr0SAlkrmyEVm6+CE3BwRWpKB+cJMBuGiwPwv\nr/ASRiJrkDThbNWAUtX70rUmCqDV6/MujLXViqOc/Q2OHvcXd1oGDccJSQT92/1z\n7nonnedyYQIDqUt7u68WL8JRxp7pFsEqKLVuWSgxW3c=","translations":{}},{"version":"1.4.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/calendar/releases/download/v1.4.0/calendar.tar.gz","created":"2016-10-06T19:58:12.724588Z","licenses":["agpl"],"lastModified":"2016-10-06T19:58:12.790604Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"b//hJbICFMLR0Va1BGMzpLpaPREOo9QhjgfrHvDOfXVpddhvCM8ocz74X1s5hKyy\nGg67EE0pOp0dBf6RyJjduI+Dz1wQX55My7J9G1vXGCN30C/8zAcKSJoA218IWcub\nICavLkz2PkiitIOSZyBCAfEiSAeHPop/JGkq3KxQDC7QwFC78BnE9/adD9tO55c/\nDGLhvP/uTJIeH8RUifikTqVMmPH+aP3uPbZzl+AxhUezRiNCpEtZPA5QGqtQdJU4\nFc6x3d9y4IWbJV4TEIAP8jdfqtLVUQ6szFVnN8Oi1wtN9e8LIylBSYbmIZRj0+qh\nZcgntzEq6U843ZwXcAnL5jNYV0m+KNI+EkXFeWHkjvbwfCdvGPBvgFVbhc0YPzXU\nqHOe4Lvcx9X20ALG/MacV9zX69GzNnWgbBp9RnIHuaSRPFEKrNXUeXl2THuKsTyQ\nF9QtTwS5U5DcMyTO2RAN45NrRxIh8IL4stoIg5rmF7/ZaOm/Jza2gnUquOTarDE/\ntiWnNW5kWUAWyYYHvQgQix/of9qXvc2hhZaw0y623WDNrEwA+rngnjDMLA/vNv3B\nhgwQ6NbCOuHWsRK3S8DcJFpB9Kj/i7CDvDLEuJYnjSTvQ/q1XqawbJPDoRlydX43\n3/L0LvHvKVakYybv2OE5gy6bQ2Dw8e7D27DtZ6XTaBY=","translations":{}}],"screenshots":[{"url":"https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/1.png"},{"url":"https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/2.png"},{"url":"https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/3.png"},{"url":"https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/4.png"}],"translations":{"en":{"name":"Calendar","summary":"Calendar GUI for Nextcloud's CalDAV server","description":"The Nextcloud calendar app is a user interface for Nextcloud's CalDAV server.\n\nIt integrates with other apps, allows you to manage calendars and events, display external calendars and invite attendees to your events"}},"isFeatured":true,"authors":[{"name":"Georg Ehrke","mail":"","homepage":"https://georg.coffee"},{"name":"Raghu Nayyar","mail":"","homepage":"http://raghunayyar.com"},{"name":"Thomas Citharel","mail":"","homepage":"https://tcit.fr"}],"ratingRecent":0.944444444444444,"ratingOverall":0.944444444444444,"ratingNumRecent":9,"ratingNumOverall":9,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIEAzCCAusCAhARMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYxMDAzMTMyNjQwWhcNMjcwMTA5MTMyNjQwWjATMREwDwYD\r\nVQQDEwhjYWxlbmRhcjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMm6\r\nFTeqgzCXprkU83VM4/DrZWn3kqtfaR/edkC4gYT3ug7RHa/Uv1C/S++vr7pvgpnk\r\nYzQoavl/0Qlh5sKEYX+0ud/LQDoiidwBRDckFUQ1bRfVLxAD9UAVvDRHxDqJMOx2\r\ngZArbeQ3ztdSHZp4ThzBFWq2FILsJD86weG7LwHjzhW6SWgLb/YTLbuuW6tRCDVV\r\nbtB0I/a0vCwj2u91Chw3u6pWWjPakc9DQrIDH4HCIBKQ4zVrYDxAmJDRFGDvVVWx\r\nuIAeux8sd8drqSMqAhX+XMcZPRD71NQTWbCupSwWO8kgjmZnBpIiBNpzvMQzJf3A\r\nQloZtjZ2RDXAQG88eTeT8pp8yEOCEoDLpGdraKxJrh/z2Dsk30JP3lOiNYJ9vBaB\r\nC8NJbJ3oAlG7THwUaFF9fsdAKoTwzs5Xms04TI7W/v4Z/GClOzMymnR1T4sR72Oy\r\n3WaMNHv/1QGffvQn2/TtZt23Ou3P083xWx2vn5FgTcac8+x85vRgWsVCA4hq9v6m\r\nAlktB0+UWDEXpDTKD9BdFNWM8Ig9jQf7EJrvTLNnS7FIJZMB4GK8lpvPxyvACWnh\r\nR2hQOe987Zvl3B1JZNO5RvtSeYld9Y9UfMgW1aPRweDNjSuZYAKlugx1ZoyI5HyA\r\nQjfzAwicIMwZsCJDV/P5ZO8FE+23rdWaoJczpBqDAgMBAAEwDQYJKoZIhvcNAQEL\r\nBQADggEBAHQXwvj8q5khWR/ilg3JGYpmMNBYHE9OeDaOcNArkKaGMd478SDPOXeu\r\nyW7hCvNEpiTk5g0h3g3yleZFws0xH8fPsQgZANgvQXb3RCcD61NL77d0cMTr7Xzr\r\nN3Lq/ML1YLc/WwL4uV1XvpMQMwALFL1p63BU2c0ysO31zbLOjMKAJi0hHFDYz5ZQ\r\nD3xxtc17ll3B5IqrMnMHRqmOQ39Sbe56Y7T4agaIz/sUWpseo85D5kt7UAIOR+Mr\r\nQ0Bl/QinETk72afGR46Qvc7tC1t9JjQQD3AUbEGuJdGvXjJJ9GREYu01XoODmPdT\r\njXXOI8XIOK6kxXhPHUc3iWu9b4KqGm0=\r\n-----END CERTIFICATE-----"},{"id":"gpxpod","categories":["multimedia","tools"],"userDocs":"https://gitlab.com/eneiluj/gpxpod-oc/wikis/userdoc","adminDocs":"https://gitlab.com/eneiluj/gpxpod-oc/wikis/admindoc","developerDocs":"https://gitlab.com/eneiluj/gpxpod-oc/wikis/devdoc","issueTracker":"https://gitlab.com/eneiluj/gpxpod-oc/issues","website":"https://gitlab.com/eneiluj/gpxpod-oc","created":"2016-10-31T10:57:44.387319Z","lastModified":"2016-11-23T17:27:37.793159Z","releases":[{"version":"1.0.8","phpExtensions":[],"databases":[{"id":"pgsql","versionSpec":">=9.4.0","rawVersionSpec":">=9.4"},{"id":"sqlite","versionSpec":"*","rawVersionSpec":"*"},{"id":"mysql","versionSpec":">=5.5.0","rawVersionSpec":">=5.5"}],"shellCommands":[],"phpVersionSpec":">=5.6.0","platformVersionSpec":">=9.0.0","minIntSize":32,"download":"https://gitlab.com/eneiluj/gpxpod-oc/uploads/963bbf246412bcbe8979bccadb3b8d03/gpxpod-1.0.8.tar.gz","created":"2016-11-23T17:27:37.783365Z","licenses":["agpl"],"lastModified":"2016-11-23T17:27:37.862469Z","isNightly":false,"rawPhpVersionSpec":">=5.6","rawPlatformVersionSpec":">=9.0","signature":"hqhMh1l/mnwbYf4uPzEjjLFtZWHidzgR57X471OuXv2K/s87T5WhIkTSKk+2r8sp\nS7CtrF5+Pc5AgCCHvwzawN3e2+4eO4cK0+HD9CCzygzzHZEbSjufNHMMQucVoSD8\nPqR6MV9azzUpwHa/5d8fp3cFLVAle+aG0o4v5eHky9c7eaKxVJcgfjw3pjDE73N6\ngJVdtw1jf1kOFYk5pZQxDfBKFDrO5BRo5ZfZGuOuP2u/SmTwj42oTZiT7oTVWhqd\nLvJw+2TPv7B8s0Gin+J5e9K1Rs6CEWQ6WBxM+NhS5KgWB5Ig3pwm0QvMgza2cvoh\nlwVobOotfKLUBJzg0+wR7B2YH9Ao+m94h93vg7H0OKPReoTKhlDj2UExoTyeurV8\nhJdQv8sKVAxjC7/xrVaGSjM4YxFdBpzq8Zl8z4zq1o2voH5+u4ko3c62C1loDpsC\n8KrL1t6A7QpMk/XAMrPqwEPmFqlLEdv6FhzpOGyt4IEVnv6vdMTShcYw3tPvU/mD\njPtiVwpo8gWbGVIfpmwBg4wPaTrWK8V3+/1iTahIQHZfu4Lebb5mzht80HLQIcd8\n+oB4cGDEX4Rix1WxnCmE5ZzURY8xQXcvqYN+mTrUDh/3OtxQPSm5yC945SGoFNpr\nBYxfEyQcwulZrOMBdY0Ssj1AB5NOeC9OHwjJrnVe7dQ=","translations":{"en":{"changelog":"### Added\n- save/restore options for logged user\n- option to choose picture style (popup/small/big marker)\n [#25](https://gitlab.com/eneiluj/gpxpod-oc/issues/25) @eneiluj\n- add average speed and average moving speed in comparison table\n\n### Changed\n\n### Fixed\n- bug when python PIL is not available\n- deletion of bad parameter given to getGeoPicsFromFolder() in controller\n [#20](https://gitlab.com/eneiluj/gpxpod-oc/issues/20) @eneiluj\n- bug in file cleaning, bad use of array\\_unique\n [#22](https://gitlab.com/eneiluj/gpxpod-oc/issues/22) @eneiluj\n- python script do not need to be exectuable now\n [#23](https://gitlab.com/eneiluj/gpxpod-oc/issues/23) @eneiluj\n- jquery.colorbox was brought by \"First run wizard\" app, now included\n [#21](https://gitlab.com/eneiluj/gpxpod-oc/issues/21) @eneiluj\n- avoid JS error when failed to get options values by ajax"}}},{"version":"1.0.8","phpExtensions":[],"databases":[{"id":"pgsql","versionSpec":">=9.4.0","rawVersionSpec":">=9.4"},{"id":"sqlite","versionSpec":"*","rawVersionSpec":"*"},{"id":"mysql","versionSpec":">=5.5.0","rawVersionSpec":">=5.5"}],"shellCommands":[],"phpVersionSpec":">=5.6.0","platformVersionSpec":">=9.0.0","minIntSize":32,"download":"https://pluton.cassio.pe/~julien/gpxpod-nightly.tar.gz","created":"2016-11-16T14:06:33.937534Z","licenses":["agpl"],"lastModified":"2016-11-16T14:06:33.971502Z","isNightly":true,"rawPhpVersionSpec":">=5.6","rawPlatformVersionSpec":">=9.0","signature":"JtUhKRDFGYDx9xtHjdfEUFOb0O4idexUYw6ixlBhKPP8Dn7NfyBfV6KH6MJTIVLU\nQ5Jw6tv/Nr1YDOvVikcWPG0p23mQdn1+7w8DzzIGKmknxCat9/vKr83oJZdWYxS7\nTJ4I7qTvWNlbMfK8OEdl13VJXgc6ftX+1isluLYqLjEm3aBFCS+/awYNMmXO55a1\nyG0NgJRu3pw1CBCMhDaRLsunhpRNDVLsamZj1SPmeT8qy0I/arFaG6hQnAo6JosE\ndi1XkvK6TEt9g16L6eizd+JpGE7xiWFP9ZEmMmmQSOLQYwU5Sk1YWcrW3EX4vtz5\nWnEIC0SENyyAyzBO6YJfu/EP2lLnlbNJiuc4zzKLqRw/zyz3j+imJLcXHIA78ZkQ\nuyUOBkkk3xeyBGeUcYfDuBqYQOQs+F/7+cNMsIBKJhx9ef3OPURBc7X16upk3mxV\n6GsOktbHkgUwWk3WiXRriBIqbAZocvDp0+PN++PAEZVWFEZEJzztd4Fxaeo+QSN5\n5Pz/9yXYRsoSPZv82Tlh7dx5tIPUvYb+UsANh5eGWUGufTSwgYBN0H2KT/iO35D7\nkDzNyh1qNakfBhAgPjrC2p4mBKBJJjlM0D9erDwr5D4GSTW2fp92vlRHeD0X8sqo\n3kBbwGuWnmhdJhbd7zYy0jVM6tVX/zgbhycimNALG0I=","translations":{"en":{"changelog":"### Added\n- save/restore options for logged user\n- option to choose picture style (popup/small/big marker)\n [#25](https://gitlab.com/eneiluj/gpxpod-oc/issues/25) @eneiluj\n\n### Changed\n\n### Fixed\n- bug when python PIL is not available\n- deletion of bad parameter given to getGeoPicsFromFolder() in controller\n [#20](https://gitlab.com/eneiluj/gpxpod-oc/issues/20) @eneiluj\n- bug in file cleaning, bad use of array\\_unique\n [#22](https://gitlab.com/eneiluj/gpxpod-oc/issues/22) @eneiluj\n- python script do not need to be exectuable now\n [#23](https://gitlab.com/eneiluj/gpxpod-oc/issues/23) @eneiluj\n- jquery.colorbox was brought by \"First run wizard\" app, now included\n [#21](https://gitlab.com/eneiluj/gpxpod-oc/issues/21) @eneiluj"}}},{"version":"1.0.7","phpExtensions":[],"databases":[{"id":"pgsql","versionSpec":">=9.4.0","rawVersionSpec":">=9.4"},{"id":"sqlite","versionSpec":"*","rawVersionSpec":"*"},{"id":"mysql","versionSpec":">=5.5.0","rawVersionSpec":">=5.5"}],"shellCommands":[],"phpVersionSpec":">=5.6.0","platformVersionSpec":">=9.0.0","minIntSize":32,"download":"https://pluton.cassio.pe/~julien/gpxpod-1.0.7.tar.gz","created":"2016-11-14T00:57:37.521001Z","licenses":["agpl"],"lastModified":"2016-11-14T20:35:45.363487Z","isNightly":false,"rawPhpVersionSpec":">=5.6","rawPlatformVersionSpec":">=9.0","signature":"SigBof6QJZ9IMZyFgc+B3LO2+EXaAPvnxUHjJQjIl3jLzomocpDGR6WjO6gtvB81\nzXUHjJ8+huc+P9TvgjUGRTmn9a/29HZ4IKTXnYBKIUY7wSLcJNMbJSp2Zd3OFHAG\nJwRaEdh/cIRk2X6NE1VT6dFCxB+LhTM4BXOEwuNYQvU1lZDVQgTz/r68zFLWBt6R\nqhBCNJHrVp87ecS4+XaGq/CfT4k1ihiOv+f4eX9iaPzUhxBJ71iYKF7wHpDoVmIk\nNrzWFUJH3BLBuW9oiC0PApli6Xu5RXrWUsOV7OAmxXgylRCPuTFwe09hw16JMbiS\nii8WFiUtp4qW53+7eoS7Fllm7CRi/Dg6Jvjtp3msrf1m+OiYM7dLyoKw22/S4P/a\nBIErZpSCHaCfrZ+DBXrAYcas27GWE7HizzG3yXk3aDJMa0Otcsq56bSPo01JDfNx\nm1y9iuwmlon8zKKoxsJCwxaFDnQpqazaLcUO0ATHUk8LdomTA7MCXVvNFPaO86Ea\n16iyw7Cfs0k3GrvN71+SdpvWss359CEEwBMpDwJZqwSFbLRyHtogUgbRWLIJqR4n\n5uVvJqirxWkr/EtXw6UkDWAI3ZoMhMRtjn4H4ekANP5mC8R0yp+UuFs2RkEC5uA0\nKzzh73WmxmpeUl6jcMZ49gXn3PTCC2fJNrdmSYch5Dc=","translations":{"en":{"changelog":"### Added\n- option to choose waypoint style\n- show elevation, lat, lng in waypoint popup\n- ability to display geotagged jpg pictures on the map\n- pictures slideshow with colorbox\n- pictures work in public dir link\n- use NC/OC thumbnails to display pictures on the map\n- options block hidden by default\n\n### Fixed\n- fix bug in geojson generation for waypoint-only files"}}},{"version":"1.0.6","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.6.0","platformVersionSpec":">=9.0.0","minIntSize":32,"download":"https://pluton.cassio.pe/~julien/gpxpod-1.0.6.tar.gz","created":"2016-11-07T12:11:00.619161Z","licenses":["agpl"],"lastModified":"2016-11-07T12:11:00.699921Z","isNightly":false,"rawPhpVersionSpec":">=5.6","rawPlatformVersionSpec":">=9.0","signature":"WBts2fm2rW/7LMHYjcx9a0k0WTXV6PnGRxTl+158cjfV7ruMpNvhK58iTjrox69k\nFWAoIi1wNAlLBu9Xet1j7HKi4TC9q61IEN+lPlnwBCu0uHawiqS2gqB4i8A019Ei\noLsgAPWh8ndy6+gyUtPhVLVduLH76aT6KTwAiHPknV0zPtxsUy1P6nbbNOS5A5rG\nSQBqljy0TbcjOctTudEPp1IqjJIwcd12eZ9MLG4CEIO13n53pMAsuXJf4jnKSCm0\ngimvsFOwFRjBab3ZPwtOqeVw6aIh/lYF3U3/k8YBpaDN74m30nDtkp8teXBgshSY\nVYvX3yOAYe0PIR419IX0eoHb61K0VfZYvPT4FsOqjDr0zlVB8Rjq+6SiK4vMD2+6\neGE0aHbjR9HV5jymUnFYdm/hlhcZGaKrAiQKfBY6Vh0SWKfIv7bdGfQYauePAdZt\njlsV8lIwOy7FGAeP81CcjzWWfDeBgYr+MSzfoDNoTi41MvUaT14iWPIU/s5P1/Qv\nALGxgsbmB19wEgNbdh1UtTUY3xARLpWPYdUqU7yDcsddX9vCoCG2G5wCcbYJRj8o\nC+H7wdgPJoiMY/p4Go/lyWkvmzhfXrOeXytZIFXjb3ERVd1vD9WSt1DSy/7gsFYt\nxzzOPgqMvL3BbeluNuzNv366oT872s3OuFKa1ZOYY7A=","translations":{}},{"version":"1.0.5","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.6.0","platformVersionSpec":">=9.0.0","minIntSize":32,"download":"https://pluton.cassio.pe/~julien/gpxpod-1.0.5.tar.gz","created":"2016-10-31T11:08:41.017766Z","licenses":["agpl"],"lastModified":"2016-10-31T11:08:41.068782Z","isNightly":false,"rawPhpVersionSpec":">=5.6","rawPlatformVersionSpec":">=9.0","signature":"UXeZVh5f0/WZE+r/dHWc1pu9q4qr/zACX6XraMhhIuKIp7vNCwUESeqJtVc99QZw\nw9kJp0isvib6l0zbQBRS1vI7xwKKBQyeaEhIciEs1JjsaCiato1Gyi26N+fY2N0Z\nFWlTwCsF3DdlwERXTYfeCpsOWCoxLxHKhnJIjUc0PVme/Ste4zxYj+5Su1RpadSw\n4vGnkW8zy/0tzua50NQCrOg+B4jXzH9kMWAP47w3sdP5CYalHSHl8EX0D1RjgGU5\n7vZYX3wF853FvQDbL4JXXCJupj3wZe8py8McWpQIcgz1p3KmE7A7d/rdNWExT+T+\nDxtStJ56qTRMz4aFwoSFxJrrEfgHIsE9Gv+Vo7nshCUYA8gkfHeckiaUtH1EiFTh\nVNeO6mTIqGpRosFvfUrZMKcuF5j74vGQjNM1o+M5N31gtLoPSkU605f/U4v+j2oC\n3/N1rYF2SEDFO0EgAGXaXVhB0ltSDkHJw6vZJ1L8Qz6tooUMDxaMri8vycA6LHvE\nqN+z+S6TXMfLvN/6ATYPGhicrWmkMT/k7v1az/hcnfH+zRyLZyFx94s88JWF7Jf+\nI+tgDbfqTMAIcytJUC+KfdQW1ueXh5F0owrOYM6jgBRvhqj1T8s+Twgw8orGmRPe\n9h8G9Z3wZAooQvmC0KdVhLuOeIkqt/S5krELNFFBRnk=","translations":{}}],"screenshots":[{"url":"https://gitlab.com/eneiluj/gpxpod-oc/uploads/db5af6ba7ae1cd4d22ea81d418f5c762/screen1.jpg"},{"url":"https://gitlab.com/eneiluj/gpxpod-oc/uploads/123588561a8067185572a8d1887ef906/screen2.jpg"},{"url":"https://gitlab.com/eneiluj/gpxpod-oc/uploads/427688b80bf8428dd45bd15d69b19075/screen3.jpg"}],"translations":{"en":{"name":"GpxPod","summary":"Display, analyse, compare and share gpx tracks","description":"\n# GpxPod owncloud/nextcloud application\n\nIf you want to help to translate this app in your language, take the english=>french files in \"l10n\" directory as examples.\n\nThis app's purpose is to display gpx, kml and tcx files collections,\nview elevation profiles and tracks stats, filter tracks,\n color tracks by speed, slope, elevation and compare divergent parts of similar tracks.\n\nIt's compatible with SQLite, MySQL and PostgreSQL databases.\n\nIt works with gpx/kml/tcx files anywhere in your files, files shared with you, files in folders shared with you.\nkml and tcx files will be displayed only if GpsBabel is found on the server system.\nElevations can be corrected for entire folders or specific track if SRTM.py (gpxelevations) is found.\nPersonal map tile servers can be added.\nIt works with encrypted data folder (server side encryption).\nA public link pointing to a specific track/folder can be shared if the corresponding gpx file/folder is already shared by public link.\n!!! GpxPod now uses the owncloud database to store meta-information. If you want to get rid of the .geojson, .geojson.colored and .markers produced by previous gpxpod versions, there are two buttons at the bottom of the \"Settings\" tab in user interface. !!!\nGeolocated pictures can be displayed if python PIL is installed on the server.\n\nGpxPod proudly uses Leaflet with lots of plugins to display the map.\n\nThis app is tested under Owncloud/Nextcloud 9.0/10 with Firefox and Chromium.\nThis app is under development.\n\nLink to Owncloud application website : https://apps.owncloud.com/content/show.php/GpxPod?content=174248\n\n## Install\n\nNo special installation instruction except :\n!! Server needs python2.x or 3.x \"gpxpy\" and \"geojson\" module to work !!\nThey may be installed with pip.\n\nFor example, on Debian-like systems :\n\n```\nsudo apt-get install python-pip\nsudo pip install gpxpy geojson\n```\nor on Redhat-like systems :\n```\nsudo yum install python-pip\nsudo pip install gpxpy geojson\n```\n\nThen put gpxpod directory in the Owncloud/Nextcloud apps to install.\nThere are several ways to do that.\n\n### Clone the git repository\n\n```\ncd /path/to/owncloud/apps\ngit clone https://gitlab.com/eneiluj/gpxpod-oc.git gpxpod\n```\n\n### Download from apps.owncloud.org\n\nExtract gpxpod archive you just downloaded from apps.owncloud.org :\n```\ncd /path/to/owncloud/apps\ntar xvf 174733-gpxpod-1.0.0.tar.gz\n```\n\n### Post install precautions\n\nJust in case, make python scripts executables :\n```\ncd /path/to/owncloud/apps\nchmod +x gpxpod/*.py\n```\n\n## Known issues\n\n* bad management of file names including simple or double quotes\n* _WARNING_, kml conversion will NOT work with recent kml files using the proprietary \"gx:track\" extension tag.\n\nAny feedback will be appreciated.\n\n "}},"isFeatured":false,"authors":[{"name":"Julien Veyssier","mail":"","homepage":""},{"name":"Fritz Kleinschroth","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\nMIIEATCCAukCAhAaMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\ndXRob3JpdHkwHhcNMTYxMDMxMTA1MTI2WhcNMjcwMjA2MTA1MTI2WjARMQ8wDQYD\nVQQDDAZncHhwb2QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCq9p5l\nzNzR98l/xPgrplWrGQBhF6aQSLpnIyCdLAYKk+CmXn47W1pHh5CRYyCCyB8YPBBG\nTwbpP69pP1updfK2vUt+ShYmCXLxOLB3qEdhnwgqFfwpC48Ocev9d6XcacYp7jwu\nRNtv0ocMkm5o0TWWupcutQWkmqzCVq+OkrqM0xrf3mfPymuM6edEREshukoL86Ei\ngTuMMGT0XO99LikszvdceNQYEATix1MHzSVhkE7jHCNBXb95H6nQGr0v7R1MIbrI\nGFlgqxwwNNKwBFNfPMWZVnKwz9hoIwW6WOuu7ntwVcPqwB/gUsRZJTu7EjIW0trX\nnhA6xLlc4X66W1sdUCkJOxsV+Y21akz6wynI0SzIfjALLI2Ls4QWrPM8GOX8nPVM\nm+Y5WXzqLJScdWYoefFJKS7kxwUJRewREB9ykCG5OdDubV+Iu/6jh6HWx3h4p3ih\nqkDypPWoxpfLgA8VZkLD1RRKGkRa858QBGdF/RHbYT3JfLEp9l9gJVKZE/yw7HKk\nwsZ/T6CMpLyorpd1XWtp2wLX8lr3pp9ecVDOdAMSqD2thDMDsZA82JrJ/vITwkCF\nBlqtDZmT0UnpxYNYTfYBam5Cd00jsqCt+Hr+QkODNe8Yae9c/D0zE3h2Vt7g9H+W\n7Ei+rF5nDYTBAApoETxK7+aUZpycBf3THAJOcwIDAQABMA0GCSqGSIb3DQEBCwUA\nA4IBAQBbCGAEwg3M5QJDMnZgu0zNOH2f9bamAS9ksyCZqzLoeQic1W7GYYe9NqAi\n7lO5jXRZpTN4L133IUQPtxCxuDooD2vFmCne92tLxJbc7uqlSVfhL8uMVOlnrA99\nKTAhySTZU5so8/OibrngnBmcdWwbhaWoCQ671M8aXM1wg2FVYDqB2GP3RvbpW11L\nOc+4tfh4mO4TwXygf7KYMOJyJW8mNNY7PZ+XW2Qe3vSXR3DuN8H8fgMh5wppXPJf\nE0+yNs42hwFjSojtI8BCb0s5DTleaakpDo8HQGNzEXP8tBlUYudtjzdP0jxFXbFa\nsT9pcMdeJ0/t5HqJSx1EjUCLYS4y\n-----END CERTIFICATE-----"},{"id":"ownpad","categories":["tools"],"userDocs":"https://github.com/otetard/ownpad/blob/master/README.md#mimetype-detection","adminDocs":"","developerDocs":"","issueTracker":"https://github.com/otetard/ownpad/issues","website":"","created":"2016-09-29T15:58:52.814912Z","lastModified":"2016-11-19T17:37:52.278497Z","releases":[{"version":"0.5.6","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/otetard/ownpad/releases/download/v0.5.6/ownpad.tar.gz","created":"2016-11-19T17:37:52.234684Z","licenses":["agpl"],"lastModified":"2016-11-19T17:37:52.423930Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"dh+Txg1iVfqXr8+cxplNQuBZGErSnXUo0ewGwnybNMJqp8/EjEo72+zPpW3dVnhY\n67YCvhrm2bo+VRdFFymEfymzSJu9nWVFkGJhEwvTxPyIdAtuD5YAVrzmnR6L+H7m\n7Q1nXE63ICPCAQpHkxIfIXLh25OhWeyofBB8AVsjDUNn58FEYJ8fFkr6dCgPriZS\nsM2J+xtZMDYufy+xFMsVf/Q3WopjFuBjMC3qOecW76ZTwtREaswOC2RtpzUku2r1\nsogrfFlFer3Ii9/CWgOktnLfjB1DzbTwdEkM2xNVBRJgdMXt2VLA9FsxFFkjmr5A\nl7x9cNLWA8RLpOIpIMBbaef75u5HgRBvSvq114UsA9GCu/EYbIgD8YxEt7xuKd4t\nenksJB5gJ2IQNdHrPbsil59AsJ/dismDN6ktYgWQEk5dINzvm9EAvucueW0Gt+Jr\nqEC5WBgJucsFxSvkHh52v43M8jgPYBfHWEL/M/+377z3+mbuIh+BcQ+vcDdiqxTF\no3n0+gw3QYIhLEe75sUhxG6ynVUdW25AKKju1kVj3KJnZTBH1R8t8/zy4DnJG8d4\nuRGqyU4BXpZjEC3nVlsC7vCncWWhxl0WZQ/MWKqsfjVAU4I88E518D6NioqMnPEJ\niCZ2x+69UCDEQyfCSKajgAYT17r3OhZei8F9KSCH8Vw=","translations":{}},{"version":"0.5.5","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <11.0.0","minIntSize":32,"download":"https://github.com/otetard/ownpad/releases/download/v0.5.5/ownpad.tar.gz","created":"2016-10-06T07:51:05.278637Z","licenses":["agpl"],"lastModified":"2016-10-06T07:51:05.348825Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=10","signature":"nYsQ9U5r7uXwtcquaWGm2XMJBNYCcA95aUx9gLZ/wEmjCHqId7+MzcCdBnom33+j\nat2XR2a4R96UAUP78bfSC4Yb7nPepFT51Y8CSpV3mDT85/+SgJdq500fXldq+qGY\nffXLneadAztyOfZO9TXljaCLdREYI0LJIGVENsxBQVKM/eyGIuZO7fF70cH5vbfS\ns37+BXB+fxcDTlP2Xuulra8HsNoS81bzjsdVMLM7B7QwwO6rZ1zd5c3UzQ1LmY5g\npQUBNd0KjfHfZ6+Fd64XZO6NGfgucGNmL3lgxdsfUqKiLtikvFxK39dYW5MckV8p\nvLoS2nZ7cgETQmAW9Ahn3ro7gXWcPxzL41oWtZOOHRRC2Yz5zlZ3Bky1o+bF9g5a\nYdDF13zV6utUkhlplZhWbjKaXa04rzOvmut8Iqhx/tmDtZRYtaQXJZWutVJYtPC3\nH86uJJnUHHNFHeoT560mp1Hq0dTeR+G+yWsPacPD1rTYgZOUVEtj3Y+YdbTODR2o\nOdGzeYFl+6CL/OcY4wPGRUCTFwvc31lIUd4DK5SPfN+IGtuuXhAqVhwy6lpkcKRs\ncj8sBoVXbMvEtMnt5uARBvA4tyVffUL4oyoIsUnvXz4u+q4WVt3T17swLm6HjGVC\nNVqU0srHN7EeBRhHlXP1CrKQWGQlS4k9j9Li4Iw+X8s=","translations":{}}],"screenshots":[],"translations":{"en":{"name":"Ownpad","summary":"\n Create and open Etherpad and Ethercalc documents.\n ","description":"\n Ownpad is an ownCloud application that allows to create and open\n Etherpad and Ethercalc documents.\n\n This application requires to have access to an instance of\n Etherpad and/or Ethercalc to work properly.\n "}},"isFeatured":false,"authors":[{"name":"Olivier Tétard","mail":"olivier.tetard@miskin.fr","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\nMIIEATCCAukCAhAPMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\ndXRob3JpdHkwHhcNMTYwOTI5MTU1NDA3WhcNMjcwMTA1MTU1NDA3WjARMQ8wDQYD\nVQQDDAZvd25wYWQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC6CY7I\nHRJTaqDu376vt+kruX+QOL864joScxRuh3IOVcQktCvxasuA0EtrX7TCAQrV1tBK\nfkqJxU9uOV54RTgyh30yH/ZtnF2bYQwViGM06Snc0riqWydFrN5fxK52dpZWs63o\nUFCNhHxrX4aUGyfXu5nQMISLm4QHoZ3LDLofk1ZsiK62fM/Jz8N2PM8qeHzf1ATo\nSKcAOd3UeaS9C8bv2DuiZM7unkSO/tjrBzkMiq8ds9sIzBBsyk6BRh2HQjHPOtmO\ned+pS9mIZmc2xhssXoHL4IfZwTqwhktpsaTl7v0ROw2dwDATz/QoKMkUpboQ5lkz\nwgLQhoIZw6uAZ1R/Qjze59I3iU8zIo9quDarHBotZNXboYCmg9FRfE4mHtegVaa8\nv1a1JvFQ5gvsWEsKSV6Bzb65GTp4KG4q7YnUrzh6HJyDCGLvLlWm5OWsFj6sNzXX\nwLOv6JLORMbF4ZIo2iybb3x7gdfCu9JxMZ4JtOUC8KSJ6+ub15C1Aia3lN68dNts\nY6KwUF1Ted0o4OQPAulq5pUc+g6dTYmIKsavIiPKhMtl86AbUK50vRTeuGdFsT7X\nav73IanPdFI9bKth+tajgvB6dxcVnvBXbrsLUyEcsxsxtBJvQcMYS4aZ6ZJYLTep\n7AdK0Zt1iMdXB8+4PCps4rcG6bYB/uJeEAVm7QIDAQABMA0GCSqGSIb3DQEBCwUA\nA4IBAQCM10O+sCYhIExnx01vGzKlnRS7MSQNx8ZMmbR5Elfz4AVJAEJ96ytS2DXH\n2c+hcD0wAenXQEFk920AEqFQBT8DP34p0FmF83aMHW08ovzFiu4MdlhcqrLnko0h\ncZTXHVyS/8JZh+o6SVm8R0/BBLF1MQQ5TqRkJehbmk6gL0+MSYxehUDKWTjJITkR\nifneTw/Ba1d0AXBOq0c0HFyGxMPIlWe4qn5LtxH5t0wyVGeSj4jyv4nvd3ZGuAgY\nEUa2uYht/z475k4+vf0YhV98iQH07GnmlfD2TDZgmOCQGKlNfJh1v88OZyLLa3dz\ngRHzGwKbAiJ8T8bbpZ3e2ozXxADr\n-----END CERTIFICATE-----"},{"id":"announcementcenter","categories":["organization"],"userDocs":"","adminDocs":"","developerDocs":"","issueTracker":"https://github.com/nextcloud/announcementcenter/issues","website":"https://github.com/nextcloud/announcementcenter","created":"2016-09-14T10:38:53.939634Z","lastModified":"2016-11-24T11:21:50.324839Z","releases":[{"version":"2.0.1","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=10.0.0 <11.0.0","minIntSize":32,"download":"https://github.com/nextcloud/announcementcenter/releases/download/v2.0.1/announcementcenter-2.0.1.tar.gz","created":"2016-11-24T11:21:50.317635Z","licenses":["agpl"],"lastModified":"2016-11-24T11:21:50.386203Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=10 <=10","signature":"lmqeE6xBqUJfhuXPbjCfuWiIP0FEB4V/SsF/OvYar6rLpvDpJVf3DJoeIoxXurRP\nE9/xCcNN44P8PreRRDnFLCa0XsKOtwoGa56Lxk7IKvtiQG6xu4J6PKM+q/tIeF9K\nakw0LQXtjZB5InPhnCDDbY5YS9jgGEBylSHsgNgrElipcW+BzOBu1Amw4FECVlQw\ncQ83bio+YPZvsnE5+v3/bAx0m6QNxfyN9Sn6rMEqRkY3jfA3vejXGQH/XkputfV+\n5hOz48KbOVg7cKxg+ieJlSwC0aYjb+RXiopjc3icCoIF1llltOOeSsVYSflOb080\nupociPgQ6qIab/VNNXa2YQ==","translations":{}},{"version":"2.0.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=10.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/announcementcenter/releases/download/v2.0.0/announcementcenter-2.0.0.tar.gz","created":"2016-10-06T12:41:56.195206Z","licenses":["agpl"],"lastModified":"2016-10-06T12:41:56.263124Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=10 <=11","signature":"NVWYz73KtuoZ7ti2sluztJO5aFUc7PzhlDcg0VWyAQd1H7sk5wjw7i0bhrjw8O7M\nLsrb+PegnsL9eMlYM2WrRom+RF1PDP482xymZf1T8vh8qcTCm3TK89xSuiSm8yoA\niWUb/Uv/ODj74wVDWqWxAFKaAG/FestCB3InOOZQqQZLzlAV0U9ziYDGNzBjFqof\n9rLNxJ2IOqZOA7hhMIKhSrpA0KkSfNhBsVf8CWClYnVkZQiq0LoYkHkHIlXmXUr3\nOfQFKEjtsx+bNLa6CkAaocHGHJXAofX3GQZ9cjBsjZqiTfbXfcVk0kRfz7pwL92L\nI1McfJYvgMxDQG5bjRpNJw==","translations":{}}],"screenshots":[{"url":"https://github.com/nextcloud/announcementcenter/raw/stable10/docs/AnnouncementCenterFrontpage.png"}],"translations":{"en":{"name":"Announcement Center","summary":"An announcement center for Nextcloud","description":"An announcement center for Nextcloud"}},"isFeatured":true,"authors":[{"name":"Joas Schilling","mail":"","homepage":""}],"ratingRecent":0.75,"ratingOverall":0.75,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIDDTCCAfUCAhABMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYwODIzMDkyNTQ0WhcNMjYxMTI5MDkyNTQ0WjAdMRswGQYD\r\nVQQDDBJhbm5vdW5jZW1lbnRjZW50ZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw\r\nggEKAoIBAQDPx4Hp1HdBo5v7bDEiVcv2UrVjNW+fPPKS/5rwbagtPcE/1v3WDcwX\r\nvFwaXk8qCn2UpPSQ2b1rTuTDm51G1ZmEZhNiio+rBfEe9F+3tLsq9lElqIPKhkAq\r\nEUVI6dcN+jSqvLmLhuwloEoQQSYaLrX75mY3lGqTb83h1l2Pk/brVixuVf4vJW31\r\nTgeieuGKnC+keLzKOrvTHffJakU8ktwB2Nuu1o+jN5a7u1bxKkP3LjEWPjq236hk\r\nAoOcW/wi1dUEyUKUZsZQeJyvTJh1UXdLHKwYywtUu1/VLZ1IUtNyPBfiQ8ukPp3T\r\nTnSSmG3ZnvsfM6DmAvLZ8bBQkMBzEcTLAgMBAAEwDQYJKoZIhvcNAQELBQADggEB\r\nAAB3i2NgiZ4rpNag7cXYdaFxAxdDWnke1+LX2V2R3hzGmx73/W6cKLpo3JBn9+zT\r\n1aEjlqkt0yHu4aAPVYQzOa5zIV8mjP84p3ODSyV9J8lfjFNXT7wdA8+9PVx3lVki\r\n2ONoCNBh1kOxnxI4+BsMlQfF00ZbBSuGcMm3Ep3lTFWXzuUn3MQITzPwkL5LkW6a\r\nsli/yAYQRTVDsXD8A3ACYT7BG31jGxyXtIHzqCci0MhZFdKKayMYkwfjZchIUtGN\r\nJJoU8LQoHwGRtp3wutk0GlFzpEQEvSsn/Lsvvot5IfIe46tnzA6MVj5s64s5G8+Q\r\nphhXFlzXqO/VxquPdbfYjvU=\r\n-----END CERTIFICATE-----"},{"id":"ocsms","categories":["tools"],"userDocs":"","adminDocs":"","developerDocs":"","issueTracker":"https://github.com/nerzhul/ocsms/issues","website":"https://github.com/nerzhul/ocsms","created":"2016-09-19T21:56:04.745481Z","lastModified":"2016-11-11T16:29:55.864273Z","releases":[{"version":"1.10.1","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0","minIntSize":32,"download":"https://ftp.unix-experience.fr/owncloud-sms/v1.10.1.tar.gz","created":"2016-11-11T16:29:55.856768Z","licenses":["agpl"],"lastModified":"2016-11-11T16:29:55.947926Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9.0","signature":"hVzbkmmtJCtiOkZGe1mkWElqS3IPQ8wLtSzikVvoKmcg+Zq3YLQjpQWzy0t3UVjo\n9I/BfnL0bF+kjtGc9xF6M8IQaFqPrfJmN+lNT8WYIKLI97TTsLmJGg8Q8PAux3nY\n8/NxMjWdByMw9nVBClKo0o9eSW4+EnaUSJ62Gl/XWjq728kbB16WZm+iesk8LjJJ\nqqAgczWGwz6lkZTCN5o9n0a/YoLJTf4iT+OItHZyS609Cqaxx9CAmZPj/Xn5g1fm\n8hqO2ITAXLoBj4rYS/QsZTMcubtGkJ8fq3XYKVSv2UXZfvGsNWbbGV7puKN33uWJ\n5MrdoMlJ8XnJRPDlCBcb00LY+AB+hAMooLnNy765/Ew6ztp4KNLEPWGG+Ut8/Lkk\n0jIULl1RF/FjlW8P26NfwH36K30RCJFY06OFcWnxGBkkQaNFORDIsKcqTAxkl4x5\nnfKBkNdQZppCVfOSKOZj4NkWfWx75Ouq1S0QksmOsMZoOcjy1TbBKR8h6dt9DQub\nWpYBL0QwyQShGp0Vb1qCKkP69ZQAHVUJNzIFPz9LyoguvFyv8iZmAPLYDnFBvlf2\nnSHtA19rnJmZ4H7RJ02r6BdkstxISvEiHU7RLjNQxcb+DptIWX5C03wH87HTNIhr\nvptPorEoSY1KwW9fqUvvLE/c+vfkr5cvIEwZlyVKVXU=","translations":{}}],"screenshots":[],"translations":{"en":{"name":"ownCloud SMS","summary":"A app to sync SMS with your ownCloud","description":"A app to sync SMS with your ownCloud"}},"isFeatured":false,"authors":[{"name":"Loic Blot","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIEADCCAugCAhALMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYwOTE5MjE1MzU5WhcNMjYxMjI2MjE1MzU5WjAQMQ4wDAYD\r\nVQQDDAVvY3NtczCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANqZVIzM\r\nwBJuacuvgYKr2KnXuYhjKjZ58nfspSebsaGLr0ifBbo8L+NH5eaynnLCNhpegmu0\r\nO8D+KrbM1LtIkcdg1/eFpN5dTc6G2OAc9H9stmHs9nroF6MNhszgdZCz8Q8xkSoD\r\nGdSm8hdPg5GcfLrH27UilGtzdQlWJ1DralLMt3l+SfGJo152c/dc+e6SuT8+EbY2\r\nCeLdH5ImasXNpUgY+tAoEt2ZvhBrUghykBJTJVOjwL1jGLT37ybMtV4FBKo6hpeg\r\ntq/YzEk1ijBAC4pmoNWixDKCdolpVJVz0fijI9mlda3llurcp8eMhxfYJ9soXLHp\r\njvLX02YY6RfPcyy48uWVk4IEt9BvZWEVAAp7hCGA2yXrVSsR37E6sDbLsBcKav9A\r\n6dkGAgfmGkr2WT6O1/EhK/MakmnYO4WD1B+E7PnxtP/wOa+aQBmntQcd7igDiwzG\r\n6h05NYAWcRhqfZ4KWYsq0t0SezMbuHOhwzzi22q8wijC5YZbmhKSh+b3N8XwYKDi\r\nZaw+fSahPbRWaLyR3wn9zh7vKCwqrG3ugrNo6CtyoACAnmxKZ97ROFJIQTe3ndLL\r\nmv7Wy8iCZLhRYUaW/GKrF11AFwBVec9xmvkgU+PIKq2HSjwi9sCF+pFyhVjmq29C\r\nmZEPKUV7ySIpNHXpsXm8kTJJfqjSdb2ECbLfAgMBAAEwDQYJKoZIhvcNAQELBQAD\r\nggEBABvn97e8Nw8KAscf6FX/nZ99rEX+3IrZxTC8fmBgNwAvlbF2A+QZQcFI4G9/\r\n85nHK117+u7XDuwWl4QG3flWlI0hDE59Ud9Bd4AiTQ12VoXlNdYoTg/mXARxVozb\r\nKYqZ+1xRQclZKb2AqW8YiGo18okIKovn9VVRAFYPYx4O3Ve1FjgfsaMlIZLiXUFm\r\nkk+2qWo6kYsdU9FABLo6izx7RFOMbnYNre5FmDrWP1Dga/U7ErK/Dilh8g9b3HrP\r\nwP8OIZhdtFWw21wDTfyqrb9EhC/tsjPVP9u+bqyognHeiMhjbVYRbSvz5o8T7Mhj\r\nbxalCt4/LnMIfMwVyIvye7Uy2GY=\r\n-----END CERTIFICATE-----"},{"id":"rainloop","categories":["social","tools"],"userDocs":"","adminDocs":"","developerDocs":"","issueTracker":"https://github.com/RainLoop/rainloop-webmail/issues","website":"http://www.rainloop.net/","created":"2016-10-20T04:17:37.217555Z","lastModified":"2016-11-18T11:36:04.309739Z","releases":[{"version":"4.26.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":">=5.4.0","platformVersionSpec":">=10.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/pierre-alain-b/rainloop-nextcloud/releases/download/v4.26.0/rainloop-4.26.0.tar.gz","created":"2016-10-20T04:28:21.491747Z","licenses":["agpl"],"lastModified":"2016-11-18T11:36:04.619927Z","isNightly":false,"rawPhpVersionSpec":">=5.4","rawPlatformVersionSpec":">=10 <=11","signature":"nTYIVSB6mIwKtXIrKoVGsOGFflpLjed8jFem1VLQNtXQj4bztnNrdc4YaPIn0yzM\nyLpMSqRDNzdYNFuOeDiyKLPJPTA++MotLCNjEe7kxUekek+m+qzgnGBdcT7RQT6R\np9xWGecnVx94d6aA55uiRhgQRyHpdDMMLCOz1be+HvpwHy69DRFZ1+SPmGUt6eW0\nu5yS0vHCu1K22cbrVNXFKjxAOlGcIDm61oQuz7ycl3uAujZO4rZbWt55jilgKGak\new559A5gTp9W+j+TWKIcg6LIZ9zLRlGjcQrWJrsc+OBZQcqiYimSFyO6HhfT9TPS\nPof//I+dSsd+H0SRGGeL8DvSnK+NKZL1q5EX5pziqsv6nZFITpCDwmAN+I8AnXXL\nSNkFi53M8RZTOABpD2x7YPYP1cEvwrRweqV/C/oHcYnpfh7D2DjFeWwXsjeAXrHY\nhgFhPrg+7rf7g6UmJFOCp0dC9sBdyQ3KtJkv7bGqPr854r2cdA7xW0QHWQ2in9qQ\nLhIczc32ECi3ZVVgyF8zyT4Y/3MRS05oX3FHvHyt88mjni6bVaO78F7ZRSha8gHh\nNOAkku7AMXPvUCHaZP2iVCCoAViEso8GeR3O8xh2G42Ai61RLYwx8LB1+23EoJTr\nmfFuRYNSg+qAKCokXNnh+lDlwu4AkaQo3vtKGPXvU7A=","translations":{}}],"screenshots":[{"url":"https://raw.githubusercontent.com/pierre-alain-b/rainloop-nextcloud/master/screenshots/2016.10.20-screenshot.jpg"}],"translations":{"en":{"name":"RainLoop","summary":"RainLoop Webmail","description":"Simple, modern and fast web-based email client."}},"isFeatured":false,"authors":[{"name":"RainLoop Team","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\nMIIEAzCCAusCAhAXMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\ndXRob3JpdHkwHhcNMTYxMDE5MTkzNDEwWhcNMjcwMTI1MTkzNDEwWjATMREwDwYD\nVQQDDAhyYWlubG9vcDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANqB\n5jnF9qZ/qjckt0kRjpHCOMtJumW/KiQoMeNP5nGv4ad0DS3KemOapUef8Zn7qCYb\nMnODhK7HBwPifFzI1j8bnT2hP6E0geFLb0MdN59d2NF0n4CCs1+BnepQPJ1kFbPK\n35wQRi0RDeTf/GQ+/owEVCU9a9W1P/VUXk8Z0vMoQxCXEdRqnB63SgsKl7DB9G/C\n4SYrgGor+OHVGl4ntMZhJujiM996DttrNK3iZRGkQ07L+lfUIwQ52XOhQNRdic4p\nB03lw7PpChwPGMv/EEvdR5HpCJQBJniqJbbu3Jh8bMBKTE/8fCzN3vMXICB2g3Bq\nlKkZW6fnJRGsrZ79fsQnl+WBPNSrWRLOxOfe1fyCFV1ljFB4nTH7uF3pC8ZRgJes\nkHIESHz3GJm28hn4+17ESMGHBCbs7L9FK2GY31cobU0VRntLxpSG+d9njbIAgMG1\nS7U+oKVFQhSVpdXNOaUNqhcQ3HkbQTLEP0k53A/lhLQb2+KPd8nntaELjwNyrmZg\nsVMgHj/zdlvrbguZjZFzUzDBFvkuv/5M58lNT/D1C6ufVp/R6eLsYI+nnk1ojAjz\nl7N6U8X5SXpD+Bm7+Kn1PH+bHl7cViCx8oXJXO2RhP+COXckw7BDZKtjItYHNG7M\npFwgYqWpvCu9LN6IN5a/eLqSI76dOOP3iYbaTH+NAgMBAAEwDQYJKoZIhvcNAQEL\nBQADggEBAGB0Vq0l6ndGTgNbZxSEFyBR3u3tiR3pWK81DYjsui7qBoO6P/BaGmf+\nraSwHPaBOwA9XNS8jcGLh5xdqY2p/m0dTS64xNjVL9nweWsG+FwVnPANo8C4nXdm\n9ajJ4cdg54stQK8qn1uh/xPcd23GKfYJazjYSwYmZ3pXXdzlGN9NxkeYJQxJ6B+5\npzAeVGiABI/e5URpxzz2UayRX7EE+vtpe3B84hzkLqsq0N39ZN6KLfaTyEBGLzqE\niLYeXQTV0XSRs8xVt+iyGlj7nPkv2DR0oCqRpWUFWeSBI//niDG5WxS3qg8kacSW\nfDSYhSN+IjrnIkwNtc8V9t7/GeQB5FE=\n-----END CERTIFICATE-----"},{"id":"richdocuments","categories":["integration","office"],"userDocs":"https://nextcloud.com/collaboraonline/","adminDocs":"https://nextcloud.com/collaboraonline/","developerDocs":"","issueTracker":"https://github.com/owncloud/richdocuments/issues","website":"","created":"2016-10-31T08:55:45.631429Z","lastModified":"2016-11-24T12:13:53.905352Z","releases":[{"version":"1.1.3","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=8.2.0 <9.3.0","minIntSize":32,"download":"https://github.com/owncloud/richdocuments/releases/download/1.1.3/richdocuments.tar.gz","created":"2016-10-31T09:03:40.389355Z","licenses":["agpl"],"lastModified":"2016-10-31T09:03:40.439510Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=8.2 <=9.2","signature":"s5giQeiU2zwV5X6FmxWXiG9LtNDeKBlFqK+hfvGNbGZ+nic77Y+AnXHodV4lb3Ko\n0C0ThFLuafaZRdp9rBIN2K/acCfCYKJewGuYErb7FlEl+P9J4OQbb9pva0htZJw6\niuG5eyeTufi5MKB4vuj4+jo9zhepOFAtZMa7o+ZCfJkt8vDBuq5AXxomEiZRtW+n\nf9PPUnq0z7DJVwINhHvvBZJlSLjkpJ6VIHAr+/ElWr8O/mDKq5S5ohbvpDcPqR7b\njnsBckFDLFUz1FX9dA0JCJEKMMfkcfGqZcjH17NdjKAxRW2soN5cEKluu5MkOhz9\nFEPKfshzbrfUIm5MaFGv6w==","translations":{}},{"version":"1.1.14","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/owncloud/richdocuments/releases/download/1.1.14/richdocuments.tar.gz","created":"2016-11-24T12:10:13.337165Z","licenses":["agpl"],"lastModified":"2016-11-24T12:13:53.963638Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"prDGlfRPxqT6LP0BsAFPwGww7P4Bngha2N4u5B6+F02N+RVOjGtTcXKqvM1KjZb1\nCo7qJvgJmjpvIvDmB+rup02i8ObfwP2ct6UdsD7ouzOWJG2sJANXK31bHyvOmQ2h\nvKu5eNcOkf+WFyFKYi51TbsfWn2+1Wge3WWujKAVcEvqtcOOz+uMWNtqzBptEupk\nE1aaRnQfTx488YB8Ubul06LIY0PNCHgGCWPgy817tOVT7JA+V0P0FFonl/PXE0dr\nWgtxRJmvGaNiFzYq+kQmdKMfayZTm3kdVgP0W52t5wp878K0i4s2KPg5lANvjTz7\nDCT+VV2IGIE52o4RpMUGyQ==","translations":{}}],"screenshots":[{"url":"https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-document.png"},{"url":"https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-app.png"},{"url":"https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-presentation.png"},{"url":"https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-spreadsheet.png"}],"translations":{"en":{"name":"Collabora Online","summary":"Edit office documents directly in your browser.","description":"Collabora Online allows you to to work with all kinds of office documents directly in your browser. This application requires Collabora Cloudsuite to be installed on one of your servers, please read the documentation to learn more about that."}},"isFeatured":false,"authors":[{"name":"Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\nMIIDCDCCAfACAhAZMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\ndXRob3JpdHkwHhcNMTYxMDMxMDg1NDExWhcNMjcwMjA2MDg1NDExWjAYMRYwFAYD\nVQQDEw1yaWNoZG9jdW1lbnRzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC\nAQEA1jk29m6JykcJ2Ld0YEpjPMYh6kwxY6GysNJnfkA/th7tPWL3+vBJ9oTYyVnZ\njwAE1Cqwfa9MyBKMZ2IdfIqtT8PeWzuFP7Ib942EdxUpwwh9F3lykeGsj0h4zQwX\nF9OooiS99PfLX+JpkKm15Ujb00iLB6xQmq0+3NeOT1CTD1ziJ1ueOcxBKMwaFp2a\nPuz3F5ywqCvpmxG/OBuOs0LI3/zStXhBNbUMxBrWblr7zaVNJXl/I2JCKj8Wah/H\nXUEEGbW15fAUP1f+90eQSxpEoCZDBHXOQCTJYzySGv+BjU+qlI9/gS0QbrsiyzUf\nO5lyvi8LvUZBzpBw+yg1U75rqQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQA9jU3m\nZmD0ywO3MUsG/GLigFtcWi/p7zp2BliR+NpuY2qNFYDcsIb8ZUudmUc/cJRRctzy\nAPaLLj/d+h5RFaxjTVvim1PSe6M7urK/IMSvyUVYCeQRYpG8ZJixKTCOVIBaWHMz\nxTfc51tm9EPlpJpK6JtaWrYYoWGE3k9sINdJ4JkvKkE2CBAqVhX6ZGyEQ0bnEhtk\nRu1DXn+LW7TJ4NZ8VtLWvmW/6Kfmi7dQ1V++Kmn0lO5ntRt5altePbStCHC8bhGp\nmyBOrjhrJgLIwvgH26MYZhdiSkFzoE38nMPZdrUmUDxcPCwucWJqgzDPudguFthj\nWCVZ3TTG/2z3+tWM\n-----END CERTIFICATE-----"},{"id":"ocr","categories":["files","tools"],"userDocs":"https://janis91.github.io/ocr/","adminDocs":"https://github.com/janis91/ocr/wiki","developerDocs":"https://github.com/janis91/ocr/wiki","issueTracker":"https://github.com/janis91/ocr/issues","website":"https://janis91.github.io/ocr/","created":"2016-09-19T12:07:49.220376Z","lastModified":"2016-11-21T11:22:21.024501Z","releases":[{"version":"1.0.0","phpExtensions":[],"databases":[{"id":"pgsql","versionSpec":"*","rawVersionSpec":"*"},{"id":"mysql","versionSpec":"*","rawVersionSpec":"*"},{"id":"sqlite","versionSpec":"*","rawVersionSpec":"*"}],"shellCommands":["ocrmypdf","tesseract"],"phpVersionSpec":">=5.6.0 <8.0.0","platformVersionSpec":">=10.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/janis91/ocr/releases/download/v1.0.0/ocr.tar.gz","created":"2016-10-24T06:50:43.283900Z","licenses":["agpl"],"lastModified":"2016-11-21T11:22:21.269108Z","isNightly":false,"rawPhpVersionSpec":">=5.6 <=7","rawPlatformVersionSpec":">=10 <=11","signature":"CBJkCIiUKyf2NuWfz2zJ3grhf8p7wJes7DPV/OxUzhlxIH0Fh7K54+U5A9JOOi6f\nWPhjXG1ylkyIVY1glr/B8svWNsD4jAclpnUi1/9ZW5UPT8LnRBfTbtF9Uoj0OgNs\ntsGQYbpuREoHnjbJWTRe0kq1OsOfX44xuf8PuX43B+lpQPW4iRSSz3ZIhdPcDGq1\n7pyqQM7gdKhBQ6/tOiwd7Enyt5Hi4V6jhwhUOCYeTNiLD2V3yKL+qA9DzpXUfNNw\nLGTjcaMrifibHQIZBZWbPPMmCfMJZ7GO9oR4gWHwkhWqt0yVWAJXAHJBLd5vXC5I\njtRTXRpHO/k6Dtqem8tZCVoDE5MAC7fDZ/0XzoFiXHciP6MenVasVcXo6xJOJc5y\nGsrecNftUEhP/ngxA6lMBVkLmmdpiexVisvsavPi64i34OUA6qOuxjgNVBDwg56i\n2lOEVvHa3nn0UX7ZZoQ/Nu6Mz7J3Hx/VDlttPuWe42eeJAphyDGubT1M62gW8dVB\nD3tJOF7spnK6I3BhVLviou/zs30AIRVBDTU0Orzx78cbInwy6/vyJib2a1olAaHz\nv05SzlQRnBWM4jYBe0mA/2ds9AO6VrXGrT/iLlHemj6JYoGBM185TGewA7OJyX3a\nHSlSDqaremmi+aS3onx3AKhXykDxTRkMVarePwTzzFs=","translations":{}},{"version":"0.8.8","phpExtensions":[],"databases":[{"id":"pgsql","versionSpec":"*","rawVersionSpec":"*"},{"id":"mysql","versionSpec":"*","rawVersionSpec":"*"},{"id":"sqlite","versionSpec":"*","rawVersionSpec":"*"}],"shellCommands":["ocrmypdf","tesseract"],"phpVersionSpec":">=5.6.0 <8.0.0","platformVersionSpec":">=10.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/janis91/ocr/releases/download/v0.8.8-beta/ocr-0.8.8-beta.tar.gz","created":"2016-10-10T18:01:16.076330Z","licenses":["agpl"],"lastModified":"2016-10-10T18:01:16.169733Z","isNightly":false,"rawPhpVersionSpec":">=5.6 <=7","rawPlatformVersionSpec":">=10 <=11","signature":"uEvhHfQCrzb6z+QuOoO8rYXiMsZFkrFWEqDvTyOTSgFKvo7dVoj3EfDfaApgcKEB\nIM/SqjLSO0lNhrp8F2mST3twbvLDprKsfrDWKFE6eiH0yKl2aNB+cHWE27utARaX\n/QZBD114vbWeDnbaBa4b9OwtBXDqKJrnO1LmqSLFP8guAlVTkU1jSPkRTpmwAcAZ\nJA/aiN/D2LSGfiNp/YdeTuzU+gPINIs9dCb6+PPkyam8PCBaXUSSaW+c0lAQHln+\ntb3EXxZ5YXdjPWrpEyHvFLk1N8s/w615QoMxr5fEs1M8D29aGbcL/wu7LXH4X0Yn\noiWwIFbpfrpJQlrIFumxWZR74JXiNr9J7ijnQ7SjxdHCcrLxMdnZ2cwq4iD6PnYm\nnIojhlhPOqUIzsWYCYutLWDQbUQz9eyWbj/+7XL+5KjetUUr/MnCu6xJ27IqFbAX\nHc8KRCO+9I0/qMQ2/rCZXBMeo39MGhhkgkVl5YAKwC1IEN/jlfyVNXZwYlfcHLKj\n6aNQ4zN6gGOerWWZ8qXtOeNJN+qv0nmXUKrZdnZUAhxOdB4G9Ym+JujxJZ9yNIWV\nsiqAI9J+OIzCwv/dzZhaHadONoo/RTF+Fl6Hy56HyBtMehb8w9p8ksVediqf33yt\nFAE/tzKtNK5NiRd+8MZkq/GbocaFUv3C7Y6pLMpTE1c=","translations":{}}],"screenshots":[{"url":"https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc1.png"},{"url":"https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc2.png"},{"url":"https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc3.png"}],"translations":{"en":{"name":"OCR","summary":"Character recoginition for your images and pdf files.","description":"# Description\n\nNextcloud OCR (optical character recoginition) processing for images and PDF with tesseract-ocr and OCRmyPDF brings OCR capability to your Nextcloud 10.\nThe app uses tesseract-ocr, OCRmyPDF and a php internal message queueing service in order to process images (png, jpeg, tiff) and PDF (currently not all PDF-types are supported, for more information see [here](https://github.com/jbarlow83/OCRmyPDF)) asynchronously and save the output file to the same folder in nextcloud, so you are able to search in it.\nThe source data won't get lost. Instead:\n - in case of a PDF a copy will be saved with an extra layer of the processed text, so that you are able to search in it.\n - in case of a image the result of the OCR processing will be saved in a .txt file next to the image (same folder).\n\n**One big feature is the asynchronous ocr processing brought by the internal php message queueing system (Semaphore functions), which supports workers to handle tasks asynchronous from the rest of nextcloud.**\n\n## Prerequisites, Requirements and Dependencies\nThe OCR app has some prerequisites:\n - **[Nextcloud 10](https://nextcloud.com/)** or higher\n - **Linux** server as environment. (tested with Debian 8, Raspbian and Ubuntu 14.04 (Trusty))\n - **[OCRmyPDF](https://github.com/jbarlow83/OCRmyPDF)** >v2.x (tested with v4.1.3 (v4 is recommended))\n - **[tesseract-ocr](https://github.com/tesseract-ocr/tesseract)** >v3.02.02 with corresponding language files (e.g. tesseract-ocr-eng)\n\nFor further information see the homepage or the appropriate documentation."},"de":{"name":"OCR","summary":"Schrifterkennung für Bilder (mit Text) und PDF Dateien.","description":"# Beschreibung\n\nOCR (Automatische Texterkennung) für Bilder (mit Text) und PDF Dateien mithilfe von tesseract-ocr und OCRmyPDF ermöglicht Ihnen automatische Schrifterkennung direkt in Ihrer Nextcloud 10.\nDie App nutzt Tesseract-ocr, OCRmyPDF und den internen Message Queueing Service von PHP, um so asynchron (im Hintegrund) Bilder (PNG, JPEG, TIFF) und PDFs (aktuell werden nicht alle Typen unterstützt, näheres [hier](https://github.com/jbarlow83/OCRmyPDF)) zu verarbeiten. Das Ergebnis, welches jetzt durchsuchbar, kopierbar und ähnliches ist, wird anschließend im selben Ordner gespeichert, wie die Ursprungsdatei.\nDie Ursuprungsdatei geht dabei nicht verloren:\n - im Falle einer PDF wird eine Kopie mit einer zusätzlichen Textebene gespeichert, damit sie durchsuchbar und kopierbar wird.\n - im Falle eines Bildes wird das Resultat in einer txt-Datei gespeichert.\n\n**Ein großer Vorteil ist, dass das Ausführen und Verarbeiten asynchron im Hintergrund stattfindet. Dies geschieht mithilfe der PHP internernen Unterstützung einer Message Queue (Semaphore Funktionen). Die Aufgaben werden somit getrennt von der Nextcloud in einem eigenen Arbeits-Prozess (Worker) abgearbeitet.**\n\n## Anforderungen und Abhängigkeiten\nFür die OCR App müssen folgende Anforderungen erfüllt sein:\n - **[Nextcloud 10](https://nextcloud.com/)** oder höher\n - **Linux** server als Betriebssystem. (getestet mit Debian 8, Raspbian und Ubuntu 14.04 (Trusty))\n - **[OCRmyPDF](https://github.com/jbarlow83/OCRmyPDF)** >v2.x (getestet mit v4.1.3 (v4 empfohlen))\n - **[tesseract-ocr](https://github.com/tesseract-ocr/tesseract)** >v3.02.02 mit den dazugehörigen Übersetzungs- und Sprachdateien (z. B. tesseract-ocr-deu)\n\nFür weiter Informationen besuchen Sie die Homepage oder lesen Sie die zutreffende Dokumentation."}},"isFeatured":false,"authors":[{"name":"Janis Koehr","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\nMIID/jCCAuYCAhAKMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\ndXRob3JpdHkwHhcNMTYwOTE5MTEzNTAxWhcNMjYxMjI2MTEzNTAxWjAOMQwwCgYD\nVQQDDANvY3IwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDDpXiwec4f\nXAT//7YBPSb4z6ZsBJSMfBq0VTL/HagjJnQ7BL+WagzWlS69IStNDqlIlenamYRX\n4B40heJIUinzYKjTRbr5UAw6MX29HibZccm/qgrk36o1XTgIsoRhmvSxbXDVIo1k\nbDOJN8gc2Gvswa8X+uOe9pfcDgAdqGxOvFnoKW89GnB01pCNT+xakNErGAFqVLsr\n2AeademAZnbxJ1cB54tQn2Bygb/7DKKY8EmFfIq6/27n9Jbph1FG9HIlWRT4/M2H\nU2pG3cCScWMEBPsW7kpfpnzLk7Q30Oj6k/rEYjJgmNYgg6oVnn0D9uRmhBYBnGyx\nMab1ilsK53lyuzQY0pmU8V5ULqpnNFAK6DVFfofEamDUhBPO+TZXEA5cZmuULRpf\nQQXmGpUQSyV6pS9WirMIqXFp9wmQ4vtjMdhu/6CP7cmtYZdq9uOhWEHbQM0mZUkb\n8hMjeItPx9XITI7Cge1JUOI8ZIwiB3USnQXcMd3v82l++/VgqHB7s5OaKPhygsWI\nM6RCoBcGiuQB5/fEUOg5ACOpGVyJiBda0Mi57AdoxdJmfnr7Bxcf2tAWIJL9Y7T3\nE1+V2BMxJOWwvVz26Cq83F41yXK2hJS+SbfQTqNUR8Cfh50CS9POvgRxNrJK9yvI\nkKle3ITRtGVM1XU0njWjnsdGg3D3O2mmjQIDAQABMA0GCSqGSIb3DQEBCwUAA4IB\nAQAbFddMbgfPI1szT57V1FKZrOrdYqQ7qjewlIQOzshGydbMtqS/9XL5hYocJCMt\nY6w+C/i6iEzO2Jx8D/k4rcZMXoVR6y3ZvO0Ke0gzSRsU+5eYj2FK1VV+cNIQW5Iu\nCYYIVa7pVPVHdeQH2Bba680bLV0HMF6b1fI9IwkfdCAinvCYZLjyEXZlmB7YjyA8\nHR7qPCNz4uG2Va7mlUHE3UYUYnlv8JFOV3YdbVL0nxhWwIdzSri5sxFIhdlabpzY\nyA1z/MCBEyTRo80jxFmL+MpwbsdbUJi7Qxlnd56zb6HHDGrLHXZTh9LXgyVbnhWL\nkxomWjIXQh4aMHQL4QF7U4EK\n-----END CERTIFICATE-----"},{"id":"spreedme","categories":["tools"],"userDocs":"https://github.com/strukturag/nextcloud-spreedme/blob/master/README.md","adminDocs":"https://github.com/strukturag/nextcloud-spreedme/blob/master/README.md","developerDocs":"","issueTracker":"https://github.com/strukturag/nextcloud-spreedme/issues","website":"","created":"2016-09-27T08:43:07.835196Z","lastModified":"2016-11-21T16:51:23.703819Z","releases":[{"version":"0.3.4","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://apps.owncloud.com/CONTENT/content-files/174436-spreedme.tar.gz","created":"2016-11-21T16:51:23.689599Z","licenses":["agpl"],"lastModified":"2016-11-21T16:51:23.826509Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"Mhy3hXeGWlIujx1Op39MMRdqHYOo360BCwr4FPWoTNNggH3aS0gWlh48DAfGYK9W\netNiOqIuRyA0NrVlsqR2vDILgFtODJSbKPyHd3PQn3hcGsjogjQ+dkKciLNLinw7\nOhbv6aDdRFLBeRHpX/7wOnWL5W3ko/gyn0Awvi88M9+nC5aARtqncQqPy2SxDGzH\nKlOZHSNDnEQCGMhA8hNWWKdVwNUJHod/wmBWpW5QVNSJq5DqrKZcNwpGM2UUJoql\nEqUMwDXk5uVH5r5k62Tr9kguDWoUEG1OqQSyeMY24AmA64tq/HSlAdZ+CX32bc4E\nZvm+n8poJBrdSVmWEaa4ZfYaLFdOc6Kcuid1B1Sv9kPhD9WD6T1sicdzjDzcorBK\n/MLReCuSb2E8aPTnFWRoAZ4xCUGs1IXzX5fmxI8VdzwR42R6RhGJ/rqMuZRFenZF\nbOks45K5gE1da4QpkYOUQa3GVMNPqPiT3CqjmJ8tjxq7bGpb6v+YoCLACjjPpPZL\n2Y28qLxwHVaINDFUUxD75WWdrlulRbqHwiSw8jolP9qrpXhDuLAqYam9tRwV5K5R\n8uNawnFwWkicBEYkN/WtBTouWzehOPn38tHXov6SyEyD6lkuxUBZrsGQ2ru+t33U\nk0kKCbV0GFw43I+3Ji5DiB4TUVNZYVoPG1B7Qve+UfA=","translations":{}},{"version":"0.3.3","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <11.0.0","minIntSize":32,"download":"https://apps.owncloud.com/CONTENT/content-files/174436-spreedme.tar.gz","created":"2016-10-20T09:09:26.520692Z","licenses":["agpl"],"lastModified":"2016-10-20T09:09:26.666738Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=10","signature":"D62Ck7JUnrYbrfFlX7xXVaYUMZIh2acmykIKapqfemD/tuX5Bvb08GYGTeFG61MA\nQzsqcIylDfGnC1UJbf8yWEX7PbyJD5w/R4WlbFv34njDvM8rBs4HpzSjkqQoykOF\nZpYAjH2ydfKqtZadgoIRm7et5B8X2AeoGg11ec52DId5t1wAEBcDIv824CDBUt8t\n0pVY8Z8n1MUYwU7DCjCbPy23br2+EBODFCHp+cFfMBLg3F0BJI5nY3Q8ku+0tqMR\n0NDxQcscNZ2Ck/wpVDWylfhpS+ICIxSMiyq7urP593mRrK3399SUyaMqDfgl/pxo\nqTzdBxHLaAqcnKZYglbqp+Gxbyj4teqCod8TiSMlp90VaxhC72ACuVQQRWQKuTNI\nZeW3YweWB5d7VErqBNmQR1tGnX5YFFHiKo41fVDQFsrOqHx4zP6AeU3nkl2ol/r/\n3pg553so1MOxMkyLEhGYGMfrdQqVEtajNWHUdj3B73LS+M3jcjBFIdOD+AGXPtDX\njCRymt07c1znhkL+aT8yY5SHMVbKBZj9mExL49hcLjAYYc4U++60uq9MFH5r9g4T\ndph+yT6VVEM/UH2HjvKsHv2wm937sNgG3EXQdh79JU8nCXIz7cVrJ8f5/9r6n1VP\nBbjtfDAPEjmfVCXX2gmgLuZHV+GMhLBS9bTh+61AhhE=","translations":{}},{"version":"0.3.2","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <11.0.0","minIntSize":32,"download":"https://apps.owncloud.com/CONTENT/content-files/174436-spreedme.tar.gz","created":"2016-10-06T08:14:05.212553Z","licenses":["agpl"],"lastModified":"2016-10-06T08:14:05.278533Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=10","signature":"X9zXDyMBPoXPMpZ+XXWK3MLufjY2MG8lJ+93LiW3rv0iq9yd8PafK4IvP9czO6o9\nf/vNilq+1mfl6mjTvL6QF5+sySlzbRGbT3uTBwYXyYL07HVYgl1ZLrwe0kxvxqaW\nxTvPem7+HzwClI3VnWc7ylQfzGrcYIaSIg7nNq1GOHocsgZVNyj/nVW/eQx24MjZ\nuLzZs9SJqYoBGq+mo63vRswhqv5OzGebo+G6dHm0hvRSOw9qsWCDWBugiSRU8zU4\nD9PQ0e8WbyrIrQhBoUvvkuijO3zCySx606S1HUyaHmbJzMc4Fbpwz6ggmi6IRBbT\nFBKB1DWJDwN/7mY4fhS4KhircVnAHDqiBVCTu5i3pSfMPrwFymcmbn9OBuFHAFuZ\nd9PZvWQg4v32w+Q/NNvZVW5lRi+l0w5DEqNREaj79hljk2reZMaB65lvtV9NCYw+\nHmwWqsGqZ1SgGZuhYkOzEIkCfJ2fF/VpyavJ4X6bHP9yYdkt1pxnSSoZ2HC8mkG4\nBnPf28mEXRcY8EJv0rEePqKSBIhAt8yfEW+joH/8nupe1qOdfPvP08ifLad5m76s\nt23UzlSljzq9kVO+d16z2uagKomN9USZaNnJcUDVblfjvCPpdiHLfRPEJnRsDZCm\nNffFWEMcz+TWmwBboZgTRO9v0bPDEuwfCCEW0zy8rT0=","translations":{}}],"screenshots":[{"url":"https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/conference.gif"},{"url":"https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/presentation.png"},{"url":"https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/import.png"},{"url":"https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/users.png"}],"translations":{"en":{"name":"Spreed.ME","summary":"Audio-, video- and text chat for your Nextcloud","description":"Securely communicate with your friends and family using rich audio-, video- and text chat, and much more right from your Nextcloud – in your browser"}},"isFeatured":false,"authors":[{"name":"struktur AG","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\r\nMIIEAzCCAusCAhANMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\r\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\r\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\r\ndXRob3JpdHkwHhcNMTYwOTI2MTYxNzMzWhcNMjcwMTAyMTYxNzMzWjATMREwDwYD\r\nVQQDEwhzcHJlZWRtZTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKLx\r\n2dCPBLIgX948BnOdLij0YyI2+FKD6uZOvzxMaoi3rlxNf8MJgraNMzTBWEXtxT5b\r\n7ZISNp89WEXhaQ1dwwCocodd/xow4Ek63m5nUvTZXsm+YSbMgrFbxzsBhYU7KuIE\r\nT/jhKdzYgemzErwwN/gtwkLMfPo3jkgg6c8NPPohYv6k7V4VnsqtJ0JS0kX19FqM\r\nMiNz9XkcncBHy9x0BSxy4+YnwbFcgIx/MtYKlBL8NkPuuJaB/6C1O+IPYhdEdnpX\r\n+RaIue71nSStOYOqT4YDqHAIw7EmqgA1my09mmK+0Pn92GJVEAEN7JGBSQ+F32RI\r\ndB3ivGAOVtUtVvJlepWdbHxj1xqeP+LCjWzHMLQjm0TyH8VqU4Cg/wxwAEFnBATH\r\naOaWwrggzY2d9KBo1mp0k71NArLbBdlHykFU4bgiSDWrXXMz0fZzLQVwGI0Eqcxc\r\nouf6t0kvrK8oKjrnso+FjBoT7lHV/H6ny4ufxIEDAJ/FEBV/gMizt5fDZ+DvmMw4\r\nq+a088/lXoiI/vWPoGfOa77H5BQOt3y70Pmwv2uVYp46dtU8oat+ZvyW9iMmgP1h\r\nJSEHj1WGGGlp45d10l4OghwfTB0OSuPUYwWR+lZnV8sukGvQzC9iRV1DGl/rREMC\r\ncQ5ajRAtO5NPnThvN5/Zuh4n8JoDc0GK4jEZsIivAgMBAAEwDQYJKoZIhvcNAQEL\r\nBQADggEBAGHMRbPV0WTI9r1w6m2iJRrMbZtbBb+mQr8NtOoXQwvSXWT1lXMP2N8u\r\nLQ1a8U5UaUjeg7TnoUWTEOqU05HpwA8GZtdWZqPPQpe691kMNvfqF64g0le2kzOL\r\nhuMP9kpDGzSD8pEKf1ihxvEWNUBmwewrZTC3+b4gM+MJ3BBCfb5SCzMURLirfFST\r\naxCNzc7veb2M98hS73w5ZE6vO+C/wz0GTsxuK0AoLitApT5naQnjvxSvSsjFPEGD\r\nsUNUEU2Decyp0jxLVnrrpz6Y5UupfBR0V8yAv1t5Od/mCKLc5DxHsDWiKOpsob9U\r\nJN+bdzJil2NNftihD4Dm7Ha7OS3O8W0=\r\n-----END CERTIFICATE-----"},{"id":"nextant","categories":["files","tools"],"userDocs":"","adminDocs":"https://github.com/nextcloud/nextant/wiki","developerDocs":"","issueTracker":"https://github.com/nextcloud/nextant/issues","website":"https://github.com/nextcloud/nextant/wiki","created":"2016-09-14T14:34:35.977699Z","lastModified":"2016-11-22T16:02:57.758477Z","releases":[{"version":"0.6.6","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/v0.6.6/nextant-0.6.6.tar.gz","created":"2016-11-16T15:11:14.344704Z","licenses":["agpl"],"lastModified":"2016-11-16T20:39:59.030384Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"aOZeEeThyZ0V/vXBcn6c+Z0vyCsZcN6nfSJ8oWEea4zXh4g705Si+MFZESqix3M2\nOPCnA/U8eASwdRTAEwQJrW5ECmu1THXSIsrzQzc9kFycvyOGzCgAWtuu0ayzZD2/\nU5aDWlzpLHC1Czg9QJ5UnfZR0AfChWQ402N1YzGqMShdJv6AHXFrVE+uYnIyxuYI\noPJQBUYbQwthVUjpYwFwSxw50YU17gmx5RZ0Y0OPz3i/EiuEUrxopXtfDVYAuCML\npDw37LOTRQ2JqxSU3teALh8LcrwJbTeOP0n4bTeV+vU3jvtiaEoRrwfVrK41F701\nQymGXy1/EFG0kxPGS2dRNPBAXYLZfeoWlROl3D5BWlbsCcXKU1S+22yn0TEdS7x1\nY44x8jRKnBddDE7qkn+QoQYHNNcxOREsFFLmIoyCUpdNOdDX2PvTFUYkIqdnXaJy\noAKv2GkvWPQ0aiiBtA1i4oXuzvHW/M2wOrK7v7DCpNfILrD/sjxpljxcX082nRCd\n9P3iPd2hQ6yOM9fG21LVN74b6wggI81BzFf/xJPd4ZqYLjfeG/yqd0zaiMOzMm1W\nse+kc/a4iB3BoCNX3E942pBBzew4ya8LkCXdCHUUsuelDf1va1ikTh/G7D84ll9/\n2avNqQnUh3hgOnxFCLI/5VrbqxfSTVdO6O/LTuAmwgw=","translations":{}},{"version":"0.6.5","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/v0.6.5/nextant-0.6.5.tar.gz","created":"2016-11-09T16:58:06.856332Z","licenses":["agpl"],"lastModified":"2016-11-09T16:58:07.139404Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"DVOIbLEVggiLkNkuPW+pXqu8WYT15unUsMoqHSw81NiU6HF0Nuf3XiwnHJJDDqo5\nyX+QyHADO4ZiQpvXhGigvwD2eS1jVLatAztyxE0tEQv5eBU/7R0jQYxI8YCnC/jE\nZDa0qs+TI58EkDek0LBzueVQqrLubKgGU9P+E9H8gbWi1JHvl/2LdY7CplPqaJ+J\nMRokobPntzgx9m4DZC1RsCoXzSON7o2gp2cmunPJiXVHPhMUfIfolGEbNGJ1/xdp\nra7Y7XkPnDx4po98a38UpUh1x/2m5goOV54em35bWbh4ShNDykiE5ttz6tOywlYN\ngxceSsStTKyqscVaOV2Xu6Ive0pY9CInvrSfRnRktIWBYDyWdbK9sJuqs/s69kqn\nKQ/SjzE2smw0zwOUMnSaz0Jzr1vdPFgNu2xDYAVQO5G03V+wQ5AhxuhBz5Xp5Fll\nLaOhymZLCC7lq0DUqkeTeQ2QCfiG23hvG2VUPsIqW7xFe2YzKHZVXi9JuH//Gwym\nDmJmcyZDMvNwNiObx3ZRKsZNH2XwbldFZ9nTpb9AafyoSR/qbwd473NewaDLRTiY\nLrOP5Wx1xx6DOkRmDF2l2iT1bSJ6eoAoWQU2I0aYRH9NAr2Ugd4f2Um4o61EJaL+\nRHT9cERRySEloU/NdgmZEOi+CG0rEu+9LC5G/jGlHE8=","translations":{}},{"version":"0.6.4","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/v0.6.4/nextant-0.6.4.tar.gz","created":"2016-11-05T18:17:47.622023Z","licenses":["agpl"],"lastModified":"2016-11-05T18:17:47.678445Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"RdkvnhNjw+kAnT6Or3+N9FzAv9DjJ9BAlmgANMwZZcaqo1gZRFewsGD2Rx1KEb9X\numSC28tl2B5/3r/+dprVJmOnYJny/7+kDmI/d+vigKfnaQJOUZ0ya5+f72pFgow7\nth8fw9rX/3+zIBs2IeEN66cis8ioFq97BJDsnDMBDr7wl7CnFJjYe6eviWuiFTnC\n4sBXlYjHoaIRRu561nwAooV+WXmWsparYPVhj2cXdyP/CnWo5HSF5jA51WCsz7Up\n7a0URXdh85xmxEbZtnjUymTW2BIegdxj9Erbfiuy/m3ApgnP+DiEQRcM13J7pXqg\n4cgFOBSzKDZgim599WBW2uNO1ztnDYOzz47GXDfJhcdvKiZZoQpUF9W4LMRtheMz\nxD9YArO3j3d+VOInSYU2Rpvhugwo1LExhwnRdT4+cOZfEeq0VojiM7yBZLDdEjIb\nGdYUJtNWSU0F6cPab2Au8FgZymLrHL9EpGvxuA1oAwtRxHAgMElJG2O6Jp89gGl9\nh/AptypeTvzNEc9/Kg24ueBKqmSUd5a45pZ3gM2pNATJhUK7fzLb/K6cq/kEzZtj\nOPra1ZfP0/20u8VP32Rgw1cFmIjqt8DFzUmOMpMfyoJkdldtTwQtGk+yIvtN1zp6\nT2zDknAKA2N/rZ/0SJl8KxVVNLhQWtYBJ+rFAdapuxI=","translations":{}},{"version":"0.6.3","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/v0.6.3/nextant-0.6.3.tar.gz","created":"2016-11-03T21:51:27.654342Z","licenses":["agpl"],"lastModified":"2016-11-04T18:25:35.697130Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"Hf5GB4xd+rVXzWvVpGbbF5tqmnI+DGHlNHdLYPImFLS/Z4K5wKeNp80E5sd/RkAi\nhyuEsdWHlGDVMT6s7oeCmH/ClyWqLNSz9VH4KYqyFgD4+usHZp9PrEeEKbvPDPKv\nD3eB7Ats34cWcpf4E1oR5wsPicgmdgIgb2uMXzc/1G9xUBRWzocwCstzjEEAB/VJ\nvJuHvhDTGG294P4gOb82MxKCQ8LZ4i1QXzOf/mLETOubiUbZtJgTReYvpdAo2Wct\nbdfDFw13LYZkCf71r9jIQ3PSPlIpD+0BwAlE1fi0Br9dP2JjIfiKN6CGVaki6O0v\nKR42jtcE9xXiAop0Ym1FYMWJvQUy5PFLMwYDfEd6CvfEFJl+fi+RjXNDNZcTyw00\nHa48sACoGzxwts2JknWMU57mwvi0Z4uwpE0cFp/PRzBsXmSlCzWHjJhu7+2qambE\nAabdP9nH2NvqJHUJyPsxtDSrSWCBY4CoL3wYu36UrIA4NepyudMPNe9fhKTEU0bg\n8DLclw6hYdj5p9Zj3OUuwOZLz6r85KwnooTsUjOYkBXvdUuHWkgONqqZlPMApS4i\nChRQ7ysHAinPyyzsvr0PR9g6J52CSCO/7qwSJy6yqSzuSWrbZUa4FVTcKIwWJJPu\nJ2XzB4rWVG1wWjzMM6MIvFbO2HY9upzh651OdOwsYvk=","translations":{}},{"version":"0.6.2","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/v0.6.2/nextant-0.6.2.tar.gz","created":"2016-11-01T11:24:58.054892Z","licenses":["agpl"],"lastModified":"2016-11-01T11:24:58.151609Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"h8KgwMh2RGGIp7q/II23VSfE5Ibkha7p/C1kvIfG6QIIc2Zu/Mm3Oekynnysh5ZJ\nZuMTaeWbejbBAmlnxW+AwBWa/s2PoMhv7foVvdtg76l9/qr+9jGvUM7D1LbbBvAy\n/XW6JSrhhBZHOohdU7kwV5Xnwsn/NC/zUe0G4eZ+9fc9uSntkob9wnWvUs2daAeD\nY6Mi7Xt/XAIX65OIVTKfC6ah1SlbXgtJ2i2j4G32I9jRhmbkpt/UJEangn90fHnY\nQXNJ85OyV0aNMafNHoMSL3uLscdvjp0Hy8w4iBeavsRlCs0GiUoG1+YdwTwmC9EM\n4CjbMfRJ0DYK7u697TOmS8MQzk8O7f5THtjeokZlrom2YnV9t6gLvjnxl/+gXPdJ\nmgLixnA8P6tPsff9pquHKQZsvxjv6vVa2DVJc8VpcqJRih7yj/3V7rxesEP7MUnP\nznIOcwzTsKXHuAnvujpCwyQj3QtpQK2XJPQ5WkKgwbTdvriVJfnzPironhcHo1vC\nbuUDOdhL59aySChw2cZGD9lCWaxYR7I1BDDzWKNl9Qg0AZ2auyGUGTv8P2vi5qUB\n0CmnkzkZurR5ju6Nb9/2lcZvda7QJdIdMtm2Wnn+Ak/Z3Y4IehB5PPDP5/MMAhQY\nXE8Jqe0mGtiU/O2346L5IThkS58JlRmep4kYv+II9zE=","translations":{}},{"version":"0.6.1","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/v0.6.1/nextant-0.6.1.tar.gz","created":"2016-10-27T21:16:47.066097Z","licenses":["agpl"],"lastModified":"2016-10-27T21:16:47.125641Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"axSX4Kz2P4PbKU676DibjPZsxk8hCIG3lLOmeMXoiBhp3ka4wJ8u5tNwTzgY8/MV\n3mjXe5DNttD66SqmiRNSPKbotYHVFFW3wFK+Dgh/++n/KTomGYUeIwt88Z9ecbuG\nNT6U46jFrfZBYzRHWzbgiJ4c7MCoid9cfmoB7HDuQSyw+E0S2vbLL8+jzMcIzF+5\nTh/sJEterXCyrWSciw/9x98F+4svNbskdEIvrOox3+K6UIhpsojqJR2+bQhG3rsM\nPerOb6J+bzHdLV1ZL/4nWEz1F30T7B08QxY/4pHD68JFQcdtzmHMIhXfCoRvWhN2\nVRnizx3IXBALY4F49Ql6bjsnr6BCp+LroM5RSQ3eupDcqejDJLbjPz8xfOMOwlx7\nz84Xd0MUyqaEkxg1ihsWLbPlYACUZ2aoDkSQUIbfZTTiov7eqTM8UBc/UqVID/LU\nyEW4gjFZzQy6kX76XRAGq1vebKFjCU63asCnVyJhF/YQVTu1hPGbFslkRKnYuh8W\ne4MeaNfbdjcSEX+7oTcPJz6V09pOPvukXL0M1m7lS9PhTisI6oGj8c33GPYp/DSK\n6SGk+ukbt1mwFuFKdTvAMxo1lk96D+pKUv4MX/ralaaoIAmwPTGsSQ04RyL454ae\nU6q8PApwrVyPHYwMBPtXGoQMyb2ZV9rylazYbKCQ8I0=","translations":{}},{"version":"0.6.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/v0.6.0/nextant-0.6.0.tar.gz","created":"2016-10-26T01:46:48.419025Z","licenses":["agpl"],"lastModified":"2016-10-26T01:46:48.521063Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"W2TmbX/NbbfPPjIJLalO0kCDhhQF1pEohH/CxO9bY+yR+a5NKiTbpAhG2McqpTSj\nmgC4J8/thmwGlWGC+VW+KlpXzzjc7wCgMGMKViOpGD3pIy8p8U5MXTqVgjjrEb9g\nKgr9uErXzxJ5oDfkx8Uh1bUeBJTsAAivGJqMlhBYFGxw8BSB09sfOZytNxo4wbwZ\nNAcYP1qvkUQ8CVR0nInSTRfLvAp5+e/8xxyYZwJIWrdNgpoP0CxiwzKP/VSjBk/U\nsPU4R72UQnVZB0InRCeh/KNTwu1YiPkUKm+mNmt2hCfN7Fm6bY2rUMH7oa8KTkqn\nh52FhbaYRSAR1OPdC5RnHiQWlPh71gq+4Xqgp19Eawnl/QiVteVifSjNQZ+Ban8M\nRyw/PxHnzIWg/OAjx81Jx9mXjUIHSeUxMTJTKTp+lEqIAzjku0iHeU5UPGCfE+VM\nwmopZfnlfk2nLkUwjQXLCIcnZD1ME1m0h/H4Ad0Q/qXpBScUp47npkxg2b8zPIhk\n3aXUmNPLgwyXPWvAuaBK/WwpNefUnqWFns8t2Alpzg/EpC2PrZqciCNDcRFEycoa\nX+JsFyD7eYA7Dc9iIf09gXZX+tZ+Jinb+iPDwYrl1u/7IIBoBlUGCgo+cF7/dL9S\nc3vYeWw6MCH8Sv+ckgS2g726BfdN5EjB/8cb071b4lE=","translations":{}},{"version":"0.5.1","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/daita/nextant/releases/download/0.5.1/nextant-0.5.1.tar.gz","created":"2016-10-17T15:23:04.515057Z","licenses":["agpl"],"lastModified":"2016-10-17T15:23:04.576640Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"Pp3rC/9RmAYURneGpGit4HZ2t1qH9A9nwsUnGDgRuJ0akIii7CtJC+n8l1b9k73/\nhxMYnp2JOBu2HWKgFp9a3yeo1xphI5hOUdVQ1UZAWxIQyDI1FZVYDr81l7GCdkqm\n2lMxgviFADSYURCgEnAsj9Nt0NZ6LDcJZiJg3iPAjkDI0U+KnEBjtx/XRFqGUnfp\nCUZ/XLHh/hvoEitSHepTBDCMKkTNjbDEwBYfA2rAoz4zbMR5zKLU+1r1DIUgWSRe\nbk2i8TaTDVL4cbb6MhkGKwkujb+Atikvkpi45o7+fyQMs84c6fjjh/TZJaC+dMyG\n1GCikMPwwtEPjXtnLzynERAxJOd5mP4Ee4sD8ZrnzNUehpyFR88pwWU6r+dmiebb\nnsYlGkhIu2aIO2O4HZ4sUTsO5sfjZ9me7jsafhgJl6iG4IBeHa/L1MsSbhsh6mvH\nYsz4Xsluwr0QcFLmSDDQQYynyogKfJZG2xQsadM0GETWgXE44dVeRvMUsILfB4uZ\nmfKgd23SgaOhYC8m4bg5Hxnkl+xHJnyGZ6jhqg7bhuKwsoLymc18Vmjmb7a45HGV\nXbL5CTmw9yaPOBS3v7v91TnlB+0lhlzbKzZ0xIhY55qsTC76uScbTLwndPqNGaF7\n2koxRbJ3jcmf/Z2MLymdRi2BTZbZkPkxgVrSf9plaR0=","translations":{}},{"version":"0.5.0","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/daita/nextant/releases/download/0.5.0/nextant-0.5.0.tar.gz","created":"2016-10-11T11:47:46.191539Z","licenses":["agpl"],"lastModified":"2016-10-11T11:55:40.393000Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"qzQJSLK8nkrQedwwxUdhxL8bq3aXyppAlWJo+n3GqSvqA8uNTzl3Wsci0LsnBV0E\nDvDNW8K0enhl563F/bywQrDhgKl8jTX/CA5KCxqO9P+tvE80zAfMqiRnQayVcWuY\nSWX6RqfI/kqiWyN1SsFp2EDlas6eb+xfIoiJamlfsN0qzHYOFt5W77wmw2Bn9dB5\n9nwHHyC0z60Pf2pPduc/KuZ/971WrDFaIapL7Gm+z9XoaKSwUT575VtS+RNJkOKy\niBrwnHdc8x/62HPFOXsUYjCt2aEmLzPCQN8Ke5pd3596hm5wbAVzTHuxf2H35tb3\nljfGqAZ5AJX2Xd13d4aHXFdSEILwv6IFq2fx0hO3vkvFEoKF5oQ2t3hi++Mw/h8R\n15OKZCOC1bFH3gTwdshmnHSTSr3LxDeTF60aH16wpXcehQuJHagpb/aG8mPD1w+v\n759/mekqa4LYlqT9TLWTqX3UPeQXYIwcPijG84IvW1BDK1M4Mj2Vqsld4jXwG6CP\nORIL8xoQbA52dQI1Y19JXcU9zxIb6GaHYgpV0wejatsZRfhPv2Yd0CBShF4HY7aw\nnfcm88pqzOKNvjnLZjTFQwuJ0AUUSOsWhgZzYt8tATJ2KDZ+lxz+WAMGXJAC/ciY\ntrrglY7YxwJNLbYp+arE0sowZx+IOVaSZBvmUGHiEBY=","translations":{}},{"version":"0.4.2","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/daita/nextant/releases/download/0.4.2/nextant-0.4.2.tar.gz","created":"2016-10-06T10:31:12.482416Z","licenses":["agpl"],"lastModified":"2016-10-06T10:31:12.551117Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"QHJhYcBMi5HyPofshZ7EdcXsOfRrl7o48Y3BBBq8CkmYtFDbekghdJqjFbwwZa5u\n8FtgMVwssql/RSDNP6M2Zc/MpQ3K9gDm+DyxE5KRmtMEpzHB+oD+1DxP7kAoyW8/\nnBr5iiQSdLCelddMcTwbdxskLFUXIs3cFuLGhMvr8pdQOAgfxte5lolrj4/8EsJ0\n0yUImgIYG4NlgmvCygGApdpVaOcK7XVtv4oH+x43JmX9YZ3Ce0DQPYPUbFTCf4ZS\nS075j1vcnPx2cRFGxc+YpKzYVVYoy7ZdB75Hq+kaei/atxrTyV5+gcCrVPnH1RkX\n6G8rgu5l8FoGJYopi8/9dd8LsGLFx53CHMdEVob3tFR0WeK4TJAGJa403zE6S3hM\nxr86WCedmjuti0uOhSQr5AEVAoXZ/JUWQMMsPAUMuKEYVjKfmve6TlcNMC2oM5XT\nXcOf4OP3pcQq4ViN53o4Pj6NGSci6IzD6xLeAxKZUoTX37ArVKH6RHS5Najc193H\nRhYRnfE7D5YOr1u10HaZCFCVJif2MgMP0/uH2759NoRjXFowrh7Z6dW7JQG5lbHN\ne0jjJH1Y8m8H1peGGcmM0YxFiOVZ0ER7P+AxT4Cbau/cVhaS8vnPF2a2a6YFRiFS\nVH4aqazvvXrtifDr3lfvlyPCrP/570nwvOJgZGk+K/Y=","translations":{}},{"version":"0.10.0-alpha","phpExtensions":[],"databases":[],"shellCommands":[],"phpVersionSpec":"*","platformVersionSpec":">=9.0.0 <12.0.0","minIntSize":32,"download":"https://github.com/nextcloud/nextant/releases/download/0.10.0/nextant-master-0.10.0.tar.gz","created":"2016-11-22T16:02:57.740378Z","licenses":["agpl"],"lastModified":"2016-11-22T16:02:57.900805Z","isNightly":false,"rawPhpVersionSpec":"*","rawPlatformVersionSpec":">=9 <=11","signature":"kDO3xbPpoUdl2qo362tXfJIqKeiKE12M8FkMXbdKiRNzuQyvDOehQq3dErALZDOr\nLG47Tpez/Kn9Fsx1y4dQDx0w9SD3pyoqvjj1O6KkTYN6srpitQcj9EzEItCY+MZd\ngRSc7Px9MzxpFpgwtuThGVlSt5kLMd0vjWFLVcv7k07rZfWEsTwXd24INIDtlr1A\nC7hyLB777nEOGa7oAzx8nr+FJcIbmu9opVZk8AL40FOFDNBgfAy2AS9hGZreUmRV\ndV9Zh7UAR+RsEeO51xcU/CKqC8Jb0jL1gkYyUaQy16oe1HF9bRs1PWuNL5mYwsmy\nZNn0ay/a7mb7hxJbza1F3lbgBtodvbgUm7+So/QvaR29CSAqqoUXeQy6FfSBVWhZ\nYlTxdQfKcBcUPFO14BBk/O5p5iQaG8JCLJ/EZGDPDIVDMn7crGQ4oLZJv80eqTeB\n7ueDmWaD3gQ9j2XKsMk1uLSyY4unt9AaTofBylsKD1SjLhyxofGZym4jc2+M1GnQ\nyLcoEMSexnKuextu4nzrA0y5k3z9tvO07R29lwT1GFp6oGAakMLob/6XrGsm3YQY\nRQXgfXKFw8XmXBumqG8ayEIyvQ/O8nO6r4R1H8a7ooj6oWa3PhPsen+gLE0SpJPZ\nz3e2TLliwC4VtZp69H7u3px5Qn1Fc6RMDTh571edCr8=","translations":{}}],"screenshots":[{"url":"https://raw.githubusercontent.com/nextcloud/nextant/master/screenshots/displayResult.jpg"},{"url":"https://raw.githubusercontent.com/nextcloud/nextant/master/screenshots/admin.jpg"}],"translations":{"en":{"name":"Nextant","summary":"Navigate through your cloud using Solr","description":"\n\t Navigate through your cloud using Solr\n\n\n**Nextant** performs fast and concise _Full-Text Search_ within:\n\n- your own files,\n- shared files,\n- external storage,\n- bookmarks\n\n\n### Recognized file format:\n- plain text,\n- rtf,\n- pdf,\n- html,\n- openoffice,\n- microsoft office,\n- image JPEG and TIFF (will requiert Tesseract installed)\n- pdf with no text layer (will also requiert Tesseract) _[work in progress]_\n\n\n\n## Installation\n\n- [You first need to install a Solr servlet](https://github.com/nextcloud/nextant/wiki)\n- Download the .zip from the appstore, unzip and place this app in **nextcloud/apps/** (or clone the github and build the app yourself)\n- Enable the app in the app list,\n- Edit the settings in the administration page.\n- Extract the current files from your cloud using the **./occ nextant:index** commands\n- Have a look to this [explanation on how Nextant works](https://github.com/nextcloud/nextant/wiki/Extracting,-Live-Update)\n- _(Optional)_ [Installing Tesseract](https://github.com/tesseract-ocr/tesseract/wiki) ([Optical Character Recognition](https://en.wikipedia.org/wiki/Optical_character_recognition) (OCR) Engine) will allow Nextant to extract text from images and pdfs without text layer.\n\n\n\t"}},"isFeatured":false,"authors":[{"name":"Maxence Lange","mail":"","homepage":""}],"ratingRecent":0.5,"ratingOverall":0.5,"ratingNumRecent":0,"ratingNumOverall":0,"certificate":"-----BEGIN CERTIFICATE-----\nMIIEAjCCAuoCAhAFMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD\nVQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI\nMTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB\ndXRob3JpdHkwHhcNMTYwOTE0MTI1NDQwWhcNMjYxMjIxMTI1NDQwWjASMRAwDgYD\nVQQDDAduZXh0YW50MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsbnQ\n+9acjKHfcrUj4yqBpD++GmQ5z2Sp8C8uOz4ZbLyM9bUXEYHo4a4u3CdC49kGUkb3\np5MkEAEzslTWDi1eh5MZgPWpbPgItsDsXY1o55O3jtxNkzSG5/yYcPQcuKtIOm9S\n7DY0K+UQt3nK+RrXEZfARMNrzFbEzpE3b7w901Yl5n+m/B8rhW4pqg8uSfx3u04J\nwduV1fHwoHUB0Ox5HyWib4Pq1XppNh7xdc2Fg93JxshwuCPJyOOzrFTnxC7s1yzQ\nUvaqkjPW5QeQRunQjZ2XtpYH8f8v01W18bNEiHwqtFwuDEyCVx1rvEMgUDVXdPkP\ngZrlB5TzGmz0U3HzYvf6205WuzfHxz7kPj502wP51PoZBKpniggKzmuXkx6BpsZC\nZX45VpDHdiATLwRj1t2bMs3C01nzpIWO5ZwFtkepH3Y+mvwX5lDh/XDsqJC2Yo8o\nWMmniWNW7dspufYOsBUqqYGP7rkailgVT4oYk6D1j6oFZ5SSpfPF5lsyYedDSM6y\nbIGVkSF+sjLK6R9BenBijKceAKsS//WwRYCBPC+JHlsYpXKW12bL+C47Kj2/N6d4\nrYryzV6ofVSF6pwIq0oEjoyfBfNpYavf3xrRkSSmIIlPSnMY7DT1xkGD5retxSm6\n+WIfkWKRZpv2S6PhMHGLspYc4H5Dj8c48rG5Co8CAwEAATANBgkqhkiG9w0BAQsF\nAAOCAQEAOZUwyPaUi+1BOUgQJMWqYRoTVZUyBshTXSC7jSwa97b7qADV9ooA6TYF\nzgsPcE41k7jRkUbnjcY45RGtL3vqsgZbx5TjPa5fGMxlqJ6eYBOY61Q6VIHEVm3u\nxnPEO9dsMoDBijvo5D7KtE+Ccs907Rq70kCsbrdgPHkyb5tDSnCKogN1LiQrg1EP\nmy7Z1C7jG9/h57vx0+QBMDCYnTmqLsvMKqo27uHskzAiB7VXLEdSZ2FtMGHkLUQO\n0bfhnvTZ2VhMmK83t7ovo71An4ycmsolGD/MA0vNI78VrVISrdI8rRh2WntUnCBU\nEJL3BaQAQaASSsvFrcozYxrQG4VzEg==\n-----END CERTIFICATE-----"}] EOD; - static $expectedResponse = array ( + public static $expectedResponse = [ 'data' => - array ( - 0 => - array ( - 'id' => 'direct_menu', - 'categories' => - array ( - 0 => 'customization', - ), - 'userDocs' => '', - 'adminDocs' => '', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/juliushaertl/direct_menu/issues', - 'website' => '', - 'created' => '2016-10-01T09:16:06.030994Z', - 'lastModified' => '2016-10-06T14:01:05.584192Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '0.9.2', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/juliushaertl/direct_menu/releases/download/v0.9.2/direct_menu.tar.gz', - 'created' => '2016-10-06T14:01:05.578297Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-10-06T14:01:05.643813Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'ERBS9G5bZ3vwCizz2Ht5DehsVJmb63bzF3aYcH7xjbDVMPagOFWdUAiLDwTeZR1n + [ + 0 => + [ + 'id' => 'direct_menu', + 'categories' => + [ + 0 => 'customization', + ], + 'userDocs' => '', + 'adminDocs' => '', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/juliushaertl/direct_menu/issues', + 'website' => '', + 'created' => '2016-10-01T09:16:06.030994Z', + 'lastModified' => '2016-10-06T14:01:05.584192Z', + 'releases' => + [ + 0 => + [ + 'version' => '0.9.2', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/juliushaertl/direct_menu/releases/download/v0.9.2/direct_menu.tar.gz', + 'created' => '2016-10-06T14:01:05.578297Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-10-06T14:01:05.643813Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'ERBS9G5bZ3vwCizz2Ht5DehsVJmb63bzF3aYcH7xjbDVMPagOFWdUAiLDwTeZR1n i4gdZ73J/IjHQQJoOPwtCjgbZgLPFqL5x13CLUO9mb/33dZe/+gqEDc/3AuJ4TlA XUdLxHRb1bwIlJOwuSr/E24452VG20WUhLXBoM0Zm7WcMxvJWo2zAWnuqnLX3dy9 cPB4PX+6JU2lUMINj8OYQmM1QnqvjG8YV0cYHbBbnSicOGwXEnni7mojsC8T0cn7 @@ -112,42 +112,42 @@ u2SqRhwybS8j4YvfjAL9RPdRfPLwf6X2gx/Y6QFrKHH0QMI/9J/ZFyoUQcqKbsHV bkR1DTBCyDjdpNBidpa3/26675dz5IT5Zedp4BBBREQzX08cIhJx5mgqDdX3CU09 uWtzoaLi71/1BWTFAN+Y9VyfZ8/Z3Pg3vKedRJ565mztIj0geL3riEsC5YnPS0+C +a3B9sDiiOa101EORzX3lrPqL7reEPdCxrIwN+hKFBQ=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://bitgrid.net/~jus/direct_menu_nc.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Direct Menu', - 'summary' => 'Provide easy access to all apps in the header.', - 'description' => 'Provide easy access to all apps in the header.', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Julius Härtl', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://bitgrid.net/~jus/direct_menu_nc.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Direct Menu', + 'summary' => 'Provide easy access to all apps in the header.', + 'description' => 'Provide easy access to all apps in the header.', + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Julius Härtl', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEBjCCAu4CAhADMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -171,68 +171,68 @@ e/zxnB1EmeI2X5D2xceJDLB7Fy5W0EGrLixRIdFaSUommWFUm9E2hSIaNlziSBdc G2dF9Gtu4GiQ5fuaJknaxlgXHovfqeZwZJX9o4M+Ug81AqiY7XjdiaCPdh0Tthcx 2OmWZo7UBREWenjKyFZZ/iKoqH5sdenBtpo= -----END CERTIFICATE-----', - ), - 1 => - array ( - 'id' => 'apporder', - 'categories' => - array ( - 0 => 'customization', - ), - 'userDocs' => '', - 'adminDocs' => '', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/juliushaertl/apporder/issues', - 'website' => '', - 'created' => '2016-10-01T09:16:47.111889Z', - 'lastModified' => '2016-10-12T19:50:16.038821Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '0.3.3', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/juliushaertl/apporder/releases/download/0.3.3/apporder.tar.gz', - 'created' => '2016-10-12T19:14:10.802359Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-10-12T19:50:16.104357Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'nhlT9lhrmBxIsqh/e3RLm2NDw/U8ZvvoMyYQTLMM3H19DQmVcPYPYC9QWVTsowUzXblVaOXVGylbpKma9yOlOAqJtF3qyXecLl4+tA/Awb6BBhKPgHFdcLDAL5yy1K7/uei3SgEojMlJoI9vEK5I1C5YTh43yNH+//Im6MAuNYFUTlMXK426zdOe6ogpCI5GlYdXopqYANxcpT+WXWET6DDSM5Ev+MYwMcSAY4r8+tvARRU4ZAenRgjkBT6R5z6cD76emRax14tbV6vkjjwRcO+dQtM0tFPbd+5fsNInbauv50VzIMgjA6RnKTOI17gRsSdGlsV4vZn2aIxEPWauu6T/UohMvAE9HMn13vtbpPBSFwJAktj6yHASYGzupNQLprA0+OdyALoLZPpQAKNEXA42a4EVISBKu0EmduHJlUPeqhnIGkkGgVNWS8AWqzP2nFoPdXBgUWateiMcBTHxgEKDac5YmNc9lsXpzf1OxBaXHBhGYKuXPwIfyH3jTWb1OdwixJEuRe9dl63T9qOTRre8QWns/bMqKLibGfMtFhVB21ARJayBuX70eVvabG/2N7Y5t1zUlFygIKu51tvo3AVCRDdRrFWDvkAjxzIz5FIdALVZ+DReFYu/r4WF/w3V9rInFuEDSwb/OH4r8sQycs07tSlMyA74Y3FpjKTBxso=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://bitgrid.net/~jus/apporder-nc.gif', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'AppOrder', - 'summary' => 'Sort apps in the menu with drag and drop', - 'description' => ' + ], + 1 => + [ + 'id' => 'apporder', + 'categories' => + [ + 0 => 'customization', + ], + 'userDocs' => '', + 'adminDocs' => '', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/juliushaertl/apporder/issues', + 'website' => '', + 'created' => '2016-10-01T09:16:47.111889Z', + 'lastModified' => '2016-10-12T19:50:16.038821Z', + 'releases' => + [ + 0 => + [ + 'version' => '0.3.3', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/juliushaertl/apporder/releases/download/0.3.3/apporder.tar.gz', + 'created' => '2016-10-12T19:14:10.802359Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-10-12T19:50:16.104357Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'nhlT9lhrmBxIsqh/e3RLm2NDw/U8ZvvoMyYQTLMM3H19DQmVcPYPYC9QWVTsowUzXblVaOXVGylbpKma9yOlOAqJtF3qyXecLl4+tA/Awb6BBhKPgHFdcLDAL5yy1K7/uei3SgEojMlJoI9vEK5I1C5YTh43yNH+//Im6MAuNYFUTlMXK426zdOe6ogpCI5GlYdXopqYANxcpT+WXWET6DDSM5Ev+MYwMcSAY4r8+tvARRU4ZAenRgjkBT6R5z6cD76emRax14tbV6vkjjwRcO+dQtM0tFPbd+5fsNInbauv50VzIMgjA6RnKTOI17gRsSdGlsV4vZn2aIxEPWauu6T/UohMvAE9HMn13vtbpPBSFwJAktj6yHASYGzupNQLprA0+OdyALoLZPpQAKNEXA42a4EVISBKu0EmduHJlUPeqhnIGkkGgVNWS8AWqzP2nFoPdXBgUWateiMcBTHxgEKDac5YmNc9lsXpzf1OxBaXHBhGYKuXPwIfyH3jTWb1OdwixJEuRe9dl63T9qOTRre8QWns/bMqKLibGfMtFhVB21ARJayBuX70eVvabG/2N7Y5t1zUlFygIKu51tvo3AVCRDdRrFWDvkAjxzIz5FIdALVZ+DReFYu/r4WF/w3V9rInFuEDSwb/OH4r8sQycs07tSlMyA74Y3FpjKTBxso=', + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://bitgrid.net/~jus/apporder-nc.gif', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'AppOrder', + 'summary' => 'Sort apps in the menu with drag and drop', + 'description' => ' Enable sorting for icons inside the app menu. The order will be saved for each user individually. Administrators can define a custom default order. AppOrder works with the default owncloud menu as well as with the direct_menu @@ -252,23 +252,23 @@ personal order by changing the following parameter in your config/config.php: Users will now get redirected to the first app of the default order or to the first app of the user order. ', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Julius Härtl', - 'mail' => 'jus@bitgrid.net', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Julius Härtl', + 'mail' => 'jus@bitgrid.net', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEAzCCAusCAhAEMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -292,49 +292,49 @@ CSKtBro2jcnxzI3BvHdQcx4RAGo8sUzaqKBmsy+JmAqpCSk8f1zHR94x4Akp7n44 Tu+WGOL2Ee5U4k4XFdzeSLODWby08iU+Gx3bXTR6WIvXCYeIVsCPKK/luvfGkiSR CpW1GUIA1cyulT4uyHf9g6BMdYVOsFQ= -----END CERTIFICATE-----', - ), - 2 => - array ( - 'id' => 'twofactor_totp', - 'categories' => - array ( - 0 => 'tools', - ), - 'userDocs' => '', - 'adminDocs' => '', - 'developerDocs' => '', - 'issueTracker' => '', - 'website' => '', - 'created' => '2016-10-08T14:13:54.356716Z', - 'lastModified' => '2016-10-12T14:38:56.186269Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '0.4.1', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '>=5.4.0 <7.1.0', - 'platformVersionSpec' => '>=10.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/ChristophWurst/twofactor_totp/releases/download/0.4.1/twofactor_totp.tar.gz', - 'created' => '2016-10-12T14:38:56.174612Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-10-12T14:38:56.248223Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '>=5.4 <=7.0', - 'rawPlatformVersionSpec' => '>=10 <=11', - 'signature' => 'bnwWxmHEn8xkoWbtwhC1kIrJ0dQfAI3PUtU62k+Tru/BHt1G2aVxqO8bCdghojZ7 + ], + 2 => + [ + 'id' => 'twofactor_totp', + 'categories' => + [ + 0 => 'tools', + ], + 'userDocs' => '', + 'adminDocs' => '', + 'developerDocs' => '', + 'issueTracker' => '', + 'website' => '', + 'created' => '2016-10-08T14:13:54.356716Z', + 'lastModified' => '2016-10-12T14:38:56.186269Z', + 'releases' => + [ + 0 => + [ + 'version' => '0.4.1', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '>=5.4.0 <7.1.0', + 'platformVersionSpec' => '>=10.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/ChristophWurst/twofactor_totp/releases/download/0.4.1/twofactor_totp.tar.gz', + 'created' => '2016-10-12T14:38:56.174612Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-10-12T14:38:56.248223Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '>=5.4 <=7.0', + 'rawPlatformVersionSpec' => '>=10 <=11', + 'signature' => 'bnwWxmHEn8xkoWbtwhC1kIrJ0dQfAI3PUtU62k+Tru/BHt1G2aVxqO8bCdghojZ7 zdFMlIJw4kekYFsVfLk8jzjUTZKVbNVKCdkHrVTQ0bUUryMAMLqGQ3PSRI5NX6D5 FpkvwO1coYwU0XVWF8KAS0meX0ztSkT3Mv96LLrxr8F8SrB/MGmKIE4WTjt1fAIa ZLAVEUo/3sNFTGLYBtL3wjctrkZvJltP8abeRfls9FkRHu+rN7R3uLFzk42uZn3X @@ -345,38 +345,38 @@ h7ro5ls+d3OQ8i3i4vdZm821Ytxdu/DQBHiVoOBarvFWwWAv2zd2VAvpTmk6J5yv 3y+csRqpEJYd9fcVMPsTu7WBRRrpBsAqdAHJcZEwak2kz1kdOgSf8FIzP1z6Q71d Ml2RKcPeutMHHSLiGIN/h7fM5aSs49wGgGZmfz28fHVd7/U0HFSMYmkT/GMq5tMP Iyc+QZAN4qbX8G0k/QSTkK/L4lOT2hQiQqiSqmWItMk=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Two Factor TOTP Provider', - 'summary' => 'A Two-Factor-Auth Provider for TOTP (e.g. Google Authenticator)', - 'description' => 'A Two-Factor-Auth Provider for TOTP (e.g. Google Authenticator)', - ), - ), - 'isFeatured' => true, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Christoph Wurst', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Two Factor TOTP Provider', + 'summary' => 'A Two-Factor-Auth Provider for TOTP (e.g. Google Authenticator)', + 'description' => 'A Two-Factor-Auth Provider for TOTP (e.g. Google Authenticator)', + ], + ], + 'isFeatured' => true, + 'authors' => + [ + 0 => + [ + 'name' => 'Christoph Wurst', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIECTCCAvECAhASMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -400,51 +400,51 @@ dIu2MkhxAZk9FZfnFkjTaAXcBHafJce7H/IEjHDEoIkFp5KnAQLHsJb4n8JeXmi9 VMgQ6yUWNuzOQMZpMIV7RMOUZHvxiX/ZWUFzXNYX0GYub6p4O2uh3LJE+xXyDf77 RBO7PLY3m4TXCeKesxZlkoGke+lnq7B8tkADdPI= -----END CERTIFICATE-----', - ), - 3 => - array ( - 'id' => 'contacts', - 'categories' => - array ( - 0 => 'office', - 1 => 'organization', - 2 => 'social', - ), - 'userDocs' => 'https://docs.nextcloud.com/server/11/user_manual/pim/contacts.html', - 'adminDocs' => 'https://docs.nextcloud.com/server/11/admin_manual/configuration_server/occ_command.html?highlight=occ%20commands#dav-label', - 'developerDocs' => 'https://github.com/nextcloud/contacts#building-the-app', - 'issueTracker' => 'https://github.com/nextcloud/contacts/issues', - 'website' => 'https://github.com/nextcloud/contacts#readme', - 'created' => '2016-10-30T14:00:58.922766Z', - 'lastModified' => '2016-11-22T22:08:01.904319Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '1.5.0', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/nextcloud/contacts/releases/download/v1.5.0/contacts.tar.gz', - 'created' => '2016-11-22T22:08:01.861942Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-22T22:08:02.306939Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'ZqqhqtbHcNB+rzGCQ7FDIjjvHjit+dhAE1UhFgiXApkx3tmPP4nJOBAGNjHe+2Ao + ], + 3 => + [ + 'id' => 'contacts', + 'categories' => + [ + 0 => 'office', + 1 => 'organization', + 2 => 'social', + ], + 'userDocs' => 'https://docs.nextcloud.com/server/11/user_manual/pim/contacts.html', + 'adminDocs' => 'https://docs.nextcloud.com/server/11/admin_manual/configuration_server/occ_command.html?highlight=occ%20commands#dav-label', + 'developerDocs' => 'https://github.com/nextcloud/contacts#building-the-app', + 'issueTracker' => 'https://github.com/nextcloud/contacts/issues', + 'website' => 'https://github.com/nextcloud/contacts#readme', + 'created' => '2016-10-30T14:00:58.922766Z', + 'lastModified' => '2016-11-22T22:08:01.904319Z', + 'releases' => + [ + 0 => + [ + 'version' => '1.5.0', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/nextcloud/contacts/releases/download/v1.5.0/contacts.tar.gz', + 'created' => '2016-11-22T22:08:01.861942Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-22T22:08:02.306939Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'ZqqhqtbHcNB+rzGCQ7FDIjjvHjit+dhAE1UhFgiXApkx3tmPP4nJOBAGNjHe+2Ao VcTIX2SrWEfieRrA4Gp+0k7pUPWag1Z0T1OVOwO4cmS1AVFyGIOE1bRvDhMfsWTU 4CI4oXaKBFAY6mtnf7VJ7EeIdNqhImkohyWDQ88NiPRLM1XNkJJk6AvZBcT0fvCv o145X4dLpbixSXsN99QFNJ/oXvK+9tBGwTd5i/WnNFY90vcNRLia8aRo7SA0YJRx @@ -455,54 +455,54 @@ Me1EZcde8SLEpTbCWYIfIw/O9Fkp5cWD/dAqoiO6g+gNxSZ/gGp57qoGfFxn7d/x H3aH8GljatAFjrwItw1JzR0THt0ukkOK+bw/pfCslk10sjHMitmz/GXa4qMS91DZ BKLUd0dSfQUQzkfwcojImbzJRvca4/DYe3mfG7+RCH0tDL6t72dKL9joB++u5R1u VZPgkToexlXcKWpiDB8H2/SEShKr4udAOjR5de9CYWM=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://raw.githubusercontent.com/nextcloud/screenshots/master/apps/Contacts/contacts.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Contacts', - 'summary' => 'The new and improved app for your Contacts.', - 'description' => 'The new and improved app for your Contacts.', - ), - ), - 'isFeatured' => true, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Alexander Weidinger', - 'mail' => '', - 'homepage' => '', - ), - 1 => - array ( - 'name' => 'Jan-Christoph Borchardt', - 'mail' => '', - 'homepage' => '', - ), - 2 => - array ( - 'name' => 'Hendrik Leppelsack', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://raw.githubusercontent.com/nextcloud/screenshots/master/apps/Contacts/contacts.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Contacts', + 'summary' => 'The new and improved app for your Contacts.', + 'description' => 'The new and improved app for your Contacts.', + ], + ], + 'isFeatured' => true, + 'authors' => + [ + 0 => + [ + 'name' => 'Alexander Weidinger', + 'mail' => '', + 'homepage' => '', + ], + 1 => + [ + 'name' => 'Jan-Christoph Borchardt', + 'mail' => '', + 'homepage' => '', + ], + 2 => + [ + 'name' => 'Hendrik Leppelsack', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEAzCCAusCAhATMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -526,49 +526,49 @@ iuPit2pjkw3nWz0JRHneRXz/BNoAWBnJiV7JMF2xwBAHN4ghTM8NSJzrGTurmpMI Gld7yCP47xNPaAZEC66odcClvNtJ2Clgp8739jD6uJJCqcKDejeef0VU1PG7AXId 52bVrGMxJwOuL1393vKxGH0PHDzcB1M= -----END CERTIFICATE-----', - ), - 4 => - array ( - 'id' => 'mail', - 'categories' => - array ( - 0 => 'tools', - ), - 'userDocs' => '', - 'adminDocs' => 'https://github.com/nextcloud/mail#readme', - 'developerDocs' => '', - 'issueTracker' => '', - 'website' => '', - 'created' => '2016-10-19T19:41:41.710285Z', - 'lastModified' => '2016-10-19T19:57:33.689238Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '0.6.0', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '>=5.4.0 <7.1.0', - 'platformVersionSpec' => '>=10.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/nextcloud/mail/releases/download/v0.6.0/mail.tar.gz', - 'created' => '2016-10-19T19:57:33.676730Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-10-19T19:57:33.834580Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '>=5.4 <=7.0', - 'rawPlatformVersionSpec' => '>=10 <=11', - 'signature' => 'VbMsvDpt+gSPeFM8LrZXEK10rk8kkLlgCcblgqNdCSeGZeVpwDAYv3CccVSLa0+l + ], + 4 => + [ + 'id' => 'mail', + 'categories' => + [ + 0 => 'tools', + ], + 'userDocs' => '', + 'adminDocs' => 'https://github.com/nextcloud/mail#readme', + 'developerDocs' => '', + 'issueTracker' => '', + 'website' => '', + 'created' => '2016-10-19T19:41:41.710285Z', + 'lastModified' => '2016-10-19T19:57:33.689238Z', + 'releases' => + [ + 0 => + [ + 'version' => '0.6.0', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '>=5.4.0 <7.1.0', + 'platformVersionSpec' => '>=10.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/nextcloud/mail/releases/download/v0.6.0/mail.tar.gz', + 'created' => '2016-10-19T19:57:33.676730Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-10-19T19:57:33.834580Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '>=5.4 <=7.0', + 'rawPlatformVersionSpec' => '>=10 <=11', + 'signature' => 'VbMsvDpt+gSPeFM8LrZXEK10rk8kkLlgCcblgqNdCSeGZeVpwDAYv3CccVSLa0+l lTSqQ0VIoH+OIU6vIQNBKHmSCzTplk7OrY0+L5FajXx8LnBaOh892GfGSlEt1neN KyM0i0uOjO/xpCP/NoUlgkz6hnmYY5XEdN6DTsJtJ/XZhDQ45IYuIkMkHE/eFehS 0JnOagIz+PSipeBY2Ry+tV8YbRa7bC1JAvZzlod0dyI015AHZESeitRUY+MwMWkt @@ -579,11 +579,11 @@ sP8OrkQFooL4E7S4BWfdSiN/a8jUITJQkuXp/OVrVGeCupLWJh7qegUw6DvoqyGy D4c6b+qYn68kx3CLaPPiz+tFAZQZQdj7+Kx/lohso8yTnVSiGYrMj4IvvCbpsQjg WF3WSqF/K/tTnPYTWb9NUPSihTbVNv6AXOfTsPEp/ba2YSS5DjvjVjkr5vhR9eg1 ikQ3Cw6lW3vaA4LVCC+hFkMRnI4N0bo5qQavP3PnZPc=', - 'translations' => - array ( - 'en' => - array ( - 'changelog' => '### Added + 'translations' => + [ + 'en' => + [ + 'changelog' => '### Added - Alias support [#1523](https://github.com/owncloud/mail/pull/1523) @tahaalibra - New incoming messages are prefetched @@ -616,37 +616,37 @@ ikQ3Cw6lW3vaA4LVCC+hFkMRnI4N0bo5qQavP3PnZPc=', [#1603](https://github.com/owncloud/mail/pull/1603) @ChristophWurst - Update folder counters when reading/deleting messages [#1585](https://github.com/owncloud/mail/pull/1585)', - ), - ), - ), - ), - 'screenshots' => - array ( - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Mail', - 'summary' => 'Easy to use email client which connects to your mail server via IMAP and SMTP.', - 'description' => 'Easy to use email client which connects to your mail server via IMAP and SMTP.', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Christoph Wurst, Thomas Müller, Jan-Christoph Borchardt, Steffen Lindner & many more …', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + ], + ], + ], + ], + 'screenshots' => + [ + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Mail', + 'summary' => 'Easy to use email client which connects to your mail server via IMAP and SMTP.', + 'description' => 'Easy to use email client which connects to your mail server via IMAP and SMTP.', + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Christoph Wurst, Thomas Müller, Jan-Christoph Borchardt, Steffen Lindner & many more …', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIID/zCCAucCAhAVMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -670,99 +670,99 @@ ZETmzhx0BXDt5enJYs8R2KMYJNIme1easQRYmWKliXogNY09W7ifT9FHtVW1HX+K xRS4JXbapjolkxyGSpP+iYSgItVnYzl6o9KZResR4yDsBv7G/8fpV4GQU9IS3zLD PiZOosVHWJdpUKCw9V4P1prGTQ== -----END CERTIFICATE-----', - ), - 5 => - array ( - 'id' => 'audioplayer', - 'categories' => - array ( - 0 => 'multimedia', - ), - 'userDocs' => 'https://github.com/rello/audioplayer/wiki#user-documentation', - 'adminDocs' => 'https://github.com/rello/audioplayer/wiki#admin-documentation', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/rello/audioplayer/issues', - 'website' => 'https://github.com/rello/audioplayer', - 'created' => '2016-09-16T05:44:24.857567Z', - 'lastModified' => '2016-11-17T22:34:34.637028Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '1.3.1', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '>=5.4.0', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/Rello/audioplayer/releases/download/1.3.1/audioplayer-1.3.1.tar.gz', - 'created' => '2016-11-17T22:34:34.215350Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-17T22:34:34.867778Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '>=5.4', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'p6Zz0IEFrxvw6y/3jHgGWWCxR6qpMzvU2HKfxcIVsK6sJnoRUhWLeAXwZ432fH2a S2llj+IGS9OvW+5VQElrXgPtEjDK1BT00DRJnp5RFCRlUv0LNoedJMzx6B6AHqPP JBufk3cG1O/CO0M0L1ITGSmSOzfKvWTRo3lxVGF792NyBaP/SyZCkH1N1TzBQzUi Ywl3+HiglPcXbHjtJm/arnKorbJWVKoaN93xFuaBapd2ozQSpi0fE0uGRsici+U7 HNa1M5WFE1rzUJoufE0E9246At07rFY1e+TdNEq8IlLgCXg5vGCKkEyuWpWno6aX LfRaIiT9x39UTAwNvuDKS0c+n4uWDYPsGfKhDx9N7CXpUrthfXVEWRzZEXG7as10 6ANvrRPJemSZH8FUSrdJhD7k12qa9R825y7mIG68Li8P71V92EOxFfo9tNXqXwBt VuDGxBqByFVPqSCj5I8hrzJzQl2Xt40g8+8ZcSF96RMg/pM+bwRMTv+mz0V+vQQ4 DWjqnWVPalaJ1PPD5/QFFErtXuNRbyxKZ6BMWxfJlLM9Kz66P75K+8fYaSwz+2KG NxY7I3svzS2K9LGH3fBLUy1t3Hl+c3zGFq/ll1MJrf9NswV4yxt2WmISfM/KDww8 yELkGs2cRzbw2tCvnmYlJJhIqRLkyFAbDzWRH/XdVx4=', - 'translations' => - array ( - 'en' => - array ( - 'changelog' => '2016-11-17 + ], + 5 => + [ + 'id' => 'audioplayer', + 'categories' => + [ + 0 => 'multimedia', + ], + 'userDocs' => 'https://github.com/rello/audioplayer/wiki#user-documentation', + 'adminDocs' => 'https://github.com/rello/audioplayer/wiki#admin-documentation', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/rello/audioplayer/issues', + 'website' => 'https://github.com/rello/audioplayer', + 'created' => '2016-09-16T05:44:24.857567Z', + 'lastModified' => '2016-11-17T22:34:34.637028Z', + 'releases' => + [ + 0 => + [ + 'version' => '1.3.1', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '>=5.4.0', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/Rello/audioplayer/releases/download/1.3.1/audioplayer-1.3.1.tar.gz', + 'created' => '2016-11-17T22:34:34.215350Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-17T22:34:34.867778Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '>=5.4', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'p6Zz0IEFrxvw6y/3jHgGWWCxR6qpMzvU2HKfxcIVsK6sJnoRUhWLeAXwZ432fH2a S2llj+IGS9OvW+5VQElrXgPtEjDK1BT00DRJnp5RFCRlUv0LNoedJMzx6B6AHqPP JBufk3cG1O/CO0M0L1ITGSmSOzfKvWTRo3lxVGF792NyBaP/SyZCkH1N1TzBQzUi Ywl3+HiglPcXbHjtJm/arnKorbJWVKoaN93xFuaBapd2ozQSpi0fE0uGRsici+U7 HNa1M5WFE1rzUJoufE0E9246At07rFY1e+TdNEq8IlLgCXg5vGCKkEyuWpWno6aX LfRaIiT9x39UTAwNvuDKS0c+n4uWDYPsGfKhDx9N7CXpUrthfXVEWRzZEXG7as10 6ANvrRPJemSZH8FUSrdJhD7k12qa9R825y7mIG68Li8P71V92EOxFfo9tNXqXwBt VuDGxBqByFVPqSCj5I8hrzJzQl2Xt40g8+8ZcSF96RMg/pM+bwRMTv+mz0V+vQQ4 DWjqnWVPalaJ1PPD5/QFFErtXuNRbyxKZ6BMWxfJlLM9Kz66P75K+8fYaSwz+2KG NxY7I3svzS2K9LGH3fBLUy1t3Hl+c3zGFq/ll1MJrf9NswV4yxt2WmISfM/KDww8 yELkGs2cRzbw2tCvnmYlJJhIqRLkyFAbDzWRH/XdVx4=', + 'translations' => + [ + 'en' => + [ + 'changelog' => '2016-11-17 - fix: one-click-play for wav not working - fix: wrong sql statement for PostgreSQL [#90](https://github.com/rello/audioplayer/issues/90)', - ), - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://github.com/rello/screenshots/raw/master/audioplayer_main.png', - ), - 1 => - array ( - 'url' => 'https://github.com/rello/screenshots/raw/master/audioplayer_lists.png', - ), - 2 => - array ( - 'url' => 'https://github.com/rello/screenshots/raw/master/audioplayer_share.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Audio Player', - 'summary' => 'Audio Player for ownCloud and Nextcloud', - 'description' => 'Audio Player for MP3, MP4, Ogg, and Wave with a lot of flexibility for all your needs.', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Marcel Scherello', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + ], + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://github.com/rello/screenshots/raw/master/audioplayer_main.png', + ], + 1 => + [ + 'url' => 'https://github.com/rello/screenshots/raw/master/audioplayer_lists.png', + ], + 2 => + [ + 'url' => 'https://github.com/rello/screenshots/raw/master/audioplayer_share.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Audio Player', + 'summary' => 'Audio Player for ownCloud and Nextcloud', + 'description' => 'Audio Player for MP3, MP4, Ogg, and Wave with a lot of flexibility for all your needs.', + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Marcel Scherello', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEBjCCAu4CAhAIMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -786,49 +786,49 @@ zi7mQDFxmAE6FWSMBgKKUb4tqLc5oBap8e12tPEZl/UR6d9iUB2ltvrm3T3vrjjl FNvGFVBn4r5qCiChEoq+rCXHRjPi/eCfbW21XeLFDiLxapcZyc85JIcA7znUYoFe P7Y/ekMscwWhLbF91OaQlcWpRtEMyde/DaI= -----END CERTIFICATE-----', - ), - 6 => - array ( - 'id' => 'calendar', - 'categories' => - array ( - 0 => 'organization', - ), - 'userDocs' => 'https://docs.nextcloud.com/server/10/user_manual/pim/calendar.html', - 'adminDocs' => '', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/nextcloud/calendar/issues', - 'website' => 'https://github.com/nextcloud/calendar/', - 'created' => '2016-10-01T12:40:39.060903Z', - 'lastModified' => '2016-11-22T20:31:13.029921Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '1.4.1', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/nextcloud/calendar/releases/download/v1.4.1/calendar.tar.gz', - 'created' => '2016-11-22T20:31:13.020268Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-22T20:31:13.087340Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'nThwe9CJBCan9nuDLdhfBiQyPhmum6Aa0UcYsIDdhGMw+C2acf81KhEmBJuTTWxo + ], + 6 => + [ + 'id' => 'calendar', + 'categories' => + [ + 0 => 'organization', + ], + 'userDocs' => 'https://docs.nextcloud.com/server/10/user_manual/pim/calendar.html', + 'adminDocs' => '', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/nextcloud/calendar/issues', + 'website' => 'https://github.com/nextcloud/calendar/', + 'created' => '2016-10-01T12:40:39.060903Z', + 'lastModified' => '2016-11-22T20:31:13.029921Z', + 'releases' => + [ + 0 => + [ + 'version' => '1.4.1', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/nextcloud/calendar/releases/download/v1.4.1/calendar.tar.gz', + 'created' => '2016-11-22T20:31:13.020268Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-22T20:31:13.087340Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'nThwe9CJBCan9nuDLdhfBiQyPhmum6Aa0UcYsIDdhGMw+C2acf81KhEmBJuTTWxo WGby6WcrcJJmeuCW+ePU91ju7Pd76RirprhVXIEceIDzSCxin+K0oZCZ1IGVIJjP IkVehTsLuCeTBbjvz1b3k5QFyhUhvd32Xt7k5d7VARyI4OqnqYYNBtH9vvgeRrFw AxsQr4o4axof6i3iykLg6WfWarYArY4dIuu5DkPuGPWf2bbgjwWEra4sQejhOs7G @@ -839,68 +839,68 @@ hh1FBfA5pvCJbkJ6nr5bU4bKaffwDX1nr5h77FS5zzn0Pyd7ZIExmVmNtaeJfnfV eFLKrUg3EvnTjvknbBxMB55h9jNJr0SAlkrmyEVm6+CE3BwRWpKB+cJMBuGiwPwv r/ASRiJrkDThbNWAUtX70rUmCqDV6/MujLXViqOc/Q2OHvcXd1oGDccJSQT92/1z 7nonnedyYQIDqUt7u68WL8JRxp7pFsEqKLVuWSgxW3c=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/1.png', - ), - 1 => - array ( - 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/2.png', - ), - 2 => - array ( - 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/3.png', - ), - 3 => - array ( - 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/4.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Calendar', - 'summary' => 'Calendar GUI for Nextcloud\'s CalDAV server', - 'description' => 'The Nextcloud calendar app is a user interface for Nextcloud\'s CalDAV server. + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/1.png', + ], + 1 => + [ + 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/2.png', + ], + 2 => + [ + 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/3.png', + ], + 3 => + [ + 'url' => 'https://raw.githubusercontent.com/nextcloud/calendar/master/screenshots/4.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Calendar', + 'summary' => 'Calendar GUI for Nextcloud\'s CalDAV server', + 'description' => 'The Nextcloud calendar app is a user interface for Nextcloud\'s CalDAV server. It integrates with other apps, allows you to manage calendars and events, display external calendars and invite attendees to your events', - ), - ), - 'isFeatured' => true, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Georg Ehrke', - 'mail' => '', - 'homepage' => 'https://georg.coffee', - ), - 1 => - array ( - 'name' => 'Raghu Nayyar', - 'mail' => '', - 'homepage' => 'http://raghunayyar.com', - ), - 2 => - array ( - 'name' => 'Thomas Citharel', - 'mail' => '', - 'homepage' => 'https://tcit.fr', - ), - ), - 'ratingRecent' => 0.94444444444444398, - 'ratingOverall' => 0.94444444444444398, - 'ratingNumRecent' => 9, - 'ratingNumOverall' => 9, - 'certificate' => '-----BEGIN CERTIFICATE----- + ], + ], + 'isFeatured' => true, + 'authors' => + [ + 0 => + [ + 'name' => 'Georg Ehrke', + 'mail' => '', + 'homepage' => 'https://georg.coffee', + ], + 1 => + [ + 'name' => 'Raghu Nayyar', + 'mail' => '', + 'homepage' => 'http://raghunayyar.com', + ], + 2 => + [ + 'name' => 'Thomas Citharel', + 'mail' => '', + 'homepage' => 'https://tcit.fr', + ], + ], + 'ratingRecent' => 0.94444444444444398, + 'ratingOverall' => 0.94444444444444398, + 'ratingNumRecent' => 9, + 'ratingNumOverall' => 9, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEAzCCAusCAhARMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -924,49 +924,49 @@ D3xxtc17ll3B5IqrMnMHRqmOQ39Sbe56Y7T4agaIz/sUWpseo85D5kt7UAIOR+Mr Q0Bl/QinETk72afGR46Qvc7tC1t9JjQQD3AUbEGuJdGvXjJJ9GREYu01XoODmPdT jXXOI8XIOK6kxXhPHUc3iWu9b4KqGm0= -----END CERTIFICATE-----', - ), - 8 => - array ( - 'id' => 'ownpad', - 'categories' => - array ( - 0 => 'tools', - ), - 'userDocs' => 'https://github.com/otetard/ownpad/blob/master/README.md#mimetype-detection', - 'adminDocs' => '', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/otetard/ownpad/issues', - 'website' => '', - 'created' => '2016-09-29T15:58:52.814912Z', - 'lastModified' => '2016-11-19T17:37:52.278497Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '0.5.6', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/otetard/ownpad/releases/download/v0.5.6/ownpad.tar.gz', - 'created' => '2016-11-19T17:37:52.234684Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-19T17:37:52.423930Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'dh+Txg1iVfqXr8+cxplNQuBZGErSnXUo0ewGwnybNMJqp8/EjEo72+zPpW3dVnhY + ], + 8 => + [ + 'id' => 'ownpad', + 'categories' => + [ + 0 => 'tools', + ], + 'userDocs' => 'https://github.com/otetard/ownpad/blob/master/README.md#mimetype-detection', + 'adminDocs' => '', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/otetard/ownpad/issues', + 'website' => '', + 'created' => '2016-09-29T15:58:52.814912Z', + 'lastModified' => '2016-11-19T17:37:52.278497Z', + 'releases' => + [ + 0 => + [ + 'version' => '0.5.6', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/otetard/ownpad/releases/download/v0.5.6/ownpad.tar.gz', + 'created' => '2016-11-19T17:37:52.234684Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-19T17:37:52.423930Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'dh+Txg1iVfqXr8+cxplNQuBZGErSnXUo0ewGwnybNMJqp8/EjEo72+zPpW3dVnhY 67YCvhrm2bo+VRdFFymEfymzSJu9nWVFkGJhEwvTxPyIdAtuD5YAVrzmnR6L+H7m 7Q1nXE63ICPCAQpHkxIfIXLh25OhWeyofBB8AVsjDUNn58FEYJ8fFkr6dCgPriZS sM2J+xtZMDYufy+xFMsVf/Q3WopjFuBjMC3qOecW76ZTwtREaswOC2RtpzUku2r1 @@ -977,46 +977,46 @@ qEC5WBgJucsFxSvkHh52v43M8jgPYBfHWEL/M/+377z3+mbuIh+BcQ+vcDdiqxTF o3n0+gw3QYIhLEe75sUhxG6ynVUdW25AKKju1kVj3KJnZTBH1R8t8/zy4DnJG8d4 uRGqyU4BXpZjEC3nVlsC7vCncWWhxl0WZQ/MWKqsfjVAU4I88E518D6NioqMnPEJ iCZ2x+69UCDEQyfCSKajgAYT17r3OhZei8F9KSCH8Vw=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Ownpad', - 'summary' => ' + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Ownpad', + 'summary' => ' Create and open Etherpad and Ethercalc documents. ', - 'description' => ' + 'description' => ' Ownpad is an ownCloud application that allows to create and open Etherpad and Ethercalc documents. This application requires to have access to an instance of Etherpad and/or Ethercalc to work properly. ', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Olivier Tétard', - 'mail' => 'olivier.tetard@miskin.fr', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Olivier Tétard', + 'mail' => 'olivier.tetard@miskin.fr', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEATCCAukCAhAPMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -1040,90 +1040,90 @@ ifneTw/Ba1d0AXBOq0c0HFyGxMPIlWe4qn5LtxH5t0wyVGeSj4jyv4nvd3ZGuAgY EUa2uYht/z475k4+vf0YhV98iQH07GnmlfD2TDZgmOCQGKlNfJh1v88OZyLLa3dz gRHzGwKbAiJ8T8bbpZ3e2ozXxADr -----END CERTIFICATE-----', - ), - 9 => - array ( - 'id' => 'announcementcenter', - 'categories' => - array ( - 0 => 'organization', - ), - 'userDocs' => '', - 'adminDocs' => '', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/nextcloud/announcementcenter/issues', - 'website' => 'https://github.com/nextcloud/announcementcenter', - 'created' => '2016-09-14T10:38:53.939634Z', - 'lastModified' => '2016-11-24T11:21:50.324839Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '2.0.0', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=10.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/nextcloud/announcementcenter/releases/download/v2.0.0/announcementcenter-2.0.0.tar.gz', - 'created' => '2016-10-06T12:41:56.195206Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-10-06T12:41:56.263124Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=10 <=11', - 'signature' => 'NVWYz73KtuoZ7ti2sluztJO5aFUc7PzhlDcg0VWyAQd1H7sk5wjw7i0bhrjw8O7M + ], + 9 => + [ + 'id' => 'announcementcenter', + 'categories' => + [ + 0 => 'organization', + ], + 'userDocs' => '', + 'adminDocs' => '', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/nextcloud/announcementcenter/issues', + 'website' => 'https://github.com/nextcloud/announcementcenter', + 'created' => '2016-09-14T10:38:53.939634Z', + 'lastModified' => '2016-11-24T11:21:50.324839Z', + 'releases' => + [ + 0 => + [ + 'version' => '2.0.0', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=10.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/nextcloud/announcementcenter/releases/download/v2.0.0/announcementcenter-2.0.0.tar.gz', + 'created' => '2016-10-06T12:41:56.195206Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-10-06T12:41:56.263124Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=10 <=11', + 'signature' => 'NVWYz73KtuoZ7ti2sluztJO5aFUc7PzhlDcg0VWyAQd1H7sk5wjw7i0bhrjw8O7M Lsrb+PegnsL9eMlYM2WrRom+RF1PDP482xymZf1T8vh8qcTCm3TK89xSuiSm8yoA iWUb/Uv/ODj74wVDWqWxAFKaAG/FestCB3InOOZQqQZLzlAV0U9ziYDGNzBjFqof 9rLNxJ2IOqZOA7hhMIKhSrpA0KkSfNhBsVf8CWClYnVkZQiq0LoYkHkHIlXmXUr3 OfQFKEjtsx+bNLa6CkAaocHGHJXAofX3GQZ9cjBsjZqiTfbXfcVk0kRfz7pwL92L I1McfJYvgMxDQG5bjRpNJw==', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://github.com/nextcloud/announcementcenter/raw/stable10/docs/AnnouncementCenterFrontpage.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Announcement Center', - 'summary' => 'An announcement center for Nextcloud', - 'description' => 'An announcement center for Nextcloud', - ), - ), - 'isFeatured' => true, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Joas Schilling', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.75, - 'ratingOverall' => 0.75, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://github.com/nextcloud/announcementcenter/raw/stable10/docs/AnnouncementCenterFrontpage.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Announcement Center', + 'summary' => 'An announcement center for Nextcloud', + 'description' => 'An announcement center for Nextcloud', + ], + ], + 'isFeatured' => true, + 'authors' => + [ + 0 => + [ + 'name' => 'Joas Schilling', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.75, + 'ratingOverall' => 0.75, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIDDTCCAfUCAhABMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -1142,50 +1142,50 @@ sli/yAYQRTVDsXD8A3ACYT7BG31jGxyXtIHzqCci0MhZFdKKayMYkwfjZchIUtGN JJoU8LQoHwGRtp3wutk0GlFzpEQEvSsn/Lsvvot5IfIe46tnzA6MVj5s64s5G8+Q phhXFlzXqO/VxquPdbfYjvU= -----END CERTIFICATE-----', - ), - 11 => - array ( - 'id' => 'rainloop', - 'categories' => - array ( - 0 => 'social', - 1 => 'tools', - ), - 'userDocs' => '', - 'adminDocs' => '', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/RainLoop/rainloop-webmail/issues', - 'website' => 'http://www.rainloop.net/', - 'created' => '2016-10-20T04:17:37.217555Z', - 'lastModified' => '2016-11-18T11:36:04.309739Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '4.26.0', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '>=5.4.0', - 'platformVersionSpec' => '>=10.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/pierre-alain-b/rainloop-nextcloud/releases/download/v4.26.0/rainloop-4.26.0.tar.gz', - 'created' => '2016-10-20T04:28:21.491747Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-18T11:36:04.619927Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '>=5.4', - 'rawPlatformVersionSpec' => '>=10 <=11', - 'signature' => 'nTYIVSB6mIwKtXIrKoVGsOGFflpLjed8jFem1VLQNtXQj4bztnNrdc4YaPIn0yzM + ], + 11 => + [ + 'id' => 'rainloop', + 'categories' => + [ + 0 => 'social', + 1 => 'tools', + ], + 'userDocs' => '', + 'adminDocs' => '', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/RainLoop/rainloop-webmail/issues', + 'website' => 'http://www.rainloop.net/', + 'created' => '2016-10-20T04:17:37.217555Z', + 'lastModified' => '2016-11-18T11:36:04.309739Z', + 'releases' => + [ + 0 => + [ + 'version' => '4.26.0', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '>=5.4.0', + 'platformVersionSpec' => '>=10.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/pierre-alain-b/rainloop-nextcloud/releases/download/v4.26.0/rainloop-4.26.0.tar.gz', + 'created' => '2016-10-20T04:28:21.491747Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-18T11:36:04.619927Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '>=5.4', + 'rawPlatformVersionSpec' => '>=10 <=11', + 'signature' => 'nTYIVSB6mIwKtXIrKoVGsOGFflpLjed8jFem1VLQNtXQj4bztnNrdc4YaPIn0yzM yLpMSqRDNzdYNFuOeDiyKLPJPTA++MotLCNjEe7kxUekek+m+qzgnGBdcT7RQT6R p9xWGecnVx94d6aA55uiRhgQRyHpdDMMLCOz1be+HvpwHy69DRFZ1+SPmGUt6eW0 u5yS0vHCu1K22cbrVNXFKjxAOlGcIDm61oQuz7ycl3uAujZO4rZbWt55jilgKGak @@ -1196,42 +1196,42 @@ hgFhPrg+7rf7g6UmJFOCp0dC9sBdyQ3KtJkv7bGqPr854r2cdA7xW0QHWQ2in9qQ LhIczc32ECi3ZVVgyF8zyT4Y/3MRS05oX3FHvHyt88mjni6bVaO78F7ZRSha8gHh NOAkku7AMXPvUCHaZP2iVCCoAViEso8GeR3O8xh2G42Ai61RLYwx8LB1+23EoJTr mfFuRYNSg+qAKCokXNnh+lDlwu4AkaQo3vtKGPXvU7A=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://raw.githubusercontent.com/pierre-alain-b/rainloop-nextcloud/master/screenshots/2016.10.20-screenshot.jpg', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'RainLoop', - 'summary' => 'RainLoop Webmail', - 'description' => 'Simple, modern and fast web-based email client.', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'RainLoop Team', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://raw.githubusercontent.com/pierre-alain-b/rainloop-nextcloud/master/screenshots/2016.10.20-screenshot.jpg', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'RainLoop', + 'summary' => 'RainLoop Webmail', + 'description' => 'Simple, modern and fast web-based email client.', + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'RainLoop Team', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEAzCCAusCAhAXMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -1255,103 +1255,103 @@ pzAeVGiABI/e5URpxzz2UayRX7EE+vtpe3B84hzkLqsq0N39ZN6KLfaTyEBGLzqE iLYeXQTV0XSRs8xVt+iyGlj7nPkv2DR0oCqRpWUFWeSBI//niDG5WxS3qg8kacSW fDSYhSN+IjrnIkwNtc8V9t7/GeQB5FE= -----END CERTIFICATE-----', - ), - 12 => - array ( - 'id' => 'richdocuments', - 'categories' => - array ( - 0 => 'integration', - 1 => 'office', - ), - 'userDocs' => 'https://nextcloud.com/collaboraonline/', - 'adminDocs' => 'https://nextcloud.com/collaboraonline/', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/owncloud/richdocuments/issues', - 'website' => '', - 'created' => '2016-10-31T08:55:45.631429Z', - 'lastModified' => '2016-11-24T12:13:53.905352Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '1.1.14', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/owncloud/richdocuments/releases/download/1.1.14/richdocuments.tar.gz', - 'created' => '2016-11-24T12:10:13.337165Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-24T12:13:53.963638Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'prDGlfRPxqT6LP0BsAFPwGww7P4Bngha2N4u5B6+F02N+RVOjGtTcXKqvM1KjZb1 + ], + 12 => + [ + 'id' => 'richdocuments', + 'categories' => + [ + 0 => 'integration', + 1 => 'office', + ], + 'userDocs' => 'https://nextcloud.com/collaboraonline/', + 'adminDocs' => 'https://nextcloud.com/collaboraonline/', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/owncloud/richdocuments/issues', + 'website' => '', + 'created' => '2016-10-31T08:55:45.631429Z', + 'lastModified' => '2016-11-24T12:13:53.905352Z', + 'releases' => + [ + 0 => + [ + 'version' => '1.1.14', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/owncloud/richdocuments/releases/download/1.1.14/richdocuments.tar.gz', + 'created' => '2016-11-24T12:10:13.337165Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-24T12:13:53.963638Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'prDGlfRPxqT6LP0BsAFPwGww7P4Bngha2N4u5B6+F02N+RVOjGtTcXKqvM1KjZb1 Co7qJvgJmjpvIvDmB+rup02i8ObfwP2ct6UdsD7ouzOWJG2sJANXK31bHyvOmQ2h vKu5eNcOkf+WFyFKYi51TbsfWn2+1Wge3WWujKAVcEvqtcOOz+uMWNtqzBptEupk E1aaRnQfTx488YB8Ubul06LIY0PNCHgGCWPgy817tOVT7JA+V0P0FFonl/PXE0dr WgtxRJmvGaNiFzYq+kQmdKMfayZTm3kdVgP0W52t5wp878K0i4s2KPg5lANvjTz7 DCT+VV2IGIE52o4RpMUGyQ==', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-document.png', - ), - 1 => - array ( - 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-app.png', - ), - 2 => - array ( - 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-presentation.png', - ), - 3 => - array ( - 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-spreadsheet.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Collabora Online', - 'summary' => 'Edit office documents directly in your browser.', - 'description' => 'Collabora Online allows you to to work with all kinds of office documents directly in your browser. This application requires Collabora Cloudsuite to be installed on one of your servers, please read the documentation to learn more about that.', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-document.png', + ], + 1 => + [ + 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-app.png', + ], + 2 => + [ + 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-presentation.png', + ], + 3 => + [ + 'url' => 'https://nextcloud.com/wp-content/themes/next/assets/img/features/collabora-spreadsheet.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Collabora Online', + 'summary' => 'Edit office documents directly in your browser.', + 'description' => 'Collabora Online allows you to to work with all kinds of office documents directly in your browser. This application requires Collabora Cloudsuite to be installed on one of your servers, please read the documentation to learn more about that.', + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Collabora Productivity based on work of Frank Karlitschek, Victor Dubiniuk', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIDCDCCAfACAhAZMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -1370,70 +1370,70 @@ Ru1DXn+LW7TJ4NZ8VtLWvmW/6Kfmi7dQ1V++Kmn0lO5ntRt5altePbStCHC8bhGp myBOrjhrJgLIwvgH26MYZhdiSkFzoE38nMPZdrUmUDxcPCwucWJqgzDPudguFthj WCVZ3TTG/2z3+tWM -----END CERTIFICATE-----', - ), - 13 => - array ( - 'id' => 'ocr', - 'categories' => - array ( - 0 => 'files', - 1 => 'tools', - ), - 'userDocs' => 'https://janis91.github.io/ocr/', - 'adminDocs' => 'https://github.com/janis91/ocr/wiki', - 'developerDocs' => 'https://github.com/janis91/ocr/wiki', - 'issueTracker' => 'https://github.com/janis91/ocr/issues', - 'website' => 'https://janis91.github.io/ocr/', - 'created' => '2016-09-19T12:07:49.220376Z', - 'lastModified' => '2016-11-21T11:22:21.024501Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '1.0.0', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - 0 => - array ( - 'id' => 'pgsql', - 'versionSpec' => '*', - 'rawVersionSpec' => '*', - ), - 1 => - array ( - 'id' => 'mysql', - 'versionSpec' => '*', - 'rawVersionSpec' => '*', - ), - 2 => - array ( - 'id' => 'sqlite', - 'versionSpec' => '*', - 'rawVersionSpec' => '*', - ), - ), - 'shellCommands' => - array ( - 0 => 'ocrmypdf', - 1 => 'tesseract', - ), - 'phpVersionSpec' => '>=5.6.0 <8.0.0', - 'platformVersionSpec' => '>=10.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/janis91/ocr/releases/download/v1.0.0/ocr.tar.gz', - 'created' => '2016-10-24T06:50:43.283900Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-21T11:22:21.269108Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '>=5.6 <=7', - 'rawPlatformVersionSpec' => '>=10 <=11', - 'signature' => 'CBJkCIiUKyf2NuWfz2zJ3grhf8p7wJes7DPV/OxUzhlxIH0Fh7K54+U5A9JOOi6f + ], + 13 => + [ + 'id' => 'ocr', + 'categories' => + [ + 0 => 'files', + 1 => 'tools', + ], + 'userDocs' => 'https://janis91.github.io/ocr/', + 'adminDocs' => 'https://github.com/janis91/ocr/wiki', + 'developerDocs' => 'https://github.com/janis91/ocr/wiki', + 'issueTracker' => 'https://github.com/janis91/ocr/issues', + 'website' => 'https://janis91.github.io/ocr/', + 'created' => '2016-09-19T12:07:49.220376Z', + 'lastModified' => '2016-11-21T11:22:21.024501Z', + 'releases' => + [ + 0 => + [ + 'version' => '1.0.0', + 'phpExtensions' => + [ + ], + 'databases' => + [ + 0 => + [ + 'id' => 'pgsql', + 'versionSpec' => '*', + 'rawVersionSpec' => '*', + ], + 1 => + [ + 'id' => 'mysql', + 'versionSpec' => '*', + 'rawVersionSpec' => '*', + ], + 2 => + [ + 'id' => 'sqlite', + 'versionSpec' => '*', + 'rawVersionSpec' => '*', + ], + ], + 'shellCommands' => + [ + 0 => 'ocrmypdf', + 1 => 'tesseract', + ], + 'phpVersionSpec' => '>=5.6.0 <8.0.0', + 'platformVersionSpec' => '>=10.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/janis91/ocr/releases/download/v1.0.0/ocr.tar.gz', + 'created' => '2016-10-24T06:50:43.283900Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-21T11:22:21.269108Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '>=5.6 <=7', + 'rawPlatformVersionSpec' => '>=10 <=11', + 'signature' => 'CBJkCIiUKyf2NuWfz2zJ3grhf8p7wJes7DPV/OxUzhlxIH0Fh7K54+U5A9JOOi6f WPhjXG1ylkyIVY1glr/B8svWNsD4jAclpnUi1/9ZW5UPT8LnRBfTbtF9Uoj0OgNs tsGQYbpuREoHnjbJWTRe0kq1OsOfX44xuf8PuX43B+lpQPW4iRSSz3ZIhdPcDGq1 7pyqQM7gdKhBQ6/tOiwd7Enyt5Hi4V6jhwhUOCYeTNiLD2V3yKL+qA9DzpXUfNNw @@ -1444,33 +1444,33 @@ GsrecNftUEhP/ngxA6lMBVkLmmdpiexVisvsavPi64i34OUA6qOuxjgNVBDwg56i D3tJOF7spnK6I3BhVLviou/zs30AIRVBDTU0Orzx78cbInwy6/vyJib2a1olAaHz v05SzlQRnBWM4jYBe0mA/2ds9AO6VrXGrT/iLlHemj6JYoGBM185TGewA7OJyX3a HSlSDqaremmi+aS3onx3AKhXykDxTRkMVarePwTzzFs=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc1.png', - ), - 1 => - array ( - 'url' => 'https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc2.png', - ), - 2 => - array ( - 'url' => 'https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc3.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'OCR', - 'summary' => 'Character recoginition for your images and pdf files.', - 'description' => '# Description + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc1.png', + ], + 1 => + [ + 'url' => 'https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc2.png', + ], + 2 => + [ + 'url' => 'https://raw.githubusercontent.com/janis91/ocr/master/screenshots/sc3.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'OCR', + 'summary' => 'Character recoginition for your images and pdf files.', + 'description' => '# Description Nextcloud OCR (optical character recoginition) processing for images and PDF with tesseract-ocr and OCRmyPDF brings OCR capability to your Nextcloud 10. The app uses tesseract-ocr, OCRmyPDF and a php internal message queueing service in order to process images (png, jpeg, tiff) and PDF (currently not all PDF-types are supported, for more information see [here](https://github.com/jbarlow83/OCRmyPDF)) asynchronously and save the output file to the same folder in nextcloud, so you are able to search in it. @@ -1488,12 +1488,12 @@ The OCR app has some prerequisites: - **[tesseract-ocr](https://github.com/tesseract-ocr/tesseract)** >v3.02.02 with corresponding language files (e.g. tesseract-ocr-eng) For further information see the homepage or the appropriate documentation.', - ), - 'de' => - array ( - 'name' => 'OCR', - 'summary' => 'Schrifterkennung für Bilder (mit Text) und PDF Dateien.', - 'description' => '# Beschreibung + ], + 'de' => + [ + 'name' => 'OCR', + 'summary' => 'Schrifterkennung für Bilder (mit Text) und PDF Dateien.', + 'description' => '# Beschreibung OCR (Automatische Texterkennung) für Bilder (mit Text) und PDF Dateien mithilfe von tesseract-ocr und OCRmyPDF ermöglicht Ihnen automatische Schrifterkennung direkt in Ihrer Nextcloud 10. Die App nutzt Tesseract-ocr, OCRmyPDF und den internen Message Queueing Service von PHP, um so asynchron (im Hintegrund) Bilder (PNG, JPEG, TIFF) und PDFs (aktuell werden nicht alle Typen unterstützt, näheres [hier](https://github.com/jbarlow83/OCRmyPDF)) zu verarbeiten. Das Ergebnis, welches jetzt durchsuchbar, kopierbar und ähnliches ist, wird anschließend im selben Ordner gespeichert, wie die Ursprungsdatei. @@ -1511,23 +1511,23 @@ Für die OCR App müssen folgende Anforderungen erfüllt sein: - **[tesseract-ocr](https://github.com/tesseract-ocr/tesseract)** >v3.02.02 mit den dazugehörigen Übersetzungs- und Sprachdateien (z. B. tesseract-ocr-deu) Für weiter Informationen besuchen Sie die Homepage oder lesen Sie die zutreffende Dokumentation.', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Janis Koehr', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Janis Koehr', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIID/jCCAuYCAhAKMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -1551,49 +1551,49 @@ HR7qPCNz4uG2Va7mlUHE3UYUYnlv8JFOV3YdbVL0nxhWwIdzSri5sxFIhdlabpzY yA1z/MCBEyTRo80jxFmL+MpwbsdbUJi7Qxlnd56zb6HHDGrLHXZTh9LXgyVbnhWL kxomWjIXQh4aMHQL4QF7U4EK -----END CERTIFICATE-----', - ), - 14 => - array ( - 'id' => 'spreedme', - 'categories' => - array ( - 0 => 'tools', - ), - 'userDocs' => 'https://github.com/strukturag/nextcloud-spreedme/blob/master/README.md', - 'adminDocs' => 'https://github.com/strukturag/nextcloud-spreedme/blob/master/README.md', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/strukturag/nextcloud-spreedme/issues', - 'website' => '', - 'created' => '2016-09-27T08:43:07.835196Z', - 'lastModified' => '2016-11-21T16:51:23.703819Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '0.3.4', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://apps.owncloud.com/CONTENT/content-files/174436-spreedme.tar.gz', - 'created' => '2016-11-21T16:51:23.689599Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-21T16:51:23.826509Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'Mhy3hXeGWlIujx1Op39MMRdqHYOo360BCwr4FPWoTNNggH3aS0gWlh48DAfGYK9W + ], + 14 => + [ + 'id' => 'spreedme', + 'categories' => + [ + 0 => 'tools', + ], + 'userDocs' => 'https://github.com/strukturag/nextcloud-spreedme/blob/master/README.md', + 'adminDocs' => 'https://github.com/strukturag/nextcloud-spreedme/blob/master/README.md', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/strukturag/nextcloud-spreedme/issues', + 'website' => '', + 'created' => '2016-09-27T08:43:07.835196Z', + 'lastModified' => '2016-11-21T16:51:23.703819Z', + 'releases' => + [ + 0 => + [ + 'version' => '0.3.4', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://apps.owncloud.com/CONTENT/content-files/174436-spreedme.tar.gz', + 'created' => '2016-11-21T16:51:23.689599Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-21T16:51:23.826509Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'Mhy3hXeGWlIujx1Op39MMRdqHYOo360BCwr4FPWoTNNggH3aS0gWlh48DAfGYK9W etNiOqIuRyA0NrVlsqR2vDILgFtODJSbKPyHd3PQn3hcGsjogjQ+dkKciLNLinw7 Ohbv6aDdRFLBeRHpX/7wOnWL5W3ko/gyn0Awvi88M9+nC5aARtqncQqPy2SxDGzH KlOZHSNDnEQCGMhA8hNWWKdVwNUJHod/wmBWpW5QVNSJq5DqrKZcNwpGM2UUJoql @@ -1604,54 +1604,54 @@ bOks45K5gE1da4QpkYOUQa3GVMNPqPiT3CqjmJ8tjxq7bGpb6v+YoCLACjjPpPZL 2Y28qLxwHVaINDFUUxD75WWdrlulRbqHwiSw8jolP9qrpXhDuLAqYam9tRwV5K5R 8uNawnFwWkicBEYkN/WtBTouWzehOPn38tHXov6SyEyD6lkuxUBZrsGQ2ru+t33U k0kKCbV0GFw43I+3Ji5DiB4TUVNZYVoPG1B7Qve+UfA=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/conference.gif', - ), - 1 => - array ( - 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/presentation.png', - ), - 2 => - array ( - 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/import.png', - ), - 3 => - array ( - 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/users.png', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Spreed.ME', - 'summary' => 'Audio-, video- and text chat for your Nextcloud', - 'description' => 'Securely communicate with your friends and family using rich audio-, video- and text chat, and much more right from your Nextcloud – in your browser', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'struktur AG', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/conference.gif', + ], + 1 => + [ + 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/presentation.png', + ], + 2 => + [ + 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/import.png', + ], + 3 => + [ + 'url' => 'https://raw.githubusercontent.com/strukturag/nextcloud-spreedme/master/screenshots/appstore/users.png', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Spreed.ME', + 'summary' => 'Audio-, video- and text chat for your Nextcloud', + 'description' => 'Securely communicate with your friends and family using rich audio-, video- and text chat, and much more right from your Nextcloud – in your browser', + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'struktur AG', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEAzCCAusCAhANMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -1675,50 +1675,50 @@ axCNzc7veb2M98hS73w5ZE6vO+C/wz0GTsxuK0AoLitApT5naQnjvxSvSsjFPEGD sUNUEU2Decyp0jxLVnrrpz6Y5UupfBR0V8yAv1t5Od/mCKLc5DxHsDWiKOpsob9U JN+bdzJil2NNftihD4Dm7Ha7OS3O8W0= -----END CERTIFICATE-----', - ), - 15 => - array ( - 'id' => 'nextant', - 'categories' => - array ( - 0 => 'files', - 1 => 'tools', - ), - 'userDocs' => '', - 'adminDocs' => 'https://github.com/nextcloud/nextant/wiki', - 'developerDocs' => '', - 'issueTracker' => 'https://github.com/nextcloud/nextant/issues', - 'website' => 'https://github.com/nextcloud/nextant/wiki', - 'created' => '2016-09-14T14:34:35.977699Z', - 'lastModified' => '2016-11-22T16:02:57.758477Z', - 'releases' => - array ( - 0 => - array ( - 'version' => '0.6.6', - 'phpExtensions' => - array ( - ), - 'databases' => - array ( - ), - 'shellCommands' => - array ( - ), - 'phpVersionSpec' => '*', - 'platformVersionSpec' => '>=9.0.0 <12.0.0', - 'minIntSize' => 32, - 'download' => 'https://github.com/nextcloud/nextant/releases/download/v0.6.6/nextant-0.6.6.tar.gz', - 'created' => '2016-11-16T15:11:14.344704Z', - 'licenses' => - array ( - 0 => 'agpl', - ), - 'lastModified' => '2016-11-16T20:39:59.030384Z', - 'isNightly' => false, - 'rawPhpVersionSpec' => '*', - 'rawPlatformVersionSpec' => '>=9 <=11', - 'signature' => 'aOZeEeThyZ0V/vXBcn6c+Z0vyCsZcN6nfSJ8oWEea4zXh4g705Si+MFZESqix3M2 + ], + 15 => + [ + 'id' => 'nextant', + 'categories' => + [ + 0 => 'files', + 1 => 'tools', + ], + 'userDocs' => '', + 'adminDocs' => 'https://github.com/nextcloud/nextant/wiki', + 'developerDocs' => '', + 'issueTracker' => 'https://github.com/nextcloud/nextant/issues', + 'website' => 'https://github.com/nextcloud/nextant/wiki', + 'created' => '2016-09-14T14:34:35.977699Z', + 'lastModified' => '2016-11-22T16:02:57.758477Z', + 'releases' => + [ + 0 => + [ + 'version' => '0.6.6', + 'phpExtensions' => + [ + ], + 'databases' => + [ + ], + 'shellCommands' => + [ + ], + 'phpVersionSpec' => '*', + 'platformVersionSpec' => '>=9.0.0 <12.0.0', + 'minIntSize' => 32, + 'download' => 'https://github.com/nextcloud/nextant/releases/download/v0.6.6/nextant-0.6.6.tar.gz', + 'created' => '2016-11-16T15:11:14.344704Z', + 'licenses' => + [ + 0 => 'agpl', + ], + 'lastModified' => '2016-11-16T20:39:59.030384Z', + 'isNightly' => false, + 'rawPhpVersionSpec' => '*', + 'rawPlatformVersionSpec' => '>=9 <=11', + 'signature' => 'aOZeEeThyZ0V/vXBcn6c+Z0vyCsZcN6nfSJ8oWEea4zXh4g705Si+MFZESqix3M2 OPCnA/U8eASwdRTAEwQJrW5ECmu1THXSIsrzQzc9kFycvyOGzCgAWtuu0ayzZD2/ U5aDWlzpLHC1Czg9QJ5UnfZR0AfChWQ402N1YzGqMShdJv6AHXFrVE+uYnIyxuYI oPJQBUYbQwthVUjpYwFwSxw50YU17gmx5RZ0Y0OPz3i/EiuEUrxopXtfDVYAuCML @@ -1729,29 +1729,29 @@ oAKv2GkvWPQ0aiiBtA1i4oXuzvHW/M2wOrK7v7DCpNfILrD/sjxpljxcX082nRCd 9P3iPd2hQ6yOM9fG21LVN74b6wggI81BzFf/xJPd4ZqYLjfeG/yqd0zaiMOzMm1W se+kc/a4iB3BoCNX3E942pBBzew4ya8LkCXdCHUUsuelDf1va1ikTh/G7D84ll9/ 2avNqQnUh3hgOnxFCLI/5VrbqxfSTVdO6O/LTuAmwgw=', - 'translations' => - array ( - ), - ), - ), - 'screenshots' => - array ( - 0 => - array ( - 'url' => 'https://raw.githubusercontent.com/nextcloud/nextant/master/screenshots/displayResult.jpg', - ), - 1 => - array ( - 'url' => 'https://raw.githubusercontent.com/nextcloud/nextant/master/screenshots/admin.jpg', - ), - ), - 'translations' => - array ( - 'en' => - array ( - 'name' => 'Nextant', - 'summary' => 'Navigate through your cloud using Solr', - 'description' => ' + 'translations' => + [ + ], + ], + ], + 'screenshots' => + [ + 0 => + [ + 'url' => 'https://raw.githubusercontent.com/nextcloud/nextant/master/screenshots/displayResult.jpg', + ], + 1 => + [ + 'url' => 'https://raw.githubusercontent.com/nextcloud/nextant/master/screenshots/admin.jpg', + ], + ], + 'translations' => + [ + 'en' => + [ + 'name' => 'Nextant', + 'summary' => 'Navigate through your cloud using Solr', + 'description' => ' Navigate through your cloud using Solr @@ -1787,23 +1787,23 @@ se+kc/a4iB3BoCNX3E942pBBzew4ya8LkCXdCHUUsuelDf1va1ikTh/G7D84ll9/ ', - ), - ), - 'isFeatured' => false, - 'authors' => - array ( - 0 => - array ( - 'name' => 'Maxence Lange', - 'mail' => '', - 'homepage' => '', - ), - ), - 'ratingRecent' => 0.5, - 'ratingOverall' => 0.5, - 'ratingNumRecent' => 0, - 'ratingNumOverall' => 0, - 'certificate' => '-----BEGIN CERTIFICATE----- + ], + ], + 'isFeatured' => false, + 'authors' => + [ + 0 => + [ + 'name' => 'Maxence Lange', + 'mail' => '', + 'homepage' => '', + ], + ], + 'ratingRecent' => 0.5, + 'ratingOverall' => 0.5, + 'ratingNumRecent' => 0, + 'ratingNumOverall' => 0, + 'certificate' => '-----BEGIN CERTIFICATE----- MIIEAjCCAuoCAhAFMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNVBAYTAkRFMRswGQYD VQQIDBJCYWRlbi1XdWVydHRlbWJlcmcxFzAVBgNVBAoMDk5leHRjbG91ZCBHbWJI MTYwNAYDVQQDDC1OZXh0Y2xvdWQgQ29kZSBTaWduaW5nIEludGVybWVkaWF0ZSBB @@ -1827,12 +1827,12 @@ my7Z1C7jG9/h57vx0+QBMDCYnTmqLsvMKqo27uHskzAiB7VXLEdSZ2FtMGHkLUQO 0bfhnvTZ2VhMmK83t7ovo71An4ycmsolGD/MA0vNI78VrVISrdI8rRh2WntUnCBU EJL3BaQAQaASSsvFrcozYxrQG4VzEg== -----END CERTIFICATE-----', - ), - ), + ], + ], 'timestamp' => 1234, 'ncversion' => '11.0.0.2', 'ETag' => '"myETag"', - ); + ]; protected function setUp(): void { @@ -1863,12 +1863,12 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== public function testGetWithFilter() { $this->config->method('getSystemValue') - ->willReturnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'appstoreenabled') { return true; - } else if ($key === 'version') { + } elseif ($key === 'version') { return '11.0.0.2'; - } else if ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') { + } elseif ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') { return 'https://custom.appsstore.endpoint/api/v1'; } else { return $default; @@ -1918,16 +1918,16 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== $dataToPut['data'] = array_values($dataToPut['data']); $originalArray = json_decode(self::$responseJson, true); $mappedOriginalArray = []; - foreach($originalArray as $key => $value) { - foreach($value as $releaseKey => $releaseValue) { - if($releaseKey === 'id') { + foreach ($originalArray as $key => $value) { + foreach ($value as $releaseKey => $releaseValue) { + if ($releaseKey === 'id') { $mappedOriginalArray[$releaseValue] = $originalArray[$key]; } } } - foreach($dataToPut['data'] as $key => $appValue) { - foreach($appValue as $appKey => $value) { - if($appKey === 'certificate' || $appKey === 'description') { + foreach ($dataToPut['data'] as $key => $appValue) { + foreach ($appValue as $appKey => $value) { + if ($appKey === 'certificate' || $appKey === 'description') { $dataToPut['data'][$key][$appKey] = $mappedOriginalArray[$appValue['id']][$appKey]; } } @@ -1946,14 +1946,14 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== public function testAppstoreDisabled() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($var, $default) { + ->willReturnCallback(function ($var, $default) { if ($var === 'appstoreenabled') { return false; - } else if ($var === 'version') { + } elseif ($var === 'version') { return '11.0.0.2'; } return $default; - })); + }); $this->appData ->expects($this->never()) ->method('getFolder'); @@ -1965,14 +1965,14 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== public function testNoInternet() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($var, $default) { + ->willReturnCallback(function ($var, $default) { if ($var === 'has_internet_connection') { return false; - } else if ($var === 'version') { + } elseif ($var === 'version') { return '11.0.0.2'; } return $default; - })); + }); $this->appData ->expects($this->never()) ->method('getFolder'); @@ -1982,12 +1982,12 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== public function testSetVersion() { $this->config->method('getSystemValue') - ->willReturnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'appstoreenabled') { return true; - } else if ($key === 'version') { + } elseif ($key === 'version') { return '10.0.7.2'; - } else if ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') { + } elseif ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') { return 'https://custom.appsstore.endpoint/api/v1'; } else { return $default; @@ -2037,16 +2037,16 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== $dataToPut['data'] = array_values($dataToPut['data']); $originalArray = json_decode(self::$responseJson, true); $mappedOriginalArray = []; - foreach($originalArray as $key => $value) { - foreach($value as $releaseKey => $releaseValue) { - if($releaseKey === 'id') { + foreach ($originalArray as $key => $value) { + foreach ($value as $releaseKey => $releaseValue) { + if ($releaseKey === 'id') { $mappedOriginalArray[$releaseValue] = $originalArray[$key]; } } } - foreach($dataToPut['data'] as $key => $appValue) { - foreach($appValue as $appKey => $value) { - if($appKey === 'certificate' || $appKey === 'description') { + foreach ($dataToPut['data'] as $key => $appValue) { + foreach ($appValue as $appKey => $value) { + if ($appKey === 'certificate' || $appKey === 'description') { $dataToPut['data'][$key][$appKey] = $mappedOriginalArray[$appValue['id']][$appKey]; } } diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php index 8a82322b61c..47be7adcc7b 100644 --- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php @@ -41,12 +41,12 @@ class CategoryFetcherTest extends FetcherBase { public function testAppstoreDisabled() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($var, $default) { + ->willReturnCallback(function ($var, $default) { if ($var === 'appstoreenabled') { return false; } return $default; - })); + }); $this->appData ->expects($this->never()) ->method('getFolder'); @@ -57,12 +57,12 @@ class CategoryFetcherTest extends FetcherBase { public function testNoInternet() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($var, $default) { + ->willReturnCallback(function ($var, $default) { if ($var === 'has_internet_connection') { return false; } return $default; - })); + }); $this->appData ->expects($this->never()) ->method('getFolder'); diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index 9dac4dd7499..2e04f22760e 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -210,10 +210,10 @@ abstract class FetcherBase extends TestCase { public function testGetWithAlreadyExistingFileAndOutdatedTimestamp() { $this->config->method('getSystemValue') - ->willReturnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'appstoreenabled') { return true; - } else if ($key === 'version') { + } elseif ($key === 'version') { return '11.0.0.2'; } else { return $default; @@ -239,7 +239,7 @@ abstract class FetcherBase extends TestCase { $this->timeFactory ->expects($this->at(0)) ->method('getTime') - ->willReturn(1501); + ->willReturn(4801); $client = $this->createMock(IClient::class); $this->clientService ->expects($this->once()) @@ -463,7 +463,7 @@ abstract class FetcherBase extends TestCase { public function testGetWithExceptionInClient() { $this->config->method('getSystemValue') - ->willReturnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'appstoreenabled') { return true; } else { @@ -503,10 +503,10 @@ abstract class FetcherBase extends TestCase { public function testGetMatchingETag() { $this->config->method('getSystemValue') - ->willReturnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'appstoreenabled') { return true; - } else if ($key === 'version') { + } elseif ($key === 'version') { return '11.0.0.2'; } else { return $default; @@ -533,11 +533,11 @@ abstract class FetcherBase extends TestCase { $this->timeFactory ->expects($this->at(0)) ->method('getTime') - ->willReturn(1501); + ->willReturn(4801); $this->timeFactory ->expects($this->at(1)) ->method('getTime') - ->willReturn(1502); + ->willReturn(4802); $client = $this->createMock(IClient::class); $this->clientService ->expects($this->once()) @@ -559,7 +559,7 @@ abstract class FetcherBase extends TestCase { $response->method('getStatusCode') ->willReturn(304); - $newData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; + $newData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"myETag\""}'; $file ->expects($this->at(1)) ->method('putContent') @@ -584,10 +584,10 @@ abstract class FetcherBase extends TestCase { public function testGetNoMatchingETag() { $this->config->method('getSystemValue') - ->willReturnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'appstoreenabled') { return true; - } else if ($key === 'version') { + } elseif ($key === 'version') { return '11.0.0.2'; } else { return $default; @@ -638,7 +638,7 @@ abstract class FetcherBase extends TestCase { $response->method('getHeader') ->with($this->equalTo('ETag')) ->willReturn('"newETag"'); - $fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":1502,"ncversion":"11.0.0.2","ETag":"\"newETag\""}'; + $fileData = '{"data":[{"id":"MyNewApp","foo":"foo"},{"id":"bar"}],"timestamp":4802,"ncversion":"11.0.0.2","ETag":"\"newETag\""}'; $file ->expects($this->at(1)) ->method('putContent') @@ -650,11 +650,11 @@ abstract class FetcherBase extends TestCase { $this->timeFactory ->expects($this->at(0)) ->method('getTime') - ->willReturn(1501); + ->willReturn(4801); $this->timeFactory ->expects($this->at(1)) ->method('getTime') - ->willReturn(1502); + ->willReturn(4802); $expected = [ [ @@ -671,10 +671,10 @@ abstract class FetcherBase extends TestCase { public function testFetchAfterUpgradeNoETag() { $this->config->method('getSystemValue') - ->willReturnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'appstoreenabled') { return true; - } else if ($key === 'version') { + } elseif ($key === 'version') { return '11.0.0.3'; } else { return $default; diff --git a/tests/lib/App/AppStore/Version/VersionParserTest.php b/tests/lib/App/AppStore/Version/VersionParserTest.php index 327c8cac779..edb48dc4130 100644 --- a/tests/lib/App/AppStore/Version/VersionParserTest.php +++ b/tests/lib/App/AppStore/Version/VersionParserTest.php @@ -25,7 +25,7 @@ use OC\App\AppStore\Version\Version; use OC\App\AppStore\Version\VersionParser; use Test\TestCase; -class VersionParserTest extends TestCase { +class VersionParserTest extends TestCase { /** @var VersionParser */ private $versionParser; diff --git a/tests/lib/App/CodeChecker/InfoCheckerTest.php b/tests/lib/App/CodeChecker/InfoCheckerTest.php index 531066a54c6..3b5060ae694 100644 --- a/tests/lib/App/CodeChecker/InfoCheckerTest.php +++ b/tests/lib/App/CodeChecker/InfoCheckerTest.php @@ -22,7 +22,6 @@ namespace Test\App\CodeChecker; use OC\App\CodeChecker\InfoChecker; -use OC\App\InfoParser; use Test\TestCase; class InfoCheckerTest extends TestCase { diff --git a/tests/lib/App/CodeChecker/NodeVisitorTest.php b/tests/lib/App/CodeChecker/NodeVisitorTest.php index d1b1f643677..cfc6951c614 100644 --- a/tests/lib/App/CodeChecker/NodeVisitorTest.php +++ b/tests/lib/App/CodeChecker/NodeVisitorTest.php @@ -14,7 +14,6 @@ use Test\App\CodeChecker\Mock\TestList; use Test\TestCase; class NodeVisitorTest extends TestCase { - public function providesFilesToCheck() { return [ [[['OCP\AppFramework\IApi', 1006]], 'test-deprecated-use.php'], @@ -45,10 +44,10 @@ class NodeVisitorTest extends TestCase { ], 'test-deprecated-function-sub-alias.php'], // TODO Failing to resolve variables to classes -// [[['OCP\NamespaceName\ClassName::methodName', 1007]], 'test-deprecated-method.php'], -// [[['Alias::methodName', 1002]], 'test-deprecated-method-alias.php'], -// [[['NamespaceName\ClassName::methodName', 1002]], 'test-deprecated-method-sub.php'], -// [[['SubAlias\ClassName::methodName', 1002]], 'test-deprecated-method-sub-alias.php'], + // [[['OCP\NamespaceName\ClassName::methodName', 1007]], 'test-deprecated-method.php'], + // [[['Alias::methodName', 1002]], 'test-deprecated-method-alias.php'], + // [[['NamespaceName\ClassName::methodName', 1002]], 'test-deprecated-method-sub.php'], + // [[['SubAlias\ClassName::methodName', 1002]], 'test-deprecated-method-sub-alias.php'], ]; } diff --git a/tests/lib/App/CompareVersionTest.php b/tests/lib/App/CompareVersionTest.php index af04691f276..6db31d0ee6f 100644 --- a/tests/lib/App/CompareVersionTest.php +++ b/tests/lib/App/CompareVersionTest.php @@ -87,5 +87,4 @@ class CompareVersionTest extends TestCase { $this->compare->isCompatible($actualVersion, '13.0.0.9'); } - } diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php index 943b53eee64..a7d42d28baf 100644 --- a/tests/lib/App/DependencyAnalyzerTest.php +++ b/tests/lib/App/DependencyAnalyzerTest.php @@ -32,41 +32,41 @@ class DependencyAnalyzerTest extends TestCase { ->getMock(); $this->platformMock->expects($this->any()) ->method('getPhpVersion') - ->will( $this->returnValue('5.4.3')); + ->willReturn('5.4.3'); $this->platformMock->expects($this->any()) ->method('getIntSize') - ->will( $this->returnValue('4')); + ->willReturn('4'); $this->platformMock->expects($this->any()) ->method('getDatabase') - ->will( $this->returnValue('mysql')); + ->willReturn('mysql'); $this->platformMock->expects($this->any()) ->method('getOS') - ->will( $this->returnValue('Linux')); + ->willReturn('Linux'); $this->platformMock->expects($this->any()) ->method('isCommandKnown') - ->will( $this->returnCallback(function($command) { + ->willReturnCallback(function ($command) { return ($command === 'grep'); - })); + }); $this->platformMock->expects($this->any()) ->method('getLibraryVersion') - ->will( $this->returnCallback(function($lib) { + ->willReturnCallback(function ($lib) { if ($lib === 'curl') { return "2.3.4"; } return null; - })); + }); $this->platformMock->expects($this->any()) ->method('getOcVersion') - ->will( $this->returnValue('8.0.2')); + ->willReturn('8.0.2'); $this->l10nMock = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); $this->l10nMock->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = array()) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); - })); + }); $this->analyser = new DependencyAnalyzer($this->platformMock, $this->l10nMock); } @@ -80,11 +80,11 @@ class DependencyAnalyzerTest extends TestCase { * @param string $intSize */ public function testPhpVersion($expectedMissing, $minVersion, $maxVersion, $intSize) { - $app = array( - 'dependencies' => array( - 'php' => array() - ) - ); + $app = [ + 'dependencies' => [ + 'php' => [] + ] + ]; if (!is_null($minVersion)) { $app['dependencies']['php']['@attributes']['min-version'] = $minVersion; } @@ -126,10 +126,10 @@ class DependencyAnalyzerTest extends TestCase { * @param string|null $commands */ public function testCommand($expectedMissing, $commands) { - $app = array( - 'dependencies' => array( - ) - ); + $app = [ + 'dependencies' => [ + ] + ]; if (!is_null($commands)) { $app['dependencies']['command'] = $commands; } @@ -144,11 +144,11 @@ class DependencyAnalyzerTest extends TestCase { * @param $expectedMissing * @param $libs */ - function testLibs($expectedMissing, $libs) { - $app = array( - 'dependencies' => array( - ) - ); + public function testLibs($expectedMissing, $libs) { + $app = [ + 'dependencies' => [ + ] + ]; if (!is_null($libs)) { $app['dependencies']['lib'] = $libs; } @@ -164,10 +164,10 @@ class DependencyAnalyzerTest extends TestCase { * @param $expectedMissing * @param $oss */ - function testOS($expectedMissing, $oss) { - $app = array( - 'dependencies' => array() - ); + public function testOS($expectedMissing, $oss) { + $app = [ + 'dependencies' => [] + ]; if (!is_null($oss)) { $app['dependencies']['os'] = $oss; } @@ -183,10 +183,10 @@ class DependencyAnalyzerTest extends TestCase { * @param $expectedMissing * @param $oc */ - function testOC($expectedMissing, $oc) { - $app = array( - 'dependencies' => array() - ); + public function testOC($expectedMissing, $oc) { + $app = [ + 'dependencies' => [] + ]; if (!is_null($oc)) { $app['dependencies'] = $oc; } @@ -200,7 +200,7 @@ class DependencyAnalyzerTest extends TestCase { /** * @return array */ - function providesOC() { + public function providesOC() { return [ // no version -> no missing dependency [ @@ -428,19 +428,19 @@ class DependencyAnalyzerTest extends TestCase { /** * @return array */ - function providesOS() { - return array( - array(array(), null), - array(array(), array()), - array(array('Following platforms are supported: ANDROID'), 'ANDROID'), - array(array('Following platforms are supported: WINNT'), array('WINNT')) - ); + public function providesOS() { + return [ + [[], null], + [[], []], + [['The following platforms are supported: ANDROID'], 'ANDROID'], + [['The following platforms are supported: WINNT'], ['WINNT']] + ]; } /** * @return array */ - function providesLibs() { + public function providesLibs() { return [ // we expect curl to exist [[], 'curl'], @@ -470,7 +470,7 @@ class DependencyAnalyzerTest extends TestCase { /** * @return array */ - function providesCommands() { + public function providesCommands() { return [ [[], null], // grep is known on linux @@ -488,29 +488,29 @@ class DependencyAnalyzerTest extends TestCase { /** * @return array */ - function providesDatabases() { - return array( + public function providesDatabases() { + return [ // non BC - in case on databases are defined -> all are supported - array(array(), null), - array(array(), array()), - array(array('Following databases are supported: mongodb'), 'mongodb'), - array(array('Following databases are supported: sqlite, postgres'), array('sqlite', array('@value' => 'postgres'))), - ); + [[], null], + [[], []], + [['The following databases are supported: mongodb'], 'mongodb'], + [['The following databases are supported: sqlite, postgres'], ['sqlite', ['@value' => 'postgres']]], + ]; } /** * @return array */ - function providesPhpVersion() { - return array( - array(array(), null, null, null), - array(array(), '5.4', null, null), - array(array(), null, '5.5', null), - array(array(), '5.4', '5.5', null), - array(array('PHP 5.4.4 or higher is required.'), '5.4.4', null, null), - array(array('PHP with a version lower than 5.4.2 is required.'), null, '5.4.2', null), - array(array('64bit or higher PHP required.'), null, null, 64), - array(array(), '5.4', '5.4', null), - ); + public function providesPhpVersion() { + return [ + [[], null, null, null], + [[], '5.4', null, null], + [[], null, '5.5', null], + [[], '5.4', '5.5', null], + [['PHP 5.4.4 or higher is required.'], '5.4.4', null, null], + [['PHP with a version lower than 5.4.2 is required.'], null, '5.4.2', null], + [['64bit or higher PHP required.'], null, null, 64], + [[], '5.4', '5.4', null], + ]; } } diff --git a/tests/lib/App/PlatformRepositoryTest.php b/tests/lib/App/PlatformRepositoryTest.php index 783f8f473ff..6bc256c20b0 100644 --- a/tests/lib/App/PlatformRepositoryTest.php +++ b/tests/lib/App/PlatformRepositoryTest.php @@ -25,41 +25,42 @@ class PlatformRepositoryTest extends \Test\TestCase { } public function providesVersions() { - return array( - 'none' => array('1.0.0', '1.0.0.0'), - 'none/2' => array('1.2.3.4', '1.2.3.4'), - 'parses state' => array('1.0.0RC1dev', '1.0.0.0-RC1-dev'), - 'CI parsing' => array('1.0.0-rC15-dev', '1.0.0.0-RC15-dev'), - 'delimiters' => array('1.0.0.RC.15-dev', '1.0.0.0-RC15-dev'), - 'RC uppercase' => array('1.0.0-rc1', '1.0.0.0-RC1'), - 'patch replace' => array('1.0.0.pl3-dev', '1.0.0.0-patch3-dev'), - 'forces w.x.y.z' => array('1.0-dev', '1.0.0.0-dev'), - 'forces w.x.y.z/2' => array('0', '0.0.0.0'), - 'parses long' => array('10.4.13-beta', '10.4.13.0-beta'), - 'parses long/2' => array('10.4.13beta2', '10.4.13.0-beta2'), - 'parses long/semver' => array('10.4.13beta.2', '10.4.13.0-beta2'), - 'expand shorthand' => array('10.4.13-b', '10.4.13.0-beta'), - 'expand shorthand2' => array('10.4.13-b5', '10.4.13.0-beta5'), - 'strips leading v' => array('v1.0.0', '1.0.0.0'), - 'strips v/datetime' => array('v20100102', '20100102'), - 'parses dates y-m' => array('2010.01', '2010-01'), - 'parses dates w/ .' => array('2010.01.02', '2010-01-02'), - 'parses dates w/ -' => array('2010-01-02', '2010-01-02'), - 'parses numbers' => array('2010-01-02.5', '2010-01-02-5'), - 'parses dates y.m.Y' => array('2010.1.555', '2010.1.555.0'), - 'parses datetime' => array('20100102-203040', '20100102-203040'), - 'parses dt+number' => array('20100102203040-10', '20100102203040-10'), - 'parses dt+patch' => array('20100102-203040-p1', '20100102-203040-patch1'), - 'parses master' => array('dev-master', '9999999-dev'), - 'parses trunk' => array('dev-trunk', '9999999-dev'), -// 'parses branches' => array('1.x-dev', '1.9999999.9999999.9999999-dev'), - 'parses arbitrary' => array('dev-feature-foo', 'dev-feature-foo'), - 'parses arbitrary2' => array('DEV-FOOBAR', 'dev-FOOBAR'), - 'parses arbitrary3' => array('dev-feature/foo', 'dev-feature/foo'), - 'ignores aliases' => array('dev-master as 1.0.0', '9999999-dev'), -// 'semver metadata' => array('dev-master+foo.bar', '9999999-dev'), -// 'semver metadata/2' => array('1.0.0-beta.5+foo', '1.0.0.0-beta5'), -// 'semver metadata/3' => array('1.0.0+foo', '1.0.0.0'), -// 'metadata w/ alias' => array('1.0.0+foo as 2.0', '1.0.0.0'), - ); - }} + return [ + 'none' => ['1.0.0', '1.0.0.0'], + 'none/2' => ['1.2.3.4', '1.2.3.4'], + 'parses state' => ['1.0.0RC1dev', '1.0.0.0-RC1-dev'], + 'CI parsing' => ['1.0.0-rC15-dev', '1.0.0.0-RC15-dev'], + 'delimiters' => ['1.0.0.RC.15-dev', '1.0.0.0-RC15-dev'], + 'RC uppercase' => ['1.0.0-rc1', '1.0.0.0-RC1'], + 'patch replace' => ['1.0.0.pl3-dev', '1.0.0.0-patch3-dev'], + 'forces w.x.y.z' => ['1.0-dev', '1.0.0.0-dev'], + 'forces w.x.y.z/2' => ['0', '0.0.0.0'], + 'parses long' => ['10.4.13-beta', '10.4.13.0-beta'], + 'parses long/2' => ['10.4.13beta2', '10.4.13.0-beta2'], + 'parses long/semver' => ['10.4.13beta.2', '10.4.13.0-beta2'], + 'expand shorthand' => ['10.4.13-b', '10.4.13.0-beta'], + 'expand shorthand2' => ['10.4.13-b5', '10.4.13.0-beta5'], + 'strips leading v' => ['v1.0.0', '1.0.0.0'], + 'strips v/datetime' => ['v20100102', '20100102'], + 'parses dates y-m' => ['2010.01', '2010-01'], + 'parses dates w/ .' => ['2010.01.02', '2010-01-02'], + 'parses dates w/ -' => ['2010-01-02', '2010-01-02'], + 'parses numbers' => ['2010-01-02.5', '2010-01-02-5'], + 'parses dates y.m.Y' => ['2010.1.555', '2010.1.555.0'], + 'parses datetime' => ['20100102-203040', '20100102-203040'], + 'parses dt+number' => ['20100102203040-10', '20100102203040-10'], + 'parses dt+patch' => ['20100102-203040-p1', '20100102-203040-patch1'], + 'parses master' => ['dev-master', '9999999-dev'], + 'parses trunk' => ['dev-trunk', '9999999-dev'], + // 'parses branches' => array('1.x-dev', '1.9999999.9999999.9999999-dev'), + 'parses arbitrary' => ['dev-feature-foo', 'dev-feature-foo'], + 'parses arbitrary2' => ['DEV-FOOBAR', 'dev-FOOBAR'], + 'parses arbitrary3' => ['dev-feature/foo', 'dev-feature/foo'], + 'ignores aliases' => ['dev-master as 1.0.0', '9999999-dev'], + // 'semver metadata' => array('dev-master+foo.bar', '9999999-dev'), + // 'semver metadata/2' => array('1.0.0-beta.5+foo', '1.0.0.0-beta5'), + // 'semver metadata/3' => array('1.0.0+foo', '1.0.0.0'), + // 'metadata w/ alias' => array('1.0.0+foo as 2.0', '1.0.0.0'), + ]; + } +} diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php index 14114e8fad7..3a4c16b3396 100644 --- a/tests/lib/AppConfigTest.php +++ b/tests/lib/AppConfigTest.php @@ -8,6 +8,7 @@ */ namespace Test; + use OCP\IConfig; /** diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php index ccc694942a1..595a556a9a8 100644 --- a/tests/lib/AppFramework/AppTest.php +++ b/tests/lib/AppFramework/AppTest.php @@ -30,7 +30,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\Response; function rrmdir($directory) { - $files = array_diff(scandir($directory), array('.','..')); + $files = array_diff(scandir($directory), ['.','..']); foreach ($files as $file) { if (is_dir($directory . '/' . $file)) { rrmdir($directory . '/' . $file); @@ -43,7 +43,6 @@ function rrmdir($directory) { class AppTest extends \Test\TestCase { - private $container; private $io; private $api; @@ -59,12 +58,12 @@ class AppTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->container = new \OC\AppFramework\DependencyInjection\DIContainer('test', array()); + $this->container = new \OC\AppFramework\DependencyInjection\DIContainer('test', []); $this->controller = $this->createMock(Controller::class); $this->dispatcher = $this->createMock(Dispatcher::class); $this->io = $this->createMock(Http\IOutput::class); - $this->headers = array('key' => 'value'); + $this->headers = ['key' => 'value']; $this->output = 'hi'; $this->controllerName = 'Controller'; $this->controllerMethod = 'method'; @@ -72,7 +71,7 @@ class AppTest extends \Test\TestCase { $this->container[$this->controllerName] = $this->controller; $this->container['Dispatcher'] = $this->dispatcher; $this->container['OCP\\AppFramework\\Http\\IOutput'] = $this->io; - $this->container['urlParams'] = array(); + $this->container['urlParams'] = []; $this->appPath = __DIR__ . '/../../../apps/namespacetestapp'; $infoXmlPath = $this->appPath . '/appinfo/info.xml'; @@ -80,20 +79,20 @@ class AppTest extends \Test\TestCase { $xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<info>' . - '<id>namespacetestapp</id>' . + '<id>namespacetestapp</id>' . '<namespace>NameSpaceTestApp</namespace>' . '</info>'; file_put_contents($infoXmlPath, $xml); } - public function testControllerNameAndMethodAreBeingPassed(){ + public function testControllerNameAndMethodAreBeingPassed() { $return = ['HTTP/2.0 200 OK', [], [], null, new Response()]; $this->dispatcher->expects($this->once()) ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) - ->will($this->returnValue($return)); + ->willReturn($return); $this->io->expects($this->never()) ->method('setOutput'); @@ -127,13 +126,13 @@ class AppTest extends \Test\TestCase { } - public function testOutputIsPrinted(){ + public function testOutputIsPrinted() { $return = ['HTTP/2.0 200 OK', [], [], $this->output, new Response()]; $this->dispatcher->expects($this->once()) ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) - ->will($this->returnValue($return)); + ->willReturn($return); $this->io->expects($this->once()) ->method('setOutput') ->with($this->equalTo($this->output)); @@ -156,7 +155,7 @@ class AppTest extends \Test\TestCase { ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) - ->will($this->returnValue($return)); + ->willReturn($return); $this->io->expects($this->once()) ->method('setHeader') ->with($this->equalTo($statusCode)); @@ -166,7 +165,7 @@ class AppTest extends \Test\TestCase { } - public function testCallbackIsCalled(){ + public function testCallbackIsCalled() { $mock = $this->getMockBuilder('OCP\AppFramework\Http\ICallbackResponse') ->getMock(); @@ -175,7 +174,7 @@ class AppTest extends \Test\TestCase { ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) - ->will($this->returnValue($return)); + ->willReturn($return); $mock->expects($this->once()) ->method('callback'); App::main($this->controllerName, $this->controllerMethod, $this->container, []); @@ -190,7 +189,7 @@ class AppTest extends \Test\TestCase { ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) - ->will($this->returnValue($return)); + ->willReturn($return); $this->io->expects($this->never()) ->method('setOutput'); @@ -207,7 +206,7 @@ class AppTest extends \Test\TestCase { ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) - ->will($this->returnValue($return)); + ->willReturn($return); $this->io->expects($this->never()) ->method('setOutput'); @@ -224,12 +223,11 @@ class AppTest extends \Test\TestCase { ->method('dispatch') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) - ->will($this->returnValue($return)); + ->willReturn($return); $this->io->expects($this->never()) ->method('setOutput'); App::main('Foo', $this->controllerMethod, $this->container); } - } diff --git a/tests/lib/AppFramework/Controller/ApiControllerTest.php b/tests/lib/AppFramework/Controller/ApiControllerTest.php index ccc44b97764..71eb97b94da 100644 --- a/tests/lib/AppFramework/Controller/ApiControllerTest.php +++ b/tests/lib/AppFramework/Controller/ApiControllerTest.php @@ -27,7 +27,8 @@ use OC\AppFramework\Http\Request; use OCP\AppFramework\ApiController; use OCP\IConfig; -class ChildApiController extends ApiController {}; +class ChildApiController extends ApiController { +}; class ApiControllerTest extends \Test\TestCase { @@ -57,5 +58,4 @@ class ApiControllerTest extends \Test\TestCase { $this->assertEquals('false', $headers['Access-Control-Allow-Credentials']); $this->assertEquals(100, $headers['Access-Control-Max-Age']); } - } diff --git a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php index 8eb76d3cb27..4c79adcb4a7 100644 --- a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php +++ b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php @@ -23,16 +23,9 @@ namespace Test\AppFramework\Controller; -use OC\AppFramework\Middleware\PublicShare\Exceptions\NeedAuthenticationException; -use OC\AppFramework\Middleware\PublicShare\PublicShareMiddleware; use OCP\AppFramework\AuthPublicShareController; -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; -use OCP\AppFramework\PublicShareController; -use OCP\Files\NotFoundException; -use OCP\IConfig; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; @@ -136,7 +129,7 @@ class AuthPublicShareControllerTest extends \Test\TestCase { $hashSet = false; $this->session ->method('set') - ->will($this->returnCallback(function($key, $value) use (&$tokenSet, &$hashSet) { + ->willReturnCallback(function ($key, $value) use (&$tokenSet, &$hashSet) { if ($key === 'public_link_authenticated_token' && $value === 'token') { $tokenSet = true; return true; @@ -146,7 +139,7 @@ class AuthPublicShareControllerTest extends \Test\TestCase { return true; } return false; - })); + }); $this->urlGenerator->method('linkToRoute') ->willReturn('myLink!'); diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php index b1cb1ceab6f..e07089e0c82 100644 --- a/tests/lib/AppFramework/Controller/ControllerTest.php +++ b/tests/lib/AppFramework/Controller/ControllerTest.php @@ -27,11 +27,9 @@ use OC\AppFramework\Http\Request; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\JSONResponse; -use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; class ChildController extends Controller { - public function __construct($appName, $request) { parent::__construct($appName, $request); $this->registerResponder('tom', function ($respone) { @@ -41,7 +39,7 @@ class ChildController extends Controller { public function custom($in) { $this->registerResponder('json', function ($response) { - return new JSONResponse(array(strlen($response))); + return new JSONResponse([strlen($response)]); }); return $in; @@ -89,7 +87,7 @@ class ControllerTest extends \Test\TestCase { ->getMock(); $this->app->expects($this->any()) ->method('getAppName') - ->will($this->returnValue('apptemplate_advanced')); + ->willReturn('apptemplate_advanced'); $this->controller = new ChildController($this->app, $request); } @@ -103,9 +101,9 @@ class ControllerTest extends \Test\TestCase { public function testFormat() { - $response = $this->controller->buildResponse(array('hi'), 'json'); + $response = $this->controller->buildResponse(['hi'], 'json'); - $this->assertEquals(array('hi'), $response->getData()); + $this->assertEquals(['hi'], $response->getData()); } @@ -118,10 +116,10 @@ class ControllerTest extends \Test\TestCase { 'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'", ]; - $response = $this->controller->customDataResponse(array('hi')); + $response = $this->controller->customDataResponse(['hi']); $response = $this->controller->buildResponse($response, 'json'); - $this->assertEquals(array('hi'), $response->getData()); + $this->assertEquals(['hi'], $response->getData()); $this->assertEquals(300, $response->getStatus()); $this->assertEquals($expectedHeaders, $response->getHeaders()); } @@ -131,7 +129,7 @@ class ControllerTest extends \Test\TestCase { $response = $this->controller->custom('hi'); $response = $this->controller->buildResponse($response, 'json'); - $this->assertEquals(array(2), $response->getData()); + $this->assertEquals([2], $response->getData()); } @@ -158,6 +156,4 @@ class ControllerTest extends \Test\TestCase { $this->assertEquals('tom', $responder); } - - } diff --git a/tests/lib/AppFramework/Controller/OCSControllerTest.php b/tests/lib/AppFramework/Controller/OCSControllerTest.php index f5eb838b584..91a61047871 100644 --- a/tests/lib/AppFramework/Controller/OCSControllerTest.php +++ b/tests/lib/AppFramework/Controller/OCSControllerTest.php @@ -30,7 +30,8 @@ use OCP\AppFramework\OCSController; use OCP\IConfig; use OCP\Security\ISecureRandom; -class ChildOCSController extends OCSController {} +class ChildOCSController extends OCSController { +} class OCSControllerTest extends \Test\TestCase { @@ -108,7 +109,7 @@ class OCSControllerTest extends \Test\TestCase { )); $controller->setOCSVersion(1); $expected = '{"ocs":{"meta":{"status":"ok","statuscode":100,"message":"OK",' . - '"totalitems":"","itemsperpage":""},"data":{"test":"hi"}}}'; + '"totalitems":"","itemsperpage":""},"data":{"test":"hi"}}}'; $params = new DataResponse(['test' => 'hi']); $response = $controller->buildResponse($params, 'json'); diff --git a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php index 318647ca844..521c45e47c6 100644 --- a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php +++ b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php @@ -23,18 +23,9 @@ namespace Test\AppFramework\Controller; -use OC\AppFramework\Middleware\PublicShare\Exceptions\NeedAuthenticationException; -use OC\AppFramework\Middleware\PublicShare\PublicShareMiddleware; -use OCP\AppFramework\AuthPublicShareController; -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\NotFoundResponse; -use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\PublicShareController; -use OCP\Files\NotFoundException; -use OCP\IConfig; use OCP\IRequest; use OCP\ISession; -use OCP\IURLGenerator; class PublicShareControllerTest extends \Test\TestCase { @@ -98,5 +89,4 @@ class PublicShareControllerTest extends \Test\TestCase { $this->assertEquals($expected, $this->controller->isAuthenticated()); } - } diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php index c8ebda55a86..73138749a33 100644 --- a/tests/lib/AppFramework/Db/EntityTest.php +++ b/tests/lib/AppFramework/Db/EntityTest.php @@ -1,29 +1,28 @@ <?php /** -* ownCloud - App Framework -* -* @author Bernhard Posselt -* @copyright 2012 Bernhard Posselt dev@bernhard-posselt.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * ownCloud - App Framework + * + * @author Bernhard Posselt + * @copyright 2012 Bernhard Posselt dev@bernhard-posselt.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ namespace Test\AppFramework\Db; - use OCP\AppFramework\Db\Entity; use PHPUnit\Framework\Constraint\IsType; @@ -63,7 +62,6 @@ class TestEntity extends Entity { class EntityTest extends \Test\TestCase { - private $entity; protected function setUp(): void { @@ -72,20 +70,20 @@ class EntityTest extends \Test\TestCase { } - public function testResetUpdatedFields(){ + public function testResetUpdatedFields() { $entity = new TestEntity(); $entity->setId(3); $entity->resetUpdatedFields(); - $this->assertEquals(array(), $entity->getUpdatedFields()); + $this->assertEquals([], $entity->getUpdatedFields()); } - public function testFromRow(){ - $row = array( + public function testFromRow() { + $row = [ 'pre_name' => 'john', 'email' => 'john@something.com' - ); + ]; $this->entity = TestEntity::fromRow($row); $this->assertEquals($row['pre_name'], $this->entity->getPreName()); @@ -93,7 +91,7 @@ class EntityTest extends \Test\TestCase { } - public function testGetSetId(){ + public function testGetSetId() { $id = 3; $this->entity->setId(3); @@ -101,28 +99,28 @@ class EntityTest extends \Test\TestCase { } - public function testColumnToPropertyNoReplacement(){ + public function testColumnToPropertyNoReplacement() { $column = 'my'; $this->assertEquals('my', $this->entity->columnToProperty($column)); } - public function testColumnToProperty(){ + public function testColumnToProperty() { $column = 'my_attribute'; $this->assertEquals('myAttribute', $this->entity->columnToProperty($column)); } - public function testPropertyToColumnNoReplacement(){ + public function testPropertyToColumnNoReplacement() { $property = 'my'; $this->assertEquals('my', $this->entity->propertyToColumn($property)); } - public function testSetterMarksFieldUpdated(){ + public function testSetterMarksFieldUpdated() { $this->entity->setId(3); $this->assertContains('id', $this->entity->getUpdatedFields()); @@ -130,7 +128,7 @@ class EntityTest extends \Test\TestCase { - public function testCallShouldOnlyWorkForGetterSetter(){ + public function testCallShouldOnlyWorkForGetterSetter() { $this->expectException(\BadFunctionCallException::class); $this->entity->something(); @@ -138,22 +136,22 @@ class EntityTest extends \Test\TestCase { - public function testGetterShouldFailIfAttributeNotDefined(){ + public function testGetterShouldFailIfAttributeNotDefined() { $this->expectException(\BadFunctionCallException::class); $this->entity->getTest(); } - public function testSetterShouldFailIfAttributeNotDefined(){ + public function testSetterShouldFailIfAttributeNotDefined() { $this->expectException(\BadFunctionCallException::class); $this->entity->setTest(); } - public function testFromRowShouldNotAssignEmptyArray(){ - $row = array(); + public function testFromRowShouldNotAssignEmptyArray() { + $row = []; $entity2 = new TestEntity(); $this->entity = TestEntity::fromRow($row); @@ -161,27 +159,27 @@ class EntityTest extends \Test\TestCase { } - public function testIdGetsConvertedToInt(){ - $row = array('id' => '4'); + public function testIdGetsConvertedToInt() { + $row = ['id' => '4']; $this->entity = TestEntity::fromRow($row); $this->assertSame(4, $this->entity->getId()); } - public function testSetType(){ - $row = array('testId' => '4'); + public function testSetType() { + $row = ['testId' => '4']; $this->entity = TestEntity::fromRow($row); $this->assertSame(4, $this->entity->getTestId()); } - public function testFromParams(){ - $params = array( + public function testFromParams() { + $params = [ 'testId' => 4, 'email' => 'john@doe' - ); + ]; $entity = TestEntity::fromParams($params); @@ -190,7 +188,7 @@ class EntityTest extends \Test\TestCase { $this->assertTrue($entity instanceof TestEntity); } - public function testSlugify(){ + public function testSlugify() { $entity = new TestEntity(); $entity->setName('Slugify this!'); $this->assertEquals('slugify-this', $entity->slugify('name')); @@ -215,12 +213,12 @@ class EntityTest extends \Test\TestCase { public function testGetFieldTypes() { $entity = new TestEntity(); - $this->assertEquals(array( + $this->assertEquals([ 'id' => 'integer', 'testId' => 'integer', 'trueOrFalse' => 'bool', 'anotherBool' => 'boolean', - ), $entity->getFieldTypes()); + ], $entity->getFieldTypes()); } diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php index a69980fbb26..e5a4b63b7a3 100644 --- a/tests/lib/AppFramework/Db/MapperTest.php +++ b/tests/lib/AppFramework/Db/MapperTest.php @@ -44,12 +44,24 @@ class Example extends Entity { class ExampleMapper extends Mapper { - public function __construct(IDBConnection $db){ parent::__construct($db, 'table'); } - public function find($table, $id){ return $this->findOneQuery($table, $id); } - public function findOneEntity($table, $id){ return $this->findEntity($table, $id); } - public function findAllEntities($table){ return $this->findEntities($table); } - public function mapRow($row){ return $this->mapRowToEntity($row); } - public function execSql($sql, $params){ return $this->execute($sql, $params); } + public function __construct(IDBConnection $db) { + parent::__construct($db, 'table'); + } + public function find($table, $id) { + return $this->findOneQuery($table, $id); + } + public function findOneEntity($table, $id) { + return $this->findEntity($table, $id); + } + public function findAllEntities($table) { + return $this->findEntities($table); + } + public function mapRow($row) { + return $this->mapRowToEntity($row); + } + public function execSql($sql, $params) { + return $this->execute($sql, $params); + } } @@ -66,75 +78,75 @@ class MapperTest extends MapperTestUtility { } - public function testMapperShouldSetTableName(){ + public function testMapperShouldSetTableName() { $this->assertEquals('*PREFIX*table', $this->mapper->getTableName()); } - public function testFindQuery(){ + public function testFindQuery() { $sql = 'hi'; - $params = array('jo'); - $rows = array( - array('hi') - ); + $params = ['jo']; + $rows = [ + ['hi'] + ]; $this->setMapperResult($sql, $params, $rows); $this->mapper->find($sql, $params); } - public function testFindEntity(){ + public function testFindEntity() { $sql = 'hi'; - $params = array('jo'); - $rows = array( - array('pre_name' => 'hi') - ); + $params = ['jo']; + $rows = [ + ['pre_name' => 'hi'] + ]; $this->setMapperResult($sql, $params, $rows, null, null, true); $this->mapper->findOneEntity($sql, $params); } - public function testFindNotFound(){ + public function testFindNotFound() { $sql = 'hi'; - $params = array('jo'); - $rows = array(); + $params = ['jo']; + $rows = []; $this->setMapperResult($sql, $params, $rows); $this->expectException(DoesNotExistException::class); $this->mapper->find($sql, $params); } - public function testFindEntityNotFound(){ + public function testFindEntityNotFound() { $sql = 'hi'; - $params = array('jo'); - $rows = array(); + $params = ['jo']; + $rows = []; $this->setMapperResult($sql, $params, $rows, null, null, true); $this->expectException(DoesNotExistException::class); $this->mapper->findOneEntity($sql, $params); } - public function testFindMultiple(){ + public function testFindMultiple() { $sql = 'hi'; - $params = array('jo'); - $rows = array( - array('jo'), array('ho') - ); + $params = ['jo']; + $rows = [ + ['jo'], ['ho'] + ]; $this->setMapperResult($sql, $params, $rows, null, null, true); $this->expectException(MultipleObjectsReturnedException::class); $this->mapper->find($sql, $params); } - public function testFindEntityMultiple(){ + public function testFindEntityMultiple() { $sql = 'hi'; - $params = array('jo'); - $rows = array( - array('jo'), array('ho') - ); + $params = ['jo']; + $rows = [ + ['jo'], ['ho'] + ]; $this->setMapperResult($sql, $params, $rows, null, null, true); $this->expectException(MultipleObjectsReturnedException::class); $this->mapper->findOneEntity($sql, $params); } - public function testDelete(){ + public function testDelete() { $sql = 'DELETE FROM `*PREFIX*table` WHERE `id` = ?'; - $params = array(2); + $params = [2]; $this->setMapperResult($sql, $params, [], null, null, true); $entity = new Example(); @@ -144,16 +156,16 @@ class MapperTest extends MapperTestUtility { } - public function testCreate(){ + public function testCreate() { $this->db->expects($this->once()) ->method('lastInsertId') ->with($this->equalTo('*PREFIX*table')) - ->will($this->returnValue(3)); + ->willReturn(3); $this->mapper = new ExampleMapper($this->db); $sql = 'INSERT INTO `*PREFIX*table`(`pre_name`,`email`) ' . 'VALUES(?,?)'; - $params = array('john', 'my@email'); + $params = ['john', 'my@email']; $entity = new Example(); $entity->setPreName($params[0]); $entity->setEmail($params[1]); @@ -164,16 +176,16 @@ class MapperTest extends MapperTestUtility { } - public function testCreateShouldReturnItemWithCorrectInsertId(){ + public function testCreateShouldReturnItemWithCorrectInsertId() { $this->db->expects($this->once()) ->method('lastInsertId') ->with($this->equalTo('*PREFIX*table')) - ->will($this->returnValue(3)); + ->willReturn(3); $this->mapper = new ExampleMapper($this->db); $sql = 'INSERT INTO `*PREFIX*table`(`pre_name`,`email`) ' . 'VALUES(?,?)'; - $params = array('john', 'my@email'); + $params = ['john', 'my@email']; $entity = new Example(); $entity->setPreName($params[0]); $entity->setEmail($params[1]); @@ -195,14 +207,14 @@ class MapperTest extends MapperTestUtility { } - public function testUpdate(){ + public function testUpdate() { $sql = 'UPDATE `*PREFIX*table` ' . 'SET ' . '`pre_name` = ?,'. '`email` = ? ' . 'WHERE `id` = ?'; - $params = array('john', 'my@email', 1); + $params = ['john', 'my@email', 1]; $entity = new Example(); $entity->setPreName($params[0]); $entity->setEmail($params[1]); @@ -214,8 +226,8 @@ class MapperTest extends MapperTestUtility { } - public function testUpdateNoId(){ - $params = array('john', 'my@email'); + public function testUpdateNoId() { + $params = ['john', 'my@email']; $entity = new Example(); $entity->setPreName($params[0]); $entity->setEmail($params[1]); @@ -226,8 +238,8 @@ class MapperTest extends MapperTestUtility { } - public function testUpdateNothingChangedNoQuery(){ - $params = array('john', 'my@email'); + public function testUpdateNothingChangedNoQuery() { + $params = ['john', 'my@email']; $entity = new Example(); $entity->setId(3); $entity->setEmail($params[1]); @@ -240,8 +252,8 @@ class MapperTest extends MapperTestUtility { } - public function testMapRowToEntity(){ - $entity1 = $this->mapper->mapRow(array('pre_name' => 'test1', 'email' => 'test2')); + public function testMapRowToEntity() { + $entity1 = $this->mapper->mapRow(['pre_name' => 'test1', 'email' => 'test2']); $entity2 = new Example(); $entity2->setPreName('test1'); $entity2->setEmail('test2'); @@ -249,40 +261,40 @@ class MapperTest extends MapperTestUtility { $this->assertEquals($entity2, $entity1); } - public function testFindEntities(){ + public function testFindEntities() { $sql = 'hi'; - $rows = array( - array('pre_name' => 'hi') - ); + $rows = [ + ['pre_name' => 'hi'] + ]; $entity = new Example(); $entity->setPreName('hi'); $entity->resetUpdatedFields(); - $this->setMapperResult($sql, array(), $rows, null, null, true); + $this->setMapperResult($sql, [], $rows, null, null, true); $result = $this->mapper->findAllEntities($sql); - $this->assertEquals(array($entity), $result); + $this->assertEquals([$entity], $result); } - public function testFindEntitiesNotFound(){ + public function testFindEntitiesNotFound() { $sql = 'hi'; - $rows = array(); - $this->setMapperResult($sql, array(), $rows); + $rows = []; + $this->setMapperResult($sql, [], $rows); $result = $this->mapper->findAllEntities($sql); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); } - public function testFindEntitiesMultiple(){ + public function testFindEntitiesMultiple() { $sql = 'hi'; - $rows = array( - array('pre_name' => 'jo'), array('email' => 'ho') - ); + $rows = [ + ['pre_name' => 'jo'], ['email' => 'ho'] + ]; $entity1 = new Example(); $entity1->setPreName('jo'); $entity1->resetUpdatedFields(); $entity2 = new Example(); $entity2->setEmail('ho'); $entity2->resetUpdatedFields(); - $this->setMapperResult($sql, array(), $rows); + $this->setMapperResult($sql, [], $rows); $result = $this->mapper->findAllEntities($sql); - $this->assertEquals(array($entity1, $entity2), $result); + $this->assertEquals([$entity1, $entity2], $result); } } diff --git a/tests/lib/AppFramework/Db/MapperTestUtility.php b/tests/lib/AppFramework/Db/MapperTestUtility.php index 83156a3932b..1224e6d24ed 100644 --- a/tests/lib/AppFramework/Db/MapperTestUtility.php +++ b/tests/lib/AppFramework/Db/MapperTestUtility.php @@ -23,7 +23,6 @@ namespace Test\AppFramework\Db; - /** * Simple utility class for testing mappers */ @@ -89,26 +88,26 @@ abstract class MapperTestUtility extends \Test\TestCase { * of the database query. If not provided, it wont be assumed that fetch * will be called on the result */ - protected function setMapperResult($sql, $arguments=array(), $returnRows=array(), - $limit=null, $offset=null, $expectClose=false){ - if($limit === null && $offset === null) { + protected function setMapperResult($sql, $arguments=[], $returnRows=[], + $limit=null, $offset=null, $expectClose=false) { + if ($limit === null && $offset === null) { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql)) ->will(($this->returnValue($this->query))); - } elseif($limit !== null && $offset === null) { + } elseif ($limit !== null && $offset === null) { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql), $this->equalTo($limit)) ->will(($this->returnValue($this->query))); - } elseif($limit === null && $offset !== null) { + } elseif ($limit === null && $offset !== null) { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql), $this->equalTo(null), $this->equalTo($offset)) ->will(($this->returnValue($this->query))); - } else { + } else { $this->db->expects($this->at($this->prepareAt)) ->method('prepare') ->with($this->equalTo($sql), @@ -124,12 +123,12 @@ abstract class MapperTestUtility extends \Test\TestCase { $this->query->expects($this->any()) ->method('fetch') - ->will($this->returnCallback( - function() use ($iterators, $fetchAt){ + ->willReturnCallback( + function () use ($iterators, $fetchAt) { $iterator = $iterators[$fetchAt]; $result = $iterator->next(); - if($result === false) { + if ($result === false) { $fetchAt++; } @@ -137,10 +136,10 @@ abstract class MapperTestUtility extends \Test\TestCase { return $result; } - )); + ); if ($this->isAssocArray($arguments)) { - foreach($arguments as $key => $argument) { + foreach ($arguments as $key => $argument) { $pdoConstant = $this->getPDOType($argument); $this->query->expects($this->at($this->queryAt)) ->method('bindValue') @@ -151,7 +150,7 @@ abstract class MapperTestUtility extends \Test\TestCase { } } else { $index = 1; - foreach($arguments as $argument) { + foreach ($arguments as $argument) { $pdoConstant = $this->getPDOType($argument); $this->query->expects($this->at($this->queryAt)) ->method('bindValue') @@ -165,9 +164,8 @@ abstract class MapperTestUtility extends \Test\TestCase { $this->query->expects($this->at($this->queryAt)) ->method('execute') - ->will($this->returnCallback(function($sql, $p=null, $o=null, $s=null) { - - })); + ->willReturnCallback(function ($sql, $p=null, $o=null, $s=null) { + }); $this->queryAt++; @@ -183,22 +181,19 @@ abstract class MapperTestUtility extends \Test\TestCase { $this->prepareAt++; $this->fetchAt++; } - - } class ArgumentIterator { - private $arguments; - public function __construct($arguments){ + public function __construct($arguments) { $this->arguments = $arguments; } - public function next(){ + public function next() { $result = array_shift($this->arguments); - if($result === null){ + if ($result === null) { return false; } else { return $result; diff --git a/tests/lib/AppFramework/Db/QBMapperTest.php b/tests/lib/AppFramework/Db/QBMapperTest.php index 6fa0fe10d88..7865979ef41 100644 --- a/tests/lib/AppFramework/Db/QBMapperTest.php +++ b/tests/lib/AppFramework/Db/QBMapperTest.php @@ -42,7 +42,6 @@ use OCP\IDBConnection; * @method void setIntegerProp(integer $integerProp) */ class QBTestEntity extends Entity { - protected $intProp; protected $boolProp; protected $stringProp; @@ -106,7 +105,6 @@ class QBMapperTest extends \Test\TestCase { * @throws \ReflectionException */ protected function setUp(): void { - $this->db = $this->getMockBuilder(IDBConnection::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php index 95d368a448e..ba114433a4c 100644 --- a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php +++ b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php @@ -25,7 +25,6 @@ namespace Test\AppFramework\DependencyInjection; - use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\Http\Request; use OC\AppFramework\Middleware\Security\SecurityMiddleware; @@ -50,24 +49,24 @@ class DIContainerTest extends \Test\TestCase { } - public function testProvidesRequest(){ + public function testProvidesRequest() { $this->assertTrue(isset($this->container['Request'])); } - public function testProvidesMiddlewareDispatcher(){ + public function testProvidesMiddlewareDispatcher() { $this->assertTrue(isset($this->container['MiddlewareDispatcher'])); } - public function testProvidesAppName(){ + public function testProvidesAppName() { $this->assertTrue(isset($this->container['AppName'])); } - public function testAppNameIsSetCorrectly(){ + public function testAppNameIsSetCorrectly() { $this->assertEquals('name', $this->container['AppName']); } - public function testMiddlewareDispatcherIncludesSecurityMiddleware(){ + public function testMiddlewareDispatcherIncludesSecurityMiddleware() { $this->container['Request'] = new Request( ['method' => 'GET'], $this->createMock(ISecureRandom::class), diff --git a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php index 669063f4d18..78a1d40bea6 100644 --- a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php +++ b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php @@ -28,11 +28,14 @@ use OC\AppFramework\Utility\SimpleContainer; use OC\ServerContainer; use Test\TestCase; -interface Interface1 {} +interface Interface1 { +} -class ClassA1 implements Interface1 {} +class ClassA1 implements Interface1 { +} -class ClassA2 implements Interface1 {} +class ClassA2 implements Interface1 { +} class ClassB { /** @var Interface1 */ diff --git a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php index 6acc21550d1..0c8d125d960 100644 --- a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php +++ b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php @@ -8,7 +8,6 @@ namespace Test\AppFramework\Http; -use OCP\AppFramework\Http; use OCP\AppFramework\Http\ContentSecurityPolicy; /** diff --git a/tests/lib/AppFramework/Http/DataResponseTest.php b/tests/lib/AppFramework/Http/DataResponseTest.php index b629c6d385e..e7624c92d7e 100644 --- a/tests/lib/AppFramework/Http/DataResponseTest.php +++ b/tests/lib/AppFramework/Http/DataResponseTest.php @@ -23,7 +23,6 @@ namespace Test\AppFramework\Http; - use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; @@ -41,15 +40,15 @@ class DataResponseTest extends \Test\TestCase { public function testSetData() { - $params = array('hi', 'yo'); + $params = ['hi', 'yo']; $this->response->setData($params); - $this->assertEquals(array('hi', 'yo'), $this->response->getData()); + $this->assertEquals(['hi', 'yo'], $this->response->getData()); } public function testConstructorAllowsToSetData() { - $data = array('hi'); + $data = ['hi']; $code = 300; $response = new DataResponse($data, $code); @@ -59,9 +58,9 @@ class DataResponseTest extends \Test\TestCase { public function testConstructorAllowsToSetHeaders() { - $data = array('hi'); + $data = ['hi']; $code = 300; - $headers = array('test' => 'something'); + $headers = ['test' => 'something']; $response = new DataResponse($data, $code, $headers); $expectedHeaders = [ @@ -78,13 +77,11 @@ class DataResponseTest extends \Test\TestCase { public function testChainability() { - $params = array('hi', 'yo'); + $params = ['hi', 'yo']; $this->response->setData($params) ->setStatus(Http::STATUS_NOT_FOUND); $this->assertEquals(Http::STATUS_NOT_FOUND, $this->response->getStatus()); - $this->assertEquals(array('hi', 'yo'), $this->response->getData()); + $this->assertEquals(['hi', 'yo'], $this->response->getData()); } - - } diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index 1c4dc067b5d..c4c973aec90 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -51,10 +51,10 @@ class TestController extends Controller { * @return array */ public function exec($int, $bool, $test=4, $test2=1) { - $this->registerResponder('text', function($in) { - return new JSONResponse(array('text' => $in)); + $this->registerResponder('text', function ($in) { + return new JSONResponse(['text' => $in]); }); - return array($int, $bool, $test, $test2); + return [$int, $bool, $test, $test2]; } @@ -66,11 +66,10 @@ class TestController extends Controller { * @return DataResponse */ public function execDataResponse($int, $bool, $test=4, $test2=1) { - return new DataResponse(array( - 'text' => array($int, $bool, $test, $test2) - )); + return new DataResponse([ + 'text' => [$int, $bool, $test, $test2] + ]); } - } @@ -140,23 +139,22 @@ class DispatcherTest extends \Test\TestCase { * @param string $httpHeaders */ private function setMiddlewareExpectations($out=null, - $httpHeaders=null, $responseHeaders=array(), + $httpHeaders=null, $responseHeaders=[], $ex=false, $catchEx=true) { - - if($ex) { + if ($ex) { $exception = new \Exception(); $this->middlewareDispatcher->expects($this->once()) ->method('beforeController') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod)) ->will($this->throwException($exception)); - if($catchEx) { + if ($catchEx) { $this->middlewareDispatcher->expects($this->once()) ->method('afterException') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($exception)) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); } else { $this->middlewareDispatcher->expects($this->once()) ->method('afterException') @@ -173,51 +171,43 @@ class DispatcherTest extends \Test\TestCase { $this->equalTo($this->controllerMethod)); $this->controller->expects($this->once()) ->method($this->controllerMethod) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); } $this->response->expects($this->once()) ->method('render') - ->will($this->returnValue($out)); + ->willReturn($out); $this->response->expects($this->once()) ->method('getStatus') - ->will($this->returnValue(Http::STATUS_OK)); - $this->response->expects($this->once()) - ->method('getLastModified') - ->will($this->returnValue($this->lastModified)); - $this->response->expects($this->once()) - ->method('getETag') - ->will($this->returnValue($this->etag)); + ->willReturn(Http::STATUS_OK); $this->response->expects($this->once()) ->method('getHeaders') - ->will($this->returnValue($responseHeaders)); + ->willReturn($responseHeaders); $this->http->expects($this->once()) ->method('getStatusHeader') - ->with($this->equalTo(Http::STATUS_OK), - $this->equalTo($this->lastModified), - $this->equalTo($this->etag)) - ->will($this->returnValue($httpHeaders)); + ->with($this->equalTo(Http::STATUS_OK)) + ->willReturn($httpHeaders); $this->middlewareDispatcher->expects($this->once()) ->method('afterController') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($this->response)) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $this->middlewareDispatcher->expects($this->once()) ->method('afterController') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($this->response)) - ->will($this->returnValue($this->response)); + ->willReturn($this->response); $this->middlewareDispatcher->expects($this->once()) ->method('beforeOutput') ->with($this->equalTo($this->controller), $this->equalTo($this->controllerMethod), $this->equalTo($out)) - ->will($this->returnValue($out)); + ->willReturn($out); } @@ -226,15 +216,15 @@ class DispatcherTest extends \Test\TestCase { $response = $this->dispatcher->dispatch($this->controller, $this->controllerMethod); $this->assertNull($response[0]); - $this->assertEquals(array(), $response[1]); + $this->assertEquals([], $response[1]); $this->assertNull($response[2]); } - public function testHeadersAndOutputAreReturned(){ + public function testHeadersAndOutputAreReturned() { $out = 'yo'; $httpHeaders = 'Http'; - $responseHeaders = array('hell' => 'yeah'); + $responseHeaders = ['hell' => 'yeah']; $this->setMiddlewareExpectations($out, $httpHeaders, $responseHeaders); $response = $this->dispatcher->dispatch($this->controller, @@ -249,7 +239,7 @@ class DispatcherTest extends \Test\TestCase { public function testExceptionCallsAfterException() { $out = 'yo'; $httpHeaders = 'Http'; - $responseHeaders = array('hell' => 'yeah'); + $responseHeaders = ['hell' => 'yeah']; $this->setMiddlewareExpectations($out, $httpHeaders, $responseHeaders, true); $response = $this->dispatcher->dispatch($this->controller, @@ -272,7 +262,6 @@ class DispatcherTest extends \Test\TestCase { $this->controller, $this->controllerMethod ); - } @@ -281,14 +270,14 @@ class DispatcherTest extends \Test\TestCase { ->method('beforeController'); $this->middlewareDispatcher->expects($this->once()) ->method('afterController') - ->will($this->returnCallback(function($a, $b, $in) { + ->willReturnCallback(function ($a, $b, $in) { return $in; - })); + }); $this->middlewareDispatcher->expects($this->once()) ->method('beforeOutput') - ->will($this->returnCallback(function($a, $b, $in) { + ->willReturnCallback(function ($a, $b, $in) { return $in; - })); + }); } @@ -296,8 +285,8 @@ class DispatcherTest extends \Test\TestCase { $this->request = new Request( [ 'post' => [ - 'int' => '3', - 'bool' => 'false' + 'int' => '3', + 'bool' => 'false' ], 'method' => 'POST' ], @@ -488,8 +477,4 @@ class DispatcherTest extends \Test\TestCase { $this->assertEquals('{"text":[3,true,4,1]}', $response[3]); } - - - - } diff --git a/tests/lib/AppFramework/Http/DownloadResponseTest.php b/tests/lib/AppFramework/Http/DownloadResponseTest.php index 5f816eaeb76..1ad53f5db13 100644 --- a/tests/lib/AppFramework/Http/DownloadResponseTest.php +++ b/tests/lib/AppFramework/Http/DownloadResponseTest.php @@ -23,11 +23,9 @@ namespace Test\AppFramework\Http; - use OCP\AppFramework\Http\DownloadResponse; class ChildDownloadResponse extends DownloadResponse { - }; @@ -50,6 +48,4 @@ class DownloadResponseTest extends \Test\TestCase { $this->assertContains('attachment; filename="file"', $headers['Content-Disposition']); $this->assertContains('content', $headers['Content-Type']); } - - } diff --git a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php index c19caad23c7..121bb904d18 100644 --- a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php +++ b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php @@ -8,7 +8,6 @@ namespace Test\AppFramework\Http; -use OCP\AppFramework\Http; use OCP\AppFramework\Http\EmptyContentSecurityPolicy; /** diff --git a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php index 1cebc9ef0f2..18c255463c5 100644 --- a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php +++ b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> diff --git a/tests/lib/AppFramework/Http/FeaturePolicyTest.php b/tests/lib/AppFramework/Http/FeaturePolicyTest.php index af21457bf0a..869650f42b1 100644 --- a/tests/lib/AppFramework/Http/FeaturePolicyTest.php +++ b/tests/lib/AppFramework/Http/FeaturePolicyTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> diff --git a/tests/lib/AppFramework/Http/HttpTest.php b/tests/lib/AppFramework/Http/HttpTest.php index 79c03ce1ab0..d3d23425f7c 100644 --- a/tests/lib/AppFramework/Http/HttpTest.php +++ b/tests/lib/AppFramework/Http/HttpTest.php @@ -26,7 +26,6 @@ namespace Test\AppFramework\Http; use OC\AppFramework\Http; class HttpTest extends \Test\TestCase { - private $server; /** @@ -37,7 +36,7 @@ class HttpTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->server = array(); + $this->server = []; $this->http = new Http($this->server); } @@ -54,44 +53,11 @@ class HttpTest extends \Test\TestCase { $this->assertEquals('HTTP/1.0 200 OK', $header); } - - public function testEtagMatchReturnsNotModified() { - $http = new Http(array('HTTP_IF_NONE_MATCH' => 'hi')); - - $header = $http->getStatusHeader(Http::STATUS_OK, null, 'hi'); - $this->assertEquals('HTTP/1.1 304 Not Modified', $header); - } - - - public function testQuotedEtagMatchReturnsNotModified() { - $http = new Http(array('HTTP_IF_NONE_MATCH' => '"hi"')); - - $header = $http->getStatusHeader(Http::STATUS_OK, null, 'hi'); - $this->assertEquals('HTTP/1.1 304 Not Modified', $header); - } - - - public function testLastModifiedMatchReturnsNotModified() { - $dateTime = new \DateTime(null, new \DateTimeZone('GMT')); - $dateTime->setTimestamp('12'); - - $http = new Http( - array( - 'HTTP_IF_MODIFIED_SINCE' => 'Thu, 01 Jan 1970 00:00:12 +0000') - ); - - $header = $http->getStatusHeader(Http::STATUS_OK, $dateTime); - $this->assertEquals('HTTP/1.1 304 Not Modified', $header); - } - - - public function testTempRedirectBecomesFoundInHttp10() { - $http = new Http(array(), 'HTTP/1.0'); + $http = new Http([], 'HTTP/1.0'); $header = $http->getStatusHeader(Http::STATUS_TEMPORARY_REDIRECT); $this->assertEquals('HTTP/1.0 302 Found', $header); } // TODO: write unittests for http codes - } diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php index 95d2e2a0a4c..504876b2d88 100644 --- a/tests/lib/AppFramework/Http/JSONResponseTest.php +++ b/tests/lib/AppFramework/Http/JSONResponseTest.php @@ -25,7 +25,6 @@ namespace Test\AppFramework\Http; - use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; @@ -49,15 +48,15 @@ class JSONResponseTest extends \Test\TestCase { public function testSetData() { - $params = array('hi', 'yo'); + $params = ['hi', 'yo']; $this->json->setData($params); - $this->assertEquals(array('hi', 'yo'), $this->json->getData()); + $this->assertEquals(['hi', 'yo'], $this->json->getData()); } public function testSetRender() { - $params = array('test' => 'hi'); + $params = ['test' => 'hi']; $this->json->setData($params); $expected = '{"test":"hi"}'; @@ -100,7 +99,7 @@ class JSONResponseTest extends \Test\TestCase { } public function testConstructorAllowsToSetData() { - $data = array('hi'); + $data = ['hi']; $code = 300; $response = new JSONResponse($data, $code); @@ -110,12 +109,11 @@ class JSONResponseTest extends \Test\TestCase { } public function testChainability() { - $params = array('hi', 'yo'); + $params = ['hi', 'yo']; $this->json->setData($params) ->setStatus(Http::STATUS_NOT_FOUND); $this->assertEquals(Http::STATUS_NOT_FOUND, $this->json->getStatus()); - $this->assertEquals(array('hi', 'yo'), $this->json->getData()); + $this->assertEquals(['hi', 'yo'], $this->json->getData()); } - } diff --git a/tests/lib/AppFramework/Http/OCSResponseTest.php b/tests/lib/AppFramework/Http/OCSResponseTest.php index e092cb53f58..e33f1399b84 100644 --- a/tests/lib/AppFramework/Http/OCSResponseTest.php +++ b/tests/lib/AppFramework/Http/OCSResponseTest.php @@ -23,48 +23,42 @@ namespace Test\AppFramework\Http; - use OCP\AppFramework\Http\OCSResponse; class OCSResponseTest extends \Test\TestCase { + public function testHeadersJSON() { + $response = new OCSResponse('json', 1, 2, 3); + $type = $response->getHeaders()['Content-Type']; + $this->assertEquals('application/json; charset=utf-8', $type); + } - public function testHeadersJSON() { - $response = new OCSResponse('json', 1, 2, 3); - $type = $response->getHeaders()['Content-Type']; - $this->assertEquals('application/json; charset=utf-8', $type); - } - - - public function testHeadersXML() { - $response = new OCSResponse('xml', 1, 2, 3); - $type = $response->getHeaders()['Content-Type']; - $this->assertEquals('application/xml; charset=utf-8', $type); - } - - - public function testRender() { - $response = new OCSResponse( - 'xml', 2, 'message', ['test' => 'hi'], 3, 4 - ); - $out = $response->render(); - $expected = "<?xml version=\"1.0\"?>\n" . - "<ocs>\n" . - " <meta>\n" . - " <status>failure</status>\n" . - " <statuscode>2</statuscode>\n" . - " <message>message</message>\n" . - " <totalitems>3</totalitems>\n" . - " <itemsperpage>4</itemsperpage>\n" . - " </meta>\n" . - " <data>\n" . - " <test>hi</test>\n" . - " </data>\n" . - "</ocs>\n"; - - $this->assertEquals($expected, $out); + public function testHeadersXML() { + $response = new OCSResponse('xml', 1, 2, 3); + $type = $response->getHeaders()['Content-Type']; + $this->assertEquals('application/xml; charset=utf-8', $type); + } - } + public function testRender() { + $response = new OCSResponse( + 'xml', 2, 'message', ['test' => 'hi'], 3, 4 + ); + $out = $response->render(); + $expected = "<?xml version=\"1.0\"?>\n" . + "<ocs>\n" . + " <meta>\n" . + " <status>failure</status>\n" . + " <statuscode>2</statuscode>\n" . + " <message>message</message>\n" . + " <totalitems>3</totalitems>\n" . + " <itemsperpage>4</itemsperpage>\n" . + " </meta>\n" . + " <data>\n" . + " <test>hi</test>\n" . + " </data>\n" . + "</ocs>\n"; + $this->assertEquals($expected, $out); + } } diff --git a/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php b/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php index 90fb8cceca1..cbf8f8303c3 100644 --- a/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php +++ b/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php @@ -29,7 +29,6 @@ use OCP\AppFramework\Http\Template\PublicTemplateResponse; use Test\TestCase; class PublicTemplateResponseTest extends TestCase { - public function testSetParamsConstructor() { $template = new PublicTemplateResponse('app', 'home', ['key' => 'value']); $this->assertContains('core/js/public/publicpage', \OC_Util::$scripts); @@ -79,5 +78,4 @@ class PublicTemplateResponseTest extends TestCase { $this->assertEquals(['key' => 'value'], $template->getParams()); $this->assertEquals('public', $template->getRenderAs()); } - } diff --git a/tests/lib/AppFramework/Http/RedirectResponseTest.php b/tests/lib/AppFramework/Http/RedirectResponseTest.php index fc24f323c6a..5130d36937f 100644 --- a/tests/lib/AppFramework/Http/RedirectResponseTest.php +++ b/tests/lib/AppFramework/Http/RedirectResponseTest.php @@ -42,14 +42,12 @@ class RedirectResponseTest extends \Test\TestCase { public function testHeaders() { $headers = $this->response->getHeaders(); $this->assertEquals('/url', $headers['Location']); - $this->assertEquals(Http::STATUS_SEE_OTHER, + $this->assertEquals(Http::STATUS_SEE_OTHER, $this->response->getStatus()); } - public function testGetRedirectUrl(){ + public function testGetRedirectUrl() { $this->assertEquals('/url', $this->response->getRedirectUrl()); } - - } diff --git a/tests/lib/AppFramework/Http/RequestStream.php b/tests/lib/AppFramework/Http/RequestStream.php index 8f6dffd4e91..3868ed16505 100644 --- a/tests/lib/AppFramework/Http/RequestStream.php +++ b/tests/lib/AppFramework/Http/RequestStream.php @@ -10,7 +10,7 @@ class RequestStream { protected $position; protected $varname; - function stream_open($path, $mode, $options, &$opened_path) { + public function stream_open($path, $mode, $options, &$opened_path) { $url = parse_url($path); $this->varname = $url["host"]; $this->position = 0; @@ -18,13 +18,13 @@ class RequestStream { return true; } - function stream_read($count) { + public function stream_read($count) { $ret = substr($GLOBALS[$this->varname], $this->position, $count); $this->position += strlen($ret); return $ret; } - function stream_write($data) { + public function stream_write($data) { $left = substr($GLOBALS[$this->varname], 0, $this->position); $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); $GLOBALS[$this->varname] = $left . $data . $right; @@ -32,40 +32,40 @@ class RequestStream { return strlen($data); } - function stream_tell() { + public function stream_tell() { return $this->position; } - function stream_eof() { + public function stream_eof() { return $this->position >= strlen($GLOBALS[$this->varname]); } - function stream_seek($offset, $whence) { + public function stream_seek($offset, $whence) { switch ($whence) { case SEEK_SET: if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { - $this->position = $offset; - return true; + $this->position = $offset; + return true; } else { - return false; + return false; } break; case SEEK_CUR: if ($offset >= 0) { - $this->position += $offset; - return true; + $this->position += $offset; + return true; } else { - return false; + return false; } break; case SEEK_END: if (strlen($GLOBALS[$this->varname]) + $offset >= 0) { - $this->position = strlen($GLOBALS[$this->varname]) + $offset; - return true; + $this->position = strlen($GLOBALS[$this->varname]) + $offset; + return true; } else { - return false; + return false; } break; @@ -77,7 +77,7 @@ class RequestStream { public function stream_stat() { $size = strlen($GLOBALS[$this->varname]); $time = time(); - $data = array( + $data = [ 'dev' => 0, 'ino' => 0, 'mode' => 0777, @@ -91,16 +91,16 @@ class RequestStream { 'ctime' => $time, 'blksize' => -1, 'blocks' => -1, - ); + ]; return array_values($data) + $data; //return false; } - function stream_metadata($path, $option, $var) { - if($option == STREAM_META_TOUCH) { + public function stream_metadata($path, $option, $var) { + if ($option == STREAM_META_TOUCH) { $url = parse_url($path); $varname = $url["host"]; - if(!isset($GLOBALS[$varname])) { + if (!isset($GLOBALS[$varname])) { $GLOBALS[$varname] = ''; } return true; diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index be019050e1b..a8e2f2248c6 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -51,10 +51,10 @@ class RequestTest extends \Test\TestCase { } public function testRequestAccessors() { - $vars = array( - 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), + $vars = [ + 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'], 'method' => 'GET', - ); + ]; $request = new Request( $vars, @@ -77,17 +77,16 @@ class RequestTest extends \Test\TestCase { $this->assertSame('Joey', $request->get['nickname']); // Always returns null if variable not set. $this->assertSame(null, $request->{'flickname'}); - } // urlParams has precedence over POST which has precedence over GET public function testPrecedence() { - $vars = array( - 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), - 'post' => array('name' => 'Jane Doe', 'nickname' => 'Janey'), - 'urlParams' => array('user' => 'jw', 'name' => 'Johnny Weissmüller'), + $vars = [ + 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'], + 'post' => ['name' => 'Jane Doe', 'nickname' => 'Janey'], + 'urlParams' => ['user' => 'jw', 'name' => 'Johnny Weissmüller'], 'method' => 'GET' - ); + ]; $request = new Request( $vars, @@ -107,10 +106,10 @@ class RequestTest extends \Test\TestCase { public function testImmutableArrayAccess() { $this->expectException(\RuntimeException::class); - $vars = array( - 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), + $vars = [ + 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'], 'method' => 'GET' - ); + ]; $request = new Request( $vars, @@ -127,10 +126,10 @@ class RequestTest extends \Test\TestCase { public function testImmutableMagicAccess() { $this->expectException(\RuntimeException::class); - $vars = array( - 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), + $vars = [ + 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'], 'method' => 'GET' - ); + ]; $request = new Request( $vars, @@ -147,10 +146,10 @@ class RequestTest extends \Test\TestCase { public function testGetTheMethodRight() { $this->expectException(\LogicException::class); - $vars = array( - 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), + $vars = [ + 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'], 'method' => 'GET', - ); + ]; $request = new Request( $vars, @@ -164,10 +163,10 @@ class RequestTest extends \Test\TestCase { } public function testTheMethodIsRight() { - $vars = array( - 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'), + $vars = [ + 'get' => ['name' => 'John Q. Public', 'nickname' => 'Joey'], 'method' => 'GET', - ); + ]; $request = new Request( $vars, @@ -186,10 +185,10 @@ class RequestTest extends \Test\TestCase { public function testJsonPost() { global $data; $data = '{"name": "John Q. Public", "nickname": "Joey"}'; - $vars = array( + $vars = [ 'method' => 'POST', - 'server' => array('CONTENT_TYPE' => 'application/json; utf-8') - ); + 'server' => ['CONTENT_TYPE' => 'application/json; utf-8'] + ]; $request = new Request( $vars, @@ -210,10 +209,10 @@ class RequestTest extends \Test\TestCase { public function testNotJsonPost() { global $data; $data = 'this is not valid json'; - $vars = array( + $vars = [ 'method' => 'POST', - 'server' => array('CONTENT_TYPE' => 'application/json; utf-8') - ); + 'server' => ['CONTENT_TYPE' => 'application/json; utf-8'] + ]; $request = new Request( $vars, @@ -230,12 +229,12 @@ class RequestTest extends \Test\TestCase { public function testPatch() { global $data; - $data = http_build_query(array('name' => 'John Q. Public', 'nickname' => 'Joey'), '', '&'); + $data = http_build_query(['name' => 'John Q. Public', 'nickname' => 'Joey'], '', '&'); - $vars = array( + $vars = [ 'method' => 'PATCH', - 'server' => array('CONTENT_TYPE' => 'application/x-www-form-urlencoded'), - ); + 'server' => ['CONTENT_TYPE' => 'application/x-www-form-urlencoded'], + ]; $request = new Request( $vars, @@ -257,10 +256,10 @@ class RequestTest extends \Test\TestCase { // PUT content $data = '{"name": "John Q. Public", "nickname": "Joey"}'; - $vars = array( + $vars = [ 'method' => 'PUT', - 'server' => array('CONTENT_TYPE' => 'application/json; utf-8'), - ); + 'server' => ['CONTENT_TYPE' => 'application/json; utf-8'], + ]; $request = new Request( $vars, @@ -278,10 +277,10 @@ class RequestTest extends \Test\TestCase { // PATCH content $data = '{"name": "John Q. Public", "nickname": null}'; - $vars = array( + $vars = [ 'method' => 'PATCH', - 'server' => array('CONTENT_TYPE' => 'application/json; utf-8'), - ); + 'server' => ['CONTENT_TYPE' => 'application/json; utf-8'], + ]; $request = new Request( $vars, @@ -302,14 +301,14 @@ class RequestTest extends \Test\TestCase { global $data; $data = file_get_contents(__DIR__ . '/../../../data/testimage.png'); - $vars = array( + $vars = [ 'put' => $data, 'method' => 'PUT', 'server' => [ 'CONTENT_TYPE' => 'image/png', 'CONTENT_LENGTH' => (string)strlen($data) ], - ); + ]; $request = new Request( $vars, @@ -326,20 +325,19 @@ class RequestTest extends \Test\TestCase { try { $resource = $request->put; - } catch(\LogicException $e) { + } catch (\LogicException $e) { return; } $this->fail('Expected LogicException.'); - } public function testSetUrlParameters() { - $vars = array( - 'post' => array(), + $vars = [ + 'post' => [], 'method' => 'POST', - 'urlParams' => array('id' => '2'), - ); + 'urlParams' => ['id' => '2'], + ]; $request = new Request( $vars, @@ -349,7 +347,7 @@ class RequestTest extends \Test\TestCase { $this->stream ); - $newParams = array('id' => '3', 'test' => 'test2'); + $newParams = ['id' => '3', 'test' => 'test2']; $request->setUrlParameters($newParams); $this->assertSame('test2', $request->getParam('test')); $this->assertEquals('3', $request->getParam('id')); @@ -378,7 +376,7 @@ class RequestTest extends \Test\TestCase { $this->secureRandom->expects($this->once()) ->method('generate') ->with('20') - ->will($this->returnValue('GeneratedByOwnCloudItself')); + ->willReturn('GeneratedByOwnCloudItself'); $request = new Request( [], @@ -409,7 +407,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue([])); + ->willReturn([]); $request = new Request( [ @@ -433,12 +431,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['10.0.0.2'])); + ->willReturn(['10.0.0.2']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue([])); + ->willReturn([]); $request = new Request( [ @@ -462,12 +460,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['10.0.0.2'])); + ->willReturn(['10.0.0.2']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue(['HTTP_X_FORWARDED'])); + ->willReturn(['HTTP_X_FORWARDED']); $request = new Request( [ @@ -491,12 +489,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['2001:db8:85a3:8d3:1319:8a2e:370:7348'])); + ->willReturn(['2001:db8:85a3:8d3:1319:8a2e:370:7348']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue(['HTTP_X_FORWARDED'])); + ->willReturn(['HTTP_X_FORWARDED']); $request = new Request( [ @@ -520,16 +518,16 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['10.0.0.2'])); + ->willReturn(['10.0.0.2']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue([ + ->willReturn([ 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED' - ])); + ]); $request = new Request( [ @@ -553,16 +551,16 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['2001:db8:85a3:8d3:1319:8a2e:370:7348'])); + ->willReturn(['2001:db8:85a3:8d3:1319:8a2e:370:7348']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue([ + ->willReturn([ 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED' - ])); + ]); $request = new Request( [ @@ -586,12 +584,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['192.168.2.0/24'])); + ->willReturn(['192.168.2.0/24']); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('forwarded_for_headers') - ->will($this->returnValue(['HTTP_X_FORWARDED_FOR'])); + ->willReturn(['HTTP_X_FORWARDED_FOR']); $request = new Request( [ @@ -615,7 +613,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('trusted_proxies') - ->will($this->returnValue(['192.168.2.0/24'])); + ->willReturn(['192.168.2.0/24']); $request = new Request( [ @@ -690,17 +688,17 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('overwriteprotocol') - ->will($this->returnValue('customProtocol')); + ->willReturn('customProtocol'); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('overwritecondaddr') - ->will($this->returnValue('')); + ->willReturn(''); $this->config ->expects($this->at(2)) ->method('getSystemValue') ->with('overwriteprotocol') - ->will($this->returnValue('customProtocol')); + ->willReturn('customProtocol'); $request = new Request( [], @@ -716,13 +714,13 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithProtoValid() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $requestHttps = new Request( [ @@ -757,9 +755,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithHttpsServerValueOn() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { return $default; - })); + }); $request = new Request( [ @@ -778,9 +776,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithHttpsServerValueOff() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { return $default; - })); + }); $request = new Request( [ @@ -799,9 +797,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolWithHttpsServerValueEmpty() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { return $default; - })); + }); $request = new Request( [ @@ -820,9 +818,9 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolDefault() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { return $default; - })); + }); $request = new Request( [], @@ -837,13 +835,13 @@ class RequestTest extends \Test\TestCase { public function testGetServerProtocolBehindLoadBalancers() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -904,7 +902,7 @@ class RequestTest extends \Test\TestCase { /** * @return array */ - function userAgentProvider() { + public function userAgentProvider() { return [ [ 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)', @@ -1059,13 +1057,13 @@ class RequestTest extends \Test\TestCase { public function testInsecureServerHostHttpFromForwardedHeaderSingle() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -1088,13 +1086,13 @@ class RequestTest extends \Test\TestCase { public function testInsecureServerHostHttpFromForwardedHeaderStacked() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -1117,15 +1115,15 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithOverwriteHost() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'overwritecondaddr') { return ''; - } else if ($key === 'overwritehost') { + } elseif ($key === 'overwritehost') { return 'my.overwritten.host'; } return $default; - })); + }); $request = new Request( [], @@ -1141,15 +1139,15 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithTrustedDomain() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; - } else if ($key === 'trusted_domains') { + } elseif ($key === 'trusted_domains') { return ['my.trusted.host']; } return $default; - })); + }); $request = new Request( [ @@ -1170,15 +1168,15 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithUntrustedDomain() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; - } else if ($key === 'trusted_domains') { + } elseif ($key === 'trusted_domains') { return ['my.trusted.host']; } return $default; - })); + }); $request = new Request( [ @@ -1199,12 +1197,12 @@ class RequestTest extends \Test\TestCase { public function testGetServerHostWithNoTrustedDomain() { $this->config ->method('getSystemValue') - ->will($this->returnCallback(function($key, $default) { + ->willReturnCallback(function ($key, $default) { if ($key === 'trusted_proxies') { return ['1.2.3.4']; } return $default; - })); + }); $request = new Request( [ @@ -1273,7 +1271,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('')); + ->willReturn(''); $request = new Request( [], $this->secureRandom, @@ -1290,17 +1288,17 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('www.owncloud.org')); + ->willReturn('www.owncloud.org'); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('overwritecondaddr') - ->will($this->returnValue('')); + ->willReturn(''); $this->config ->expects($this->at(2)) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('www.owncloud.org')); + ->willReturn('www.owncloud.org'); $request = new Request( [], @@ -1485,7 +1483,7 @@ class RequestTest extends \Test\TestCase { ->expects($this->once()) ->method('getSystemValue') ->with('overwritewebroot') - ->will($this->returnValue('')); + ->willReturn(''); $request = new Request( [ @@ -1517,12 +1515,12 @@ class RequestTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getSystemValue') ->with('overwritewebroot') - ->will($this->returnValue($overwriteWebRoot)); + ->willReturn($overwriteWebRoot); $this->config ->expects($this->at(1)) ->method('getSystemValue') ->with('overwritecondaddr') - ->will($this->returnValue($overwriteCondAddr)); + ->willReturn($overwriteCondAddr); $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') ->setMethods(['getScriptName']) @@ -1542,7 +1540,7 @@ class RequestTest extends \Test\TestCase { $request ->expects($this->once()) ->method('getScriptName') - ->will($this->returnValue('/scriptname.php')); + ->willReturn('/scriptname.php'); $this->assertSame($expectedUri, $request->getRequestUri()); } diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php index 3d76d24496d..f33d0a0089d 100644 --- a/tests/lib/AppFramework/Http/ResponseTest.php +++ b/tests/lib/AppFramework/Http/ResponseTest.php @@ -23,7 +23,6 @@ namespace Test\AppFramework\Http; - use OCP\AppFramework\Http; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Utility\ITimeFactory; @@ -41,7 +40,7 @@ class ResponseTest extends \Test\TestCase { } - public function testAddHeader(){ + public function testAddHeader() { $this->childResponse->addHeader(' hello ', 'world'); $headers = $this->childResponse->getHeaders(); $this->assertEquals('world', $headers['hello']); @@ -49,11 +48,11 @@ class ResponseTest extends \Test\TestCase { public function testSetHeaders() { - $expected = array( + $expected = [ 'Last-Modified' => 1, 'ETag' => 3, 'Something-Else' => 'hi' - ); + ]; $this->childResponse->setHeaders($expected); $headers = $this->childResponse->getHeaders(); @@ -88,14 +87,14 @@ class ResponseTest extends \Test\TestCase { $this->assertEquals(new Http\EmptyContentSecurityPolicy(), $this->childResponse->getContentSecurityPolicy()); } - public function testAddHeaderValueNullDeletesIt(){ + public function testAddHeaderValueNullDeletesIt() { $this->childResponse->addHeader('hello', 'world'); $this->childResponse->addHeader('hello', null); $this->assertEquals(3, count($this->childResponse->getHeaders())); } - public function testCacheHeadersAreDisabledByDefault(){ + public function testCacheHeadersAreDisabledByDefault() { $headers = $this->childResponse->getHeaders(); $this->assertEquals('no-cache, no-store, must-revalidate', $headers['Cache-Control']); } @@ -105,31 +104,31 @@ class ResponseTest extends \Test\TestCase { $this->childResponse->addCookie('foo', 'bar'); $this->childResponse->addCookie('bar', 'foo', new \DateTime('1970-01-01')); - $expectedResponse = array( - 'foo' => array( + $expectedResponse = [ + 'foo' => [ 'value' => 'bar', 'expireDate' => null, - ), - 'bar' => array( + ], + 'bar' => [ 'value' => 'foo', 'expireDate' => new \DateTime('1970-01-01') - ) - ); + ] + ]; $this->assertEquals($expectedResponse, $this->childResponse->getCookies()); } - function testSetCookies() { - $expected = array( - 'foo' => array( + public function testSetCookies() { + $expected = [ + 'foo' => [ 'value' => 'bar', 'expireDate' => null, - ), - 'bar' => array( + ], + 'bar' => [ 'value' => 'foo', 'expireDate' => new \DateTime('1970-01-01') - ) - ); + ] + ]; $this->childResponse->setCookies($expected); $cookies = $this->childResponse->getCookies(); @@ -138,15 +137,15 @@ class ResponseTest extends \Test\TestCase { } - function testInvalidateCookie() { + public function testInvalidateCookie() { $this->childResponse->addCookie('foo', 'bar'); $this->childResponse->invalidateCookie('foo'); - $expected = array( - 'foo' => array( + $expected = [ + 'foo' => [ 'value' => 'expired', 'expireDate' => new \DateTime('1971-01-01') - ) - ); + ] + ]; $cookies = $this->childResponse->getCookies(); @@ -154,40 +153,40 @@ class ResponseTest extends \Test\TestCase { } - function testInvalidateCookies() { + public function testInvalidateCookies() { $this->childResponse->addCookie('foo', 'bar'); $this->childResponse->addCookie('bar', 'foo'); - $expected = array( - 'foo' => array( + $expected = [ + 'foo' => [ 'value' => 'bar', 'expireDate' => null - ), - 'bar' => array( + ], + 'bar' => [ 'value' => 'foo', 'expireDate' => null - ) - ); + ] + ]; $cookies = $this->childResponse->getCookies(); $this->assertEquals($expected, $cookies); - $this->childResponse->invalidateCookies(array('foo', 'bar')); - $expected = array( - 'foo' => array( + $this->childResponse->invalidateCookies(['foo', 'bar']); + $expected = [ + 'foo' => [ 'value' => 'expired', 'expireDate' => new \DateTime('1971-01-01') - ), - 'bar' => array( + ], + 'bar' => [ 'value' => 'expired', 'expireDate' => new \DateTime('1971-01-01') - ) - ); + ] + ]; $cookies = $this->childResponse->getCookies(); $this->assertEquals($expected, $cookies); } - public function testRenderReturnNullByDefault(){ + public function testRenderReturnNullByDefault() { $this->assertEquals(null, $this->childResponse->render()); } @@ -268,9 +267,8 @@ class ResponseTest extends \Test\TestCase { $this->assertEquals(Http::STATUS_NOT_FOUND, $this->childResponse->getStatus()); $this->assertEquals('hi', $this->childResponse->getEtag()); $this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']); - $this->assertEquals('max-age=33, must-revalidate', + $this->assertEquals('private, max-age=33, must-revalidate', $headers['Cache-Control']); - } public function testThrottle() { diff --git a/tests/lib/AppFramework/Http/StreamResponseTest.php b/tests/lib/AppFramework/Http/StreamResponseTest.php index ef7132013b6..97aced01506 100644 --- a/tests/lib/AppFramework/Http/StreamResponseTest.php +++ b/tests/lib/AppFramework/Http/StreamResponseTest.php @@ -23,7 +23,6 @@ namespace Test\AppFramework\Http; - use OCP\AppFramework\Http; use OCP\AppFramework\Http\IOutput; use OCP\AppFramework\Http\StreamResponse; @@ -40,11 +39,11 @@ class StreamResponseTest extends \Test\TestCase { ->getMock(); } - public function testOutputNotModified(){ + public function testOutputNotModified() { $path = __FILE__; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_NOT_MODIFIED)); + ->willReturn(Http::STATUS_NOT_MODIFIED); $this->output->expects($this->never()) ->method('setReadfile'); $response = new StreamResponse($path); @@ -52,25 +51,25 @@ class StreamResponseTest extends \Test\TestCase { $response->callback($this->output); } - public function testOutputOk(){ + public function testOutputOk() { $path = __FILE__; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_OK)); + ->willReturn(Http::STATUS_OK); $this->output->expects($this->once()) ->method('setReadfile') ->with($this->equalTo($path)) - ->will($this->returnValue(true)); + ->willReturn(true); $response = new StreamResponse($path); $response->callback($this->output); } - public function testOutputNotFound(){ + public function testOutputNotFound() { $path = __FILE__ . 'test'; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_OK)); + ->willReturn(Http::STATUS_OK); $this->output->expects($this->never()) ->method('setReadfile'); $this->output->expects($this->once()) @@ -81,14 +80,14 @@ class StreamResponseTest extends \Test\TestCase { $response->callback($this->output); } - public function testOutputReadFileError(){ + public function testOutputReadFileError() { $path = __FILE__; $this->output->expects($this->once()) ->method('getHttpResponseCode') - ->will($this->returnValue(Http::STATUS_OK)); + ->willReturn(Http::STATUS_OK); $this->output->expects($this->once()) ->method('setReadfile') - ->will($this->returnValue(false)); + ->willReturn(false); $this->output->expects($this->once()) ->method('setHttpResponseCode') ->with($this->equalTo(Http::STATUS_BAD_REQUEST)); @@ -96,5 +95,4 @@ class StreamResponseTest extends \Test\TestCase { $response->callback($this->output); } - } diff --git a/tests/lib/AppFramework/Http/TemplateResponseTest.php b/tests/lib/AppFramework/Http/TemplateResponseTest.php index 6672b4d0c1e..6cbf112494e 100644 --- a/tests/lib/AppFramework/Http/TemplateResponseTest.php +++ b/tests/lib/AppFramework/Http/TemplateResponseTest.php @@ -40,47 +40,46 @@ class TemplateResponseTest extends \Test\TestCase { } - public function testSetParamsConstructor(){ - $params = array('hi' => 'yo'); + public function testSetParamsConstructor() { + $params = ['hi' => 'yo']; $this->tpl = new TemplateResponse('app', 'home', $params); - $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams()); + $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams()); } - public function testSetRenderAsConstructor(){ + public function testSetRenderAsConstructor() { $renderAs = 'myrender'; - $this->tpl = new TemplateResponse('app', 'home', array(), $renderAs); + $this->tpl = new TemplateResponse('app', 'home', [], $renderAs); $this->assertEquals($renderAs, $this->tpl->getRenderAs()); } - public function testSetParams(){ - $params = array('hi' => 'yo'); + public function testSetParams() { + $params = ['hi' => 'yo']; $this->tpl->setParams($params); - $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams()); + $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams()); } - public function testGetTemplateName(){ + public function testGetTemplateName() { $this->assertEquals('home', $this->tpl->getTemplateName()); } - public function testGetRenderAs(){ + public function testGetRenderAs() { $render = 'myrender'; $this->tpl->renderAs($render); $this->assertEquals($render, $this->tpl->getRenderAs()); } public function testChainability() { - $params = array('hi' => 'yo'); + $params = ['hi' => 'yo']; $this->tpl->setParams($params) ->setStatus(Http::STATUS_NOT_FOUND); $this->assertEquals(Http::STATUS_NOT_FOUND, $this->tpl->getStatus()); - $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams()); + $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams()); } - } diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php index 8971fe4df06..617ead473c0 100644 --- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> @@ -81,7 +82,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase { public function testStandaloneTemplateResponse() { $this->dispatcher->expects($this->once()) ->method('dispatch') - ->willReturnCallback(function($eventName) { + ->willReturnCallback(function ($eventName) { if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS) { return; } @@ -97,7 +98,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase { public function testTemplateResponseNotLoggedIn() { $this->dispatcher->expects($this->once()) ->method('dispatch') - ->willReturnCallback(function($eventName) { + ->willReturnCallback(function ($eventName) { if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS) { return; } @@ -115,7 +116,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase { $this->dispatcher->expects($this->exactly(2)) ->method('dispatch') - ->willReturnCallback(function($eventName) use (&$events) { + ->willReturnCallback(function ($eventName) use (&$events) { if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS || $eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN) { $events[] = $eventName; diff --git a/tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php new file mode 100644 index 00000000000..3eeac3ef103 --- /dev/null +++ b/tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php @@ -0,0 +1,163 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace Test\AppFramework\Middleware; + +use OC\AppFramework\Middleware\CompressionMiddleware; +use OC\AppFramework\OCS\V1Response; +use OC\AppFramework\OCS\V2Response; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http; +use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\JSONResponse; +use OCP\IRequest; + +class CompressionMiddlewareTest extends \Test\TestCase { + + /** @var IRequest */ + private $request; + /** @var Controller */ + private $controller; + /** @var CompressionMiddleware */ + private $middleWare; + + protected function setUp(): void { + parent::setUp(); + + $this->request = $this->createMock(IRequest::class); + $this->middleWare = new CompressionMiddleware( + $this->request + ); + + $this->controller = $this->createMock(Controller::class); + } + + public function testGzipOCSV1() { + $this->request->method('getHeader') + ->with('Accept-Encoding') + ->willReturn('gzip'); + + $response = $this->createMock(V1Response::class); + $response->expects($this->once()) + ->method('addHeader') + ->with('Content-Encoding', 'gzip'); + + $response->method('getStatus') + ->willReturn(Http::STATUS_OK); + + $this->middleWare->beforeController($this->controller, 'myMethod'); + $this->middleWare->afterController($this->controller,'myMethod', $response); + + $output = 'myoutput'; + $result = $this->middleWare->beforeOutput($this->controller, 'myMethod', $output); + + $this->assertSame($output, gzdecode($result)); + } + + public function testGzipOCSV2() { + $this->request->method('getHeader') + ->with('Accept-Encoding') + ->willReturn('gzip'); + + $response = $this->createMock(V2Response::class); + $response->expects($this->once()) + ->method('addHeader') + ->with('Content-Encoding', 'gzip'); + + $response->method('getStatus') + ->willReturn(Http::STATUS_OK); + + $this->middleWare->beforeController($this->controller, 'myMethod'); + $this->middleWare->afterController($this->controller,'myMethod', $response); + + $output = 'myoutput'; + $result = $this->middleWare->beforeOutput($this->controller, 'myMethod', $output); + + $this->assertSame($output, gzdecode($result)); + } + + public function testGzipJSONResponse() { + $this->request->method('getHeader') + ->with('Accept-Encoding') + ->willReturn('gzip'); + + $response = $this->createMock(JSONResponse::class); + $response->expects($this->once()) + ->method('addHeader') + ->with('Content-Encoding', 'gzip'); + + $response->method('getStatus') + ->willReturn(Http::STATUS_OK); + + $this->middleWare->beforeController($this->controller, 'myMethod'); + $this->middleWare->afterController($this->controller,'myMethod', $response); + + $output = 'myoutput'; + $result = $this->middleWare->beforeOutput($this->controller, 'myMethod', $output); + + $this->assertSame($output, gzdecode($result)); + } + + public function testNoGzipDataResponse() { + $this->request->method('getHeader') + ->with('Accept-Encoding') + ->willReturn('gzip'); + + $response = $this->createMock(DataResponse::class); + $response->expects($this->never()) + ->method('addHeader'); + + $response->method('getStatus') + ->willReturn(Http::STATUS_OK); + $this->middleWare->beforeController($this->controller, 'myMethod'); + $this->middleWare->afterController($this->controller,'myMethod', $response); + + $output = 'myoutput'; + $result = $this->middleWare->beforeOutput($this->controller, 'myMethod', $output); + + $this->assertSame($output, $result); + } + + public function testNoGzipNo200() { + $this->request->method('getHeader') + ->with('Accept-Encoding') + ->willReturn('gzip'); + + $response = $this->createMock(JSONResponse::class); + $response->expects($this->never()) + ->method('addHeader'); + + $response->method('getStatus') + ->willReturn(Http::STATUS_NOT_FOUND); + + $this->middleWare->beforeController($this->controller, 'myMethod'); + $this->middleWare->afterController($this->controller,'myMethod', $response); + + $output = 'myoutput'; + $result = $this->middleWare->beforeOutput($this->controller, 'myMethod', $output); + + $this->assertSame($output, $result); + } +} diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index 965637cb4c4..25cfa32dc7c 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -25,7 +25,6 @@ namespace Test\AppFramework\Middleware; use OC\AppFramework\Http\Request; use OC\AppFramework\Middleware\MiddlewareDispatcher; -use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; use OCP\IConfig; @@ -61,17 +60,17 @@ class TestMiddleware extends Middleware { $this->beforeControllerThrowsEx = $beforeControllerThrowsEx; } - public function beforeController($controller, $methodName){ + public function beforeController($controller, $methodName) { self::$beforeControllerCalled++; $this->beforeControllerOrder = self::$beforeControllerCalled; $this->controller = $controller; $this->methodName = $methodName; - if($this->beforeControllerThrowsEx){ + if ($this->beforeControllerThrowsEx) { throw new \Exception(); } } - public function afterException($controller, $methodName, \Exception $exception){ + public function afterException($controller, $methodName, \Exception $exception) { self::$afterExceptionCalled++; $this->afterExceptionOrder = self::$afterExceptionCalled; $this->controller = $controller; @@ -80,7 +79,7 @@ class TestMiddleware extends Middleware { parent::afterException($controller, $methodName, $exception); } - public function afterController($controller, $methodName, Response $response){ + public function afterController($controller, $methodName, Response $response) { self::$afterControllerCalled++; $this->afterControllerOrder = self::$afterControllerCalled; $this->controller = $controller; @@ -89,7 +88,7 @@ class TestMiddleware extends Middleware { return parent::afterController($controller, $methodName, $response); } - public function beforeOutput($controller, $methodName, $output){ + public function beforeOutput($controller, $methodName, $output) { self::$beforeOutputCalled++; $this->beforeOutputOrder = self::$beforeOutputCalled; $this->controller = $controller; @@ -101,7 +100,6 @@ class TestMiddleware extends Middleware { class MiddlewareDispatcherTest extends \Test\TestCase { - public $exception; public $response; private $out; @@ -125,7 +123,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - private function getControllerMock(){ + private function getControllerMock() { return $this->getMockBuilder('OCP\AppFramework\Controller') ->setMethods(['method']) ->setConstructorArgs(['app', @@ -138,14 +136,14 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - private function getMiddleware($beforeControllerThrowsEx=false){ + private function getMiddleware($beforeControllerThrowsEx=false) { $m1 = new TestMiddleware($beforeControllerThrowsEx); $this->dispatcher->registerMiddleware($m1); return $m1; } - public function testAfterExceptionShouldReturnResponseOfMiddleware(){ + public function testAfterExceptionShouldReturnResponseOfMiddleware() { $response = new Response(); $m1 = $this->getMockBuilder('\OCP\AppFramework\Middleware') ->setMethods(['afterException', 'beforeController']) @@ -158,7 +156,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { ->getMock(); $m2->expects($this->once()) ->method('afterException') - ->will($this->returnValue($response)); + ->willReturn($response); $this->dispatcher->registerMiddleware($m1); $this->dispatcher->registerMiddleware($m2); @@ -168,7 +166,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterExceptionShouldThrowAgainWhenNotHandled(){ + public function testAfterExceptionShouldThrowAgainWhenNotHandled() { $m1 = new TestMiddleware(false); $m2 = new TestMiddleware(true); @@ -181,7 +179,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeControllerCorrectArguments(){ + public function testBeforeControllerCorrectArguments() { $m1 = $this->getMiddleware(); $this->dispatcher->beforeController($this->controller, $this->method); @@ -190,7 +188,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterControllerCorrectArguments(){ + public function testAfterControllerCorrectArguments() { $m1 = $this->getMiddleware(); $this->dispatcher->afterController($this->controller, $this->method, $this->response); @@ -201,7 +199,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterExceptionCorrectArguments(){ + public function testAfterExceptionCorrectArguments() { $m1 = $this->getMiddleware(); $this->expectException(\Exception::class); @@ -215,7 +213,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeOutputCorrectArguments(){ + public function testBeforeOutputCorrectArguments() { $m1 = $this->getMiddleware(); $this->dispatcher->beforeOutput($this->controller, $this->method, $this->out); @@ -226,7 +224,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeControllerOrder(){ + public function testBeforeControllerOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -236,7 +234,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { $this->assertEquals(2, $m2->beforeControllerOrder); } - public function testAfterControllerOrder(){ + public function testAfterControllerOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -247,7 +245,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterExceptionOrder(){ + public function testAfterExceptionOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -260,7 +258,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeOutputOrder(){ + public function testBeforeOutputOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -271,7 +269,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares(){ + public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(true); $m3 = $this->getMockBuilder('\OCP\AppFramework\Middleware')->getMock(); @@ -282,7 +280,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { $m3->expects($this->never()) ->method('afterController'); $m3->method('beforeOutput') - ->will($this->returnArgument(2)); + ->willReturnArgument(2); $this->dispatcher->registerMiddleware($m3); diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php index 4ac6fa647f7..42e38bbd999 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php @@ -28,7 +28,8 @@ use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; use OCP\IConfig; -class ChildMiddleware extends Middleware {}; +class ChildMiddleware extends Middleware { +}; class MiddlewareTest extends \Test\TestCase { @@ -91,6 +92,4 @@ class MiddlewareTest extends \Test\TestCase { $this->assertEquals('test', $output); } - - } diff --git a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php new file mode 100644 index 00000000000..89ae75bcac2 --- /dev/null +++ b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php @@ -0,0 +1,106 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace Test\AppFramework\Middleware; + +use OC\AppFramework\Middleware\NotModifiedMiddleware; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http; +use OCP\IRequest; + +class NotModifiedMiddlewareTest extends \Test\TestCase { + + /** @var IRequest */ + private $request; + /** @var Controller */ + private $controller; + /** @var NotModifiedMiddleware */ + private $middleWare; + + protected function setUp(): void { + parent::setUp(); + + $this->request = $this->createMock(IRequest::class); + $this->middleWare = new NotModifiedMiddleware( + $this->request + ); + + $this->controller = $this->createMock(Controller::class); + } + + public function dataModified(): array { + $now = new \DateTime(); + + return [ + [null, '', null, '', false], + ['etag', 'etag', null, '', false], + ['etag', '"wrongetag"', null, '', false], + ['etag', '', null, '', false], + [null, '"etag"', null, '', false], + ['etag', '"etag"', null, '', true], + + [null, '', $now, $now->format(\DateTime::RFC2822), true], + [null, '', $now, $now->format(\DateTime::ATOM), false], + [null, '', null, $now->format(\DateTime::RFC2822), false], + [null, '', $now, '', false], + + ['etag', '"etag"', $now, $now->format(\DateTime::ATOM), true], + ['etag', '"etag"', $now, $now->format(\DateTime::RFC2822), true], + ]; + } + + /** + * @dataProvider dataModified + */ + public function testMiddleware(?string $etag, string $etagHeader, ?\DateTime $lastModified, string $lastModifiedHeader, bool $notModifiedSet) { + $this->request->method('getHeader') + ->willReturnCallback(function (string $name) use ($etagHeader, $lastModifiedHeader) { + if ($name === 'IF_NONE_MATCH') { + return $etagHeader; + } + if ($name === 'IF_MODIFIED_SINCE') { + return $lastModifiedHeader; + } + return ''; + }); + + $response = new Http\Response(); + if ($etag !== null) { + $response->setETag($etag); + } + if ($lastModified !== null) { + $response->setLastModified($lastModified); + } + $response->setStatus(Http::STATUS_OK); + + $result = $this->middleWare->afterController($this->controller, 'myfunction', $response); + + if ($notModifiedSet) { + $this->assertSame(Http::STATUS_NOT_MODIFIED, $result->getStatus()); + } else { + $this->assertSame(Http::STATUS_OK, $result->getStatus()); + } + } +} diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php index e001e48acd2..834cd39185c 100644 --- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php @@ -238,5 +238,4 @@ class OCSMiddlewareTest extends \Test\TestCase { $this->assertSame(Http::STATUS_UNAUTHORIZED, $newResponse->getStatus()); } } - } diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php index 82f354d127d..ed6d06d4bf5 100644 --- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php @@ -282,6 +282,4 @@ class PublicShareMiddlewareTest extends \Test\TestCase { $result = $this->middleware->afterException($controller, 'method', $exception); $this->assertInstanceOf(RedirectResponse::class, $result); } - - } diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php index f6ce5c27b22..55c874ccdb5 100644 --- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php @@ -26,7 +26,6 @@ use OC\AppFramework\Utility\ControllerMethodReflector; use OC\Security\Bruteforce\Throttler; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; -use OCP\Http\Client\IResponse; use OCP\IRequest; use Test\TestCase; diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php index 1c12a4aa153..a7bf2b14271 100644 --- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php @@ -140,7 +140,7 @@ class CORSMiddlewareTest extends \Test\TestCase { $this->session->expects($this->never()) ->method('logClientIn') ->with($this->equalTo('user'), $this->equalTo('pass')) - ->will($this->returnValue(true)); + ->willReturn(true); $this->reflector->reflect($this, __FUNCTION__); $middleware->beforeController($this->controller, __FUNCTION__); @@ -163,7 +163,7 @@ class CORSMiddlewareTest extends \Test\TestCase { $this->session->expects($this->once()) ->method('logClientIn') ->with($this->equalTo('user'), $this->equalTo('pass')) - ->will($this->returnValue(true)); + ->willReturn(true); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); @@ -215,7 +215,7 @@ class CORSMiddlewareTest extends \Test\TestCase { $this->session->expects($this->once()) ->method('logClientIn') ->with($this->equalTo('user'), $this->equalTo('pass')) - ->will($this->returnValue(false)); + ->willReturn(false); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); @@ -270,5 +270,4 @@ class CORSMiddlewareTest extends \Test\TestCase { $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); $middleware->afterException($this->controller, __FUNCTION__, new \Exception('A regular exception')); } - } diff --git a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php index 6d089e3880d..2dfb04e138e 100644 --- a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> diff --git a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php index e136d783616..0a4b3c4f34c 100644 --- a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> @@ -25,12 +26,9 @@ declare(strict_types=1); namespace Test\AppFramework\Middleware\Security; use OC\AppFramework\Middleware\Security\FeaturePolicyMiddleware; -use OC\Security\CSP\ContentSecurityPolicy; -use OC\Security\CSRF\CsrfToken; use OC\Security\FeaturePolicy\FeaturePolicy; use OC\Security\FeaturePolicy\FeaturePolicyManager; use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\EmptyContentSecurityPolicy; use OCP\AppFramework\Http\EmptyFeaturePolicy; use OCP\AppFramework\Http\Response; use PHPUnit\Framework\MockObject\MockObject; diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index ae0e6ff484d..306ee9f841c 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -32,17 +32,10 @@ use OC\AppFramework\Middleware\Security\Exceptions\SecurityException; use OC\Appframework\Middleware\Security\Exceptions\StrictCookieMissingException; use OC\AppFramework\Middleware\Security\SecurityMiddleware; use OC\AppFramework\Utility\ControllerMethodReflector; -use OC\Security\CSP\ContentSecurityPolicy; -use OC\Security\CSP\ContentSecurityPolicyManager; -use OC\Security\CSP\ContentSecurityPolicyNonceManager; -use OC\Security\CSRF\CsrfToken; -use OC\Security\CSRF\CsrfTokenManager; use OCP\App\IAppManager; use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\EmptyContentSecurityPolicy; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\RedirectResponse; -use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IL10N; @@ -93,7 +86,6 @@ class SecurityMiddlewareTest extends \Test\TestCase { } private function getMiddleware(bool $isLoggedIn, bool $isAdminUser, bool $isSubAdmin, bool $isAppEnabledForUser = true): SecurityMiddleware { - $this->appManager = $this->createMock(IAppManager::class); $this->appManager->expects($this->any()) ->method('isEnabledForUser') @@ -119,7 +111,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @PublicPage * @NoCSRFRequired */ - public function testSetNavigationEntry(){ + public function testSetNavigationEntry() { $this->navigationManager->expects($this->once()) ->method('setActiveEntry') ->with($this->equalTo('files')); @@ -147,7 +139,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { try { $this->reader->reflect(__CLASS__, $method); $sec->beforeController($this->controller, $method); - } catch (SecurityException $ex){ + } catch (SecurityException $ex) { $this->assertEquals($status, $ex->getCode()); } @@ -215,10 +207,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @PublicPage * @NoCSRFRequired */ - public function testNoChecks(){ + public function testNoChecks() { $this->request->expects($this->never()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $sec = $this->getMiddleware(false, false, false); @@ -231,7 +223,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @param string $method * @param string $expects */ - private function securityCheck($method, $expects, $shouldFail=false){ + private function securityCheck($method, $expects, $shouldFail=false) { // admin check requires login if ($expects === 'isAdminUser') { $isLoggedIn = true; @@ -243,7 +235,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $sec = $this->getMiddleware($isLoggedIn, $isAdminUser, false); - if($shouldFail) { + if ($shouldFail) { $this->expectException(SecurityException::class); } else { $this->addToAssertionCount(1); @@ -257,15 +249,15 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage */ - public function testCsrfCheck(){ + public function testCsrfCheck() { $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class); $this->request->expects($this->once()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); } @@ -275,10 +267,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @PublicPage * @NoCSRFRequired */ - public function testNoCsrfCheck(){ + public function testNoCsrfCheck() { $this->request->expects($this->never()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -287,13 +279,13 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage */ - public function testPassesCsrfCheck(){ + public function testPassesCsrfCheck() { $this->request->expects($this->once()) ->method('passesCSRFCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -302,15 +294,15 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage */ - public function testFailCsrfCheck(){ + public function testFailCsrfCheck() { $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class); $this->request->expects($this->once()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -327,7 +319,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ->method('passesCSRFCheck'); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -341,7 +333,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { public function testNoStrictCookieRequiredCheck() { $this->request->expects($this->never()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -393,7 +385,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { public function testCsrfOcsController(Controller $controller, bool $hasOcsApiHeader, bool $hasBearerAuth, bool $exception) { $this->request ->method('getHeader') - ->will(self::returnCallback(function ($header) use ($hasOcsApiHeader, $hasBearerAuth) { + ->willReturnCallback(function ($header) use ($hasOcsApiHeader, $hasBearerAuth) { if ($header === 'OCS-APIREQUEST' && $hasOcsApiHeader) { return 'true'; } @@ -401,7 +393,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { return 'Bearer TOKEN!'; } return ''; - })); + }); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') ->willReturn(true); @@ -418,7 +410,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @NoAdminRequired */ - public function testLoggedInCheck(){ + public function testLoggedInCheck() { $this->securityCheck(__FUNCTION__, 'isLoggedIn'); } @@ -427,7 +419,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @NoAdminRequired */ - public function testFailLoggedInCheck(){ + public function testFailLoggedInCheck() { $this->securityCheck(__FUNCTION__, 'isLoggedIn', true); } @@ -435,7 +427,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @NoCSRFRequired */ - public function testIsAdminCheck(){ + public function testIsAdminCheck() { $this->securityCheck(__FUNCTION__, 'isAdminUser'); } @@ -443,7 +435,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @SubAdminRequired */ - public function testIsNotSubAdminCheck(){ + public function testIsNotSubAdminCheck() { $this->reader->reflect(__CLASS__,__FUNCTION__); $sec = $this->getMiddleware(true, false, false); @@ -455,7 +447,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @SubAdminRequired */ - public function testIsSubAdminCheck(){ + public function testIsSubAdminCheck() { $this->reader->reflect(__CLASS__,__FUNCTION__); $sec = $this->getMiddleware(true, false, true); @@ -467,7 +459,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @SubAdminRequired */ - public function testIsSubAdminAndAdminCheck(){ + public function testIsSubAdminAndAdminCheck() { $this->reader->reflect(__CLASS__,__FUNCTION__); $sec = $this->getMiddleware(true, true, true); @@ -478,12 +470,12 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @NoCSRFRequired */ - public function testFailIsAdminCheck(){ + public function testFailIsAdminCheck() { $this->securityCheck(__FUNCTION__, 'isAdminUser', true); } - public function testAfterExceptionNotCaughtThrowsItAgain(){ + public function testAfterExceptionNotCaughtThrowsItAgain() { $ex = new \Exception(); $this->expectException(\Exception::class); $this->middleware->afterException($this->controller, 'test', $ex); @@ -511,7 +503,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { 'redirect_url' => 'nextcloud/index.php/apps/specialapp', ] ) - ->will($this->returnValue('http://localhost/nextcloud/index.php/login?redirect_url=nextcloud/index.php/apps/specialapp')); + ->willReturn('http://localhost/nextcloud/index.php/login?redirect_url=nextcloud/index.php/apps/specialapp'); $this->logger ->expects($this->once()) ->method('logException'); @@ -595,7 +587,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->assertEquals($expected , $response); } - public function testAfterAjaxExceptionReturnsJSONError(){ + public function testAfterAjaxExceptionReturnsJSONError() { $response = $this->middleware->afterException($this->controller, 'test', $this->secAjaxException); diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php index db2a9d5b625..f9739044465 100644 --- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php @@ -11,12 +11,10 @@ namespace Test\AppFramework\Middleware; -use OC\AppFramework\Http\Request; use OC\AppFramework\Middleware\SessionMiddleware; use OC\AppFramework\Utility\ControllerMethodReflector; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; -use OCP\IConfig; class SessionMiddlewareTest extends \Test\TestCase { @@ -83,5 +81,4 @@ class SessionMiddlewareTest extends \Test\TestCase { ->method('close'); return $session; } - } diff --git a/tests/lib/AppFramework/OCS/BaseResponseTest.php b/tests/lib/AppFramework/OCS/BaseResponseTest.php index 8a86ae13e79..aca8c355f41 100644 --- a/tests/lib/AppFramework/OCS/BaseResponseTest.php +++ b/tests/lib/AppFramework/OCS/BaseResponseTest.php @@ -26,11 +26,9 @@ declare(strict_types=1); namespace Test\AppFramework\Middleware; - use OC\AppFramework\OCS\BaseResponse; class BaseResponseTest extends \Test\TestCase { - public function testToXml(): void { /** @var BaseResponse $response */ @@ -58,5 +56,4 @@ class BaseResponseTest extends \Test\TestCase { $writer->outputMemory(true) ); } - } diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php index 1b7ab054a0f..34aaff82310 100644 --- a/tests/lib/AppFramework/Routing/RoutingTest.php +++ b/tests/lib/AppFramework/Routing/RoutingTest.php @@ -5,136 +5,136 @@ namespace Test\AppFramework\Routing; use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\Routing\RouteActionHandler; use OC\AppFramework\Routing\RouteConfig; +use OC\Route\Route; use OC\Route\Router; use OCP\ILogger; use OCP\Route\IRouter; use PHPUnit\Framework\MockObject\MockObject; -class RoutingTest extends \Test\TestCase -{ +class RoutingTest extends \Test\TestCase { + public function testSimpleRoute() { + $routes = ['routes' => [ + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'GET'] + ]]; + + $this->assertSimpleRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open'); + } - public function testSimpleRoute() - { - $routes = array('routes' => array( - array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'GET') - )); + public function testSimpleRouteWithUnderScoreNames() { + $routes = ['routes' => [ + ['name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'root' => ''] + ]]; - $this->assertSimpleRoute($routes, 'folders.open', 'GET', '/folders/{folderId}/open', 'FoldersController', 'open'); + $this->assertSimpleRoute($routes, 'admin_folders.open_current', 'DELETE', '/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent', [], [], '', true); } public function testSimpleOCSRoute() { $routes = ['ocs' => [ - ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'GET'] - ] + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'GET'] + ] ]; $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open'); } - public function testSimpleRouteWithMissingVerb() - { - $routes = array('routes' => array( - array('name' => 'folders#open', 'url' => '/folders/{folderId}/open') - )); + public function testSimpleRouteWithMissingVerb() { + $routes = ['routes' => [ + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open'] + ]]; - $this->assertSimpleRoute($routes, 'folders.open', 'GET', '/folders/{folderId}/open', 'FoldersController', 'open'); + $this->assertSimpleRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open'); } public function testSimpleOCSRouteWithMissingVerb() { $routes = ['ocs' => [ - ['name' => 'folders#open', 'url' => '/folders/{folderId}/open'] - ] + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open'] + ] ]; $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open'); } - public function testSimpleRouteWithLowercaseVerb() - { - $routes = array('routes' => array( - array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete') - )); + public function testSimpleRouteWithLowercaseVerb() { + $routes = ['routes' => [ + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete'] + ]]; - $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open'); + $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open'); } public function testSimpleOCSRouteWithLowercaseVerb() { $routes = ['ocs' => [ - ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete'] - ] + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete'] + ] ]; $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open'); } - public function testSimpleRouteWithRequirements() - { - $routes = array('routes' => array( - array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => array('something')) - )); + public function testSimpleRouteWithRequirements() { + $routes = ['routes' => [ + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => ['something']] + ]]; - $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', array('something')); + $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', ['something']); } public function testSimpleOCSRouteWithRequirements() { $routes = ['ocs' => [ - ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => ['something']] - ] + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => ['something']] + ] ]; $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', ['something']); } - public function testSimpleRouteWithDefaults() - { - $routes = array('routes' => array( - array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', array(), 'defaults' => array('param' => 'foobar')) - )); + public function testSimpleRouteWithDefaults() { + $routes = ['routes' => [ + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', [], 'defaults' => ['param' => 'foobar']] + ]]; - $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', array(), array('param' => 'foobar')); + $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']); } public function testSimpleOCSRouteWithDefaults() { $routes = ['ocs' => [ - ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'defaults' => ['param' => 'foobar']] - ] + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'defaults' => ['param' => 'foobar']] + ] ]; $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']); } - public function testSimpleRouteWithPostfix() - { - $routes = array('routes' => array( - array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'postfix' => '_something') - )); + public function testSimpleRouteWithPostfix() { + $routes = ['routes' => [ + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'postfix' => '_something'] + ]]; - $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', array(), array(), '_something'); + $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something'); } public function testSimpleOCSRouteWithPostfix() { $routes = ['ocs' => [ - ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'postfix' => '_something'] - ] + ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'postfix' => '_something'] + ] ]; $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something'); } - - public function testSimpleRouteWithBrokenName() - { + + public function testSimpleRouteWithBrokenName() { $this->expectException(\UnexpectedValueException::class); - $routes = array('routes' => array( - array('name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete') - )); + $routes = ['routes' => [ + ['name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete'] + ]]; - // router mock - $router = $this->getMockBuilder('\OC\Route\Router') - ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) + /** @var IRouter|MockObject $router */ + $router = $this->getMockBuilder(Router::class) + ->onlyMethods(['create']) + ->setConstructorArgs([$this->createMock(ILogger::class)]) ->getMock(); // load route configuration @@ -144,7 +144,7 @@ class RoutingTest extends \Test\TestCase $config->register(); } - + public function testSimpleOCSRouteWithBrokenName() { $this->expectException(\UnexpectedValueException::class); @@ -152,10 +152,10 @@ class RoutingTest extends \Test\TestCase ['name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete'] ]]; - // router mock - $router = $this->getMockBuilder('\OC\Route\Router') - ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) + /** @var IRouter|MockObject $router */ + $router = $this->getMockBuilder(Router::class) + ->onlyMethods(['create']) + ->setConstructorArgs([$this->createMock(ILogger::class)]) ->getMock(); // load route configuration @@ -165,15 +165,6 @@ class RoutingTest extends \Test\TestCase $config->register(); } - public function testSimpleRouteWithUnderScoreNames() - { - $routes = array('routes' => array( - array('name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete') - )); - - $this->assertSimpleRoute($routes, 'admin_folders.open_current', 'DELETE', '/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent'); - } - public function testSimpleOCSRouteWithUnderScoreNames() { $routes = ['ocs' => [ ['name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete'] @@ -182,50 +173,37 @@ class RoutingTest extends \Test\TestCase $this->assertSimpleOCSRoute($routes, 'admin_folders.open_current', 'DELETE', '/apps/app1/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent'); } - public function testOCSResource() - { + public function testOCSResource() { $routes = ['ocs-resources' => ['account' => ['url' => '/accounts']]]; $this->assertOCSResource($routes, 'account', '/apps/app1/accounts', 'AccountController', 'id'); } - public function testOCSResourceWithUnderScoreName() - { + public function testOCSResourceWithUnderScoreName() { $routes = ['ocs-resources' => ['admin_accounts' => ['url' => '/admin/accounts']]]; $this->assertOCSResource($routes, 'admin_accounts', '/apps/app1/admin/accounts', 'AdminAccountsController', 'id'); } - public function testOCSResourceWithRoot() - { + public function testOCSResourceWithRoot() { $routes = ['ocs-resources' => ['admin_accounts' => ['url' => '/admin/accounts', 'root' => '/core/endpoint']]]; $this->assertOCSResource($routes, 'admin_accounts', '/core/endpoint/admin/accounts', 'AdminAccountsController', 'id'); } - public function testResource() - { - $routes = array('resources' => array('account' => array('url' => '/accounts'))); + public function testResource() { + $routes = ['resources' => ['account' => ['url' => '/accounts']]]; - $this->assertResource($routes, 'account', '/accounts', 'AccountController', 'id'); + $this->assertResource($routes, 'account', '/apps/app1/accounts', 'AccountController', 'id'); } - public function testResourceWithUnderScoreName() - { - $routes = array('resources' => array('admin_accounts' => array('url' => '/admin/accounts'))); + public function testResourceWithUnderScoreName() { + $routes = ['resources' => ['admin_accounts' => ['url' => '/admin/accounts']]]; - $this->assertResource($routes, 'admin_accounts', '/admin/accounts', 'AdminAccountsController', 'id'); + $this->assertResource($routes, 'admin_accounts', '/apps/app1/admin/accounts', 'AdminAccountsController', 'id'); } - /** - * @param string $name - * @param string $verb - * @param string $url - * @param string $controllerName - * @param string $actionName - */ - private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName, array $requirements=array(), array $defaults=array(), $postfix='') - { + private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName, array $requirements = [], array $defaults = [], $postfix = '', $allowRootUrl = false): void { if ($postfix) { $name .= $postfix; } @@ -234,10 +212,10 @@ class RoutingTest extends \Test\TestCase $container = new DIContainer('app1'); $route = $this->mockRoute($container, $verb, $controllerName, $actionName, $requirements, $defaults); - // router mock - $router = $this->getMockBuilder('\OC\Route\Router') - ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) + /** @var IRouter|MockObject $router */ + $router = $this->getMockBuilder(Router::class) + ->onlyMethods(['create']) + ->setConstructorArgs([$this->createMock(ILogger::class)]) ->getMock(); // we expect create to be called once: @@ -245,10 +223,13 @@ class RoutingTest extends \Test\TestCase ->expects($this->once()) ->method('create') ->with($this->equalTo('app1.' . $name), $this->equalTo($url)) - ->will($this->returnValue($route)); + ->willReturn($route); // load route configuration $config = new RouteConfig($container, $router, $routes); + if ($allowRootUrl) { + self::invokePrivate($config, 'rootUrlApps', [['app1']]); + } $config->register(); } @@ -270,10 +251,9 @@ class RoutingTest extends \Test\TestCase $url, $controllerName, $actionName, - array $requirements=array(), - array $defaults=array(), - $postfix='') - { + array $requirements=[], + array $defaults=[], + $postfix='') { if ($postfix) { $name .= $postfix; } @@ -282,10 +262,10 @@ class RoutingTest extends \Test\TestCase $container = new DIContainer('app1'); $route = $this->mockRoute($container, $verb, $controllerName, $actionName, $requirements, $defaults); - // router mock - $router = $this->getMockBuilder('\OC\Route\Router') - ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) + /** @var IRouter|MockObject $router */ + $router = $this->getMockBuilder(Router::class) + ->onlyMethods(['create']) + ->setConstructorArgs([$this->createMock(ILogger::class)]) ->getMock(); // we expect create to be called once: @@ -293,7 +273,7 @@ class RoutingTest extends \Test\TestCase ->expects($this->once()) ->method('create') ->with($this->equalTo('ocs.app1.' . $name), $this->equalTo($url)) - ->will($this->returnValue($route)); + ->willReturn($route); // load route configuration $config = new RouteConfig($container, $router, $routes); @@ -311,8 +291,8 @@ class RoutingTest extends \Test\TestCase private function assertOCSResource($yaml, $resourceName, $url, $controllerName, $paramName): void { /** @var IRouter|MockObject $router */ $router = $this->getMockBuilder(Router::class) - ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) + ->onlyMethods(['create']) + ->setConstructorArgs([$this->createMock(ILogger::class)]) ->getMock(); // route mocks @@ -368,12 +348,11 @@ class RoutingTest extends \Test\TestCase * @param string $controllerName * @param string $paramName */ - private function assertResource($yaml, $resourceName, $url, $controllerName, $paramName) - { - // router mock - $router = $this->getMockBuilder('\OC\Route\Router') - ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) + private function assertResource($yaml, $resourceName, $url, $controllerName, $paramName) { + /** @var IRouter|MockObject $router */ + $router = $this->getMockBuilder(Router::class) + ->onlyMethods(['create']) + ->setConstructorArgs([$this->createMock(ILogger::class)]) ->getMock(); // route mocks @@ -391,31 +370,31 @@ class RoutingTest extends \Test\TestCase ->expects($this->at(0)) ->method('create') ->with($this->equalTo('app1.' . $resourceName . '.index'), $this->equalTo($url)) - ->will($this->returnValue($indexRoute)); + ->willReturn($indexRoute); $router ->expects($this->at(1)) ->method('create') ->with($this->equalTo('app1.' . $resourceName . '.show'), $this->equalTo($urlWithParam)) - ->will($this->returnValue($showRoute)); + ->willReturn($showRoute); $router ->expects($this->at(2)) ->method('create') ->with($this->equalTo('app1.' . $resourceName . '.create'), $this->equalTo($url)) - ->will($this->returnValue($createRoute)); + ->willReturn($createRoute); $router ->expects($this->at(3)) ->method('create') ->with($this->equalTo('app1.' . $resourceName . '.update'), $this->equalTo($urlWithParam)) - ->will($this->returnValue($updateRoute)); + ->willReturn($updateRoute); $router ->expects($this->at(4)) ->method('create') ->with($this->equalTo('app1.' . $resourceName . '.destroy'), $this->equalTo($urlWithParam)) - ->will($this->returnValue($destroyRoute)); + ->willReturn($destroyRoute); // load route configuration $config = new RouteConfig($container, $router, $yaml); @@ -430,83 +409,48 @@ class RoutingTest extends \Test\TestCase * @param string $actionName * @param array $requirements * @param array $defaults - * @return \PHPUnit_Framework_MockObject_MockObject + * @return MockObject */ private function mockRoute( DIContainer $container, $verb, $controllerName, $actionName, - array $requirements=array(), - array $defaults=array() + array $requirements=[], + array $defaults=[] ) { - $route = $this->getMockBuilder('\OC\Route\Route') - ->setMethods(['method', 'action', 'requirements', 'defaults']) + $route = $this->getMockBuilder(Route::class) + ->onlyMethods(['method', 'action', 'requirements', 'defaults']) ->disableOriginalConstructor() ->getMock(); $route - ->expects($this->exactly(1)) + ->expects($this->once()) ->method('method') ->with($this->equalTo($verb)) - ->will($this->returnValue($route)); + ->willReturn($route); $route - ->expects($this->exactly(1)) + ->expects($this->once()) ->method('action') ->with($this->equalTo(new RouteActionHandler($container, $controllerName, $actionName))) - ->will($this->returnValue($route)); + ->willReturn($route); - if(count($requirements) > 0) { + if (count($requirements) > 0) { $route - ->expects($this->exactly(1)) + ->expects($this->once()) ->method('requirements') ->with($this->equalTo($requirements)) - ->will($this->returnValue($route)); + ->willReturn($route); } if (count($defaults) > 0) { $route - ->expects($this->exactly(1)) + ->expects($this->once()) ->method('defaults') ->with($this->equalTo($defaults)) - ->will($this->returnValue($route)); + ->willReturn($route); } return $route; } - } - -/* -# -# sample routes.yaml for ownCloud -# -# the section simple describes one route - -routes: - - name: folders#open - url: /folders/{folderId}/open - verb: GET - # controller: name.split()[0] - # action: name.split()[1] - -# for a resource following actions will be generated: -# - index -# - create -# - show -# - update -# - destroy -# - new -resources: - accounts: - url: /accounts - - folders: - url: /accounts/{accountId}/folders - # actions can be used to define additional actions on the resource - actions: - - name: validate - verb: GET - on-collection: false - - * */ diff --git a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php index fe1fc5bfa1a..990ad44adf3 100644 --- a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php +++ b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php @@ -23,7 +23,6 @@ namespace Test\AppFramework\Utility; - use OC\AppFramework\Utility\ControllerMethodReflector; class BaseController { @@ -31,18 +30,20 @@ class BaseController { /** * @Annotation */ - public function test(){} + public function test() { + } /** * @Annotation */ - public function test2(){} + public function test2() { + } /** * @Annotation */ - public function test3(){} - + public function test3() { + } } class MiddleController extends BaseController { @@ -50,13 +51,15 @@ class MiddleController extends BaseController { /** * @NoAnnotation */ - public function test2() {} - - public function test3() {} + public function test2() { + } + public function test3() { + } } -class EndController extends MiddleController {} +class EndController extends MiddleController { +} class ControllerMethodReflectorTest extends \Test\TestCase { @@ -64,7 +67,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { /** * @Annotation */ - public function testReadAnnotation(){ + public function testReadAnnotation() { $reader = new ControllerMethodReflector(); $reader->reflect( '\Test\AppFramework\Utility\ControllerMethodReflectorTest', @@ -106,7 +109,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { * @Annotation * @param test */ - public function testReadAnnotationNoLowercase(){ + public function testReadAnnotationNoLowercase() { $reader = new ControllerMethodReflector(); $reader->reflect( '\Test\AppFramework\Utility\ControllerMethodReflectorTest', @@ -122,7 +125,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { * @Annotation * @param int $test */ - public function testReadTypeIntAnnotations(){ + public function testReadTypeIntAnnotations() { $reader = new ControllerMethodReflector(); $reader->reflect( '\Test\AppFramework\Utility\ControllerMethodReflectorTest', @@ -137,12 +140,13 @@ class ControllerMethodReflectorTest extends \Test\TestCase { * @param int $a * @param int $b */ - public function arguments3($a, float $b, int $c, $d){} + public function arguments3($a, float $b, int $c, $d) { + } /** * @requires PHP 7 */ - public function testReadTypeIntAnnotationsScalarTypes(){ + public function testReadTypeIntAnnotationsScalarTypes() { $reader = new ControllerMethodReflector(); $reader->reflect( '\Test\AppFramework\Utility\ControllerMethodReflectorTest', @@ -160,7 +164,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { * @Annotation * @param double $test something special */ - public function testReadTypeDoubleAnnotations(){ + public function testReadTypeDoubleAnnotations() { $reader = new ControllerMethodReflector(); $reader->reflect( '\Test\AppFramework\Utility\ControllerMethodReflectorTest', @@ -174,7 +178,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { * @Annotation * @param string $foo */ - public function testReadTypeWhitespaceAnnotations(){ + public function testReadTypeWhitespaceAnnotations() { $reader = new ControllerMethodReflector(); $reader->reflect( '\Test\AppFramework\Utility\ControllerMethodReflectorTest', @@ -185,7 +189,8 @@ class ControllerMethodReflectorTest extends \Test\TestCase { } - public function arguments($arg, $arg2='hi') {} + public function arguments($arg, $arg2='hi') { + } public function testReflectParameters() { $reader = new ControllerMethodReflector(); $reader->reflect( @@ -193,11 +198,12 @@ class ControllerMethodReflectorTest extends \Test\TestCase { 'arguments' ); - $this->assertEquals(array('arg' => null, 'arg2' => 'hi'), $reader->getParameters()); + $this->assertEquals(['arg' => null, 'arg2' => 'hi'], $reader->getParameters()); } - public function arguments2($arg) {} + public function arguments2($arg) { + } public function testReflectParameters2() { $reader = new ControllerMethodReflector(); $reader->reflect( @@ -205,7 +211,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { 'arguments2' ); - $this->assertEquals(array('arg' => null), $reader->getParameters()); + $this->assertEquals(['arg' => null], $reader->getParameters()); } @@ -232,5 +238,4 @@ class ControllerMethodReflectorTest extends \Test\TestCase { $this->assertFalse($reader->hasAnnotation('Annotation')); } - } diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php index 0341be14af9..f8a43058305 100644 --- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php +++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php @@ -25,198 +25,198 @@ namespace Test\AppFramework\Utility; use OC\AppFramework\Utility\SimpleContainer; -interface TestInterface {} +interface TestInterface { +} -class ClassEmptyConstructor implements IInterfaceConstructor {} +class ClassEmptyConstructor implements IInterfaceConstructor { +} class ClassSimpleConstructor implements IInterfaceConstructor { - public $test; - public function __construct($test) { - $this->test = $test; - } + public $test; + public function __construct($test) { + $this->test = $test; + } } class ClassComplexConstructor { - public $class; - public $test; - public function __construct(ClassSimpleConstructor $class, $test) { - $this->class = $class; - $this->test = $test; - } + public $class; + public $test; + public function __construct(ClassSimpleConstructor $class, $test) { + $this->class = $class; + $this->test = $test; + } } -interface IInterfaceConstructor {} +interface IInterfaceConstructor { +} class ClassInterfaceConstructor { - public $class; - public $test; - public function __construct(IInterfaceConstructor $class, $test) { - $this->class = $class; - $this->test = $test; - } + public $class; + public $test; + public function __construct(IInterfaceConstructor $class, $test) { + $this->class = $class; + $this->test = $test; + } } class SimpleContainerTest extends \Test\TestCase { - - - private $container; - - protected function setUp(): void { - $this->container = new SimpleContainer(); - } - - - public function testRegister() { - $this->container->registerParameter('test', 'abc'); - $this->assertEquals('abc', $this->container->query('test')); - } - - - - public function testNothingRegistered() { - $this->expectException(\OCP\AppFramework\QueryException::class); - - $this->container->query('something really hard'); - } - - - - public function testNotAClass() { - $this->expectException(\OCP\AppFramework\QueryException::class); - - $this->container->query('Test\AppFramework\Utility\TestInterface'); - } - - - public function testNoConstructorClass() { - $object = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); - $this->assertTrue($object instanceof ClassEmptyConstructor); - } - - - public function testInstancesOnlyOnce() { - $object = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); - $object2 = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); - $this->assertSame($object, $object2); - } - - public function testConstructorSimple() { - $this->container->registerParameter('test', 'abc'); - $object = $this->container->query( - 'Test\AppFramework\Utility\ClassSimpleConstructor' - ); - $this->assertTrue($object instanceof ClassSimpleConstructor); - $this->assertEquals('abc', $object->test); - } - - - public function testConstructorComplex() { - $this->container->registerParameter('test', 'abc'); - $object = $this->container->query( - 'Test\AppFramework\Utility\ClassComplexConstructor' - ); - $this->assertTrue($object instanceof ClassComplexConstructor); - $this->assertEquals('abc', $object->class->test); - $this->assertEquals('abc', $object->test); - } - - - public function testConstructorComplexInterface() { - $this->container->registerParameter('test', 'abc'); - $this->container->registerService( - 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { - return $c->query('Test\AppFramework\Utility\ClassSimpleConstructor'); - }); - $object = $this->container->query( - 'Test\AppFramework\Utility\ClassInterfaceConstructor' - ); - $this->assertTrue($object instanceof ClassInterfaceConstructor); - $this->assertEquals('abc', $object->class->test); - $this->assertEquals('abc', $object->test); - } - - - public function testOverrideService() { - $this->container->registerService( - 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { - return $c->query('Test\AppFramework\Utility\ClassSimpleConstructor'); - }); - $this->container->registerService( - 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { - return $c->query('Test\AppFramework\Utility\ClassEmptyConstructor'); - }); - $object = $this->container->query( - 'Test\AppFramework\Utility\IInterfaceConstructor' - ); - $this->assertTrue($object instanceof ClassEmptyConstructor); - } - - public function testRegisterAliasParamter() { - $this->container->registerParameter('test', 'abc'); - $this->container->registerAlias('test1', 'test'); - $this->assertEquals('abc', $this->container->query('test1')); - } - - public function testRegisterAliasService() { - $this->container->registerService('test', function() { - return new \StdClass; - }, true); - $this->container->registerAlias('test1', 'test'); - $this->assertSame( - $this->container->query('test'), $this->container->query('test')); - $this->assertSame( - $this->container->query('test1'), $this->container->query('test1')); - $this->assertSame( - $this->container->query('test'), $this->container->query('test1')); - } - - public function sanitizeNameProvider() { - return [ - ['ABC\\Foo', 'ABC\\Foo'], - ['\\ABC\\Foo', '\\ABC\\Foo'], - ['\\ABC\\Foo', 'ABC\\Foo'], - ['ABC\\Foo', '\\ABC\\Foo'], - ]; - } - - /** - * @dataProvider sanitizeNameProvider - */ - public function testSanitizeName($register, $query) { - $this->container->registerService($register, function() { - return 'abc'; - }); - $this->assertEquals('abc', $this->container->query($query)); - } - - - public function testConstructorComplexNoTestParameterFound() { - $this->expectException(\OCP\AppFramework\QueryException::class); - - $object = $this->container->query( - 'Test\AppFramework\Utility\ClassComplexConstructor' - ); - } - - public function testRegisterFactory() { - $this->container->registerService('test', function() { - return new \StdClass(); - }, false); - $this->assertNotSame( - $this->container->query('test'), $this->container->query('test')); - } - - public function testRegisterAliasFactory() { - $this->container->registerService('test', function() { - return new \StdClass(); - }, false); - $this->container->registerAlias('test1', 'test'); - $this->assertNotSame( - $this->container->query('test'), $this->container->query('test')); - $this->assertNotSame( - $this->container->query('test1'), $this->container->query('test1')); - $this->assertNotSame( - $this->container->query('test'), $this->container->query('test1')); - } - + private $container; + + protected function setUp(): void { + $this->container = new SimpleContainer(); + } + + + public function testRegister() { + $this->container->registerParameter('test', 'abc'); + $this->assertEquals('abc', $this->container->query('test')); + } + + + + public function testNothingRegistered() { + $this->expectException(\OCP\AppFramework\QueryException::class); + + $this->container->query('something really hard'); + } + + + + public function testNotAClass() { + $this->expectException(\OCP\AppFramework\QueryException::class); + + $this->container->query('Test\AppFramework\Utility\TestInterface'); + } + + + public function testNoConstructorClass() { + $object = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); + $this->assertTrue($object instanceof ClassEmptyConstructor); + } + + + public function testInstancesOnlyOnce() { + $object = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); + $object2 = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); + $this->assertSame($object, $object2); + } + + public function testConstructorSimple() { + $this->container->registerParameter('test', 'abc'); + $object = $this->container->query( + 'Test\AppFramework\Utility\ClassSimpleConstructor' + ); + $this->assertTrue($object instanceof ClassSimpleConstructor); + $this->assertEquals('abc', $object->test); + } + + + public function testConstructorComplex() { + $this->container->registerParameter('test', 'abc'); + $object = $this->container->query( + 'Test\AppFramework\Utility\ClassComplexConstructor' + ); + $this->assertTrue($object instanceof ClassComplexConstructor); + $this->assertEquals('abc', $object->class->test); + $this->assertEquals('abc', $object->test); + } + + + public function testConstructorComplexInterface() { + $this->container->registerParameter('test', 'abc'); + $this->container->registerService( + 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { + return $c->query('Test\AppFramework\Utility\ClassSimpleConstructor'); + }); + $object = $this->container->query( + 'Test\AppFramework\Utility\ClassInterfaceConstructor' + ); + $this->assertTrue($object instanceof ClassInterfaceConstructor); + $this->assertEquals('abc', $object->class->test); + $this->assertEquals('abc', $object->test); + } + + + public function testOverrideService() { + $this->container->registerService( + 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { + return $c->query('Test\AppFramework\Utility\ClassSimpleConstructor'); + }); + $this->container->registerService( + 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { + return $c->query('Test\AppFramework\Utility\ClassEmptyConstructor'); + }); + $object = $this->container->query( + 'Test\AppFramework\Utility\IInterfaceConstructor' + ); + $this->assertTrue($object instanceof ClassEmptyConstructor); + } + + public function testRegisterAliasParamter() { + $this->container->registerParameter('test', 'abc'); + $this->container->registerAlias('test1', 'test'); + $this->assertEquals('abc', $this->container->query('test1')); + } + + public function testRegisterAliasService() { + $this->container->registerService('test', function () { + return new \StdClass; + }, true); + $this->container->registerAlias('test1', 'test'); + $this->assertSame( + $this->container->query('test'), $this->container->query('test')); + $this->assertSame( + $this->container->query('test1'), $this->container->query('test1')); + $this->assertSame( + $this->container->query('test'), $this->container->query('test1')); + } + + public function sanitizeNameProvider() { + return [ + ['ABC\\Foo', 'ABC\\Foo'], + ['\\ABC\\Foo', '\\ABC\\Foo'], + ['\\ABC\\Foo', 'ABC\\Foo'], + ['ABC\\Foo', '\\ABC\\Foo'], + ]; + } + + /** + * @dataProvider sanitizeNameProvider + */ + public function testSanitizeName($register, $query) { + $this->container->registerService($register, function () { + return 'abc'; + }); + $this->assertEquals('abc', $this->container->query($query)); + } + + + public function testConstructorComplexNoTestParameterFound() { + $this->expectException(\OCP\AppFramework\QueryException::class); + + $object = $this->container->query( + 'Test\AppFramework\Utility\ClassComplexConstructor' + ); + } + + public function testRegisterFactory() { + $this->container->registerService('test', function () { + return new \StdClass(); + }, false); + $this->assertNotSame( + $this->container->query('test'), $this->container->query('test')); + } + + public function testRegisterAliasFactory() { + $this->container->registerService('test', function () { + return new \StdClass(); + }, false); + $this->container->registerAlias('test1', 'test'); + $this->assertNotSame( + $this->container->query('test'), $this->container->query('test')); + $this->assertNotSame( + $this->container->query('test1'), $this->container->query('test1')); + $this->assertNotSame( + $this->container->query('test'), $this->container->query('test1')); + } } diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 412db90849b..7ada4ec746a 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -20,253 +20,252 @@ use OCP\IAppConfig; * @group DB */ class AppTest extends \Test\TestCase { - - const TEST_USER1 = 'user1'; - const TEST_USER2 = 'user2'; - const TEST_USER3 = 'user3'; - const TEST_GROUP1 = 'group1'; - const TEST_GROUP2 = 'group2'; + public const TEST_USER1 = 'user1'; + public const TEST_USER2 = 'user2'; + public const TEST_USER3 = 'user3'; + public const TEST_GROUP1 = 'group1'; + public const TEST_GROUP2 = 'group2'; public function appVersionsProvider() { - return array( + return [ // exact match - array( + [ '6.0.0.0', - array( + [ 'requiremin' => '6.0', 'requiremax' => '6.0', - ), + ], true - ), + ], // in-between match - array( + [ '6.0.0.0', - array( + [ 'requiremin' => '5.0', 'requiremax' => '7.0', - ), + ], true - ), + ], // app too old - array( + [ '6.0.0.0', - array( + [ 'requiremin' => '5.0', 'requiremax' => '5.0', - ), + ], false - ), + ], // app too new - array( + [ '5.0.0.0', - array( + [ 'requiremin' => '6.0', 'requiremax' => '6.0', - ), + ], false - ), + ], // only min specified - array( + [ '6.0.0.0', - array( + [ 'requiremin' => '6.0', - ), + ], true - ), + ], // only min specified fail - array( + [ '5.0.0.0', - array( + [ 'requiremin' => '6.0', - ), + ], false - ), + ], // only min specified legacy - array( + [ '6.0.0.0', - array( + [ 'require' => '6.0', - ), + ], true - ), + ], // only min specified legacy fail - array( + [ '4.0.0.0', - array( + [ 'require' => '6.0', - ), + ], false - ), + ], // only max specified - array( + [ '5.0.0.0', - array( + [ 'requiremax' => '6.0', - ), + ], true - ), + ], // only max specified fail - array( + [ '7.0.0.0', - array( + [ 'requiremax' => '6.0', - ), + ], false - ), + ], // variations of versions // single OC number - array( + [ '4', - array( + [ 'require' => '4.0', - ), + ], true - ), + ], // multiple OC number - array( + [ '4.3.1', - array( + [ 'require' => '4.3', - ), + ], true - ), + ], // single app number - array( + [ '4', - array( + [ 'require' => '4', - ), + ], true - ), + ], // single app number fail - array( + [ '4.3', - array( + [ 'require' => '5', - ), + ], false - ), + ], // complex - array( + [ '5.0.0', - array( + [ 'require' => '4.5.1', - ), + ], true - ), + ], // complex fail - array( + [ '4.3.1', - array( + [ 'require' => '4.3.2', - ), + ], false - ), + ], // two numbers - array( + [ '4.3.1', - array( + [ 'require' => '4.4', - ), + ], false - ), + ], // one number fail - array( + [ '4.3.1', - array( + [ 'require' => '5', - ), + ], false - ), + ], // pre-alpha app - array( + [ '5.0.3', - array( + [ 'require' => '4.93', - ), + ], true - ), + ], // pre-alpha OC - array( + [ '6.90.0.2', - array( + [ 'require' => '6.90', - ), + ], true - ), + ], // pre-alpha OC max - array( + [ '6.90.0.2', - array( + [ 'requiremax' => '7', - ), + ], true - ), + ], // expect same major number match - array( + [ '5.0.3', - array( + [ 'require' => '5', - ), + ], true - ), + ], // expect same major number match - array( + [ '5.0.3', - array( + [ 'requiremax' => '5', - ), + ], true - ), + ], // dependencies versions before require* - array( + [ '6.0.0.0', - array( + [ 'requiremin' => '5.0', 'requiremax' => '7.0', - 'dependencies' => array( - 'owncloud' => array( - '@attributes' => array( + 'dependencies' => [ + 'owncloud' => [ + '@attributes' => [ 'min-version' => '7.0', 'max-version' => '7.0', - ), - ), - ), - ), + ], + ], + ], + ], false - ), - array( + ], + [ '6.0.0.0', - array( + [ 'requiremin' => '5.0', 'requiremax' => '7.0', - 'dependencies' => array( - 'owncloud' => array( - '@attributes' => array( + 'dependencies' => [ + 'owncloud' => [ + '@attributes' => [ 'min-version' => '5.0', 'max-version' => '5.0', - ), - ), - ), - ), + ], + ], + ], + ], false - ), - array( + ], + [ '6.0.0.0', - array( + [ 'requiremin' => '5.0', 'requiremax' => '5.0', - 'dependencies' => array( - 'owncloud' => array( - '@attributes' => array( + 'dependencies' => [ + 'owncloud' => [ + '@attributes' => [ 'min-version' => '5.0', 'max-version' => '7.0', - ), - ), - ), - ), + ], + ], + ], + ], true - ), + ], [ '9.2.0.0', [ @@ -301,7 +300,7 @@ class AppTest extends \Test\TestCase { ], true ], - ); + ]; } /** @@ -329,11 +328,11 @@ class AppTest extends \Test\TestCase { * Providers for the app config values */ public function appConfigValuesProvider() { - return array( + return [ // logged in user1 - array( + [ self::TEST_USER1, - array( + [ 'files', 'app1', 'app3', @@ -349,13 +348,13 @@ class AppTest extends \Test\TestCase { 'twofactor_backupcodes', 'viewer', 'workflowengine', - ), + ], false - ), + ], // logged in user2 - array( + [ self::TEST_USER2, - array( + [ 'files', 'app1', 'app3', @@ -371,13 +370,13 @@ class AppTest extends \Test\TestCase { 'twofactor_backupcodes', 'viewer', 'workflowengine', - ), + ], false - ), + ], // logged in user3 - array( + [ self::TEST_USER3, - array( + [ 'files', 'app1', 'app3', @@ -394,13 +393,13 @@ class AppTest extends \Test\TestCase { 'twofactor_backupcodes', 'viewer', 'workflowengine', - ), + ], false - ), + ], // no user, returns all apps - array( + [ null, - array( + [ 'files', 'app1', 'app3', @@ -417,13 +416,13 @@ class AppTest extends \Test\TestCase { 'twofactor_backupcodes', 'viewer', 'workflowengine', - ), + ], false, - ), + ], // user given, but ask for all - array( + [ self::TEST_USER1, - array( + [ 'files', 'app1', 'app3', @@ -440,10 +439,10 @@ class AppTest extends \Test\TestCase { 'twofactor_backupcodes', 'viewer', 'workflowengine', - ), + ], true, - ), - ); + ], + ]; } /** @@ -469,16 +468,16 @@ class AppTest extends \Test\TestCase { $this->setupAppConfigMock()->expects($this->once()) ->method('getValues') - ->will($this->returnValue( - array( + ->willReturn( + [ 'app3' => 'yes', 'app2' => 'no', 'app1' => 'yes', 'appforgroup1' => '["group1"]', 'appforgroup2' => '["group2"]', 'appforgroup12' => '["group2","group1"]', - ) - ) + ] + ); $apps = \OC_App::getEnabledApps(false, $forceAll); @@ -508,20 +507,20 @@ class AppTest extends \Test\TestCase { $this->setupAppConfigMock()->expects($this->once()) ->method('getValues') - ->will($this->returnValue( - array( + ->willReturn( + [ 'app3' => 'yes', 'app2' => 'no', - ) - ) + ] + ); $apps = \OC_App::getEnabledApps(); - $this->assertEquals(array('files', 'app3', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'provisioning_api', 'settings', 'twofactor_backupcodes', 'viewer', 'workflowengine'), $apps); + $this->assertEquals(['files', 'app3', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'provisioning_api', 'settings', 'twofactor_backupcodes', 'viewer', 'workflowengine'], $apps); // mock should not be called again here $apps = \OC_App::getEnabledApps(); - $this->assertEquals(array('files', 'app3', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'provisioning_api', 'settings', 'twofactor_backupcodes', 'viewer', 'workflowengine'), $apps); + $this->assertEquals(['files', 'app3', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'provisioning_api', 'settings', 'twofactor_backupcodes', 'viewer', 'workflowengine'], $apps); $this->restoreAppConfig(); \OC_User::setUserId(null); diff --git a/tests/lib/Archive/TARTest.php b/tests/lib/Archive/TARTest.php index 77df1c32ca4..6b16f061623 100644 --- a/tests/lib/Archive/TARTest.php +++ b/tests/lib/Archive/TARTest.php @@ -8,7 +8,6 @@ namespace Test\Archive; - use OC\Archive\TAR; class TARTest extends TestBase { diff --git a/tests/lib/Archive/TestBase.php b/tests/lib/Archive/TestBase.php index bdfe65d4304..a9a41ed36ba 100644 --- a/tests/lib/Archive/TestBase.php +++ b/tests/lib/Archive/TestBase.php @@ -8,7 +8,6 @@ namespace Test\Archive; - abstract class TestBase extends \Test\TestCase { /** * @var \OC\Archive\Archive @@ -29,25 +28,25 @@ abstract class TestBase extends \Test\TestCase { public function testGetFiles() { $this->instance=$this->getExisting(); $allFiles=$this->instance->getFiles(); - $expected=array('lorem.txt','logo-wide.png','dir/', 'dir/lorem.txt'); + $expected=['lorem.txt','logo-wide.png','dir/', 'dir/lorem.txt']; $this->assertEquals(4, count($allFiles), 'only found '.count($allFiles).' out of 4 expected files'); - foreach($expected as $file) { + foreach ($expected as $file) { $this->assertContains($file, $allFiles, 'cant find '. $file . ' in archive'); $this->assertTrue($this->instance->fileExists($file), 'file '.$file.' does not exist in archive'); } $this->assertFalse($this->instance->fileExists('non/existing/file')); $rootContent=$this->instance->getFolder(''); - $expected=array('lorem.txt','logo-wide.png', 'dir/'); + $expected=['lorem.txt','logo-wide.png', 'dir/']; $this->assertEquals(3, count($rootContent)); - foreach($expected as $file) { + foreach ($expected as $file) { $this->assertContains($file, $rootContent, 'cant find '. $file . ' in archive'); } $dirContent=$this->instance->getFolder('dir/'); - $expected=array('lorem.txt'); + $expected=['lorem.txt']; $this->assertEquals(1, count($dirContent)); - foreach($expected as $file) { + foreach ($expected as $file) { $this->assertContains($file, $dirContent, 'cant find '. $file . ' in archive'); } } diff --git a/tests/lib/Archive/ZIPTest.php b/tests/lib/Archive/ZIPTest.php index 573339e5a19..17a639c9f5f 100644 --- a/tests/lib/Archive/ZIPTest.php +++ b/tests/lib/Archive/ZIPTest.php @@ -8,7 +8,6 @@ namespace Test\Archive; - use OC\Archive\ZIP; class ZIPTest extends TestBase { diff --git a/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php b/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php index 49e9e79462f..f28f0ef78bb 100644 --- a/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php +++ b/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -28,12 +30,10 @@ use OC\Authentication\Token\IToken; use Test\TestCase; class RemoteWipeFinishedTest extends TestCase { - public function testGetToken() { $token = $this->createMock(IToken::class); $event = new RemoteWipeFinished($token); $this->assertSame($token, $event->getToken()); } - } diff --git a/tests/lib/Authentication/Events/RemoteWipeStartedTest.php b/tests/lib/Authentication/Events/RemoteWipeStartedTest.php index 8fbaa086656..d6b0ef7019e 100644 --- a/tests/lib/Authentication/Events/RemoteWipeStartedTest.php +++ b/tests/lib/Authentication/Events/RemoteWipeStartedTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -28,12 +30,10 @@ use OC\Authentication\Token\IToken; use Test\TestCase; class RemoteWipeStartedTest extends TestCase { - public function testGetToken() { $token = $this->createMock(IToken::class); $event = new RemoteWipeStarted($token); $this->assertSame($token, $event->getToken()); } - } diff --git a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php index 47d1d53a74c..05d38380026 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -32,7 +34,6 @@ use OCP\Activity\IManager as IActivityManager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\ILogger; -use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -150,5 +151,4 @@ class RemoteWipeActivityListenerTests extends TestCase { $this->listener->handle($event); } - } diff --git a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php index 3d47b8d4a03..9d2319fb9cc 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -237,5 +239,4 @@ class RemoteWipeEmailListenerTest extends TestCase { $this->listener->handle($event); } - } diff --git a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php index 79d362410ae..1e03a344404 100644 --- a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php +++ b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -146,5 +148,4 @@ class RemoteWipeNotificationListenerTests extends TestCase { $this->listener->handle($event); } - } diff --git a/tests/lib/Authentication/Login/ALoginCommandTest.php b/tests/lib/Authentication/Login/ALoginCommandTest.php index f09b649ffcb..03cc7dfadc7 100644 --- a/tests/lib/Authentication/Login/ALoginCommandTest.php +++ b/tests/lib/Authentication/Login/ALoginCommandTest.php @@ -118,5 +118,4 @@ abstract class ALoginCommandTest extends TestCase { $data->setUser($this->user); return $data; } - } diff --git a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php index 0d3b7acfa2d..49c81b4f385 100644 --- a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php +++ b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php @@ -27,7 +27,6 @@ namespace Test\Authentication\Login; use lib\Authentication\Login\ALoginCommandTest; use OC\Authentication\Login\ClearLostPasswordTokensCommand; -use OC\Authentication\Login\LoginData; use OCP\IConfig; use PHPUnit\Framework\MockObject\MockObject; @@ -63,5 +62,4 @@ class ClearLostPasswordTokensCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); } - } diff --git a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php index e611611dd7c..7d6152f97a1 100644 --- a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php +++ b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php @@ -62,6 +62,4 @@ class CompleteLoginCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); } - - } diff --git a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php index 82ae90015a4..9e49413e344 100644 --- a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php +++ b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php @@ -117,5 +117,4 @@ class CreateSessionTokenCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); $this->assertFalse($data->isRememberLogin()); } - } diff --git a/tests/lib/Authentication/Login/EmailLoginCommandTest.php b/tests/lib/Authentication/Login/EmailLoginCommandTest.php index 5217a4d0080..4c1f0bd0e5b 100644 --- a/tests/lib/Authentication/Login/EmailLoginCommandTest.php +++ b/tests/lib/Authentication/Login/EmailLoginCommandTest.php @@ -161,5 +161,4 @@ class EmailLoginCommandTest extends ALoginCommandTest { $this->assertEquals($emailUser, $data->getUser()); $this->assertEquals('user2', $data->getUsername()); } - } diff --git a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php index 9cb3734922e..7b461219456 100644 --- a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php +++ b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php @@ -27,20 +27,25 @@ namespace lib\Authentication\Login; use OC\Authentication\Login\FinishRememberedLoginCommand; use OC\User\Session; +use OCP\IConfig; use PHPUnit\Framework\MockObject\MockObject; class FinishRememberedLoginCommandTest extends ALoginCommandTest { /** @var Session|MockObject */ private $userSession; + /** @var IConfig|MockObject */ + private $config; protected function setUp(): void { parent::setUp(); $this->userSession = $this->createMock(Session::class); + $this->config = $this->createMock(IConfig::class); $this->cmd = new FinishRememberedLoginCommand( - $this->userSession + $this->userSession, + $this->config ); } @@ -57,6 +62,10 @@ class FinishRememberedLoginCommandTest extends ALoginCommandTest { public function testProcess() { $data = $this->getLoggedInLoginData(); + $this->config->expects($this->once()) + ->method('getSystemValue') + ->with('auto_logout', false) + ->willReturn(false); $this->userSession->expects($this->once()) ->method('createRememberMeToken') ->with($this->user); @@ -66,4 +75,17 @@ class FinishRememberedLoginCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); } + public function testProcessNotRemeberedLoginWithAutologout() { + $data = $this->getLoggedInLoginData(); + $this->config->expects($this->once()) + ->method('getSystemValue') + ->with('auto_logout', false) + ->willReturn(true); + $this->userSession->expects($this->never()) + ->method('createRememberMeToken'); + + $result = $this->cmd->process($data); + + $this->assertTrue($result->isSuccess()); + } } diff --git a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php index 3b18c97a612..18f4a4938e8 100644 --- a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php +++ b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php @@ -27,6 +27,7 @@ namespace lib\Authentication\Login; use OC\Authentication\Login\LoggedInCheckCommand; use OC\Core\Controller\LoginController; +use OCP\EventDispatcher\IEventDispatcher; use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; @@ -35,13 +36,18 @@ class LoggedInCheckCommandTest extends ALoginCommandTest { /** @var ILogger|MockObject */ private $logger; + /** @var IEventDispatcher|MockObject */ + private $dispatcher; + protected function setUp(): void { parent::setUp(); $this->logger = $this->createMock(ILogger::class); + $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->cmd = new LoggedInCheckCommand( - $this->logger + $this->logger, + $this->dispatcher ); } @@ -63,5 +69,4 @@ class LoggedInCheckCommandTest extends ALoginCommandTest { $this->assertFalse($result->isSuccess()); $this->assertSame(LoginController::LOGIN_MSG_INVALIDPASSWORD, $result->getErrorMessage()); } - } diff --git a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php index c067899ffc2..66822291ba8 100644 --- a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php +++ b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php @@ -62,5 +62,4 @@ class PreLoginHookCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); } - } diff --git a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php index 14da73b93fa..88514fec237 100644 --- a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php +++ b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php @@ -86,5 +86,4 @@ class SetUserTimezoneCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); } - } diff --git a/tests/lib/Authentication/Login/TwoFactorCommandTest.php b/tests/lib/Authentication/Login/TwoFactorCommandTest.php index 3e8ad142cc1..4796aecad2e 100644 --- a/tests/lib/Authentication/Login/TwoFactorCommandTest.php +++ b/tests/lib/Authentication/Login/TwoFactorCommandTest.php @@ -355,5 +355,4 @@ class TwoFactorCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); $this->assertEquals('two/factor/url', $result->getRedirectUrl()); } - } diff --git a/tests/lib/Authentication/Login/UidLoginCommandTest.php b/tests/lib/Authentication/Login/UidLoginCommandTest.php index c4dd3f10381..6e22609631d 100644 --- a/tests/lib/Authentication/Login/UidLoginCommandTest.php +++ b/tests/lib/Authentication/Login/UidLoginCommandTest.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace lib\Authentication\Login; -use OC\Authentication\Login\UidCheckCommand; use OC\Authentication\Login\UidLoginCommand; use OC\User\Manager; use PHPUnit\Framework\MockObject\MockObject; @@ -76,5 +75,4 @@ class UidLoginCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); $this->assertEquals($this->user, $data->getUser()); } - } diff --git a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php index b66ecdde3c4..3db23d471ec 100644 --- a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php +++ b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php @@ -60,5 +60,4 @@ class UpdateLastPasswordConfirmCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); } - } diff --git a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php index 2a2f23162bf..e6f619aac0f 100644 --- a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php +++ b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php @@ -93,5 +93,4 @@ class UserDisabledCheckCommandTest extends ALoginCommandTest { $this->assertTrue($result->isSuccess()); } - } diff --git a/tests/lib/Authentication/LoginCredentials/CredentialsTest.php b/tests/lib/Authentication/LoginCredentials/CredentialsTest.php index 263db1bbb5b..d3dcd9f4d6b 100644 --- a/tests/lib/Authentication/LoginCredentials/CredentialsTest.php +++ b/tests/lib/Authentication/LoginCredentials/CredentialsTest.php @@ -62,5 +62,4 @@ class CredentialsTest extends TestCase { public function testGetPassword() { $this->assertEquals($this->password, $this->credentials->getPassword()); } - } diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php index b75e1498889..e7b9cb5996f 100644 --- a/tests/lib/Authentication/LoginCredentials/StoreTest.php +++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php @@ -179,5 +179,4 @@ class StoreTest extends TestCase { $this->store->getLoginCredentials(); } - } diff --git a/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php b/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php index e4bc13fe5fb..0991c8b1fc8 100644 --- a/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php @@ -49,5 +49,4 @@ class DefaultTokenCleanupJobTest extends TestCase { ->with(); $this->invokePrivate($this->job, 'run', [null]); } - } diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php index 7060dc2a770..855e90ab6b9 100644 --- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php @@ -230,5 +230,4 @@ class DefaultTokenMapperTest extends TestCase { $this->mapper->deleteByName($name); $this->assertEquals(2, $this->getNumberOfTokens()); } - } diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php index b4e5e097847..d95e4c0418d 100644 --- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php @@ -64,7 +64,7 @@ class DefaultTokenProviderTest extends TestCase { $this->time = 1313131; $this->timeFactory->expects($this->any()) ->method('getTime') - ->will($this->returnValue($this->time)); + ->willReturn($this->time); $this->tokenProvider = new DefaultTokenProvider($this->mapper, $this->crypto, $this->config, $this->logger, $this->timeFactory); @@ -96,11 +96,11 @@ class DefaultTokenProviderTest extends TestCase { $this->config->expects($this->any()) ->method('getSystemValue') ->with('secret') - ->will($this->returnValue('1f4h9s')); + ->willReturn('1f4h9s'); $this->crypto->expects($this->once()) ->method('encrypt') ->with($password, $token . '1f4h9s') - ->will($this->returnValue('encryptedpassword')); + ->willReturn('encryptedpassword'); $this->mapper->expects($this->once()) ->method('insert') ->with($this->equalTo($toInsert)); @@ -136,7 +136,7 @@ class DefaultTokenProviderTest extends TestCase { $this->mapper->expects($this->once()) ->method('getTokenByUser') ->with('uid') - ->will($this->returnValue(['token'])); + ->willReturn(['token']); $this->assertEquals(['token'], $this->tokenProvider->getTokenByUser('uid')); } @@ -148,11 +148,11 @@ class DefaultTokenProviderTest extends TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('secret') - ->will($this->returnValue('1f4h9s')); + ->willReturn('1f4h9s'); $this->crypto->expects($this->once()) ->method('decrypt') ->with('someencryptedvalue', $token . '1f4h9s') - ->will($this->returnValue('passme')); + ->willReturn('passme'); $actual = $this->tokenProvider->getPassword($tk, $token); @@ -188,7 +188,7 @@ class DefaultTokenProviderTest extends TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('secret') - ->will($this->returnValue('1f4h9s')); + ->willReturn('1f4h9s'); $this->crypto->expects($this->once()) ->method('decrypt') ->with('someencryptedvalue', $token . '1f4h9s') @@ -208,11 +208,11 @@ class DefaultTokenProviderTest extends TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('secret') - ->will($this->returnValue('ocsecret')); + ->willReturn('ocsecret'); $this->crypto->expects($this->once()) ->method('encrypt') ->with($password, $tokenId . 'ocsecret') - ->will($this->returnValue('encryptedpassword')); + ->willReturn('encryptedpassword'); $this->mapper->expects($this->once()) ->method('update') ->with($token); @@ -256,10 +256,10 @@ class DefaultTokenProviderTest extends TestCase { $defaultRememberMeLifetime = 60 * 60 * 24 * 15; $this->config->expects($this->exactly(2)) ->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['session_lifetime', $defaultSessionLifetime, 150], ['remember_login_cookie_lifetime', $defaultRememberMeLifetime, 300], - ])); + ]); $this->mapper->expects($this->at(0)) ->method('invalidateOld') ->with($this->time - 150); @@ -449,7 +449,6 @@ class DefaultTokenProviderTest extends TestCase { } catch (ExpiredTokenException $e) { $this->assertSame($token, $e->getToken()); } - } public function testGetTokenById() { diff --git a/tests/lib/Authentication/Token/ManagerTest.php b/tests/lib/Authentication/Token/ManagerTest.php index 6f64424364e..fb92b3e5018 100644 --- a/tests/lib/Authentication/Token/ManagerTest.php +++ b/tests/lib/Authentication/Token/ManagerTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl> @@ -29,7 +31,6 @@ use OC\Authentication\Exceptions\InvalidTokenException; use OC\Authentication\Exceptions\PasswordlessTokenException; use OC\Authentication\Token\DefaultToken; use OC\Authentication\Token\DefaultTokenProvider; -use OC\Authentication\Token\ExpiredTokenException; use OC\Authentication\Token\IToken; use OC\Authentication\Token\Manager; use OC\Authentication\Token\PublicKeyToken; diff --git a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php index 58340b905c0..5ba7fe7c40e 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl> @@ -265,5 +266,4 @@ class PublicKeyTokenMapperTest extends TestCase { $this->assertFalse($this->mapper->hasExpiredTokens('user1')); $this->assertTrue($this->mapper->hasExpiredTokens('user3')); } - } diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index 3fa7a92bb9b..43ae0e9542c 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -61,12 +61,12 @@ class PublicKeyTokenProviderTest extends TestCase { $this->crypto = \OC::$server->getCrypto(); $this->config = $this->createMock(IConfig::class); $this->config->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['session_lifetime', 60 * 60 * 24, 150], ['remember_login_cookie_lifetime', 60 * 60 * 24 * 15, 300], ['secret', '', '1f4h9s'], ['openssl', [], []], - ])); + ]); $this->logger = $this->createMock(ILogger::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->time = 1313131; @@ -124,7 +124,7 @@ class PublicKeyTokenProviderTest extends TestCase { $this->mapper->expects($this->once()) ->method('getTokenByUser') ->with('uid') - ->will($this->returnValue(['token'])); + ->willReturn(['token']); $this->assertEquals(['token'], $this->tokenProvider->getTokenByUser('uid')); } @@ -239,10 +239,10 @@ class PublicKeyTokenProviderTest extends TestCase { $defaultRememberMeLifetime = 60 * 60 * 24 * 15; $this->config->expects($this->exactly(2)) ->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['session_lifetime', $defaultSessionLifetime, 150], ['remember_login_cookie_lifetime', $defaultRememberMeLifetime, 300], - ])); + ]); $this->mapper->expects($this->at(0)) ->method('invalidateOld') ->with($this->time - 150); @@ -285,7 +285,7 @@ class PublicKeyTokenProviderTest extends TestCase { $this->mapper ->expects($this->at(2)) ->method('delete') - ->with($this->callback(function($token) use ($oldToken) { + ->with($this->callback(function ($token) use ($oldToken) { return $token === $oldToken; })); @@ -325,7 +325,7 @@ class PublicKeyTokenProviderTest extends TestCase { $this->mapper ->expects($this->at(2)) ->method('delete') - ->with($this->callback(function($token) use ($oldToken) { + ->with($this->callback(function ($token) use ($oldToken) { return $token === $oldToken; })); @@ -389,7 +389,6 @@ class PublicKeyTokenProviderTest extends TestCase { } catch (ExpiredTokenException $e) { $this->assertSame($actual, $e->getToken()); } - } public function testGetTokenById() { diff --git a/tests/lib/Authentication/Token/PublicKeyTokenTest.php b/tests/lib/Authentication/Token/PublicKeyTokenTest.php index d0226eb9902..35c2e0ece39 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl> diff --git a/tests/lib/Authentication/Token/RemoteWipeTest.php b/tests/lib/Authentication/Token/RemoteWipeTest.php index 2ca49d36159..1338931ac72 100644 --- a/tests/lib/Authentication/Token/RemoteWipeTest.php +++ b/tests/lib/Authentication/Token/RemoteWipeTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -67,30 +69,20 @@ class RemoteWipeTest extends TestCase { public function testMarkNonWipableTokenForWipe(): void { $token = $this->createMock(IToken::class); - $this->tokenProvider->expects($this->once()) - ->method('getTokenById') - ->with(123) - ->willReturn($token); - - $result = $this->remoteWipe->markTokenForWipe(123); - + $result = $this->remoteWipe->markTokenForWipe($token); $this->assertFalse($result); } public function testMarkTokenForWipe(): void { $token = $this->createMock(IWipeableToken::class); - $this->tokenProvider->expects($this->once()) - ->method('getTokenById') - ->with(123) - ->willReturn($token); $token->expects($this->once()) ->method('wipe'); + $this->tokenProvider->expects($this->once()) ->method('updateToken') ->with($token); - $result = $this->remoteWipe->markTokenForWipe(123); - + $result = $this->remoteWipe->markTokenForWipe($token); $this->assertTrue($result); } @@ -195,5 +187,4 @@ class RemoteWipeTest extends TestCase { $this->assertTrue($result); } - } diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php index 9be2e64e980..1a21ee047df 100644 --- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -158,5 +159,4 @@ class ProviderUserAssignmentDaoTest extends TestCase { $this->assertCount(1, $statesUser1); $this->assertCount(0, $statesUser2); } - } diff --git a/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php index 0508c84787c..f8c4be09a6f 100644 --- a/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php @@ -33,7 +33,6 @@ use OC\Authentication\TwoFactorAuth\EnforcementState; use Test\TestCase; class EnforcementStateTest extends TestCase { - public function testIsEnforced() { $state = new EnforcementState(true); diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php index 63d0e993f3b..051f2936ad7 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php @@ -22,7 +22,6 @@ namespace Test\Authentication\TwoFactorAuth; -use Exception; use OC; use OC\Authentication\Token\IProvider as TokenProvider; use OC\Authentication\TwoFactorAuth\Manager; @@ -126,7 +125,7 @@ class ManagerTest extends TestCase { private function prepareNoProviders() { $this->providerLoader->method('getProviders') ->with($this->user) - ->will($this->returnValue([])); + ->willReturn([]); } private function prepareProviders() { @@ -366,11 +365,11 @@ class ManagerTest extends TestCase { $this->fakeProvider->expects($this->once()) ->method('verifyChallenge') ->with($this->user, $challenge) - ->will($this->returnValue(true)); + ->willReturn(true); $this->session->expects($this->once()) ->method('get') ->with('two_factor_remember_login') - ->will($this->returnValue(false)); + ->willReturn(false); $this->session->expects($this->at(1)) ->method('remove') ->with('two_factor_auth_uid'); @@ -449,7 +448,7 @@ class ManagerTest extends TestCase { $this->fakeProvider->expects($this->once()) ->method('verifyChallenge') ->with($this->user, $challenge) - ->will($this->returnValue(false)); + ->willReturn(false); $this->session->expects($this->never()) ->method('remove'); $this->activityManager->expects($this->once()) @@ -496,7 +495,7 @@ class ManagerTest extends TestCase { $this->session->expects($this->at(1)) ->method('exists') ->with('two_factor_auth_uid') - ->will($this->returnValue(false)); + ->willReturn(false); $this->session->expects($this->at(2)) ->method('exists') ->with(Manager::SESSION_UID_DONE) @@ -557,7 +556,7 @@ class ManagerTest extends TestCase { $this->session->expects($this->never()) ->method('exists') ->with('two_factor_auth_uid') - ->will($this->returnValue(true)); + ->willReturn(true); $this->session->expects($this->never()) ->method('remove') ->with('two_factor_auth_uid'); @@ -567,7 +566,7 @@ class ManagerTest extends TestCase { public function testPrepareTwoFactorLogin() { $this->user->method('getUID') - ->will($this->returnValue('ferdinand')); + ->willReturn('ferdinand'); $this->session->expects($this->at(0)) ->method('set') @@ -597,7 +596,7 @@ class ManagerTest extends TestCase { public function testPrepareTwoFactorLoginDontRemember() { $this->user->method('getUID') - ->will($this->returnValue('ferdinand')); + ->willReturn('ferdinand'); $this->session->expects($this->at(0)) ->method('set') @@ -630,14 +629,14 @@ class ManagerTest extends TestCase { ->willReturn('user'); $this->session->method('exists') - ->will($this->returnCallback(function ($var) { + ->willReturnCallback(function ($var) { if ($var === Manager::SESSION_UID_KEY) { return false; - } else if ($var === 'app_password') { + } elseif ($var === 'app_password') { return false; } return true; - })); + }); $this->session->expects($this->once()) ->method('get') ->with(Manager::SESSION_UID_DONE) diff --git a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php index 92d072608f2..5147d763daf 100644 --- a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php @@ -109,7 +109,7 @@ class MandatoryTwoFactorTest extends TestCase { ['twofactor_enforced_excluded_groups', [], []], ]); $this->groupManager->method('isInGroup') - ->willReturnCallback(function($user, $group) { + ->willReturnCallback(function ($user, $group) { return $user === 'user123' && $group ==='twofactorers'; }); @@ -147,7 +147,7 @@ class MandatoryTwoFactorTest extends TestCase { ['twofactor_enforced_excluded_groups', [], ['yoloers']], ]); $this->groupManager->method('isInGroup') - ->willReturnCallback(function($user, $group) { + ->willReturnCallback(function ($user, $group) { return $user === 'user123' && $group ==='yoloers'; }); @@ -194,5 +194,4 @@ class MandatoryTwoFactorTest extends TestCase { $this->mandatoryTwoFactor->setState(new EnforcementState(false)); } - } diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php index f3762976837..b77bddcd5a4 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -25,7 +26,6 @@ declare(strict_types=1); namespace lib\Authentication\TwoFactorAuth; -use Exception; use OC\Authentication\TwoFactorAuth\ProviderLoader; use OCP\App\IAppManager; use OCP\Authentication\TwoFactorAuth\IProvider; @@ -63,14 +63,14 @@ class ProviderLoaderTest extends TestCase { ->willReturn(['mail', 'twofactor_totp']); $this->appManager ->method('getAppInfo') - ->will($this->returnValueMap([ + ->willReturnMap([ ['mail', false, null, []], ['twofactor_totp', false, null, [ 'two-factor-providers' => [ '\\OCA\\MyFaulty2faApp\\DoesNotExist', ], ]], - ])); + ]); $this->loader->getProviders($this->user); } @@ -98,5 +98,4 @@ class ProviderLoaderTest extends TestCase { $this->assertArrayHasKey('test', $providers); $this->assertSame($provider, $providers['test']); } - } diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php index e34d844c3a4..0c85d0cf1ba 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php @@ -150,5 +150,4 @@ class ProviderManagerTest extends TestCase { $this->assertTrue($res); } - } diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php index f294e40111d..ef221851894 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** @@ -89,5 +90,4 @@ class ProviderSetTest extends TestCase { $this->assertTrue($set->isProviderMissing()); } - } diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php index 90fc4a9d27a..49f4eaa7020 100644 --- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at> @@ -79,7 +81,7 @@ class RegistryTest extends TestCase { ->method('dispatch') ->with( $this->equalTo(IRegistry::EVENT_PROVIDER_ENABLED), - $this->callback(function(RegistryEvent $e) use ($user, $provider) { + $this->callback(function (RegistryEvent $e) use ($user, $provider) { return $e->getUser() === $user && $e->getProvider() === $provider; }) ); @@ -100,7 +102,7 @@ class RegistryTest extends TestCase { ->method('dispatch') ->with( $this->equalTo(IRegistry::EVENT_PROVIDER_DISABLED), - $this->callback(function(RegistryEvent $e) use ($user, $provider) { + $this->callback(function (RegistryEvent $e) use ($user, $provider) { return $e->getUser() === $user && $e->getProvider() === $provider; }) ); @@ -125,5 +127,4 @@ class RegistryTest extends TestCase { $this->registry->cleanUp('twofactor_u2f'); } - } diff --git a/tests/lib/AutoLoaderTest.php b/tests/lib/AutoLoaderTest.php index b3ca21a90d4..24eaa367435 100644 --- a/tests/lib/AutoLoaderTest.php +++ b/tests/lib/AutoLoaderTest.php @@ -21,7 +21,7 @@ class AutoLoaderTest extends TestCase { public function testLegacyPath() { $this->assertEquals([ - \OC::$SERVERROOT . '/lib/private/legacy/files.php', + \OC::$SERVERROOT . '/lib/private/legacy/files.php', ], $this->loader->findClass('OC_Files')); } @@ -33,7 +33,7 @@ class AutoLoaderTest extends TestCase { public function testLoadCore() { $this->assertEquals([ - \OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php', + \OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php', ], $this->loader->findClass('OC_Foo_Bar')); } diff --git a/tests/lib/Avatar/GuestAvatarTest.php b/tests/lib/Avatar/GuestAvatarTest.php index 0d13655133b..1c424234f10 100644 --- a/tests/lib/Avatar/GuestAvatarTest.php +++ b/tests/lib/Avatar/GuestAvatarTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php index 43e325b0941..e3e0bd1d64e 100644 --- a/tests/lib/Avatar/UserAvatarTest.php +++ b/tests/lib/Avatar/UserAvatarTest.php @@ -57,20 +57,20 @@ class UserAvatarTest extends \Test\TestCase { ->willReturn($file); $this->folder->method('getFile') - ->will($this->returnCallback(function($path) { + ->willReturnCallback(function ($path) { if ($path === 'avatar.64.png') { throw new NotFoundException(); } - })); + }); $this->folder->method('fileExists') - ->will($this->returnCallback(function($path) { + ->willReturnCallback(function ($path) { if ($path === 'generated') { return true; } return false; - })); + }); - $data = NULL; + $data = null; $file->method('putContent') ->with($this->callback(function ($d) use (&$data) { $data = $d; @@ -85,10 +85,10 @@ class UserAvatarTest extends \Test\TestCase { public function testGetAvatarSizeMatch() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', true], ['avatar.128.jpg', true], - ])); + ]); $expected = new \OC_Image(); $expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png'); @@ -102,9 +102,9 @@ class UserAvatarTest extends \Test\TestCase { public function testGetAvatarSizeMinusOne() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', true], - ])); + ]); $expected = new \OC_Image(); $expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png'); @@ -118,10 +118,10 @@ class UserAvatarTest extends \Test\TestCase { public function testGetAvatarNoSizeMatch() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.png', true], ['avatar.32.png', false], - ])); + ]); $expected = new \OC_Image(); $expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png'); @@ -133,15 +133,15 @@ class UserAvatarTest extends \Test\TestCase { $file->method('getContent')->willReturn($expected->data()); $this->folder->method('getFile') - ->will($this->returnCallback( - function($path) use ($file) { + ->willReturnCallback( + function ($path) use ($file) { if ($path === 'avatar.png') { return $file; } else { throw new \OCP\Files\NotFoundException; } } - )); + ); $newFile = $this->createMock(File::class); $newFile->expects($this->once()) @@ -164,19 +164,19 @@ class UserAvatarTest extends \Test\TestCase { public function testExiststJPG() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', true], ['avatar.png', false], - ])); + ]); $this->assertTrue($this->avatar->exists()); } public function testExistsPNG() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', false], ['avatar.png', true], - ])); + ]); $this->assertTrue($this->avatar->exists()); } @@ -259,7 +259,7 @@ class UserAvatarTest extends \Test\TestCase { $colorTo = new \OC\Color(6,12,18); $steps = 6; $palette = $this->invokePrivate($this->avatar, 'mixPalette', [$steps, $colorFrom, $colorTo]); - foreach($palette as $j => $color) { + foreach ($palette as $j => $color) { // calc increment $incR = $colorTo->r / $steps * $j; $incG = $colorTo->g / $steps * $j; @@ -271,18 +271,16 @@ class UserAvatarTest extends \Test\TestCase { $this->assertTrue(gettype($hashToInt) === 'integer'); } - private function getUserWithDisplayName($name) - { + private function getUserWithDisplayName($name) { $user = $this->createMock(User::class); $user->method('getDisplayName')->willReturn($name); return $user; } - private function getUserAvatar($user) - { + private function getUserAvatar($user) { /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */ $l = $this->createMock(IL10N::class); - $l->method('t')->will($this->returnArgument(0)); + $l->method('t')->willReturnArgument(0); return new \OC\Avatar\UserAvatar( $this->folder, @@ -292,5 +290,4 @@ class UserAvatarTest extends \Test\TestCase { $this->config ); } - } diff --git a/tests/lib/BackgroundJob/DummyJobList.php b/tests/lib/BackgroundJob/DummyJobList.php index fe8ca5aefe2..529e93e960f 100644 --- a/tests/lib/BackgroundJob/DummyJobList.php +++ b/tests/lib/BackgroundJob/DummyJobList.php @@ -7,6 +7,7 @@ */ namespace Test\BackgroundJob; + use OCP\BackgroundJob\IJob; /** @@ -18,7 +19,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList { /** * @var IJob[] */ - private $jobs = array(); + private $jobs = []; private $last = 0; diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php index 7e099b23d06..3013afdfa1d 100644 --- a/tests/lib/BackgroundJob/JobListTest.php +++ b/tests/lib/BackgroundJob/JobListTest.php @@ -64,16 +64,16 @@ class JobListTest extends TestCase { } public function argumentProvider() { - return array( - array(null), - array(false), - array('foobar'), - array(12), - array(array( + return [ + [null], + [false], + ['foobar'], + [12], + [[ 'asd' => 5, 'foo' => 'bar' - )) - ); + ]] + ]; } /** @@ -150,7 +150,7 @@ class JobListTest extends TestCase { $this->config->expects($this->once()) ->method('getAppValue') ->with('backgroundjob', 'lastjob', 0) - ->will($this->returnValue(15)); + ->willReturn(15); $this->assertEquals(15, $this->instance->getLastJob()); } diff --git a/tests/lib/BackgroundJob/TestJob.php b/tests/lib/BackgroundJob/TestJob.php index a5ab4454550..e15c7e86c99 100644 --- a/tests/lib/BackgroundJob/TestJob.php +++ b/tests/lib/BackgroundJob/TestJob.php @@ -8,7 +8,6 @@ namespace Test\BackgroundJob; - class TestJob extends \OC\BackgroundJob\Job { private $testCase; diff --git a/tests/lib/Cache/CappedMemoryCacheTest.php b/tests/lib/Cache/CappedMemoryCacheTest.php index 00231004fe5..db0d2bd1193 100644 --- a/tests/lib/Cache/CappedMemoryCacheTest.php +++ b/tests/lib/Cache/CappedMemoryCacheTest.php @@ -49,7 +49,7 @@ class CappedMemoryCacheTest extends TestCache { $this->assertTrue($instance->hasKey('5')); } - function testClear() { + public function testClear() { $value = 'ipsum lorum'; $this->instance->set('1_value1', $value); $this->instance->set('1_value2', $value); @@ -63,7 +63,7 @@ class CappedMemoryCacheTest extends TestCache { $this->assertFalse($this->instance->hasKey('3_value1')); } - function testIndirectSet() { + public function testIndirectSet() { $this->instance->set('array', []); $this->instance['array'][] = 'foo'; diff --git a/tests/lib/Cache/FileCacheTest.php b/tests/lib/Cache/FileCacheTest.php index 450bdf607b3..1a28724ae12 100644 --- a/tests/lib/Cache/FileCacheTest.php +++ b/tests/lib/Cache/FileCacheTest.php @@ -21,6 +21,7 @@ */ namespace Test\Cache; + use OC\Files\Storage\Local; /** @@ -48,7 +49,7 @@ class FileCacheTest extends TestCache { * */ private $rootView; - function skip() { + public function skip() { //$this->skipUnless(OC_User::isLoggedIn()); } @@ -61,8 +62,8 @@ class FileCacheTest extends TestCache { //set up temporary storage $this->storage = \OC\Files\Filesystem::getStorage('/'); \OC\Files\Filesystem::clearMounts(); - $storage = new \OC\Files\Storage\Temporary(array()); - \OC\Files\Filesystem::mount($storage,array(),'/'); + $storage = new \OC\Files\Storage\Temporary([]); + \OC\Files\Filesystem::mount($storage,[],'/'); $datadir = str_replace('local::', '', $storage->getId()); $config = \OC::$server->getConfig(); $this->datadir = $config->getSystemValue('cachedirectory', \OC::$SERVERROOT.'/data/cache'); @@ -106,7 +107,7 @@ class FileCacheTest extends TestCache { // Restore the original mount point \OC\Files\Filesystem::clearMounts(); - \OC\Files\Filesystem::mount($this->storage, array(), '/'); + \OC\Files\Filesystem::mount($this->storage, [], '/'); parent::tearDown(); } @@ -117,7 +118,7 @@ class FileCacheTest extends TestCache { ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]) ->getMock(); - \OC\Files\Filesystem::mount($mockStorage, array(), '/test/cache'); + \OC\Files\Filesystem::mount($mockStorage, [], '/test/cache'); return $mockStorage; } @@ -127,11 +128,11 @@ class FileCacheTest extends TestCache { $mockStorage->expects($this->atLeastOnce()) ->method('filemtime') - ->will($this->returnValue(100)); + ->willReturn(100); $mockStorage->expects($this->once()) ->method('unlink') ->with('key1') - ->will($this->returnValue(true)); + ->willReturn(true); $this->instance->set('key1', 'value1'); $this->instance->gc(); @@ -142,7 +143,7 @@ class FileCacheTest extends TestCache { $mockStorage->expects($this->atLeastOnce()) ->method('filemtime') - ->will($this->returnValue(time() + 3600)); + ->willReturn(time() + 3600); $mockStorage->expects($this->never()) ->method('unlink') ->with('key1'); @@ -165,7 +166,7 @@ class FileCacheTest extends TestCache { $mockStorage->expects($this->atLeastOnce()) ->method('filemtime') - ->will($this->returnValue(100)); + ->willReturn(100); $mockStorage->expects($this->atLeastOnce()) ->method('unlink') ->will($this->onConsecutiveCalls( diff --git a/tests/lib/Cache/TestCache.php b/tests/lib/Cache/TestCache.php index 62341a5698b..9dfc46eb5a0 100644 --- a/tests/lib/Cache/TestCache.php +++ b/tests/lib/Cache/TestCache.php @@ -15,14 +15,14 @@ abstract class TestCache extends \Test\TestCase { protected $instance; protected function tearDown(): void { - if($this->instance) { + if ($this->instance) { $this->instance->clear(); } parent::tearDown(); } - function testSimple() { + public function testSimple() { $this->assertNull($this->instance->get('value1')); $this->assertFalse($this->instance->hasKey('value1')); @@ -51,7 +51,7 @@ abstract class TestCache extends \Test\TestCase { $this->assertFalse($this->instance->hasKey('value1')); } - function testClear() { + public function testClear() { $value='ipsum lorum'; $this->instance->set('1_value1', $value . '1'); $this->instance->set('1_value2', $value . '2'); diff --git a/tests/lib/Calendar/ManagerTest.php b/tests/lib/Calendar/ManagerTest.php index fa459203dac..3a2c10b6d62 100644 --- a/tests/lib/Calendar/ManagerTest.php +++ b/tests/lib/Calendar/ManagerTest.php @@ -44,19 +44,19 @@ class ManagerTest extends TestCase { public function testSearch($search1, $search2, $expected) { /** @var ICalendar | \PHPUnit_Framework_MockObject_MockObject $calendar1 */ $calendar1 = $this->createMock(ICalendar::class); - $calendar1->method('getKey')->will($this->returnValue('simple:1')); + $calendar1->method('getKey')->willReturn('simple:1'); $calendar1->expects($this->once()) ->method('search') ->with('', [], [], null, null) - ->will($this->returnValue($search1)); + ->willReturn($search1); /** @var ICalendar | PHPUnit_Framework_MockObject_MockObject $calendar2 */ $calendar2 = $this->createMock(ICalendar::class); - $calendar2->method('getKey')->will($this->returnValue('simple:2')); + $calendar2->method('getKey')->willReturn('simple:2'); $calendar2->expects($this->once()) ->method('search') ->with('', [], [], null, null) - ->will($this->returnValue($search2)); + ->willReturn($search2); $this->manager->registerCalendar($calendar1); $this->manager->registerCalendar($calendar2); @@ -71,21 +71,21 @@ class ManagerTest extends TestCase { public function testSearchOptions($search1, $search2, $expected) { /** @var ICalendar | \PHPUnit_Framework_MockObject_MockObject $calendar1 */ $calendar1 = $this->createMock(ICalendar::class); - $calendar1->method('getKey')->will($this->returnValue('simple:1')); + $calendar1->method('getKey')->willReturn('simple:1'); $calendar1->expects($this->once()) ->method('search') ->with('searchTerm', ['SUMMARY', 'DESCRIPTION'], ['timerange' => ['start' => null, 'end' => null]], 5, 20) - ->will($this->returnValue($search1)); + ->willReturn($search1); /** @var ICalendar | PHPUnit_Framework_MockObject_MockObject $calendar2 */ $calendar2 = $this->createMock(ICalendar::class); - $calendar2->method('getKey')->will($this->returnValue('simple:2')); + $calendar2->method('getKey')->willReturn('simple:2'); $calendar2->expects($this->once()) ->method('search') ->with('searchTerm', ['SUMMARY', 'DESCRIPTION'], ['timerange' => ['start' => null, 'end' => null]], 5, 20) - ->will($this->returnValue($search2)); + ->willReturn($search2); $this->manager->registerCalendar($calendar1); $this->manager->registerCalendar($calendar2); @@ -152,11 +152,11 @@ class ManagerTest extends TestCase { public function testRegisterUnregister() { /** @var ICalendar | \PHPUnit_Framework_MockObject_MockObject $calendar1 */ $calendar1 = $this->createMock(ICalendar::class); - $calendar1->method('getKey')->will($this->returnValue('key1')); + $calendar1->method('getKey')->willReturn('key1'); /** @var ICalendar | \PHPUnit_Framework_MockObject_MockObject $calendar2 */ $calendar2 = $this->createMock(ICalendar::class); - $calendar2->method('getKey')->will($this->returnValue('key2')); + $calendar2->method('getKey')->willReturn('key2'); $this->manager->registerCalendar($calendar1); $this->manager->registerCalendar($calendar2); @@ -176,11 +176,11 @@ class ManagerTest extends TestCase { public function testGetCalendars() { /** @var ICalendar | \PHPUnit_Framework_MockObject_MockObject $calendar1 */ $calendar1 = $this->createMock(ICalendar::class); - $calendar1->method('getKey')->will($this->returnValue('key1')); + $calendar1->method('getKey')->willReturn('key1'); /** @var ICalendar | \PHPUnit_Framework_MockObject_MockObject $calendar2 */ $calendar2 = $this->createMock(ICalendar::class); - $calendar2->method('getKey')->will($this->returnValue('key2')); + $calendar2->method('getKey')->willReturn('key2'); $this->manager->registerCalendar($calendar1); $this->manager->registerCalendar($calendar2); @@ -210,5 +210,4 @@ class ManagerTest extends TestCase { $isEnabled = $this->manager->isEnabled(); $this->assertTrue($isEnabled); } - } diff --git a/tests/lib/Calendar/Resource/ManagerTest.php b/tests/lib/Calendar/Resource/ManagerTest.php index 71679a86a8c..30b0e16c948 100644 --- a/tests/lib/Calendar/Resource/ManagerTest.php +++ b/tests/lib/Calendar/Resource/ManagerTest.php @@ -45,18 +45,18 @@ class ManagerTest extends TestCase { public function testRegisterUnregisterBackend() { $backend1 = $this->createMock(IBackend::class); - $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $backend1->method('getBackendIdentifier')->willReturn('backend_1'); $this->server->expects($this->at(0)) ->method('query') ->with('calendar_resource_backend1') - ->will($this->returnValue($backend1)); + ->willReturn($backend1); $backend2 = $this->createMock(IBackend::class); - $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $backend2->method('getBackendIdentifier')->willReturn('backend_2'); $this->server->expects($this->at(1)) ->method('query') ->with('calendar_resource_backend2') - ->will($this->returnValue($backend2)); + ->willReturn($backend2); $this->manager->registerBackend('calendar_resource_backend1'); $this->manager->registerBackend('calendar_resource_backend2'); @@ -74,18 +74,18 @@ class ManagerTest extends TestCase { public function testGetBackend() { $backend1 = $this->createMock(IBackend::class); - $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $backend1->method('getBackendIdentifier')->willReturn('backend_1'); $this->server->expects($this->at(0)) ->method('query') ->with('calendar_resource_backend1') - ->will($this->returnValue($backend1)); + ->willReturn($backend1); $backend2 = $this->createMock(IBackend::class); - $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $backend2->method('getBackendIdentifier')->willReturn('backend_2'); $this->server->expects($this->at(1)) ->method('query') ->with('calendar_resource_backend2') - ->will($this->returnValue($backend2)); + ->willReturn($backend2); $this->manager->registerBackend('calendar_resource_backend1'); $this->manager->registerBackend('calendar_resource_backend2'); @@ -96,18 +96,18 @@ class ManagerTest extends TestCase { public function testClear() { $backend1 = $this->createMock(IBackend::class); - $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $backend1->method('getBackendIdentifier')->willReturn('backend_1'); $this->server->expects($this->at(0)) ->method('query') ->with('calendar_resource_backend1') - ->will($this->returnValue($backend1)); + ->willReturn($backend1); $backend2 = $this->createMock(IBackend::class); - $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $backend2->method('getBackendIdentifier')->willReturn('backend_2'); $this->server->expects($this->at(1)) ->method('query') ->with('calendar_resource_backend2') - ->will($this->returnValue($backend2)); + ->willReturn($backend2); $this->manager->registerBackend('calendar_resource_backend1'); $this->manager->registerBackend('calendar_resource_backend2'); diff --git a/tests/lib/Calendar/Room/ManagerTest.php b/tests/lib/Calendar/Room/ManagerTest.php index 56f05544e29..b01d16945ad 100644 --- a/tests/lib/Calendar/Room/ManagerTest.php +++ b/tests/lib/Calendar/Room/ManagerTest.php @@ -45,18 +45,18 @@ class ManagerTest extends TestCase { public function testRegisterUnregisterBackend() { $backend1 = $this->createMock(IBackend::class); - $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $backend1->method('getBackendIdentifier')->willReturn('backend_1'); $this->server->expects($this->at(0)) ->method('query') ->with('calendar_room_backend1') - ->will($this->returnValue($backend1)); + ->willReturn($backend1); $backend2 = $this->createMock(IBackend::class); - $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $backend2->method('getBackendIdentifier')->willReturn('backend_2'); $this->server->expects($this->at(1)) ->method('query') ->with('calendar_room_backend2') - ->will($this->returnValue($backend2)); + ->willReturn($backend2); $this->manager->registerBackend('calendar_room_backend1'); $this->manager->registerBackend('calendar_room_backend2'); @@ -74,18 +74,18 @@ class ManagerTest extends TestCase { public function testGetBackend() { $backend1 = $this->createMock(IBackend::class); - $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $backend1->method('getBackendIdentifier')->willReturn('backend_1'); $this->server->expects($this->at(0)) ->method('query') ->with('calendar_room_backend1') - ->will($this->returnValue($backend1)); + ->willReturn($backend1); $backend2 = $this->createMock(IBackend::class); - $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $backend2->method('getBackendIdentifier')->willReturn('backend_2'); $this->server->expects($this->at(1)) ->method('query') ->with('calendar_room_backend2') - ->will($this->returnValue($backend2)); + ->willReturn($backend2); $this->manager->registerBackend('calendar_room_backend1'); $this->manager->registerBackend('calendar_room_backend2'); @@ -96,18 +96,18 @@ class ManagerTest extends TestCase { public function testClear() { $backend1 = $this->createMock(IBackend::class); - $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $backend1->method('getBackendIdentifier')->willReturn('backend_1'); $this->server->expects($this->at(0)) ->method('query') ->with('calendar_room_backend1') - ->will($this->returnValue($backend1)); + ->willReturn($backend1); $backend2 = $this->createMock(IBackend::class); - $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $backend2->method('getBackendIdentifier')->willReturn('backend_2'); $this->server->expects($this->at(1)) ->method('query') ->with('calendar_room_backend2') - ->will($this->returnValue($backend2)); + ->willReturn($backend2); $this->manager->registerBackend('calendar_room_backend1'); $this->manager->registerBackend('calendar_room_backend2'); diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php index e7d519a7493..536355f9697 100644 --- a/tests/lib/CapabilitiesManagerTest.php +++ b/tests/lib/CapabilitiesManagerTest.php @@ -53,7 +53,7 @@ class CapabilitiesManagerTest extends TestCase { * Test a valid capabilitie */ public function testValidCapability() { - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new SimpleCapability(); }); @@ -65,13 +65,13 @@ class CapabilitiesManagerTest extends TestCase { * Test a public capabilitie */ public function testPublicCapability() { - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new PublicSimpleCapability1(); }); - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new SimpleCapability2(); }); - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new SimpleCapability3(); }); @@ -86,7 +86,7 @@ class CapabilitiesManagerTest extends TestCase { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The given Capability (Test\\NoCapability) does not implement the ICapability interface'); - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new NoCapability(); }); @@ -98,13 +98,13 @@ class CapabilitiesManagerTest extends TestCase { * Test a bunch of merged Capabilities */ public function testMergedCapabilities() { - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new SimpleCapability(); }); - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new SimpleCapability2(); }); - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new SimpleCapability3(); }); @@ -124,10 +124,10 @@ class CapabilitiesManagerTest extends TestCase { * Test deep identical capabilities */ public function testDeepIdenticalCapabilities() { - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new DeepCapability(); }); - $this->manager->registerCapability(function() { + $this->manager->registerCapability(function () { return new DeepCapability(); }); diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php index 3d81134680a..909a11596a3 100644 --- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php @@ -23,7 +23,6 @@ namespace Test\Collaboration\Collaborators; - use OC\Collaboration\Collaborators\GroupPlugin; use OC\Collaboration\Collaborators\SearchResult; use OCP\Collaboration\Collaborators\ISearchResult; @@ -430,7 +429,6 @@ class GroupPluginTest extends TestCase { false, ], ]; - } /** @@ -460,12 +458,10 @@ class GroupPluginTest extends TestCase { $this->config->expects($this->any()) ->method('getAppValue') ->willReturnCallback( - function($appName, $key, $default) - use ($shareWithGroupOnly, $shareeEnumeration) - { + function ($appName, $key, $default) use ($shareWithGroupOnly, $shareeEnumeration) { if ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') { return $shareWithGroupOnly ? 'yes' : 'no'; - } else if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { + } elseif ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { return $shareeEnumeration ? 'yes' : 'no'; } return $default; diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php index 15dccf2c84c..eb26443a269 100644 --- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php @@ -23,7 +23,6 @@ namespace Test\Collaboration\Collaborators; - use OC\Collaboration\Collaborators\LookupPlugin; use OC\Federation\CloudId; use OCP\Collaboration\Collaborators\ISearchResult; diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index 9cf308cd414..613208d27b1 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -23,7 +23,6 @@ namespace Test\Collaboration\Collaborators; - use OC\Collaboration\Collaborators\MailPlugin; use OC\Collaboration\Collaborators\SearchResult; use OC\Federation\CloudIdManager; @@ -87,9 +86,7 @@ class MailPluginTest extends TestCase { $this->config->expects($this->any()) ->method('getAppValue') ->willReturnCallback( - function($appName, $key, $default) - use ($shareeEnumeration) - { + function ($appName, $key, $default) use ($shareeEnumeration) { if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { return $shareeEnumeration ? 'yes' : 'no'; } @@ -535,10 +532,10 @@ class MailPluginTest extends TestCase { $this->config->expects($this->any()) ->method('getAppValue') ->willReturnCallback( - function($appName, $key, $default) { + function ($appName, $key, $default) { if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { return 'yes'; - } else if ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') { + } elseif ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') { return 'yes'; } return $default; @@ -565,13 +562,13 @@ class MailPluginTest extends TestCase { $this->groupManager->expects($this->any()) ->method('getUserGroupIds') - ->willReturnCallback(function(\OCP\IUser $user) use ($userToGroupMapping) { + ->willReturnCallback(function (\OCP\IUser $user) use ($userToGroupMapping) { return $userToGroupMapping[$user->getUID()]; }); $this->groupManager->expects($this->any()) ->method('isInGroup') - ->willReturnCallback(function($userId, $group) use ($userToGroupMapping) { + ->willReturnCallback(function ($userId, $group) use ($userToGroupMapping) { return in_array($group, $userToGroupMapping[$userId]); }); @@ -607,7 +604,7 @@ class MailPluginTest extends TestCase { ], // The user `User` cannot share with the current user [ - 'test', + 'test', [ [ 'FN' => 'User', @@ -627,7 +624,7 @@ class MailPluginTest extends TestCase { ], // The user `User` cannot share with the current user, but there is an exact match on the e-mail address -> share by e-mail [ - 'test@example.com', + 'test@example.com', [ [ 'FN' => 'User', diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php index 4ac2cc124ee..a651d4ec1d4 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php @@ -23,7 +23,6 @@ namespace Test\Collaboration\Collaborators; - use OC\Collaboration\Collaborators\RemotePlugin; use OC\Collaboration\Collaborators\SearchResult; use OC\Federation\CloudIdManager; @@ -93,9 +92,7 @@ class RemotePluginTest extends TestCase { $this->config->expects($this->any()) ->method('getAppValue') ->willReturnCallback( - function($appName, $key, $default) - use ($shareeEnumeration) - { + function ($appName, $key, $default) use ($shareeEnumeration) { if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { return $shareeEnumeration ? 'yes' : 'no'; } @@ -410,20 +407,20 @@ class RemotePluginTest extends TestCase { } public function dataTestSplitUserRemoteError() { - return array( + return [ // Invalid path - array('user@'), + ['user@'], // Invalid user - array('@server'), - array('us/er@server'), - array('us:er@server'), + ['@server'], + ['us/er@server'], + ['us:er@server'], // Invalid splitting - array('user'), - array(''), - array('us/erserver'), - array('us:erserver'), - ); + ['user'], + [''], + ['us/erserver'], + ['us:erserver'], + ]; } } diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php index 43672345226..84d270de547 100644 --- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php +++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php @@ -23,14 +23,11 @@ namespace Test\Collaboration\Collaborators; - use OC\Collaboration\Collaborators\Search; use OC\Collaboration\Collaborators\SearchResult; use OCP\Collaboration\Collaborators\ISearch; -use OCP\Collaboration\Collaborators\ISearchPlugin; use OCP\Collaboration\Collaborators\SearchResultType; use OCP\IContainer; -use OCP\Share; use Test\TestCase; class SearchResultTest extends TestCase { @@ -101,5 +98,4 @@ class SearchResultTest extends TestCase { $this->assertSame($expected, $result->hasResult(new SearchResultType($type), $id)); } - } diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php index 284d8270c49..1b68e8eacc1 100644 --- a/tests/lib/Collaboration/Collaborators/SearchTest.php +++ b/tests/lib/Collaboration/Collaborators/SearchTest.php @@ -23,7 +23,6 @@ namespace Test\Collaboration\Collaborators; - use OC\Collaboration\Collaborators\Search; use OC\Collaboration\Collaborators\SearchResult; use OCP\Collaboration\Collaborators\ISearch; @@ -76,7 +75,7 @@ class SearchTest extends TestCase { $userPlugin = $this->createMock(ISearchPlugin::class); $userPlugin->expects($this->any()) ->method('search') - ->willReturnCallback(function() use ($searchResult, $mockedUserResult, $expectedMoreResults) { + ->willReturnCallback(function () use ($searchResult, $mockedUserResult, $expectedMoreResults) { $type = new SearchResultType('users'); $searchResult->addResultSet($type, $mockedUserResult); return $expectedMoreResults; @@ -85,7 +84,7 @@ class SearchTest extends TestCase { $groupPlugin = $this->createMock(ISearchPlugin::class); $groupPlugin->expects($this->any()) ->method('search') - ->willReturnCallback(function() use ($searchResult, $mockedGroupsResult, $expectedMoreResults) { + ->willReturnCallback(function () use ($searchResult, $mockedGroupsResult, $expectedMoreResults) { $type = new SearchResultType('groups'); $searchResult->addResultSet($type, $mockedGroupsResult); return $expectedMoreResults; @@ -94,11 +93,11 @@ class SearchTest extends TestCase { $remotePlugin = $this->createMock(ISearchPlugin::class); $remotePlugin->expects($this->any()) ->method('search') - ->willReturnCallback(function() use ($searchResult, $mockedRemotesResult, $expectedMoreResults) { - if($mockedRemotesResult !== null) { + ->willReturnCallback(function () use ($searchResult, $mockedRemotesResult, $expectedMoreResults) { + if ($mockedRemotesResult !== null) { $type = new SearchResultType('remotes'); $searchResult->addResultSet($type, $mockedRemotesResult['results'], $mockedRemotesResult['exact']); - if($mockedRemotesResult['exactIdMatch'] === true) { + if ($mockedRemotesResult['exactIdMatch'] === true) { $searchResult->markExactIdMatch($type); } } @@ -107,8 +106,8 @@ class SearchTest extends TestCase { $this->container->expects($this->any()) ->method('resolve') - ->willReturnCallback(function($class) use ($searchResult, $userPlugin, $groupPlugin, $remotePlugin) { - if($class === SearchResult::class) { + ->willReturnCallback(function ($class) use ($searchResult, $userPlugin, $groupPlugin, $remotePlugin) { + if ($class === SearchResult::class) { return $searchResult; } elseif ($class === $userPlugin) { return $userPlugin; @@ -152,12 +151,12 @@ class SearchTest extends TestCase { ], [ 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ], [ - ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']], - ], [ - 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false, - ], + ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ], [ + ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']], + ], [ + 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false, + ], [ 'exact' => ['users' => [], 'groups' => [], 'remotes' => []], 'users' => [ @@ -174,10 +173,10 @@ class SearchTest extends TestCase { // No groups requested [ 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_REMOTE], 1, 2, [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ], [], [ - 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false - ], + ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ], [], [ + 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false + ], [ 'exact' => ['users' => [], 'remotes' => []], 'users' => [ @@ -191,8 +190,8 @@ class SearchTest extends TestCase { // Share type restricted to user - Only one user [ 'test', [Share::SHARE_TYPE_USER], 1, 2, [ - ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ], [], [], + ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ], [], [], [ 'exact' => ['users' => []], 'users' => [ @@ -203,9 +202,9 @@ class SearchTest extends TestCase { // Share type restricted to user - Multipage result [ 'test', [Share::SHARE_TYPE_USER], 1, 2, [ - ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], - ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], - ], [], [], + ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']], + ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']], + ], [], [], [ 'exact' => ['users' => []], 'users' => [ diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php index 3aeeaa3eecb..07bcce93529 100644 --- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php @@ -27,6 +27,7 @@ use OC\Collaboration\Collaborators\SearchResult; use OC\Collaboration\Collaborators\UserPlugin; use OCP\Collaboration\Collaborators\ISearchResult; use OCP\IConfig; +use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; @@ -89,7 +90,24 @@ class UserPluginTest extends TestCase { ); } - public function getUserMock($uid, $displayName, $enabled = true) { + public function mockConfig($shareWithGroupOnly, $shareeEnumeration, $shareeEnumerationLimitToGroup) { + $this->config->expects($this->any()) + ->method('getAppValue') + ->willReturnCallback( + function ($appName, $key, $default) use ($shareWithGroupOnly, $shareeEnumeration, $shareeEnumerationLimitToGroup) { + if ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') { + return $shareWithGroupOnly ? 'yes' : 'no'; + } elseif ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { + return $shareeEnumeration ? 'yes' : 'no'; + } elseif ($appName === 'core' && $key === 'shareapi_restrict_user_enumeration_to_group') { + return $shareeEnumerationLimitToGroup ? 'yes' : 'no'; + } + return $default; + } + ); + } + + public function getUserMock($uid, $displayName, $enabled = true, $groups = []) { $user = $this->createMock(IUser::class); $user->expects($this->any()) @@ -107,6 +125,16 @@ class UserPluginTest extends TestCase { return $user; } + public function getGroupMock($gid) { + $group = $this->createMock(IGroup::class); + + $group->expects($this->any()) + ->method('getGID') + ->willReturn($gid); + + return $group; + } + public function dataGetUsers() { return [ ['test', false, true, [], [], [], [], true, false], @@ -117,33 +145,33 @@ class UserPluginTest extends TestCase { 'test', false, true, [], [], [ ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], - ], [], true, $this->getUserMock('test', 'Test') + ], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', false, false, [], [], [ ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], - ], [], true, $this->getUserMock('test', 'Test') + ], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', true, true, [], [], - [], [], true, $this->getUserMock('test', 'Test') + [], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', true, false, [], [], - [], [], true, $this->getUserMock('test', 'Test') + [], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', true, true, ['test-group'], [['test-group', 'test', 2, 0, []]], [ ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], - ], [], true, $this->getUserMock('test', 'Test') + ], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', true, false, ['test-group'], [['test-group', 'test', 2, 0, []]], [ ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']], - ], [], true, $this->getUserMock('test', 'Test') + ], [], true, $this->getUserMock('test', 'Test'), ], [ 'test', @@ -247,7 +275,7 @@ class UserPluginTest extends TestCase { true, ['abc', 'xyz'], [ - ['abc', 'test', 2, 0, ['test1' => 'Test One']], + ['abc', 'test', 2, 0, [$this->getUserMock('test1', 'Test One')]], ['xyz', 'test', 2, 0, []], ], [], @@ -263,7 +291,7 @@ class UserPluginTest extends TestCase { false, ['abc', 'xyz'], [ - ['abc', 'test', 2, 0, ['test1' => 'Test One']], + ['abc', 'test', 2, 0, [$this->getUserMock('test1', 'Test One')]], ['xyz', 'test', 2, 0, []], ], [], @@ -278,12 +306,12 @@ class UserPluginTest extends TestCase { ['abc', 'xyz'], [ ['abc', 'test', 2, 0, [ - 'test1' => 'Test One', - 'test2' => 'Test Two', + $this->getUserMock('test1', 'Test One'), + $this->getUserMock('test2', 'Test Two'), ]], ['xyz', 'test', 2, 0, [ - 'test1' => 'Test One', - 'test2' => 'Test Two', + $this->getUserMock('test1', 'Test One'), + $this->getUserMock('test2', 'Test Two'), ]], ], [], @@ -301,12 +329,12 @@ class UserPluginTest extends TestCase { ['abc', 'xyz'], [ ['abc', 'test', 2, 0, [ - 'test1' => 'Test One', - 'test2' => 'Test Two', + $this->getUserMock('test1', 'Test One'), + $this->getUserMock('test2', 'Test Two'), ]], ['xyz', 'test', 2, 0, [ - 'test1' => 'Test One', - 'test2' => 'Test Two', + $this->getUserMock('test1', 'Test One'), + $this->getUserMock('test2', 'Test Two'), ]], ], [], @@ -321,10 +349,10 @@ class UserPluginTest extends TestCase { ['abc', 'xyz'], [ ['abc', 'test', 2, 0, [ - 'test' => 'Test One', + $this->getUserMock('test', 'Test One'), ]], ['xyz', 'test', 2, 0, [ - 'test2' => 'Test Two', + $this->getUserMock('test2', 'Test Two'), ]], ], [ @@ -343,10 +371,10 @@ class UserPluginTest extends TestCase { ['abc', 'xyz'], [ ['abc', 'test', 2, 0, [ - 'test' => 'Test One', + $this->getUserMock('test', 'Test One'), ]], ['xyz', 'test', 2, 0, [ - 'test2' => 'Test Two', + $this->getUserMock('test2', 'Test Two'), ]], ], [ @@ -383,52 +411,43 @@ class UserPluginTest extends TestCase { $reachedEnd, $singleUser ) { - $this->config->expects($this->any()) - ->method('getAppValue') - ->willReturnCallback( - function($appName, $key, $default) - use ($shareWithGroupOnly, $shareeEnumeration) - { - if ($appName === 'core' && $key === 'shareapi_only_share_with_group_members') { - return $shareWithGroupOnly ? 'yes' : 'no'; - } else if ($appName === 'core' && $key === 'shareapi_allow_share_dialog_user_enumeration') { - return $shareeEnumeration ? 'yes' : 'no'; - } - return $default; - } - ); - + $this->mockConfig($shareWithGroupOnly, $shareeEnumeration, false); $this->instantiatePlugin(); $this->session->expects($this->any()) ->method('getUser') ->willReturn($this->user); - if(!$shareWithGroupOnly) { + if (!$shareWithGroupOnly) { $this->userManager->expects($this->once()) ->method('searchDisplayName') ->with($searchTerm, $this->limit, $this->offset) ->willReturn($userResponse); } else { + $groups = array_combine($groupResponse, array_map(function ($gid) { + return $this->getGroupMock($gid); + }, $groupResponse)); if ($singleUser !== false) { - $this->groupManager->expects($this->exactly(2)) - ->method('getUserGroupIds') - ->withConsecutive( - [$this->user], - [$singleUser] - ) + $this->groupManager->method('getUserGroups') + ->with($this->user) + ->willReturn($groups); + + $this->groupManager->method('getUserGroupIds') + ->with($singleUser) ->willReturn($groupResponse); } else { $this->groupManager->expects($this->once()) - ->method('getUserGroupIds') + ->method('getUserGroups') ->with($this->user) - ->willReturn($groupResponse); + ->willReturn($groups); } - $this->groupManager->expects($this->exactly(sizeof($groupResponse))) - ->method('displayNamesInGroup') - ->with($this->anything(), $searchTerm, $this->limit, $this->offset) - ->willReturnMap($userResponse); + foreach ($userResponse as $groupDefinition) { + [$gid, $search, $limit, $offset, $users] = $groupDefinition; + $groups[$gid]->method('searchDisplayName') + ->with($search, $limit, $offset) + ->willReturn($users); + } } if ($singleUser !== false) { @@ -451,24 +470,24 @@ class UserPluginTest extends TestCase { $inputUsers = [ 'alice' => 'Alice', 'bob' => 'Bob', - 'carol' => 'Carol' + 'carol' => 'Carol', ]; return [ [ $inputUsers, ['alice', 'carol'], - 'bob' + 'bob', ], [ $inputUsers, ['alice', 'bob', 'carol'], - 'dave' + 'dave', ], [ $inputUsers, ['alice', 'bob', 'carol'], - null - ] + null, + ], ]; } @@ -483,8 +502,8 @@ class UserPluginTest extends TestCase { $this->session->expects($this->once()) ->method('getUser') - ->willReturnCallback(function() use ($currentUserId) { - if($currentUserId !== null) { + ->willReturnCallback(function () use ($currentUserId) { + if ($currentUserId !== null) { return $this->getUserMock($currentUserId, $currentUserId); } return null; @@ -493,4 +512,110 @@ class UserPluginTest extends TestCase { $this->plugin->takeOutCurrentUser($users); $this->assertSame($expectedUIDs, array_keys($users)); } + + public function dataSearchEnumeration() { + return [ + [ + 'test', + ['groupA'], + [ + ['uid' => 'test1', 'groups' => ['groupA']], + ['uid' => 'test2', 'groups' => ['groupB']], + ], + ['test1'], + ], + [ + 'test', + ['groupA'], + [ + ['uid' => 'test1', 'groups' => ['groupA']], + ['uid' => 'test2', 'groups' => ['groupB', 'groupA']], + ], + ['test1', 'test2'], + ], + [ + 'test', + ['groupA'], + [ + ['uid' => 'test1', 'groups' => ['groupA', 'groupC']], + ['uid' => 'test2', 'groups' => ['groupB', 'groupA']], + ], + ['test1', 'test2'], + ], + [ + 'test', + ['groupC', 'groupB'], + [ + ['uid' => 'test1', 'groups' => ['groupA', 'groupC']], + ['uid' => 'test2', 'groups' => ['groupB', 'groupA']], + ], + ['test1', 'test2'], + ], + [ + 'test', + [], + [ + ['uid' => 'test1', 'groups' => ['groupA']], + ['uid' => 'test2', 'groups' => ['groupB', 'groupA']], + ], + [], + ], + [ + 'test', + ['groupC', 'groupB'], + [ + ['uid' => 'test1', 'groups' => []], + ['uid' => 'test2', 'groups' => []], + ], + [], + ], + ]; + } + + /** + * @dataProvider dataSearchEnumeration + */ + public function testSearchEnumerationLimit($search, $userGroups, $matchingUsers, $result) { + $this->mockConfig(false, true, true); + + $userResults = array_map(function ($user) { + return $this->getUserMock($user['uid'], $user['uid']); + }, $matchingUsers); + + $mappedResult = array_map(function ($user) { + return ['label' => $user, 'value' => ['shareType' => 0, 'shareWith' => $user]]; + }, $result); + + $this->userManager->expects($this->once()) + ->method('searchDisplayName') + ->willReturn($userResults); + $this->session->expects($this->any()) + ->method('getUser') + ->willReturn($this->getUserMock('test', 'foo')); + // current user + $this->groupManager->expects($this->at(0)) + ->method('getUserGroupIds') + ->willReturn($userGroups); + $this->groupManager->expects($this->any()) + ->method('getUserGroupIds') + ->willReturnCallback(function ($user) use ($matchingUsers) { + $neededObject = array_filter( + $matchingUsers, + function ($e) use ($user) { + return $user->getUID() === $e['uid']; + } + ); + if (count($neededObject) > 0) { + return array_shift($neededObject)['groups']; + } + return []; + }); + + $this->instantiatePlugin(); + $this->plugin->search($search, $this->limit, $this->offset, $this->searchResult); + $result = $this->searchResult->asArray(); + + $this->assertEquals([], $result['exact']['users']); + $this->assertEquals($mappedResult, $result['users']); + } } diff --git a/tests/lib/Collaboration/Resources/ManagerTest.php b/tests/lib/Collaboration/Resources/ManagerTest.php index f59c2913c88..092d4ffd39c 100644 --- a/tests/lib/Collaboration/Resources/ManagerTest.php +++ b/tests/lib/Collaboration/Resources/ManagerTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de> diff --git a/tests/lib/Collaboration/Resources/ProviderManagerTest.php b/tests/lib/Collaboration/Resources/ProviderManagerTest.php index d8bebe8fa6c..751e2cc1f8d 100644 --- a/tests/lib/Collaboration/Resources/ProviderManagerTest.php +++ b/tests/lib/Collaboration/Resources/ProviderManagerTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de> diff --git a/tests/lib/Command/AsyncBusTest.php b/tests/lib/Command/AsyncBusTest.php index 31f28bb88c9..bfe201ed369 100644 --- a/tests/lib/Command/AsyncBusTest.php +++ b/tests/lib/Command/AsyncBusTest.php @@ -23,7 +23,7 @@ class SimpleCommand implements ICommand { class StateFullCommand implements ICommand { private $state; - function __construct($state) { + public function __construct($state) { $this->state = $state; } diff --git a/tests/lib/Command/BackgroundJobsTest.php b/tests/lib/Command/BackgroundJobsTest.php index fc506be644a..9d1741aff88 100644 --- a/tests/lib/Command/BackgroundJobsTest.php +++ b/tests/lib/Command/BackgroundJobsTest.php @@ -1,27 +1,27 @@ <?php /** -* The MIT License (MIT) -* -* Copyright (c) 2015 Christian Kampka <christian@kampka.net> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ + * The MIT License (MIT) + * + * Copyright (c) 2015 Christian Kampka <christian@kampka.net> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ namespace Test\Command; @@ -34,7 +34,6 @@ use Symfony\Component\Console\Output\NullOutput; use Test\TestCase; class BackgroundJobsTest extends TestCase { - public function testCronCommand() { $config = \OC::$server->getConfig(); $job = new Cron($config); diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php index 6fa86a2e855..594d17168d6 100644 --- a/tests/lib/Command/Integrity/SignAppTest.php +++ b/tests/lib/Command/Integrity/SignAppTest.php @@ -59,17 +59,17 @@ class SignAppTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('path') - ->will($this->returnValue(null)); + ->willReturn(null); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('PrivateKey')); + ->willReturn('PrivateKey'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('Certificate')); + ->willReturn('Certificate'); $outputInterface ->expects($this->at(0)) @@ -87,17 +87,17 @@ class SignAppTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('path') - ->will($this->returnValue('AppId')); + ->willReturn('AppId'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue(null)); + ->willReturn(null); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('Certificate')); + ->willReturn('Certificate'); $outputInterface ->expects($this->at(0)) @@ -115,17 +115,17 @@ class SignAppTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('path') - ->will($this->returnValue('AppId')); + ->willReturn('AppId'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue(null)); + ->willReturn(null); $outputInterface ->expects($this->at(0)) @@ -143,23 +143,23 @@ class SignAppTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('path') - ->will($this->returnValue('AppId')); + ->willReturn('AppId'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) ->method('file_get_contents') ->with('privateKey') - ->will($this->returnValue(false)); + ->willReturn(false); $outputInterface ->expects($this->at(0)) @@ -177,28 +177,28 @@ class SignAppTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('path') - ->will($this->returnValue('AppId')); + ->willReturn('AppId'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) ->method('file_get_contents') ->with('privateKey') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with('certificate') - ->will($this->returnValue(false)); + ->willReturn(false); $outputInterface ->expects($this->at(0)) @@ -216,17 +216,17 @@ class SignAppTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('path') - ->will($this->returnValue('AppId')); + ->willReturn('AppId'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) @@ -260,17 +260,17 @@ class SignAppTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('path') - ->will($this->returnValue('AppId')); + ->willReturn('AppId'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php index 9bab016ec8f..36376ef0e7d 100644 --- a/tests/lib/Command/Integrity/SignCoreTest.php +++ b/tests/lib/Command/Integrity/SignCoreTest.php @@ -54,12 +54,12 @@ class SignCoreTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue(null)); + ->willReturn(null); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('Certificate')); + ->willReturn('Certificate'); $outputInterface ->expects($this->at(0)) @@ -77,12 +77,12 @@ class SignCoreTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('certificate') - ->will($this->returnValue(null)); + ->willReturn(null); $outputInterface ->expects($this->at(0)) @@ -100,23 +100,23 @@ class SignCoreTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('path') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) ->method('file_get_contents') ->with('privateKey') - ->will($this->returnValue(false)); + ->willReturn(false); $outputInterface ->expects($this->at(0)) @@ -134,17 +134,17 @@ class SignCoreTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('path') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) @@ -155,7 +155,7 @@ class SignCoreTest extends TestCase { ->expects($this->at(1)) ->method('file_get_contents') ->with('certificate') - ->will($this->returnValue(false)); + ->willReturn(false); $outputInterface ->expects($this->at(0)) @@ -173,17 +173,17 @@ class SignCoreTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('path') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) @@ -217,17 +217,17 @@ class SignCoreTest extends TestCase { ->expects($this->at(0)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->willReturn('privateKey'); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('path') - ->will($this->returnValue('certificate')); + ->willReturn('certificate'); $this->fileAccessHelper ->expects($this->at(0)) diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php index bd58d3fb156..245ca9693ea 100644 --- a/tests/lib/Comments/CommentTest.php +++ b/tests/lib/Comments/CommentTest.php @@ -112,7 +112,7 @@ class CommentTest extends TestCase { /** * @dataProvider roleSetterProvider */ - public function testSetRoleInvalidInput($role, $type, $id){ + public function testSetRoleInvalidInput($role, $type, $id) { $this->expectException(\InvalidArgumentException::class); $comment = new Comment(); @@ -174,14 +174,14 @@ class CommentTest extends TestCase { public function testMentions(string $message, array $expectedUids, ?string $author = null, array $expectedGuests = []): void { $comment = new Comment(); $comment->setMessage($message); - if(!is_null($author)) { + if (!is_null($author)) { $comment->setActor('user', $author); } $mentions = $comment->getMentions(); - while($mention = array_shift($mentions)) { + while ($mention = array_shift($mentions)) { if ($mention['type'] === 'user') { $id = array_shift($expectedUids); - } else if ($mention['type'] === 'guest') { + } elseif ($mention['type'] === 'guest') { $id = array_shift($expectedGuests); } else { $this->fail('Unexpected mention type'); @@ -192,7 +192,4 @@ class CommentTest extends TestCase { $this->assertEmpty($mentions); $this->assertEmpty($expectedUids); } - - - } diff --git a/tests/lib/Comments/FakeFactory.php b/tests/lib/Comments/FakeFactory.php index ff8dfd3a259..257e7dad93b 100644 --- a/tests/lib/Comments/FakeFactory.php +++ b/tests/lib/Comments/FakeFactory.php @@ -8,7 +8,6 @@ use OCP\IServerContainer; * Class FakeFactory */ class FakeFactory implements \OCP\Comments\ICommentsManagerFactory { - public function __construct(IServerContainer $serverContainer) { } diff --git a/tests/lib/Comments/FakeManager.php b/tests/lib/Comments/FakeManager.php index 9078226afb5..b165b01c3c2 100644 --- a/tests/lib/Comments/FakeManager.php +++ b/tests/lib/Comments/FakeManager.php @@ -1,6 +1,7 @@ <?php namespace Test\Comments; + use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; use OCP\IUser; @@ -9,10 +10,11 @@ use OCP\IUser; * Class FakeManager */ class FakeManager implements ICommentsManager { + public function get($id) { + } - public function get($id) {} - - public function getTree($id, $limit = 0, $offset = 0) {} + public function getTree($id, $limit = 0, $offset = 0) { + } public function getForObject( $objectType, @@ -20,7 +22,8 @@ class FakeManager implements ICommentsManager { $limit = 0, $offset = 0, \DateTime $notOlderThan = null - ) {} + ) { + } public function getForObjectSince( string $objectType, @@ -28,39 +31,56 @@ class FakeManager implements ICommentsManager { int $lastKnownCommentId, string $sortDirection = 'asc', int $limit = 30 - ): array { return []; } + ): array { + return []; + } - public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null, $verb = '') {} + public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null, $verb = '') { + } public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array { return []; } - public function create($actorType, $actorId, $objectType, $objectId) {} + public function create($actorType, $actorId, $objectType, $objectId) { + } - public function delete($id) {} + public function delete($id) { + } - public function save(IComment $comment) {} + public function save(IComment $comment) { + } - public function deleteReferencesOfActor($actorType, $actorId) {} + public function deleteReferencesOfActor($actorType, $actorId) { + } - public function deleteCommentsAtObject($objectType, $objectId) {} + public function deleteCommentsAtObject($objectType, $objectId) { + } - public function setReadMark($objectType, $objectId, \DateTime $dateTime, IUser $user) {} + public function setReadMark($objectType, $objectId, \DateTime $dateTime, IUser $user) { + } - public function getReadMark($objectType, $objectId, IUser $user) {} + public function getReadMark($objectType, $objectId, IUser $user) { + } - public function deleteReadMarksFromUser(IUser $user) {} + public function deleteReadMarksFromUser(IUser $user) { + } - public function deleteReadMarksOnObject($objectType, $objectId) {} + public function deleteReadMarksOnObject($objectType, $objectId) { + } - public function registerEventHandler(\Closure $closure) {} + public function registerEventHandler(\Closure $closure) { + } - public function registerDisplayNameResolver($type, \Closure $closure) {} + public function registerDisplayNameResolver($type, \Closure $closure) { + } - public function resolveDisplayName($type, $id) {} + public function resolveDisplayName($type, $id) { + } - public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) {} + public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user) { + } - public function getActorsInTree($id) {} + public function getActorsInTree($id) { + } } diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php index 93cafc0f933..e2bf6180709 100644 --- a/tests/lib/Comments/ManagerTest.php +++ b/tests/lib/Comments/ManagerTest.php @@ -339,7 +339,7 @@ class ManagerTest extends TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('comment_test')); + ->willReturn('comment_test'); $manager = $this->getManager(); @@ -378,7 +378,7 @@ class ManagerTest extends TestCase { $expected = array_reverse($expected); } - $this->assertSame($expected, array_map(function(IComment $c) { + $this->assertSame($expected, array_map(function (IComment $c) { return (int) $c->getId(); }, $comments)); } @@ -679,7 +679,7 @@ class ManagerTest extends TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('alice')); + ->willReturn('alice'); $dateTimeSet = new \DateTime(); @@ -696,7 +696,7 @@ class ManagerTest extends TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('alice')); + ->willReturn('alice'); $dateTimeSet = new \DateTime('yesterday'); @@ -716,7 +716,7 @@ class ManagerTest extends TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('alice')); + ->willReturn('alice'); $dateTimeSet = new \DateTime(); @@ -734,7 +734,7 @@ class ManagerTest extends TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('alice')); + ->willReturn('alice'); $dateTimeSet = new \DateTime(); @@ -863,5 +863,4 @@ class ManagerTest extends TestCase { $manager->registerDisplayNameResolver('planet', $planetClosure); $this->assertTrue(is_string($manager->resolveDisplayName(1337, 'neptune'))); } - } diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php index 109f7471e96..aa6c50528cc 100644 --- a/tests/lib/ConfigTest.php +++ b/tests/lib/ConfigTest.php @@ -9,10 +9,10 @@ namespace Test; class ConfigTest extends TestCase { - const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);'; + public const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);'; /** @var array */ - private $initialConfig = array('foo' => 'bar', 'beers' => array('Appenzeller', 'Guinness', 'Kölsch'), 'alcohol_free' => false); + private $initialConfig = ['foo' => 'bar', 'beers' => ['Appenzeller', 'Guinness', 'Kölsch'], 'alcohol_free' => false]; /** @var string */ private $configFile; /** @var \OC\Config */ @@ -35,7 +35,7 @@ class ConfigTest extends TestCase { } public function testGetKeys() { - $expectedConfig = array('foo', 'beers', 'alcohol_free'); + $expectedConfig = ['foo', 'beers', 'alcohol_free']; $this->assertSame($expectedConfig, $this->config->getKeys()); } @@ -44,8 +44,8 @@ class ConfigTest extends TestCase { $this->assertSame(null, $this->config->getValue('bar')); $this->assertSame('moo', $this->config->getValue('bar', 'moo')); $this->assertSame(false, $this->config->getValue('alcohol_free', 'someBogusValue')); - $this->assertSame(array('Appenzeller', 'Guinness', 'Kölsch'), $this->config->getValue('beers', 'someBogusValue')); - $this->assertSame(array('Appenzeller', 'Guinness', 'Kölsch'), $this->config->getValue('beers')); + $this->assertSame(['Appenzeller', 'Guinness', 'Kölsch'], $this->config->getValue('beers', 'someBogusValue')); + $this->assertSame(['Appenzeller', 'Guinness', 'Kölsch'], $this->config->getValue('beers')); } public function testGetValueReturnsEnvironmentValueIfSet() { @@ -81,9 +81,9 @@ class ConfigTest extends TestCase { $this->assertEquals($expected, $content); $this->config->setValue('bar', 'red'); - $this->config->setValue('apps', array('files', 'gallery')); + $this->config->setValue('apps', ['files', 'gallery']); $expectedConfig['bar'] = 'red'; - $expectedConfig['apps'] = array('files', 'gallery'); + $expectedConfig['apps'] = ['files', 'gallery']; $this->assertAttributeEquals($expectedConfig, 'cache', $this->config); $content = file_get_contents($this->configFile); @@ -150,7 +150,7 @@ class ConfigTest extends TestCase { $this->assertEquals(self::TESTCONTENT, file_get_contents($this->configFile)); // Write a new value to the config - $this->config->setValue('CoolWebsites', array('demo.owncloud.org', 'owncloud.org', 'owncloud.com')); + $this->config->setValue('CoolWebsites', ['demo.owncloud.org', 'owncloud.org', 'owncloud.com']); $expected = "<?php\n\$CONFIG = array (\n 'foo' => 'bar',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n 'alcohol_free' => false,\n 'php53' => 'totallyOutdated',\n 'CoolWebsites' => \n array (\n " . " 0 => 'demo.owncloud.org',\n 1 => 'owncloud.org',\n 2 => 'owncloud.com',\n ),\n);\n"; @@ -159,5 +159,4 @@ class ConfigTest extends TestCase { // Cleanup unlink($additionalConfigPath); } - } diff --git a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php index 8e7f64ff9d1..d858eab4d11 100644 --- a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php +++ b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php @@ -63,5 +63,4 @@ class ActionFactoryTest extends TestCase { $this->assertEquals(10, $action->getPriority()); $this->assertEquals('mailto:user@example.com', $action->getHref()); } - } diff --git a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php index 10584812c41..ee053ce40e5 100644 --- a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php +++ b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php @@ -24,7 +24,6 @@ namespace Tests\Contacts\ContactsMenu; -use Exception; use OC\App\AppManager; use OC\Contacts\ContactsMenu\ActionProviderStore; use OC\Contacts\ContactsMenu\Providers\EMailProvider; @@ -77,13 +76,13 @@ class ActionProviderStoreTest extends TestCase { 'contactsmenu' => [ 'OCA\Contacts\Provider1', ], - ]); + ]); $this->serverContainer->expects($this->exactly(2)) ->method('query') - ->will($this->returnValueMap([ - [EMailProvider::class, true, $provider1], - ['OCA\Contacts\Provider1', true, $provider2] - ])); + ->willReturnMap([ + [EMailProvider::class, true, $provider1], + ['OCA\Contacts\Provider1', true, $provider2] + ]); $providers = $this->actionProviderStore->getProviders($user); @@ -105,9 +104,9 @@ class ActionProviderStoreTest extends TestCase { ->willReturn([/* Empty info.xml */]); $this->serverContainer->expects($this->once()) ->method('query') - ->will($this->returnValueMap([ - [EMailProvider::class, true, $provider1], - ])); + ->willReturnMap([ + [EMailProvider::class, true, $provider1], + ]); $providers = $this->actionProviderStore->getProviders($user); @@ -130,5 +129,4 @@ class ActionProviderStoreTest extends TestCase { $this->actionProviderStore->getProviders($user); } - } diff --git a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php index da2d6ac4517..ed6e9ace403 100644 --- a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php +++ b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php @@ -28,7 +28,6 @@ use OC\Contacts\ContactsMenu\Actions\LinkAction; use Test\TestCase; class LinkActionTest extends TestCase { - private $action; protected function setUp(): void { @@ -86,5 +85,4 @@ class LinkActionTest extends TestCase { $this->assertEquals($expected, $json); } - } diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php index 49dc1d9d823..245c89c3228 100644 --- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php +++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php @@ -73,7 +73,7 @@ class ContactsStoreTest extends TestCase { 'darren@roner.au' ], ], - ]); + ]); $user->expects($this->once()) ->method('getUID') ->willReturn('user123'); @@ -83,7 +83,7 @@ class ContactsStoreTest extends TestCase { $this->assertCount(2, $entries); $this->assertEquals([ 'darren@roner.au' - ], $entries[1]->getEMailAddresses()); + ], $entries[1]->getEMailAddresses()); } public function testGetContactsHidesOwnEntry() { @@ -103,7 +103,7 @@ class ContactsStoreTest extends TestCase { 'darren@roner.au' ], ], - ]); + ]); $user->expects($this->once()) ->method('getUID') ->willReturn('user123'); @@ -131,7 +131,7 @@ class ContactsStoreTest extends TestCase { ], 'PHOTO' => base64_encode('photophotophoto'), ], - ]); + ]); $user->expects($this->once()) ->method('getUID') ->willReturn('user123'); @@ -160,7 +160,7 @@ class ContactsStoreTest extends TestCase { ], 'PHOTO' => 'VALUE=uri:https://photo', ], - ]); + ]); $user->expects($this->once()) ->method('getUID') ->willReturn('user123'); @@ -178,15 +178,20 @@ class ContactsStoreTest extends TestCase { $this->config->expects($this->at(1)) ->method('getAppValue') + ->with($this->equalTo('core'), $this->equalTo('shareapi_restrict_user_enumeration_to_group'), $this->equalTo('no')) + ->willReturn('no'); + + $this->config->expects($this->at(2)) + ->method('getAppValue') ->with($this->equalTo('core'), $this->equalTo('shareapi_exclude_groups'), $this->equalTo('no')) ->willReturn('yes'); - $this->config->expects($this->at(2)) + $this->config->expects($this->at(3)) ->method('getAppValue') ->with($this->equalTo('core'), $this->equalTo('shareapi_only_share_with_group_members'), $this->equalTo('no')) ->willReturn('yes'); - $this->config->expects($this->at(3)) + $this->config->expects($this->at(4)) ->method('getAppValue') ->with($this->equalTo('core'), $this->equalTo('shareapi_exclude_groups_list'), $this->equalTo('')) ->willReturn('["group1", "group5", "group6"]'); @@ -223,16 +228,20 @@ class ContactsStoreTest extends TestCase { $this->assertCount(0, $entries); } - public function testGetContactsOnlyIfInTheSameGroup() { + public function testGetContactsOnlyShareIfInTheSameGroup() { $this->config->expects($this->at(0))->method('getAppValue') ->with($this->equalTo('core'), $this->equalTo('shareapi_allow_share_dialog_user_enumeration'), $this->equalTo('yes')) ->willReturn('yes'); $this->config->expects($this->at(1)) ->method('getAppValue') + ->with($this->equalTo('core'), $this->equalTo('shareapi_restrict_user_enumeration_to_group'), $this->equalTo('no')) + ->willReturn('no'); + + $this->config->expects($this->at(2)) ->method('getAppValue') ->with($this->equalTo('core'), $this->equalTo('shareapi_exclude_groups'), $this->equalTo('no')) ->willReturn('no'); - $this->config->expects($this->at(2)) + $this->config->expects($this->at(3)) ->method('getAppValue') ->with($this->equalTo('core'), $this->equalTo('shareapi_only_share_with_group_members'), $this->equalTo('no')) ->willReturn('yes'); @@ -305,6 +314,92 @@ class ContactsStoreTest extends TestCase { $this->assertEquals('contact', $entries[2]->getProperty('UID')); } + public function testGetContactsOnlyEnumerateIfInTheSameGroup() { + $this->config->expects($this->at(0))->method('getAppValue') + ->with($this->equalTo('core'), $this->equalTo('shareapi_allow_share_dialog_user_enumeration'), $this->equalTo('yes')) + ->willReturn('yes'); + + $this->config->expects($this->at(1)) ->method('getAppValue') + ->with($this->equalTo('core'), $this->equalTo('shareapi_restrict_user_enumeration_to_group'), $this->equalTo('no')) + ->willReturn('yes'); + + $this->config->expects($this->at(2)) ->method('getAppValue') + ->with($this->equalTo('core'), $this->equalTo('shareapi_exclude_groups'), $this->equalTo('no')) + ->willReturn('no'); + + $this->config->expects($this->at(3)) + ->method('getAppValue') + ->with($this->equalTo('core'), $this->equalTo('shareapi_only_share_with_group_members'), $this->equalTo('no')) + ->willReturn('no'); + + /** @var IUser|PHPUnit_Framework_MockObject_MockObject $currentUser */ + $currentUser = $this->createMock(IUser::class); + $currentUser->expects($this->once()) + ->method('getUID') + ->willReturn('user001'); + + $this->groupManager->expects($this->at(0)) + ->method('getUserGroupIds') + ->with($this->equalTo($currentUser)) + ->willReturn(['group1', 'group2', 'group3']); + + $user1 = $this->createMock(IUser::class); + $this->userManager->expects($this->at(0)) + ->method('get') + ->with('user1') + ->willReturn($user1); + $this->groupManager->expects($this->at(1)) + ->method('getUserGroupIds') + ->with($this->equalTo($user1)) + ->willReturn(['group1']); + $user2 = $this->createMock(IUser::class); + $this->userManager->expects($this->at(1)) + ->method('get') + ->with('user2') + ->willReturn($user2); + $this->groupManager->expects($this->at(2)) + ->method('getUserGroupIds') + ->with($this->equalTo($user2)) + ->willReturn(['group2', 'group3']); + $user3 = $this->createMock(IUser::class); + $this->userManager->expects($this->at(2)) + ->method('get') + ->with('user3') + ->willReturn($user3); + $this->groupManager->expects($this->at(3)) + ->method('getUserGroupIds') + ->with($this->equalTo($user3)) + ->willReturn(['group8', 'group9']); + + $this->contactsManager->expects($this->once()) + ->method('search') + ->with($this->equalTo(''), $this->equalTo(['FN', 'EMAIL'])) + ->willReturn([ + [ + 'UID' => 'user1', + 'isLocalSystemBook' => true + ], + [ + 'UID' => 'user2', + 'isLocalSystemBook' => true + ], + [ + 'UID' => 'user3', + 'isLocalSystemBook' => true + ], + [ + 'UID' => 'contact', + ], + ]); + + $entries = $this->contactsStore->getContacts($currentUser, ''); + + $this->assertCount(3, $entries); + $this->assertEquals('user1', $entries[0]->getProperty('UID')); + $this->assertEquals('user2', $entries[1]->getProperty('UID')); + $this->assertEquals('contact', $entries[2]->getProperty('UID')); + } + public function testGetContactsWithFilter() { $this->config->expects($this->at(0))->method('getAppValue') ->with($this->equalTo('core'), $this->equalTo('shareapi_allow_share_dialog_user_enumeration'), $this->equalTo('yes')) diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php index 1ea4782a301..a8dd7fdc508 100644 --- a/tests/lib/Contacts/ContactsMenu/EntryTest.php +++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php @@ -110,5 +110,4 @@ class EntryTest extends TestCase { $this->assertEquals($expectedJson, $json); } - } diff --git a/tests/lib/Contacts/ContactsMenu/ManagerTest.php b/tests/lib/Contacts/ContactsMenu/ManagerTest.php index b78420e5424..561051974b7 100644 --- a/tests/lib/Contacts/ContactsMenu/ManagerTest.php +++ b/tests/lib/Contacts/ContactsMenu/ManagerTest.php @@ -222,5 +222,4 @@ class ManagerTest extends TestCase { $this->assertEquals(null, $data); } - } diff --git a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php index 85ffd1e72b1..157f8574fa4 100644 --- a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php +++ b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php @@ -67,7 +67,7 @@ class EMailproviderTest extends TestCase { ->method('getEMailAddresses') ->willReturn([ 'user@example.com', - ]); + ]); $this->actionFactory->expects($this->once()) ->method('newEMailAction') ->with($this->equalTo($iconUrl), $this->equalTo('user@example.com'), $this->equalTo('user@example.com')) @@ -94,7 +94,7 @@ class EMailproviderTest extends TestCase { ->method('getEMailAddresses') ->willReturn([ '', - ]); + ]); $this->actionFactory->expects($this->never()) ->method('newEMailAction'); $entry->expects($this->never()) @@ -102,5 +102,4 @@ class EMailproviderTest extends TestCase { $this->provider->process($entry); } - } diff --git a/tests/lib/ContactsManagerTest.php b/tests/lib/ContactsManagerTest.php index 9e8b75fbf4d..4699d894e4b 100644 --- a/tests/lib/ContactsManagerTest.php +++ b/tests/lib/ContactsManagerTest.php @@ -14,55 +14,55 @@ class ContactsManagerTest extends \Test\TestCase { $this->cm = new \OC\ContactsManager(); } - public function searchProvider(){ - $search1 = array( - 0 => array( - 'N' => array(0 => '', 1 => 'Jan', 2 => 'Jansen', 3 => '', 4 => '',), + public function searchProvider() { + $search1 = [ + 0 => [ + 'N' => [0 => '', 1 => 'Jan', 2 => 'Jansen', 3 => '', 4 => '',], 'UID' => '04ada7f5-01f9-4309-9c82-6b555b2170ed', 'FN' => 'Jan Jansen', 'id' => '1', 'addressbook-key' => 'simple:1', - ), - 0 => array( - 'N' => array(0 => '', 1 => 'Tom', 2 => 'Peeters', 3 => '', 4 => '',), + ], + 0 => [ + 'N' => [0 => '', 1 => 'Tom', 2 => 'Peeters', 3 => '', 4 => '',], 'UID' => '04ada7f5-01f9-4309-9c82-2345-2345--6b555b2170ed', 'FN' => 'Tom Peeters', 'id' => '2', 'addressbook-key' => 'simple:1', - ), - ); + ], + ]; - $search2 = array( - 0 => array( - 'N' => array(0 => '', 1 => 'fg', 2 => '', 3 => '', 4 => '',), + $search2 = [ + 0 => [ + 'N' => [0 => '', 1 => 'fg', 2 => '', 3 => '', 4 => '',], 'UID' => '04ada234h5jh357f5-01f9-4309-9c82-6b555b2170ed', 'FN' => 'Jan Rompuy', 'id' => '1', 'addressbook-key' => 'simple:2', - ), - 0 => array( - 'N' => array(0 => '', 1 => 'fg', 2 => '', 3 => '', 4 => '',), + ], + 0 => [ + 'N' => [0 => '', 1 => 'fg', 2 => '', 3 => '', 4 => '',], 'UID' => '04ada7f5-01f9-4309-345kj345j9c82-2345-2345--6b555b2170ed', 'FN' => 'Tim Peeters', 'id' => '2', 'addressbook-key' => 'simple:2', - ), - ); + ], + ]; $expectedResult = array_merge($search1, $search2); - return array( - array( + return [ + [ $search1, $search2, $expectedResult - ) - ); + ] + ]; } /** * @dataProvider searchProvider */ - public function testSearch($search1, $search2, $expectedResult ){ + public function testSearch($search1, $search2, $expectedResult) { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook1 = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -96,7 +96,7 @@ class ContactsManagerTest extends \Test\TestCase { } - public function testDeleteHavePermission(){ + public function testDeleteHavePermission() { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -116,7 +116,7 @@ class ContactsManagerTest extends \Test\TestCase { $this->assertEquals($result, 'returnMe'); } - public function testDeleteNoPermission(){ + public function testDeleteNoPermission() { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -134,7 +134,7 @@ class ContactsManagerTest extends \Test\TestCase { $this->assertEquals($result, null); } - public function testDeleteNoAddressbook(){ + public function testDeleteNoAddressbook() { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -146,10 +146,9 @@ class ContactsManagerTest extends \Test\TestCase { $this->cm->registerAddressBook($addressbook); $result = $this->cm->delete(1, 'noaddressbook'); $this->assertEquals($result, null); - } - public function testCreateOrUpdateHavePermission(){ + public function testCreateOrUpdateHavePermission() { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -164,11 +163,11 @@ class ContactsManagerTest extends \Test\TestCase { ->willReturn('returnMe'); $this->cm->registerAddressBook($addressbook); - $result = $this->cm->createOrUpdate(array(), $addressbook->getKey()); + $result = $this->cm->createOrUpdate([], $addressbook->getKey()); $this->assertEquals($result, 'returnMe'); } - public function testCreateOrUpdateNoPermission(){ + public function testCreateOrUpdateNoPermission() { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -182,12 +181,11 @@ class ContactsManagerTest extends \Test\TestCase { ->method('createOrUpdate'); $this->cm->registerAddressBook($addressbook); - $result = $this->cm->createOrUpdate(array(), $addressbook->getKey()); + $result = $this->cm->createOrUpdate([], $addressbook->getKey()); $this->assertEquals($result, null); - } - public function testCreateOrUpdateNOAdressbook(){ + public function testCreateOrUpdateNOAdressbook() { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -197,16 +195,16 @@ class ContactsManagerTest extends \Test\TestCase { ->method('createOrUpdate'); $this->cm->registerAddressBook($addressbook); - $result = $this->cm->createOrUpdate(array(), 'noaddressbook'); + $result = $this->cm->createOrUpdate([], 'noaddressbook'); $this->assertEquals($result, null); } - public function testIsEnabledIfNot(){ + public function testIsEnabledIfNot() { $result = $this->cm->isEnabled(); $this->assertFalse($result); } - public function testIsEnabledIfSo(){ + public function testIsEnabledIfSo() { /** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $addressbook */ $addressbook = $this->getMockBuilder('\OCP\IAddressBook') ->disableOriginalConstructor() @@ -227,10 +225,10 @@ class ContactsManagerTest extends \Test\TestCase { // setup return for method calls $addressbook->expects($this->any()) ->method('getKey') - ->will($this->returnValue('SIMPLE_ADDRESS_BOOK')); + ->willReturn('SIMPLE_ADDRESS_BOOK'); $addressbook->expects($this->any()) ->method('getDisplayName') - ->will($this->returnValue('A very simple Addressbook')); + ->willReturn('A very simple Addressbook'); // register the address book $this->cm->registerAddressBook($addressbook); diff --git a/tests/lib/DB/ConnectionFactoryTest.php b/tests/lib/DB/ConnectionFactoryTest.php index 6a1a9b31c4b..de232bb1fdd 100644 --- a/tests/lib/DB/ConnectionFactoryTest.php +++ b/tests/lib/DB/ConnectionFactoryTest.php @@ -26,7 +26,6 @@ use OC\SystemConfig; use Test\TestCase; class ConnectionFactoryTest extends TestCase { - public function splitHostFromPortAndSocketData() { return [ ['127.0.0.1', ['host' => '127.0.0.1']], diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php index 607674d7a38..c8b2b7ee13e 100644 --- a/tests/lib/DB/ConnectionTest.php +++ b/tests/lib/DB/ConnectionTest.php @@ -213,7 +213,7 @@ class ConnectionTest extends \Test\TestCase { ['user' => 'test2', 'category' => 'Coworkers', 'expectedResult' => 1], ]; - foreach($categoryEntries as $entry) { + foreach ($categoryEntries as $entry) { $result = $this->connection->insertIfNotExist('*PREFIX*table', [ 'textfield' => $entry['user'], @@ -236,7 +236,7 @@ class ConnectionTest extends \Test\TestCase { ['addressbookid' => 123, 'fullname' => 'test', 'expectedResult' => 1], ]; - foreach($categoryEntries as $entry) { + foreach ($categoryEntries as $entry) { $result = $this->connection->insertIfNotExist('*PREFIX*table', [ 'integerfield_default' => $entry['addressbookid'], @@ -347,5 +347,4 @@ class ConnectionTest extends \Test\TestCase { $this->connection->executeUpdate($testQuery, $testParams); $this->connection->executeUpdate($testQuery, $testParams); } - } diff --git a/tests/lib/DB/DBSchemaTest.php b/tests/lib/DB/DBSchemaTest.php index 5fb68fdf258..4b249d07c45 100644 --- a/tests/lib/DB/DBSchemaTest.php +++ b/tests/lib/DB/DBSchemaTest.php @@ -39,12 +39,12 @@ class DBSchemaTest extends TestCase { $r = '_' . \OC::$server->getSecureRandom()-> generate(4, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS) . '_'; - $content = file_get_contents( $dbfile ); - $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); - file_put_contents( $this->schema_file, $content ); - $content = file_get_contents( $dbfile2 ); - $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); - file_put_contents( $this->schema_file2, $content ); + $content = file_get_contents($dbfile); + $content = str_replace('*dbprefix*', '*dbprefix*'.$r, $content); + file_put_contents($this->schema_file, $content); + $content = file_get_contents($dbfile2); + $content = str_replace('*dbprefix*', '*dbprefix*'.$r, $content); + file_put_contents($this->schema_file2, $content); $this->table1 = $r.'cntcts_addrsbks'; $this->table2 = $r.'cntcts_cards'; diff --git a/tests/lib/DB/LegacyDBTest.php b/tests/lib/DB/LegacyDBTest.php index 200afac3f9a..cf4c746a4dd 100644 --- a/tests/lib/DB/LegacyDBTest.php +++ b/tests/lib/DB/LegacyDBTest.php @@ -16,7 +16,7 @@ use OC_DB; * @group DB */ class LegacyDBTest extends \Test\TestCase { - protected $backupGlobals = FALSE; + protected $backupGlobals = false; protected static $schema_file; protected $test_prefix; @@ -62,9 +62,9 @@ class LegacyDBTest extends \Test\TestCase { $dbFile = \OC::$SERVERROOT.'/tests/data/db_structure.xml'; $r = $this->getUniqueID('_', 4).'_'; - $content = file_get_contents( $dbFile ); - $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); - file_put_contents( self::$schema_file, $content ); + $content = file_get_contents($dbFile); + $content = str_replace('*dbprefix*', '*dbprefix*'.$r, $content); + file_put_contents(self::$schema_file, $content); OC_DB::createDbFromStructure(self::$schema_file); $this->test_prefix = $r; @@ -85,15 +85,15 @@ class LegacyDBTest extends \Test\TestCase { public function testQuotes() { $query = OC_DB::prepare('SELECT `fullname` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_1')); + $result = $query->execute(['uri_1']); $this->assertTrue((bool)$result); $row = $result->fetchRow(); $this->assertFalse($row); $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)'); - $result = $query->execute(array('fullname test', 'uri_1')); + $result = $query->execute(['fullname test', 'uri_1']); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_1')); + $result = $query->execute(['uri_1']); $this->assertTrue((bool)$result); $row = $result->fetchRow(); $this->assertArrayHasKey('fullname', $row); @@ -107,29 +107,29 @@ class LegacyDBTest extends \Test\TestCase { */ public function testNOW() { $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (NOW(),?)'); - $result = $query->execute(array('uri_2')); + $result = $query->execute(['uri_2']); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_2')); + $result = $query->execute(['uri_2']); $this->assertTrue((bool)$result); } public function testUNIX_TIMESTAMP() { $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (UNIX_TIMESTAMP(),?)'); - $result = $query->execute(array('uri_3')); + $result = $query->execute(['uri_3']); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?'); - $result = $query->execute(array('uri_3')); + $result = $query->execute(['uri_3']); $this->assertTrue((bool)$result); } public function testLastInsertId() { $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)'); - $result1 = OC_DB::executeAudited($query, array('insertid 1','uri_1')); + $result1 = OC_DB::executeAudited($query, ['insertid 1','uri_1']); $id1 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2); // we don't know the id we should expect, so insert another row - $result2 = OC_DB::executeAudited($query, array('insertid 2','uri_2')); + $result2 = OC_DB::executeAudited($query, ['insertid 2','uri_2']); $id2 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2); // now we can check if the two ids are in correct order $this->assertGreaterThan($id1, $id2); @@ -140,7 +140,7 @@ class LegacyDBTest extends \Test\TestCase { $expected = "Ћö雙喜\xE2\x80\xA2"; $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $result = $query->execute(array($expected, 'uri_1', 'This is a vCard')); + $result = $query->execute([$expected, 'uri_1', 'This is a vCard']); $this->assertEquals(1, $result); $actual = OC_DB::prepare("SELECT `fullname` FROM `$table`")->execute()->fetchOne(); @@ -156,7 +156,7 @@ class LegacyDBTest extends \Test\TestCase { $rowname = 'decimaltest'; $query = OC_DB::prepare('INSERT INTO `' . $table . '` (`' . $rowname . '`) VALUES (?)'); - $result = $query->execute(array($insert)); + $result = $query->execute([$insert]); $this->assertEquals(1, $result); $query = OC_DB::prepare('SELECT `' . $rowname . '` FROM `' . $table . '`'); $result = $query->execute(); @@ -205,35 +205,35 @@ class LegacyDBTest extends \Test\TestCase { // updating to. MySQL reports 1 here when the PDO::MYSQL_ATTR_FOUND_ROWS // flag is not specified. $query = OC_DB::prepare("UPDATE `*PREFIX*{$this->table2}` SET `uri` = ?"); - $this->assertSame(2, $query->execute(array('uri1'))); + $this->assertSame(2, $query->execute(['uri1'])); } protected function insertCardData($fullname, $uri) { $query = OC_DB::prepare("INSERT INTO `*PREFIX*{$this->table2}` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $this->assertSame(1, $query->execute(array($fullname, $uri, $this->getUniqueID()))); + $this->assertSame(1, $query->execute([$fullname, $uri, $this->getUniqueID()])); } protected function updateCardData($fullname, $uri) { $query = OC_DB::prepare("UPDATE `*PREFIX*{$this->table2}` SET `uri` = ? WHERE `fullname` = ?"); - return $query->execute(array($uri, $fullname)); + return $query->execute([$uri, $fullname]); } public function testILIKE() { $table = "*PREFIX*{$this->table2}"; $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $query->execute(array('fooBAR', 'foo', 'bar')); + $query->execute(['fooBAR', 'foo', 'bar']); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('foobar')); + $result = $query->execute(['foobar']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('foobar')); + $result = $query->execute(['foobar']); $this->assertCount(1, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('foo')); + $result = $query->execute(['foo']); $this->assertCount(0, $result->fetchAll()); } @@ -241,30 +241,30 @@ class LegacyDBTest extends \Test\TestCase { $table = "*PREFIX*{$this->table2}"; $query = OC_DB::prepare("INSERT INTO `$table` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)"); - $query->execute(array('FooBAR', 'foo', 'bar')); + $query->execute(['FooBAR', 'foo', 'bar']); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('%bar')); + $result = $query->execute(['%bar']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('foo%')); + $result = $query->execute(['foo%']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?"); - $result = $query->execute(array('%ba%')); + $result = $query->execute(['%ba%']); $this->assertCount(0, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('%bar')); + $result = $query->execute(['%bar']); $this->assertCount(1, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('foo%')); + $result = $query->execute(['foo%']); $this->assertCount(1, $result->fetchAll()); $query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?"); - $result = $query->execute(array('%ba%')); + $result = $query->execute(['%ba%']); $this->assertCount(1, $result->fetchAll()); } @@ -279,7 +279,7 @@ class LegacyDBTest extends \Test\TestCase { if ($throwsOnMysqlWithoutUTF8MB4 && $config->getSystemValue('dbtype', 'sqlite') === 'mysql' && $config->getSystemValue('mysql.utf8mb4', false) === false) { $this->markTestSkipped('MySQL requires UTF8mb4 to store value: ' . $expected); } - $result = $query->execute(array($expected)); + $result = $query->execute([$expected]); $this->assertEquals(1, $result); $actual = OC_DB::prepare("SELECT `textfield` FROM `$table`")->execute()->fetchOne(); diff --git a/tests/lib/DB/MDB2SchemaManagerTest.php b/tests/lib/DB/MDB2SchemaManagerTest.php index 8c9290c56b4..18af9716502 100644 --- a/tests/lib/DB/MDB2SchemaManagerTest.php +++ b/tests/lib/DB/MDB2SchemaManagerTest.php @@ -19,7 +19,6 @@ use Doctrine\DBAL\Platforms\OraclePlatform; * @package Test\DB */ class MDB2SchemaManagerTest extends \Test\TestCase { - protected function tearDown(): void { // do not drop the table for Oracle as it will create a bogus transaction // that will break the following test suites requiring transactions @@ -31,7 +30,6 @@ class MDB2SchemaManagerTest extends \Test\TestCase { } public function testAutoIncrement() { - $connection = \OC::$server->getDatabaseConnection(); if ($connection->getDatabasePlatform() instanceof OraclePlatform) { $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.'); @@ -40,13 +38,12 @@ class MDB2SchemaManagerTest extends \Test\TestCase { $manager = new \OC\DB\MDB2SchemaManager($connection); $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml'); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); - $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['abc']); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['abc']); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['123']); + $connection->executeUpdate('insert into `*PREFIX*table` values (?)', ['123']); $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml'); $this->addToAssertionCount(1); } - } diff --git a/tests/lib/DB/MDB2SchemaReaderTest.php b/tests/lib/DB/MDB2SchemaReaderTest.php index 3b44f15f756..2f987adb290 100644 --- a/tests/lib/DB/MDB2SchemaReaderTest.php +++ b/tests/lib/DB/MDB2SchemaReaderTest.php @@ -38,10 +38,10 @@ class MDB2SchemaReaderTest extends TestCase { ->getMock(); $config->expects($this->any()) ->method('getSystemValue') - ->will($this->returnValueMap(array( - array('dbname', 'owncloud', 'testDB'), - array('dbtableprefix', 'oc_', 'test_') - ))); + ->willReturnMap([ + ['dbname', 'owncloud', 'testDB'], + ['dbtableprefix', 'oc_', 'test_'] + ]); return $config; } @@ -85,10 +85,10 @@ class MDB2SchemaReaderTest extends TestCase { $this->assertEquals(2, $table->getColumn('decimalfield_precision_scale')->getScale()); $this->assertCount(2, $table->getIndexes()); - $this->assertEquals(array('integerfield'), $table->getIndex('primary')->getUnquotedColumns()); + $this->assertEquals(['integerfield'], $table->getIndex('primary')->getUnquotedColumns()); $this->assertTrue($table->getIndex('primary')->isPrimary()); $this->assertTrue($table->getIndex('primary')->isUnique()); - $this->assertEquals(array('booleanfield'), $table->getIndex('index_boolean')->getUnquotedColumns()); + $this->assertEquals(['booleanfield'], $table->getIndex('index_boolean')->getUnquotedColumns()); $this->assertFalse($table->getIndex('index_boolean')->isPrimary()); $this->assertFalse($table->getIndex('index_boolean')->isUnique()); } diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php index 15415a4061c..c4e9b1857fb 100644 --- a/tests/lib/DB/MigrationsTest.php +++ b/tests/lib/DB/MigrationsTest.php @@ -92,7 +92,6 @@ class MigrationsTest extends \Test\TestCase { } public function testExecuteStepWithSchemaChange() { - $schema = $this->createMock(Schema::class); $this->db->expects($this->any()) ->method('createSchema') @@ -136,7 +135,6 @@ class MigrationsTest extends \Test\TestCase { } public function testExecuteStepWithoutSchemaChange() { - $schema = $this->createMock(Schema::class); $this->db->expects($this->any()) ->method('createSchema') @@ -326,7 +324,7 @@ class MigrationsTest extends \Test\TestCase { $defaultName = 'PRIMARY'; if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) { $defaultName = \str_repeat('a', 26) . '_' . \str_repeat('b', 30) . '_seq'; - } else if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { + } elseif ($this->db->getDatabasePlatform() instanceof OraclePlatform) { $defaultName = \str_repeat('a', 26) . '_seq'; } @@ -407,7 +405,7 @@ class MigrationsTest extends \Test\TestCase { $defaultName = 'PRIMARY'; if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) { $defaultName = \str_repeat('a', 27) . '_' . \str_repeat('b', 30) . '_seq'; - } else if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { + } elseif ($this->db->getDatabasePlatform() instanceof OraclePlatform) { $defaultName = \str_repeat('a', 27) . '_seq'; } diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index e5cc28654e4..b5021dcccf9 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -65,11 +65,13 @@ class MigratorTest extends \Test\TestCase { // Try to delete if exists (IF EXISTS NOT SUPPORTED IN ORACLE) try { $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableNameTmp)); - } catch (\Doctrine\DBAL\DBALException $e) {} + } catch (\Doctrine\DBAL\DBALException $e) { + } try { $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableName)); - } catch (\Doctrine\DBAL\DBALException $e) {} + } catch (\Doctrine\DBAL\DBALException $e) { + } parent::tearDown(); } @@ -77,19 +79,19 @@ class MigratorTest extends \Test\TestCase { * @return \Doctrine\DBAL\Schema\Schema[] */ private function getDuplicateKeySchemas() { - $startSchema = new Schema(array(), array(), $this->getSchemaConfig()); + $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); $table->addColumn('id', 'integer'); $table->addColumn('name', 'string'); - $table->addIndex(array('id'), $this->tableName . '_id'); + $table->addIndex(['id'], $this->tableName . '_id'); - $endSchema = new Schema(array(), array(), $this->getSchemaConfig()); + $endSchema = new Schema([], [], $this->getSchemaConfig()); $table = $endSchema->createTable($this->tableName); $table->addColumn('id', 'integer'); $table->addColumn('name', 'string'); - $table->addUniqueIndex(array('id'), $this->tableName . '_id'); + $table->addUniqueIndex(['id'], $this->tableName . '_id'); - return array($startSchema, $endSchema); + return [$startSchema, $endSchema]; } private function getSchemaConfig() { @@ -113,9 +115,9 @@ class MigratorTest extends \Test\TestCase { $migrator = $this->manager->getMigrator(); $migrator->migrate($startSchema); - $this->connection->insert($this->tableName, array('id' => 1, 'name' => 'foo')); - $this->connection->insert($this->tableName, array('id' => 2, 'name' => 'bar')); - $this->connection->insert($this->tableName, array('id' => 2, 'name' => 'qwerty')); + $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'bar']); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'qwerty']); $migrator->checkMigrate($endSchema); $this->fail('checkMigrate should have failed'); @@ -126,9 +128,9 @@ class MigratorTest extends \Test\TestCase { $migrator = $this->manager->getMigrator(); $migrator->migrate($startSchema); - $this->connection->insert($this->tableName, array('id' => 1, 'name' => 'foo')); - $this->connection->insert($this->tableName, array('id' => 2, 'name' => 'bar')); - $this->connection->insert($this->tableName, array('id' => 3, 'name' => 'qwerty')); + $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'bar']); + $this->connection->insert($this->tableName, ['id' => 3, 'name' => 'qwerty']); $migrator->checkMigrate($endSchema); $migrator->migrate($endSchema); @@ -145,9 +147,9 @@ class MigratorTest extends \Test\TestCase { $migrator = $this->manager->getMigrator(); $migrator->migrate($startSchema); - $this->connection->insert($this->tableName, array('id' => 1, 'name' => 'foo')); - $this->connection->insert($this->tableName, array('id' => 2, 'name' => 'bar')); - $this->connection->insert($this->tableName, array('id' => 3, 'name' => 'qwerty')); + $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'bar']); + $this->connection->insert($this->tableName, ['id' => 3, 'name' => 'qwerty']); $migrator->checkMigrate($endSchema); $migrator->migrate($endSchema); @@ -163,10 +165,10 @@ class MigratorTest extends \Test\TestCase { $migrator->migrate($endSchema); - $this->connection->insert($this->tableName, array('id' => 1, 'name' => 'foo')); - $this->connection->insert($this->tableName, array('id' => 2, 'name' => 'bar')); + $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'bar']); try { - $this->connection->insert($this->tableName, array('id' => 2, 'name' => 'qwerty')); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'qwerty']); $this->fail('Expected duplicate key insert to fail'); } catch (DBALException $e) { $this->addToAssertionCount(1); @@ -174,16 +176,16 @@ class MigratorTest extends \Test\TestCase { } public function testAddingPrimaryKeyWithAutoIncrement() { - $startSchema = new Schema(array(), array(), $this->getSchemaConfig()); + $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); $table->addColumn('id', 'integer'); $table->addColumn('name', 'string'); - $endSchema = new Schema(array(), array(), $this->getSchemaConfig()); + $endSchema = new Schema([], [], $this->getSchemaConfig()); $table = $endSchema->createTable($this->tableName); - $table->addColumn('id', 'integer', array('autoincrement' => true)); + $table->addColumn('id', 'integer', ['autoincrement' => true]); $table->addColumn('name', 'string'); - $table->setPrimaryKey(array('id')); + $table->setPrimaryKey(['id']); $migrator = $this->manager->getMigrator(); $migrator->migrate($startSchema); @@ -195,17 +197,17 @@ class MigratorTest extends \Test\TestCase { } public function testReservedKeywords() { - $startSchema = new Schema(array(), array(), $this->getSchemaConfig()); + $startSchema = new Schema([], [], $this->getSchemaConfig()); $table = $startSchema->createTable($this->tableName); - $table->addColumn('id', 'integer', array('autoincrement' => true)); - $table->addColumn('user', 'string', array('length' => 255)); - $table->setPrimaryKey(array('id')); + $table->addColumn('id', 'integer', ['autoincrement' => true]); + $table->addColumn('user', 'string', ['length' => 255]); + $table->setPrimaryKey(['id']); - $endSchema = new Schema(array(), array(), $this->getSchemaConfig()); + $endSchema = new Schema([], [], $this->getSchemaConfig()); $table = $endSchema->createTable($this->tableName); - $table->addColumn('id', 'integer', array('autoincrement' => true)); - $table->addColumn('user', 'string', array('length' => 64)); - $table->setPrimaryKey(array('id')); + $table->addColumn('id', 'integer', ['autoincrement' => true]); + $table->addColumn('user', 'string', ['length' => 64]); + $table->setPrimaryKey(['id']); $migrator = $this->manager->getMigrator(); $migrator->migrate($startSchema); @@ -227,7 +229,7 @@ class MigratorTest extends \Test\TestCase { $tableFk = $startSchema->createTable($this->tableNameTmp); $tableFk->addColumn('fk_id', 'integer'); $tableFk->addColumn('name', 'string'); - $tableFk->addForeignKeyConstraint($this->tableName, array('fk_id'), array('id'), array(), $fkName); + $tableFk->addForeignKeyConstraint($this->tableName, ['fk_id'], ['id'], [], $fkName); $migrator = $this->manager->getMigrator(); $migrator->migrate($startSchema); diff --git a/tests/lib/DB/MySqlMigrationTest.php b/tests/lib/DB/MySqlMigrationTest.php index 5ebbd273c33..36ab8ef7319 100644 --- a/tests/lib/DB/MySqlMigrationTest.php +++ b/tests/lib/DB/MySqlMigrationTest.php @@ -45,5 +45,4 @@ class MySqlMigrationTest extends \Test\TestCase { $this->addToAssertionCount(1); } - } diff --git a/tests/lib/DB/OCPostgreSqlPlatformTest.php b/tests/lib/DB/OCPostgreSqlPlatformTest.php index 54701bdcec9..0821a988eb5 100644 --- a/tests/lib/DB/OCPostgreSqlPlatformTest.php +++ b/tests/lib/DB/OCPostgreSqlPlatformTest.php @@ -37,7 +37,6 @@ use Doctrine\DBAL\Types\Type; * @package Test\DB */ class OCPostgreSqlPlatformTest extends \Test\TestCase { - public function testAlterBigint() { $platform = new PostgreSqlPlatform(); $sourceSchema = new Schema(); @@ -71,5 +70,4 @@ class OCPostgreSqlPlatformTest extends \Test\TestCase { 'length' => 11, ]); } - } diff --git a/tests/lib/DB/SchemaDiffTest.php b/tests/lib/DB/SchemaDiffTest.php index 78963698571..29d456805d5 100644 --- a/tests/lib/DB/SchemaDiffTest.php +++ b/tests/lib/DB/SchemaDiffTest.php @@ -71,8 +71,7 @@ class SchemaDiffTest extends TestCase { * @param string $xml */ public function testZeroChangeOnSchemaMigrations($xml) { - - $xml = str_replace( '*dbprefix*', $this->testPrefix, $xml ); + $xml = str_replace('*dbprefix*', $this->testPrefix, $xml); $schemaFile = $this->schemaFile; file_put_contents($schemaFile, $xml); diff --git a/tests/lib/DB/SqliteMigrationTest.php b/tests/lib/DB/SqliteMigrationTest.php index ecc6cbe0951..480a5ebe74f 100644 --- a/tests/lib/DB/SqliteMigrationTest.php +++ b/tests/lib/DB/SqliteMigrationTest.php @@ -45,5 +45,4 @@ class SqliteMigrationTest extends \Test\TestCase { $this->addToAssertionCount(1); } - } diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php index 6cd8b572fcd..2beb89654f6 100644 --- a/tests/lib/DateTimeFormatterTest.php +++ b/tests/lib/DateTimeFormatterTest.php @@ -11,12 +11,12 @@ namespace Test; class DateTimeFormatterTest extends TestCase { /** @var \OC\DateTimeFormatter */ protected $formatter; - static protected $oneMinute = 60; - static protected $oneHour = 3600; - static protected $oneDay; - static protected $oneYear; + protected static $oneMinute = 60; + protected static $oneHour = 3600; + protected static $oneDay; + protected static $oneYear; - static protected $defaultTimeZone; + protected static $defaultTimeZone; public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -44,35 +44,35 @@ class DateTimeFormatterTest extends TestCase { public function formatTimeSpanData() { $time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo $deL10N = \OC::$server->getL10N('lib', 'de'); - return array( - array('seconds ago', $time, $time), - array('in a few seconds', $time + 5 , $time), - array('1 minute ago', $this->getTimestampAgo($time, 30, 1), $time), - array('15 minutes ago', $this->getTimestampAgo($time, 30, 15), $time), - array('in 15 minutes', $time, $this->getTimestampAgo($time, 30, 15)), - array('1 hour ago', $this->getTimestampAgo($time, 30, 15, 1), $time), - array('3 hours ago', $this->getTimestampAgo($time, 30, 15, 3), $time), - array('in 3 hours', $time, $this->getTimestampAgo($time, 30, 15, 3)), - array('4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4), $time), - - array('seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('1 minute ago', new \DateTime('Wed, 02 Oct 2013 23:58:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('3 minutes ago', new \DateTime('Wed, 02 Oct 2013 23:56:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('59 minutes ago', new \DateTime('Wed, 02 Oct 2013 23:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('1 hour ago', new \DateTime('Wed, 02 Oct 2013 22:59:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('3 hours ago', new \DateTime('Wed, 02 Oct 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('yesterday', new \DateTime('Tue, 01 Oct 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('2 days ago', new \DateTime('Mon, 30 Sep 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - - array($deL10N->t('seconds ago'), new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), - array($deL10N->n('%n minute ago', '%n minutes ago', 1), new \DateTime('Wed, 02 Oct 2013 23:58:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), - array($deL10N->n('%n minute ago', '%n minutes ago', 3), new \DateTime('Wed, 02 Oct 2013 23:56:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), - array($deL10N->n('%n hour ago', '%n hours ago', 1), new \DateTime('Wed, 02 Oct 2013 22:59:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), - array($deL10N->n('%n hour ago', '%n hours ago', 3), new \DateTime('Wed, 02 Oct 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), - array($deL10N->n('%n day ago', '%n days ago', 2), new \DateTime('Mon, 30 Sep 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), - - ); + return [ + ['seconds ago', $time, $time], + ['in a few seconds', $time + 5 , $time], + ['1 minute ago', $this->getTimestampAgo($time, 30, 1), $time], + ['15 minutes ago', $this->getTimestampAgo($time, 30, 15), $time], + ['in 15 minutes', $time, $this->getTimestampAgo($time, 30, 15)], + ['1 hour ago', $this->getTimestampAgo($time, 30, 15, 1), $time], + ['3 hours ago', $this->getTimestampAgo($time, 30, 15, 3), $time], + ['in 3 hours', $time, $this->getTimestampAgo($time, 30, 15, 3)], + ['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4), $time], + + ['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['1 minute ago', new \DateTime('Wed, 02 Oct 2013 23:58:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['3 minutes ago', new \DateTime('Wed, 02 Oct 2013 23:56:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['59 minutes ago', new \DateTime('Wed, 02 Oct 2013 23:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['1 hour ago', new \DateTime('Wed, 02 Oct 2013 22:59:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['3 hours ago', new \DateTime('Wed, 02 Oct 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['yesterday', new \DateTime('Tue, 01 Oct 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['2 days ago', new \DateTime('Mon, 30 Sep 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + + [$deL10N->t('seconds ago'), new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], + [$deL10N->n('%n minute ago', '%n minutes ago', 1), new \DateTime('Wed, 02 Oct 2013 23:58:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], + [$deL10N->n('%n minute ago', '%n minutes ago', 3), new \DateTime('Wed, 02 Oct 2013 23:56:30 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], + [$deL10N->n('%n hour ago', '%n hours ago', 1), new \DateTime('Wed, 02 Oct 2013 22:59:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], + [$deL10N->n('%n hour ago', '%n hours ago', 3), new \DateTime('Wed, 02 Oct 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], + [$deL10N->n('%n day ago', '%n days ago', 2), new \DateTime('Mon, 30 Sep 2013 20:39:59 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], + + ]; } /** @@ -85,60 +85,60 @@ class DateTimeFormatterTest extends TestCase { public function formatDateSpanData() { $time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo $deL10N = \OC::$server->getL10N('lib', 'de'); - return array( + return [ // Normal testing - array('today', $this->getTimestampAgo($time, 30, 15), $time), - array('yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time), - array('tomorrow', $time, $this->getTimestampAgo($time, 0, 0, 0, 1)), - array('4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time), - array('in 4 days', $time, $this->getTimestampAgo($time, 0, 0, 0, 4)), - array('5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time), - array('next month', $time, $this->getTimestampAgo($time, 0, 0, 0, 32)), - array('in 5 months', $time, $this->getTimestampAgo($time, 0, 0, 0, 155)), - array('2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time), - array('next year', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), - array('in 2 years', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 2)), + ['today', $this->getTimestampAgo($time, 30, 15), $time], + ['yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time], + ['tomorrow', $time, $this->getTimestampAgo($time, 0, 0, 0, 1)], + ['4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time], + ['in 4 days', $time, $this->getTimestampAgo($time, 0, 0, 0, 4)], + ['5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time], + ['next month', $time, $this->getTimestampAgo($time, 0, 0, 0, 32)], + ['in 5 months', $time, $this->getTimestampAgo($time, 0, 0, 0, 155)], + ['2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time], + ['next year', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['in 2 years', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 2)], // Test with compare timestamp - array('today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), - array('yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), - array('4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), - array('5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), - array('2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), + ['today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], + ['2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)], // Test translations - array($deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), - array($deL10N->t('yesterday'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), - array($deL10N->n('%n day ago', '%n days ago', 2), new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), - array($deL10N->n('%n month ago', '%n months ago', 9), new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), - array($deL10N->n('%n year ago', '%n years ago', 2), new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), + [$deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N], + [$deL10N->t('yesterday'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N], + [$deL10N->n('%n day ago', '%n days ago', 2), new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N], + [$deL10N->n('%n month ago', '%n months ago', 9), new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N], + [$deL10N->n('%n year ago', '%n years ago', 2), new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N], // Test time - array('today', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('today', new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('today', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), + ['today', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['today', new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['today', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], // Test some special yesterdays - array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), - array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), - array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), - array('yesterday', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), - array('yesterday', new \DateTime('Mon, 31 Dec 2012 00:00:00 +0000'), new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000')), + ['yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')], + ['yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')], + ['yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')], + ['yesterday', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')], + ['yesterday', new \DateTime('Mon, 31 Dec 2012 00:00:00 +0000'), new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000')], // Test last month - array('2 days ago', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), - array('last month', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 31 Oct 2013 00:00:00 +0000')), - array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), - array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Thu, 31 Oct 2013 00:00:00 +0000')), + ['2 days ago', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')], + ['last month', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 31 Oct 2013 00:00:00 +0000')], + ['last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')], + ['last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Thu, 31 Oct 2013 00:00:00 +0000')], // Test last year - array('9 months ago', new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), - array('11 months ago', new \DateTime('Thu, 03 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), - array('last year', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), - array('last year', new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), - array('2 years ago', new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), - ); + ['9 months ago', new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')], + ['11 months ago', new \DateTime('Thu, 03 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')], + ['last year', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')], + ['last year', new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')], + ['2 years ago', new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')], + ]; } /** @@ -149,9 +149,9 @@ class DateTimeFormatterTest extends TestCase { } public function formatDateData() { - return array( - array(1102831200, 'December 12, 2004'), - ); + return [ + [1102831200, 'December 12, 2004'], + ]; } /** @@ -162,10 +162,10 @@ class DateTimeFormatterTest extends TestCase { } public function formatDateTimeData() { - return array( - array(1350129205, null, 'October 13, 2012 at 11:53:25 AM GMT+0'), - array(1350129205, new \DateTimeZone('Europe/Berlin'), 'October 13, 2012 at 1:53:25 PM GMT+2'), - ); + return [ + [1350129205, null, 'October 13, 2012 at 11:53:25 AM GMT+0'], + [1350129205, new \DateTimeZone('Europe/Berlin'), 'October 13, 2012 at 1:53:25 PM GMT+2'], + ]; } /** @@ -176,7 +176,7 @@ class DateTimeFormatterTest extends TestCase { } - function testFormatDateWithInvalidTZ() { + public function testFormatDateWithInvalidTZ() { $this->expectException(\Exception::class); $this->formatter->formatDate(1350129205, 'long', new \DateTimeZone('Mordor/Barad-dûr')); diff --git a/tests/lib/Diagnostics/EventLoggerTest.php b/tests/lib/Diagnostics/EventLoggerTest.php index 323ca5c20d7..c26ca2ce202 100644 --- a/tests/lib/Diagnostics/EventLoggerTest.php +++ b/tests/lib/Diagnostics/EventLoggerTest.php @@ -61,6 +61,5 @@ class EventLoggerTest extends TestCase { $this->assertSame("test3", $events['test3']->getId()); $this->assertSame("testevent3", $events['test3']->getDescription()); $this->assertSame(2, sizeof($events)); - } } diff --git a/tests/lib/Diagnostics/QueryLoggerTest.php b/tests/lib/Diagnostics/QueryLoggerTest.php index 545a706c3cf..50d62d3d0e6 100644 --- a/tests/lib/Diagnostics/QueryLoggerTest.php +++ b/tests/lib/Diagnostics/QueryLoggerTest.php @@ -49,6 +49,5 @@ class QueryLoggerTest extends TestCase { $queries = $this->logger->getQueries(); $this->assertSame(1, sizeof($queries)); - } } diff --git a/tests/lib/DirectEditing/ManagerTest.php b/tests/lib/DirectEditing/ManagerTest.php index 737a41425e1..84685d3a16b 100644 --- a/tests/lib/DirectEditing/ManagerTest.php +++ b/tests/lib/DirectEditing/ManagerTest.php @@ -12,7 +12,6 @@ use OCP\DirectEditing\IEditor; use OCP\DirectEditing\IToken; use OCP\Files\Folder; use OCP\Files\IRootFolder; -use OCP\Files\NotFoundException; use OCP\IDBConnection; use OCP\IL10N; use OCP\IUserSession; @@ -22,9 +21,8 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class CreateEmpty extends ACreateEmpty { - - public function getId(): string { - return 'createEmpty'; + public function getId(): string { + return 'createEmpty'; } public function getName(): string { @@ -35,16 +33,15 @@ class CreateEmpty extends ACreateEmpty { return '.txt'; } - public function getMimetype(): string { + public function getMimetype(): string { return 'text/plain'; } } class Editor implements IEditor { - - public function getId(): string { - return 'testeditor'; - } + public function getId(): string { + return 'testeditor'; + } public function getName(): string { return 'Test editor'; @@ -82,7 +79,6 @@ class Editor implements IEditor { * @group DB */ class ManagerTest extends TestCase { - private $manager; /** * @var Editor @@ -195,5 +191,4 @@ class ManagerTest extends TestCase { $this->manager->create('/File.txt', 'testeditor', 'createEmpty'); } - } diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index e2c76db7ed9..3a16327ac18 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -21,7 +21,6 @@ namespace Test\Encryption; - use OC\Encryption\DecryptAll; use OC\Encryption\Exceptions\DecryptionFailedException; use OC\Encryption\Manager; @@ -33,7 +32,6 @@ use OCP\UserInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; @@ -109,7 +107,6 @@ class DecryptAllTest extends TestCase { * @param bool $userExistsChecked */ public function testDecryptAll($prepareResult, $user, $userExistsChecked) { - if ($userExistsChecked) { $this->userManager->expects($this->once())->method('userExists')->willReturn(true); } else { @@ -168,7 +165,6 @@ class DecryptAllTest extends TestCase { * @param bool $success */ public function testPrepareEncryptionModules($success) { - $user = 'user1'; $dummyEncryptionModule = $this->getMockBuilder('OCP\Encryption\IEncryptionModule') @@ -179,7 +175,9 @@ class DecryptAllTest extends TestCase { ->with($this->inputInterface, $this->outputInterface, $user) ->willReturn($success); - $callback = function() use ($dummyEncryptionModule) {return $dummyEncryptionModule;}; + $callback = function () use ($dummyEncryptionModule) { + return $dummyEncryptionModule; + }; $moduleDescription = [ 'id' => 'id', 'displayName' => 'displayName', @@ -285,7 +283,7 @@ class DecryptAllTest extends TestCase { $this->view->expects($this->any())->method('is_dir') ->willReturnCallback( - function($path) { + function ($path) { if ($path === '/user1/files/foo') { return true; } @@ -307,14 +305,12 @@ class DecryptAllTest extends TestCase { $progressBar = new ProgressBar($output); $this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']); - } /** * @dataProvider dataTrueFalse */ public function testDecryptFile($isEncrypted) { - $path = 'test.txt'; /** @var DecryptAll | \PHPUnit_Framework_MockObject_MockObject $instance */ @@ -381,7 +377,9 @@ class DecryptAllTest extends TestCase { $this->view->expects($this->once()) ->method('copy') ->with($path, $path . '.decrypted.42') - ->willReturnCallback(function() { throw new DecryptionFailedException();}); + ->willReturnCallback(function () { + throw new DecryptionFailedException(); + }); $this->view->expects($this->never())->method('rename'); $this->view->expects($this->once()) @@ -396,5 +394,4 @@ class DecryptAllTest extends TestCase { $this->invokePrivate($instance, 'decryptFile', [$path]) ); } - } diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php index 93987a8bb20..06d9116255f 100644 --- a/tests/lib/Encryption/EncryptionWrapperTest.php +++ b/tests/lib/Encryption/EncryptionWrapperTest.php @@ -21,7 +21,6 @@ namespace Test\Encryption; - use OC\Encryption\EncryptionWrapper; use OC\Encryption\Manager; use OC\Memcache\ArrayCache; @@ -94,5 +93,4 @@ class EncryptionWrapperTest extends TestCase { [false, [Storage\IDisableEncryptionStorage::class]], ]; } - } diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php index 31936a4176b..fd33077c78b 100644 --- a/tests/lib/Encryption/Keys/StorageTest.php +++ b/tests/lib/Encryption/Keys/StorageTest.php @@ -63,7 +63,7 @@ class StorageTest extends TestCase { public function testSetFileKey() { $this->util->expects($this->any()) ->method('getUidAndFilename') - ->willReturn(array('user1', '/files/foo.txt')); + ->willReturn(['user1', '/files/foo.txt']); $this->util->expects($this->any()) ->method('stripPartialFileExtension') ->willReturnArgument(0); @@ -143,7 +143,7 @@ class StorageTest extends TestCase { public function testSetFileKeySystemWide() { $this->util->expects($this->any()) ->method('getUidAndFilename') - ->willReturn(array('user1', '/files/foo.txt')); + ->willReturn(['user1', '/files/foo.txt']); $this->util->expects($this->any()) ->method('isSystemWideMountPoint') ->willReturn(true); @@ -164,7 +164,7 @@ class StorageTest extends TestCase { public function testGetFileKeySystemWide() { $this->util->expects($this->any()) ->method('getUidAndFilename') - ->willReturn(array('user1', '/files/foo.txt')); + ->willReturn(['user1', '/files/foo.txt']); $this->util->expects($this->any()) ->method('stripPartialFileExtension') ->willReturnArgument(0); @@ -272,7 +272,7 @@ class StorageTest extends TestCase { public function testDeleteFileKeySystemWide() { $this->util->expects($this->any()) ->method('getUidAndFilename') - ->willReturn(array('user1', '/files/foo.txt')); + ->willReturn(['user1', '/files/foo.txt']); $this->util->expects($this->any()) ->method('stripPartialFileExtension') ->willReturnArgument(0); @@ -296,7 +296,7 @@ class StorageTest extends TestCase { public function testDeleteFileKey() { $this->util->expects($this->any()) ->method('getUidAndFilename') - ->willReturn(array('user1', '/files/foo.txt')); + ->willReturn(['user1', '/files/foo.txt']); $this->util->expects($this->any()) ->method('stripPartialFileExtension') ->willReturnArgument(0); @@ -335,11 +335,11 @@ class StorageTest extends TestCase { ->willReturn(true); $this->util->expects($this->any()) ->method('getUidAndFilename') - ->will($this->returnCallback(array($this, 'getUidAndFilenameCallback'))); + ->willReturnCallback([$this, 'getUidAndFilenameCallback']); $this->util->expects($this->any()) ->method('isSystemWideMountPoint') - ->willReturnCallback(function($path, $owner) use ($systemWideMountSource, $systemWideMountTarget) { - if(strpos($path, 'source.txt') !== false) { + ->willReturnCallback(function ($path, $owner) use ($systemWideMountSource, $systemWideMountTarget) { + if (strpos($path, 'source.txt') !== false) { return $systemWideMountSource; } return $systemWideMountTarget; @@ -366,11 +366,11 @@ class StorageTest extends TestCase { ->willReturn(true); $this->util->expects($this->any()) ->method('getUidAndFilename') - ->will($this->returnCallback(array($this, 'getUidAndFilenameCallback'))); + ->willReturnCallback([$this, 'getUidAndFilenameCallback']); $this->util->expects($this->any()) ->method('isSystemWideMountPoint') - ->willReturnCallback(function($path, $owner) use ($systemWideMountSource, $systemWideMountTarget) { - if(strpos($path, 'source.txt') !== false) { + ->willReturnCallback(function ($path, $owner) use ($systemWideMountSource, $systemWideMountTarget) { + if (strpos($path, 'source.txt') !== false) { return $systemWideMountSource; } return $systemWideMountTarget; @@ -385,37 +385,37 @@ class StorageTest extends TestCase { $path = $args[0]; $parts = explode('/', $path); - return array($parts[1], '/' . implode('/', array_slice($parts, 2))); + return [$parts[1], '/' . implode('/', array_slice($parts, 2))]; } public function dataProviderCopyRename() { - return array( - array('/user1/files/source.txt', '/user1/files/target.txt', false, false, - '/user1/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'), - array('/user1/files/foo/source.txt', '/user1/files/target.txt', false, false, - '/user1/files_encryption/keys/files/foo/source.txt/', '/user1/files_encryption/keys/files/target.txt/'), - array('/user1/files/source.txt', '/user1/files/foo/target.txt', false, false, - '/user1/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/foo/target.txt/'), - array('/user1/files/source.txt', '/user1/files/foo/target.txt', true, true, - '/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/foo/target.txt/'), - array('/user1/files/source.txt', '/user1/files/target.txt', false, true, - '/user1/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/target.txt/'), - array('/user1/files/source.txt', '/user1/files/target.txt', true, false, - '/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'), - - array('/user2/files/source.txt', '/user1/files/target.txt', false, false, - '/user2/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'), - array('/user2/files/foo/source.txt', '/user1/files/target.txt', false, false, - '/user2/files_encryption/keys/files/foo/source.txt/', '/user1/files_encryption/keys/files/target.txt/'), - array('/user2/files/source.txt', '/user1/files/foo/target.txt', false, false, - '/user2/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/foo/target.txt/'), - array('/user2/files/source.txt', '/user1/files/foo/target.txt', true, true, - '/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/foo/target.txt/'), - array('/user2/files/source.txt', '/user1/files/target.txt', false, true, - '/user2/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/target.txt/'), - array('/user2/files/source.txt', '/user1/files/target.txt', true, false, - '/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'), - ); + return [ + ['/user1/files/source.txt', '/user1/files/target.txt', false, false, + '/user1/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'], + ['/user1/files/foo/source.txt', '/user1/files/target.txt', false, false, + '/user1/files_encryption/keys/files/foo/source.txt/', '/user1/files_encryption/keys/files/target.txt/'], + ['/user1/files/source.txt', '/user1/files/foo/target.txt', false, false, + '/user1/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/foo/target.txt/'], + ['/user1/files/source.txt', '/user1/files/foo/target.txt', true, true, + '/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/foo/target.txt/'], + ['/user1/files/source.txt', '/user1/files/target.txt', false, true, + '/user1/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/target.txt/'], + ['/user1/files/source.txt', '/user1/files/target.txt', true, false, + '/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'], + + ['/user2/files/source.txt', '/user1/files/target.txt', false, false, + '/user2/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'], + ['/user2/files/foo/source.txt', '/user1/files/target.txt', false, false, + '/user2/files_encryption/keys/files/foo/source.txt/', '/user1/files_encryption/keys/files/target.txt/'], + ['/user2/files/source.txt', '/user1/files/foo/target.txt', false, false, + '/user2/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/foo/target.txt/'], + ['/user2/files/source.txt', '/user1/files/foo/target.txt', true, true, + '/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/foo/target.txt/'], + ['/user2/files/source.txt', '/user1/files/target.txt', false, true, + '/user2/files_encryption/keys/files/source.txt/', '/files_encryption/keys/files/target.txt/'], + ['/user2/files/source.txt', '/user1/files/target.txt', true, false, + '/files_encryption/keys/files/source.txt/', '/user1/files_encryption/keys/files/target.txt/'], + ]; } /** @@ -427,12 +427,11 @@ class StorageTest extends TestCase { * @param string $expected */ public function testGetPathToKeys($path, $systemWideMountPoint, $storageRoot, $expected) { - $this->invokePrivate($this->storage, 'root_dir', [$storageRoot]); $this->util->expects($this->any()) ->method('getUidAndFilename') - ->will($this->returnCallback(array($this, 'getUidAndFilenameCallback'))); + ->willReturnCallback([$this, 'getUidAndFilenameCallback']); $this->util->expects($this->any()) ->method('isSystemWideMountPoint') ->willReturn($systemWideMountPoint); @@ -460,15 +459,15 @@ class StorageTest extends TestCase { ->willReturn(false); $this->view->expects($this->any()) ->method('mkdir') - ->will($this->returnCallback(array($this, 'mkdirCallback'))); + ->willReturnCallback([$this, 'mkdirCallback']); - $this->mkdirStack = array( + $this->mkdirStack = [ '/user1/files_encryption/keys/foo', '/user1/files_encryption/keys', '/user1/files_encryption', - '/user1'); + '/user1']; - self::invokePrivate($this->storage, 'keySetPreparation', array('/user1/files_encryption/keys/foo')); + self::invokePrivate($this->storage, 'keySetPreparation', ['/user1/files_encryption/keys/foo']); } public function mkdirCallback() { @@ -485,7 +484,6 @@ class StorageTest extends TestCase { * @param string $expected */ public function testGetFileKeyDir($isSystemWideMountPoint, $storageRoot, $expected) { - $path = '/user1/files/foo/bar.txt'; $owner = 'user1'; $relativePath = '/foo/bar.txt'; @@ -500,7 +498,6 @@ class StorageTest extends TestCase { $this->assertSame($expected, $this->invokePrivate($this->storage, 'getFileKeyDir', ['OC_DEFAULT_MODULE', $path]) ); - } public function dataTestGetFileKeyDir() { @@ -518,7 +515,6 @@ class StorageTest extends TestCase { * @param bool $createBackupDir */ public function testBackupUserKeys($createBackupDir) { - $storage = $this->getMockBuilder('OC\Encryption\Keys\Storage') ->setConstructorArgs([$this->view, $this->util]) ->setMethods(['getTimestamp']) @@ -546,7 +542,6 @@ class StorageTest extends TestCase { )->willReturn(true); $this->assertTrue($storage->backupUserKeys('encryptionModule', 'test', 'user1')); - } public function dataTestBackupUserKeys() { @@ -554,5 +549,4 @@ class StorageTest extends TestCase { [true], [false] ]; } - } diff --git a/tests/lib/Encryption/ManagerTest.php b/tests/lib/Encryption/ManagerTest.php index 6e18cd296a3..47dd7fd01fb 100644 --- a/tests/lib/Encryption/ManagerTest.php +++ b/tests/lib/Encryption/ManagerTest.php @@ -60,7 +60,9 @@ class ManagerTest extends TestCase { $em = $this->createMock(IEncryptionModule::class); $em->expects($this->any())->method('getId')->willReturn('id'); $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); - $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function() use ($em) {return $em;}); + $this->manager->registerEncryptionModule('id', 'TestDummyModule0', function () use ($em) { + return $em; + }); $this->assertFalse($this->manager->isEnabled()); } @@ -96,7 +98,6 @@ class ManagerTest extends TestCase { $this->manager->unregisterEncryptionModule('ID0'); $this->assertEmpty($this->manager->getEncryptionModules()); - } @@ -117,7 +118,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->any()) ->method('getAppValue') ->with('core', 'default_encryption_module') - ->willReturnCallback(function() { global $defaultId; return $defaultId; }); + ->willReturnCallback(function () { + global $defaultId; + return $defaultId; + }); $this->addNewEncryptionModule($this->manager, 0); $this->assertCount(1, $this->manager->getEncryptionModules()); @@ -138,7 +142,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->any()) ->method('getAppValue') ->with('core', 'default_encryption_module') - ->willReturnCallback(function() { global $defaultId; return $defaultId; }); + ->willReturnCallback(function () { + global $defaultId; + return $defaultId; + }); $this->addNewEncryptionModule($this->manager, 0); $defaultId = 'ID0'; @@ -160,7 +167,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->any()) ->method('getAppValue') ->with('core', 'default_encryption_module') - ->willReturnCallback(function() { global $defaultId; return $defaultId; }); + ->willReturnCallback(function () { + global $defaultId; + return $defaultId; + }); $this->addNewEncryptionModule($this->manager, 0); $this->assertCount(1, $this->manager->getEncryptionModules()); @@ -251,7 +261,7 @@ class ManagerTest extends TestCase { ->method('getDisplayName') ->willReturn('TestDummyModule' . $id); /** @var \OCP\Encryption\IEncryptionModule $encryptionModule */ - $manager->registerEncryptionModule('ID' . $id, 'TestDummyModule' . $id, function() use ($encryptionModule) { + $manager->registerEncryptionModule('ID' . $id, 'TestDummyModule' . $id, function () use ($encryptionModule) { return $encryptionModule; }); } diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php index 28d7ca81163..d7aa24d1f67 100644 --- a/tests/lib/Encryption/UpdateTest.php +++ b/tests/lib/Encryption/UpdateTest.php @@ -21,7 +21,6 @@ namespace Test\Encryption; - use OC\Encryption\Update; use OC\Files\Mount\Manager; use OC\Files\View; @@ -89,7 +88,6 @@ class UpdateTest extends TestCase { * @param integer $numberOfFiles */ public function testUpdate($path, $isDir, $allFiles, $numberOfFiles) { - $this->encryptionManager->expects($this->once()) ->method('getEncryptionModule') ->willReturn($this->encryptionModule); @@ -98,7 +96,7 @@ class UpdateTest extends TestCase { ->method('is_dir') ->willReturn($isDir); - if($isDir) { + if ($isDir) { $this->util->expects($this->once()) ->method('getAllFiles') ->willReturn($allFiles); @@ -121,10 +119,10 @@ class UpdateTest extends TestCase { * @return array */ public function dataTestUpdate() { - return array( - array('/user/files/foo', true, ['/user/files/foo/file1.txt', '/user/files/foo/file1.txt'], 2), - array('/user/files/test.txt', false, [], 1), - ); + return [ + ['/user/files/foo', true, ['/user/files/foo/file1.txt', '/user/files/foo/file1.txt'], 2], + ['/user/files/test.txt', false, [], 1], + ]; } /** @@ -135,7 +133,6 @@ class UpdateTest extends TestCase { * @param boolean $encryptionEnabled */ public function testPostRename($source, $target, $encryptionEnabled) { - $updateMock = $this->getUpdateMock(['update', 'getOwnerPath']); $this->encryptionManager->expects($this->once()) @@ -148,13 +145,12 @@ class UpdateTest extends TestCase { } else { $updateMock->expects($this->once()) ->method('getOwnerPath') - ->willReturnCallback(function($path) use ($target) { + ->willReturnCallback(function ($path) use ($target) { $this->assertSame( $target, $path, 'update needs to be executed for the target destination'); return ['owner', $path]; - }); $updateMock->expects($this->once())->method('update'); } @@ -168,14 +164,14 @@ class UpdateTest extends TestCase { * @return array */ public function dataTestPostRename() { - return array( - array('/test.txt', '/testNew.txt', true), - array('/test.txt', '/testNew.txt', false), - array('/folder/test.txt', '/testNew.txt', true), - array('/folder/test.txt', '/testNew.txt', false), - array('/folder/test.txt', '/testNew.txt', true), - array('/test.txt', '/folder/testNew.txt', false), - ); + return [ + ['/test.txt', '/testNew.txt', true], + ['/test.txt', '/testNew.txt', false], + ['/folder/test.txt', '/testNew.txt', true], + ['/folder/test.txt', '/testNew.txt', false], + ['/folder/test.txt', '/testNew.txt', true], + ['/test.txt', '/folder/testNew.txt', false], + ]; } @@ -185,7 +181,6 @@ class UpdateTest extends TestCase { * @param boolean $encryptionEnabled */ public function testPostRestore($encryptionEnabled) { - $updateMock = $this->getUpdateMock(['update']); $this->encryptionManager->expects($this->once()) @@ -194,7 +189,6 @@ class UpdateTest extends TestCase { if ($encryptionEnabled) { $updateMock->expects($this->once())->method('update'); - } else { $updateMock->expects($this->never())->method('update'); } @@ -208,10 +202,10 @@ class UpdateTest extends TestCase { * @return array */ public function dataTestPostRestore() { - return array( - array(true), - array(false), - ); + return [ + [true], + [false], + ]; } /** @@ -233,5 +227,4 @@ class UpdateTest extends TestCase { ] )->setMethods($methods)->getMock(); } - } diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php index e503da109a8..e1d898f5a86 100644 --- a/tests/lib/Encryption/UtilTest.php +++ b/tests/lib/Encryption/UtilTest.php @@ -56,7 +56,6 @@ class UtilTest extends TestCase { $this->groupManager, $this->config ); - } /** @@ -79,7 +78,6 @@ class UtilTest extends TestCase { * @dataProvider providesHeaders */ public function testCreateHeader($expected, $header, $moduleId) { - $em = $this->createMock(IEncryptionModule::class); $em->expects($this->any())->method('getId')->willReturn($moduleId); @@ -101,7 +99,7 @@ class UtilTest extends TestCase { $this->expectException(\OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException::class); - $header = array('header1' => 1, 'header2' => 2, 'oc_encryption_module' => 'foo'); + $header = ['header1' => 1, 'header2' => 2, 'oc_encryption_module' => 'foo']; $em = $this->createMock(IEncryptionModule::class); $em->expects($this->any())->method('getId')->willReturn('moduleId'); @@ -120,7 +118,7 @@ class UtilTest extends TestCase { $this->userManager ->expects($this->any()) ->method('userExists') - ->will($this->returnCallback(array($this, 'isExcludedCallback'))); + ->willReturnCallback([$this, 'isExcludedCallback']); $this->assertSame($expected, $this->util->isExcluded($path) @@ -128,17 +126,17 @@ class UtilTest extends TestCase { } public function providePathsForTestIsExcluded() { - return array( - array('/files_encryption', '', true), - array('files_encryption/foo.txt', '', true), - array('test/foo.txt', '', false), - array('/user1/files_encryption/foo.txt', '', true), - array('/user1/files/foo.txt', '', false), - array('/keyStorage/user1/files/foo.txt', 'keyStorage', true), - array('/keyStorage/files_encryption', '/keyStorage', true), - array('keyStorage/user1/files_encryption', '/keyStorage/', true), + return [ + ['/files_encryption', '', true], + ['files_encryption/foo.txt', '', true], + ['test/foo.txt', '', false], + ['/user1/files_encryption/foo.txt', '', true], + ['/user1/files/foo.txt', '', false], + ['/keyStorage/user1/files/foo.txt', 'keyStorage', true], + ['/keyStorage/files_encryption', '/keyStorage', true], + ['keyStorage/user1/files_encryption', '/keyStorage/', true], - ); + ]; } public function isExcludedCallback() { @@ -160,15 +158,15 @@ class UtilTest extends TestCase { } public function dataTestIsFile() { - return array( - array('/user/files/test.txt', true), - array('/user/files', true), - array('/user/files_versions/test.txt', false), - array('/user/foo/files/test.txt', false), - array('/files/foo/files/test.txt', false), - array('/user', false), - array('/user/test.txt', false), - ); + return [ + ['/user/files/test.txt', true], + ['/user/files', true], + ['/user/files_versions/test.txt', false], + ['/user/foo/files/test.txt', false], + ['/files/foo/files/test.txt', false], + ['/user', false], + ['/user/test.txt', false], + ]; } /** @@ -183,12 +181,11 @@ class UtilTest extends TestCase { } public function dataTestStripPartialFileExtension() { - return array( - array('/foo/test.txt', '/foo/test.txt'), - array('/foo/test.txt.part', '/foo/test.txt'), - array('/foo/test.txt.ocTransferId7567846853.part', '/foo/test.txt'), - array('/foo/test.txt.ocTransferId7567.part', '/foo/test.txt'), - ); + return [ + ['/foo/test.txt', '/foo/test.txt'], + ['/foo/test.txt.part', '/foo/test.txt'], + ['/foo/test.txt.ocTransferId7567846853.part', '/foo/test.txt'], + ['/foo/test.txt.ocTransferId7567.part', '/foo/test.txt'], + ]; } - } diff --git a/tests/lib/ErrorHandlerTest.php b/tests/lib/ErrorHandlerTest.php index aece7f146f6..702f64bfb99 100644 --- a/tests/lib/ErrorHandlerTest.php +++ b/tests/lib/ErrorHandlerTest.php @@ -28,15 +28,14 @@ class ErrorHandlerTest extends \Test\TestCase { * provide username, password combinations for testRemovePassword * @return array */ - function passwordProvider() { - return array( - array('user', 'password'), - array('user@owncloud.org', 'password'), - array('user', 'pass@word'), - array('us:er', 'password'), - array('user', 'pass:word'), - ); - + public function passwordProvider() { + return [ + ['user', 'password'], + ['user@owncloud.org', 'password'], + ['user', 'pass@word'], + ['us:er', 'password'], + ['user', 'pass:word'], + ]; } /** @@ -44,14 +43,13 @@ class ErrorHandlerTest extends \Test\TestCase { * @param string $username * @param string $password */ - function testRemovePassword($username, $password) { + public function testRemovePassword($username, $password) { $url = 'http://'.$username.':'.$password.'@owncloud.org'; $expectedResult = 'http://xxx:xxx@owncloud.org'; $result = TestableErrorHandler::testRemovePassword($url); $this->assertEquals($expectedResult, $result); } - } /** diff --git a/tests/lib/FileChunkingTest.php b/tests/lib/FileChunkingTest.php index 75a6913d4ad..23f50a5b6f7 100644 --- a/tests/lib/FileChunkingTest.php +++ b/tests/lib/FileChunkingTest.php @@ -24,7 +24,6 @@ namespace Test; use OCP\ICache; class FileChunkingTest extends \Test\TestCase { - public function dataIsComplete() { return [ [1, [], false], @@ -61,10 +60,10 @@ class FileChunkingTest extends \Test\TestCase { $cache->expects($this->atLeastOnce()) ->method('hasKey') - ->will($this->returnCallback(function ($key) use ($present) { + ->willReturnCallback(function ($key) use ($present) { $data = explode('-', $key); return in_array($data[3], $present); - })); + }); $fileChunking->method('getCache')->willReturn($cache); diff --git a/tests/lib/Files/AppData/AppDataTest.php b/tests/lib/Files/AppData/AppDataTest.php index 1b3f705b9b6..a03be9e45e9 100644 --- a/tests/lib/Files/AppData/AppDataTest.php +++ b/tests/lib/Files/AppData/AppDataTest.php @@ -108,5 +108,4 @@ class AppDataTest extends \Test\TestCase { $this->assertCount(1, $result); $this->assertInstanceOf(ISimpleFolder::class, $result[0]); } - } diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index b2816c03094..97663c16c02 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -8,7 +8,6 @@ namespace Test\Files\Cache; - use Doctrine\DBAL\Platforms\MySqlPlatform; use OC\Files\Cache\Cache; use OC\Files\Search\SearchComparison; @@ -55,8 +54,8 @@ class CacheTest extends \Test\TestCase { public function testSimple() { $file1 = 'foo'; $file2 = 'foo/bar'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $data2 = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $data2 = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $this->assertFalse($this->cache->inCache($file1)); $this->assertEquals($this->cache->get($file1), null); @@ -84,7 +83,7 @@ class CacheTest extends \Test\TestCase { $this->assertEquals($id1, $this->cache->getParentId($file2)); $newSize = 1050; - $newId2 = $this->cache->put($file2, array('size' => $newSize)); + $newId2 = $this->cache->put($file2, ['size' => $newSize]); $cacheData2 = $this->cache->get($file2); $this->assertEquals($newId2, $id2); $this->assertEquals($cacheData2['size'], $newSize); @@ -101,14 +100,14 @@ class CacheTest extends \Test\TestCase { public function testPartial() { $file1 = 'foo'; - $this->cache->put($file1, array('size' => 10)); - $this->assertEquals(array('size' => 10), $this->cache->get($file1)); + $this->cache->put($file1, ['size' => 10]); + $this->assertEquals(['size' => 10], $this->cache->get($file1)); - $this->cache->put($file1, array('mtime' => 15)); - $this->assertEquals(array('size' => 10, 'mtime' => 15), $this->cache->get($file1)); + $this->cache->put($file1, ['mtime' => 15]); + $this->assertEquals(['size' => 10, 'mtime' => 15], $this->cache->get($file1)); - $this->cache->put($file1, array('size' => 12)); - $this->assertEquals(array('size' => 12, 'mtime' => 15), $this->cache->get($file1)); + $this->cache->put($file1, ['size' => 12]); + $this->assertEquals(['size' => 12, 'mtime' => 15], $this->cache->get($file1)); } /** @@ -124,10 +123,10 @@ class CacheTest extends \Test\TestCase { } $file2 = $folder . '/bar'; $file3 = $folder . '/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); - $fileData = array(); - $fileData['bar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; + $fileData = []; + $fileData['bar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($folder, $data1); $this->cache->put($file2, $fileData['bar']); @@ -143,12 +142,12 @@ class CacheTest extends \Test\TestCase { } $file4 = $folder . '/unkownSize'; - $fileData['unkownSize'] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(-1, $this->cache->calculateFolderSize($folder)); - $fileData['unkownSize'] = array('size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(1025, $this->cache->calculateFolderSize($folder)); @@ -164,8 +163,8 @@ class CacheTest extends \Test\TestCase { } public function testRemoveRecursive() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); - $fileData = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'text/plain'); + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; + $fileData = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'text/plain']; $folders = ['folder', 'folder/subfolder', 'folder/sub2', 'folder/sub2/sub3']; $files = ['folder/foo.txt', 'folder/bar.txt', 'folder/subfolder/asd.txt', 'folder/sub2/qwerty.txt', 'folder/sub2/sub3/foo.txt']; @@ -183,28 +182,27 @@ class CacheTest extends \Test\TestCase { } public function folderDataProvider() { - - return array( - array('folder'), + return [ + ['folder'], // that was too easy, try something harder - array('☺, WHITE SMILING FACE, UTF-8 hex E298BA'), + ['☺, WHITE SMILING FACE, UTF-8 hex E298BA'], // what about 4 byte utf-8 - array('😐, NEUTRAL_FACE, UTF-8 hex F09F9890'), + ['😐, NEUTRAL_FACE, UTF-8 hex F09F9890'], // now the crazy stuff - array(', UNASSIGNED PRIVATE USE, UTF-8 hex EF9890'), + [', UNASSIGNED PRIVATE USE, UTF-8 hex EF9890'], // and my favorite - array('w͢͢͝h͡o͢͡ ̸͢k̵͟n̴͘ǫw̸̛s͘ ̀́w͘͢ḩ̵a҉̡͢t ̧̕h́o̵r͏̵rors̡ ̶͡͠lį̶e͟͟ ̶͝in͢ ͏t̕h̷̡͟e ͟͟d̛a͜r̕͡k̢̨ ͡h̴e͏a̷̢̡rt́͏ ̴̷͠ò̵̶f̸ u̧͘ní̛͜c͢͏o̷͏d̸͢e̡͝') - ); + ['w͢͢͝h͡o͢͡ ̸͢k̵͟n̴͘ǫw̸̛s͘ ̀́w͘͢ḩ̵a҉̡͢t ̧̕h́o̵r͏̵rors̡ ̶͡͠lį̶e͟͟ ̶͝in͢ ͏t̕h̷̡͟e ͟͟d̛a͜r̕͡k̢̨ ͡h̴e͏a̷̢̡rt́͏ ̴̷͠ò̵̶f̸ u̧͘ní̛͜c͢͏o̷͏d̸͢e̡͝'] + ]; } public function testEncryptedFolder() { $file1 = 'folder'; $file2 = 'folder/bar'; $file3 = 'folder/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); - $fileData = array(); - $fileData['bar'] = array('size' => 1000, 'encrypted' => 1, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'encrypted' => 1, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; + $fileData = []; + $fileData['bar'] = ['size' => 1000, 'encrypted' => 1, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'encrypted' => 1, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file1, $data1); $this->cache->put($file2, $fileData['bar']); @@ -217,12 +215,12 @@ class CacheTest extends \Test\TestCase { } $file4 = 'folder/unkownSize'; - $fileData['unkownSize'] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(-1, $this->cache->calculateFolderSize($file1)); - $fileData['unkownSize'] = array('size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file'); + $fileData['unkownSize'] = ['size' => 5, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file4, $fileData['unkownSize']); $this->assertEquals(1025, $this->cache->calculateFolderSize($file1)); @@ -243,10 +241,10 @@ class CacheTest extends \Test\TestCase { public function testRootFolderSizeForNonHomeStorage() { $dir1 = 'knownsize'; $dir2 = 'unknownsize'; - $fileData = array(); - $fileData[''] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir2] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory'); + $fileData = []; + $fileData[''] = ['size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir1] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir2] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory']; $this->cache->put('', $fileData['']); $this->cache->put($dir1, $fileData[$dir1]); @@ -267,13 +265,13 @@ class CacheTest extends \Test\TestCase { $this->assertFalse($this->cache->inCache($dir2)); } - function testStatus() { + public function testStatus() { $this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->getStatus('foo')); - $this->cache->put('foo', array('size' => -1)); + $this->cache->put('foo', ['size' => -1]); $this->assertEquals(\OC\Files\Cache\Cache::PARTIAL, $this->cache->getStatus('foo')); - $this->cache->put('foo', array('size' => -1, 'mtime' => 20, 'mimetype' => 'foo/file')); + $this->cache->put('foo', ['size' => -1, 'mtime' => 20, 'mimetype' => 'foo/file']); $this->assertEquals(\OC\Files\Cache\Cache::SHALLOW, $this->cache->getStatus('foo')); - $this->cache->put('foo', array('size' => 10)); + $this->cache->put('foo', ['size' => 10]); $this->assertEquals(\OC\Files\Cache\Cache::COMPLETE, $this->cache->getStatus('foo')); } @@ -290,23 +288,22 @@ class CacheTest extends \Test\TestCase { * @param $fileName */ public function testPutWithAllKindOfQuotes($fileName) { - $this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->get($fileName)); - $this->cache->put($fileName, array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file', 'etag' => $fileName)); + $this->cache->put($fileName, ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file', 'etag' => $fileName]); $cacheEntry = $this->cache->get($fileName); $this->assertEquals($fileName, $cacheEntry['etag']); $this->assertEquals($fileName, $cacheEntry['path']); } - function testSearch() { + public function testSearch() { $file1 = 'folder'; $file2 = 'folder/foobar'; $file3 = 'folder/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $fileData = array(); - $fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $fileData = []; + $fileData['foobar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file1, $data1); $this->cache->put($file2, $fileData['foobar']); @@ -328,7 +325,7 @@ class CacheTest extends \Test\TestCase { $this->assertEquals(2, count($this->cache->searchByMime('foo/file'))); } - function testSearchQueryByTag() { + public function testSearchQueryByTag() { $userId = static::getUniqueID('user'); \OC::$server->getUserManager()->createUser($userId, $userId); static::loginAsUser($userId); @@ -339,12 +336,12 @@ class CacheTest extends \Test\TestCase { $file3 = 'folder/foo'; $file4 = 'folder/foo2'; $file5 = 'folder/foo3'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $fileData = array(); - $fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); - $fileData['foo2'] = array('size' => 25, 'mtime' => 28, 'mimetype' => 'foo/file'); - $fileData['foo3'] = array('size' => 88, 'mtime' => 34, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $fileData = []; + $fileData['foobar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; + $fileData['foo2'] = ['size' => 25, 'mtime' => 28, 'mimetype' => 'foo/file']; + $fileData['foo3'] = ['size' => 88, 'mtime' => 34, 'mimetype' => 'foo/file']; $id1 = $this->cache->put($file1, $data1); $id2 = $this->cache->put($file2, $fileData['foobar']); @@ -383,14 +380,14 @@ class CacheTest extends \Test\TestCase { } } - function testSearchByQuery() { + public function testSearchByQuery() { $file1 = 'folder'; $file2 = 'folder/foobar'; $file3 = 'folder/foo'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); - $fileData = array(); - $fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); - $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; + $fileData = []; + $fileData['foobar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; + $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file1, $data1); $this->cache->put($file2, $fileData['foobar']); @@ -418,7 +415,7 @@ class CacheTest extends \Test\TestCase { , 10, 0, [], $user))); } - function movePathProvider() { + public function movePathProvider() { return [ ['folder/foo', 'folder/foobar', ['1', '2']], ['folder/foo', 'foo', ['1', '2']], @@ -429,9 +426,9 @@ class CacheTest extends \Test\TestCase { /** * @dataProvider movePathProvider */ - function testMove($sourceFolder, $targetFolder, $children) { - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar'); - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + public function testMove($sourceFolder, $targetFolder, $children) { + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar']; + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // create folders foreach ([$sourceFolder, $targetFolder] as $current) { @@ -464,12 +461,12 @@ class CacheTest extends \Test\TestCase { } } - function testGetIncomplete() { + public function testGetIncomplete() { $file1 = 'folder1'; $file2 = 'folder2'; $file3 = 'folder3'; $file4 = 'folder4'; - $data = array('size' => 10, 'mtime' => 50, 'mimetype' => 'foo/bar'); + $data = ['size' => 10, 'mtime' => 50, 'mimetype' => 'foo/bar']; $this->cache->put($file1, $data); $data['size'] = -1; @@ -481,47 +478,47 @@ class CacheTest extends \Test\TestCase { $this->assertEquals($file3, $this->cache->getIncomplete()); } - function testNonExisting() { + public function testNonExisting() { $this->assertFalse($this->cache->get('foo.txt')); $this->assertFalse($this->cache->get(-1)); - $this->assertEquals(array(), $this->cache->getFolderContents('foo')); + $this->assertEquals([], $this->cache->getFolderContents('foo')); } - function testGetById() { + public function testGetById() { $storageId = $this->storage->getId(); - $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $data = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $id = $this->cache->put('foo', $data); if (strlen($storageId) > 64) { $storageId = md5($storageId); } - $this->assertEquals(array($storageId, 'foo'), \OC\Files\Cache\Cache::getById($id)); + $this->assertEquals([$storageId, 'foo'], \OC\Files\Cache\Cache::getById($id)); } - function testStorageMTime() { - $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + public function testStorageMTime() { + $data = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $this->cache->put('foo', $data); $cachedData = $this->cache->get('foo'); $this->assertEquals($data['mtime'], $cachedData['storage_mtime']); //if no storage_mtime is saved, mtime should be used - $this->cache->put('foo', array('storage_mtime' => 30)); //when setting storage_mtime, mtime is also set + $this->cache->put('foo', ['storage_mtime' => 30]); //when setting storage_mtime, mtime is also set $cachedData = $this->cache->get('foo'); $this->assertEquals(30, $cachedData['storage_mtime']); $this->assertEquals(30, $cachedData['mtime']); - $this->cache->put('foo', array('mtime' => 25)); //setting mtime does not change storage_mtime + $this->cache->put('foo', ['mtime' => 25]); //setting mtime does not change storage_mtime $cachedData = $this->cache->get('foo'); $this->assertEquals(30, $cachedData['storage_mtime']); $this->assertEquals(25, $cachedData['mtime']); } - function testLongId() { - $storage = new LongId(array()); + public function testLongId() { + $storage = new LongId([]); $cache = $storage->getCache(); $storageId = $storage->getId(); - $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'); + $data = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $id = $cache->put('foo', $data); - $this->assertEquals(array(md5($storageId), 'foo'), \OC\Files\Cache\Cache::getById($id)); + $this->assertEquals([md5($storageId), 'foo'], \OC\Files\Cache\Cache::getById($id)); } /** @@ -544,9 +541,9 @@ class CacheTest extends \Test\TestCase { $cacheMock->expects($this->any()) ->method('normalize') - ->will($this->returnArgument(0)); + ->willReturnArgument(0); - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // put root folder $this->assertFalse($cacheMock->get('folder')); @@ -574,7 +571,6 @@ class CacheTest extends \Test\TestCase { * this test shows that there is no bug if we use the normalizer */ public function testWithNormalizer() { - if (!class_exists('Patchwork\PHP\Shim\Normalizer')) { $this->markTestSkipped('The 3rdparty Normalizer extension is not available.'); return; @@ -586,7 +582,7 @@ class CacheTest extends \Test\TestCase { // folder name "Schön" with U+0308 (un-normalized) $folderWith0308 = "\x53\x63\x68\x6f\xcc\x88\x6e"; - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // put root folder $this->assertFalse($this->cache->get('folder')); @@ -610,13 +606,13 @@ class CacheTest extends \Test\TestCase { $this->assertEquals(1, count($this->cache->getFolderContents('folder'))); } - function bogusPathNamesProvider() { - return array( - array('/bogus.txt', 'bogus.txt'), - array('//bogus.txt', 'bogus.txt'), - array('bogus/', 'bogus'), - array('bogus//', 'bogus'), - ); + public function bogusPathNamesProvider() { + return [ + ['/bogus.txt', 'bogus.txt'], + ['//bogus.txt', 'bogus.txt'], + ['bogus/', 'bogus'], + ['bogus//', 'bogus'], + ]; } /** @@ -625,7 +621,7 @@ class CacheTest extends \Test\TestCase { * @dataProvider bogusPathNamesProvider */ public function testBogusPaths($bogusPath, $fixedBogusPath) { - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; // put root folder $this->assertFalse($this->cache->get('')); @@ -647,12 +643,12 @@ class CacheTest extends \Test\TestCase { } public function testNoReuseOfFileId() { - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain']; $this->cache->put('somefile.txt', $data1); $info = $this->cache->get('somefile.txt'); $fileId = $info['fileid']; $this->cache->remove('somefile.txt'); - $data2 = array('size' => 200, 'mtime' => 100, 'mimetype' => 'text/plain'); + $data2 = ['size' => 200, 'mtime' => 100, 'mimetype' => 'text/plain']; $this->cache->put('anotherfile.txt', $data2); $info2 = $this->cache->get('anotherfile.txt'); $fileId2 = $info2['fileid']; @@ -672,7 +668,7 @@ class CacheTest extends \Test\TestCase { * @dataProvider escapingProvider */ public function testEscaping($name) { - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain']; $this->cache->put($name, $data); $this->assertTrue($this->cache->inCache($name)); $retrievedData = $this->cache->get($name); @@ -684,7 +680,7 @@ class CacheTest extends \Test\TestCase { $this->assertTrue($this->cache->inCache($name . 'asd')); $this->cache->remove($name . 'asd'); $this->assertFalse($this->cache->inCache($name . 'asd')); - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->cache->put($name, $folderData); $this->cache->put('other', $folderData); $childs = ['asd', 'bar', 'foo', 'sub/folder']; @@ -788,8 +784,8 @@ class CacheTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); - $this->storage2 = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); + $this->storage2 = new \OC\Files\Storage\Temporary([]); $this->cache = new \OC\Files\Cache\Cache($this->storage); $this->cache2 = new \OC\Files\Cache\Cache($this->storage2); } diff --git a/tests/lib/Files/Cache/HomeCacheTest.php b/tests/lib/Files/Cache/HomeCacheTest.php index 51fc2e5bc9b..aacb91c675e 100644 --- a/tests/lib/Files/Cache/HomeCacheTest.php +++ b/tests/lib/Files/Cache/HomeCacheTest.php @@ -70,7 +70,7 @@ class HomeCacheTest extends \Test\TestCase { parent::setUp(); $this->user = new DummyUser('foo', \OC::$server->getTempManager()->getTemporaryFolder()); - $this->storage = new \OC\Files\Storage\Home(array('user' => $this->user)); + $this->storage = new \OC\Files\Storage\Home(['user' => $this->user]); $this->cache = $this->storage->getCache(); } @@ -82,11 +82,11 @@ class HomeCacheTest extends \Test\TestCase { public function testRootFolderSizeIgnoresUnknownUpdate() { $dir1 = 'files/knownsize'; $dir2 = 'files/unknownsize'; - $fileData = array(); - $fileData[''] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData['files'] = array('size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir2] = array('size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory'); + $fileData = []; + $fileData[''] = ['size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData['files'] = ['size' => -1, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir1] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir2] = ['size' => -1, 'mtime' => 25, 'mimetype' => 'httpd/unix-directory']; $this->cache->put('', $fileData['']); $this->cache->put('files', $fileData['files']); @@ -114,10 +114,10 @@ class HomeCacheTest extends \Test\TestCase { public function testRootFolderSizeIsFilesSize() { $dir1 = 'files'; $afile = 'test.txt'; - $fileData = array(); - $fileData[''] = array('size' => 1500, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$dir1] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory'); - $fileData[$afile] = array('size' => 500, 'mtime' => 20); + $fileData = []; + $fileData[''] = ['size' => 1500, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$dir1] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'httpd/unix-directory']; + $fileData[$afile] = ['size' => 500, 'mtime' => 20]; $this->cache->put('', $fileData['']); $this->cache->put($dir1, $fileData[$dir1]); diff --git a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php index f93b95b5fe7..6e1430d146b 100644 --- a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php +++ b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php @@ -23,8 +23,8 @@ class MoveFromCacheTraitTest extends CacheTest { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); - $this->storage2 = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); + $this->storage2 = new \OC\Files\Storage\Temporary([]); $this->cache = new FallBackCrossCacheMoveCache($this->storage); $this->cache2 = new FallBackCrossCacheMoveCache($this->storage2); } diff --git a/tests/lib/Files/Cache/QuerySearchHelperTest.php b/tests/lib/Files/Cache/QuerySearchHelperTest.php index d5aad09a8fb..464561681d0 100644 --- a/tests/lib/Files/Cache/QuerySearchHelperTest.php +++ b/tests/lib/Files/Cache/QuerySearchHelperTest.php @@ -200,7 +200,7 @@ class QuerySearchHelperTest extends TestCase { 'mimetype' => 'image/png' ]); - $fileIds = array_map(function($i) use ($fileId) { + $fileIds = array_map(function ($i) use ($fileId) { return $fileId[$i]; }, $fileIds); diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php index 6a025410cc3..f9c05d52ee5 100644 --- a/tests/lib/Files/Cache/ScannerTest.php +++ b/tests/lib/Files/Cache/ScannerTest.php @@ -36,7 +36,7 @@ class ScannerTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); $this->scanner = new \OC\Files\Cache\Scanner($this->storage); $this->cache = new \OC\Files\Cache\Cache($this->storage); } @@ -49,7 +49,7 @@ class ScannerTest extends \Test\TestCase { parent::tearDown(); } - function testFile() { + public function testFile() { $data = "dummy file data\n"; $this->storage->file_put_contents('foo.txt', $data); $this->scanner->scanFile('foo.txt'); @@ -70,7 +70,7 @@ class ScannerTest extends \Test\TestCase { $this->assertEquals($cachedData['mimetype'], 'image/png'); } - function testFile4Byte() { + public function testFile4Byte() { $data = "dummy file data\n"; $this->storage->file_put_contents('foo🙈.txt', $data); @@ -88,7 +88,7 @@ class ScannerTest extends \Test\TestCase { } } - function testFileInvalidChars() { + public function testFileInvalidChars() { $data = "dummy file data\n"; $this->storage->file_put_contents("foo\nbar.txt", $data); @@ -105,7 +105,7 @@ class ScannerTest extends \Test\TestCase { $this->storage->file_put_contents('folder/bar.txt', $textData); } - function testFolder() { + public function testFolder() { $this->fillTestFolders(); $this->scanner->scan(''); @@ -127,7 +127,7 @@ class ScannerTest extends \Test\TestCase { $this->assertEquals($cachedDataFolder2['size'], $cachedDataText2['size']); } - function testShallow() { + public function testShallow() { $this->fillTestFolders(); $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW); @@ -155,7 +155,7 @@ class ScannerTest extends \Test\TestCase { $this->assertNotEquals($cachedDataFolder['size'], -1); } - function testBackgroundScan() { + public function testBackgroundScan() { $this->fillTestFolders(); $this->storage->mkdir('folder2'); $this->storage->file_put_contents('folder2/bar.txt', 'foobar'); @@ -177,7 +177,7 @@ class ScannerTest extends \Test\TestCase { $this->assertFalse($this->cache->getIncomplete()); } - function testBackgroundScanOnlyRecurseIncomplete() { + public function testBackgroundScanOnlyRecurseIncomplete() { $this->fillTestFolders(); $this->storage->mkdir('folder2'); $this->storage->file_put_contents('folder2/bar.txt', 'foobar'); @@ -247,7 +247,7 @@ class ScannerTest extends \Test\TestCase { $this->scanner->scan(''); $oldData = $this->cache->get(''); $this->storage->unlink('folder/bar.txt'); - $this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder'))); + $this->cache->put('folder', ['mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder')]); $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE); $newData = $this->cache->get(''); $this->assertIsString($oldData['etag']); @@ -345,7 +345,7 @@ class ScannerTest extends \Test\TestCase { // delete the folder without removing the childs $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?'; - \OC_DB::executeAudited($sql, array($oldFolderId)); + \OC_DB::executeAudited($sql, [$oldFolderId]); $cachedData = $this->cache->get('folder/bar.txt'); $this->assertEquals($oldFolderId, $cachedData['parent']); @@ -369,7 +369,7 @@ class ScannerTest extends \Test\TestCase { // delete the folder without removing the childs $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?'; - \OC_DB::executeAudited($sql, array($oldFolderId)); + \OC_DB::executeAudited($sql, [$oldFolderId]); $cachedData = $this->cache->get('folder/bar.txt'); $this->assertEquals($oldFolderId, $cachedData['parent']); @@ -406,5 +406,4 @@ class ScannerTest extends \Test\TestCase { ['/sub/folder/foo.txt', false], ]; } - } diff --git a/tests/lib/Files/Cache/UpdaterLegacyTest.php b/tests/lib/Files/Cache/UpdaterLegacyTest.php index a3b1a428c28..6d6cc08b3de 100644 --- a/tests/lib/Files/Cache/UpdaterLegacyTest.php +++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php @@ -9,7 +9,6 @@ namespace Test\Files\Cache; use OC\Files\Filesystem as Filesystem; -use OC\Files\Storage\Temporary; use OC\Files\View; /** @@ -40,7 +39,7 @@ class UpdaterLegacyTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $this->storage->mkdir('folder'); @@ -63,7 +62,7 @@ class UpdaterLegacyTest extends \Test\TestCase { Filesystem::init(self::$user, '/' . self::$user . '/files'); Filesystem::clearMounts(); - Filesystem::mount($this->storage, array(), '/' . self::$user . '/files'); + Filesystem::mount($this->storage, [], '/' . self::$user . '/files'); \OC_Hook::clear('OC_Filesystem'); } @@ -75,7 +74,9 @@ class UpdaterLegacyTest extends \Test\TestCase { $result = false; $user = \OC::$server->getUserManager()->get(self::$user); - if ($user !== null) { $result = $user->delete(); } + if ($user !== null) { + $result = $user->delete(); + } $this->assertTrue($result); $this->logout(); @@ -85,7 +86,7 @@ class UpdaterLegacyTest extends \Test\TestCase { public function testWrite() { $textSize = strlen("dummy file data\n"); $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png'); - $this->cache->put('foo.txt', array('mtime' => 100, 'storage_mtime' => 150)); + $this->cache->put('foo.txt', ['mtime' => 100, 'storage_mtime' => 150]); $rootCachedData = $this->cache->get(''); $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']); @@ -118,10 +119,10 @@ class UpdaterLegacyTest extends \Test\TestCase { } public function testWriteWithMountPoints() { - $storage2 = new \OC\Files\Storage\Temporary(array()); + $storage2 = new \OC\Files\Storage\Temporary([]); $storage2->getScanner()->scan(''); //initialize etags $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); + Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage'); $view = new View('/' . self::$user . '/files'); $folderCachedData = $view->getFileInfo('folder'); $substorageCachedData = $cache2->get(''); @@ -179,9 +180,9 @@ class UpdaterLegacyTest extends \Test\TestCase { } public function testDeleteWithMountPoints() { - $storage2 = new \OC\Files\Storage\Temporary(array()); + $storage2 = new \OC\Files\Storage\Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); + Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage'); Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); $view = new View('/' . self::$user . '/files'); $this->assertTrue($cache2->inCache('foo.txt')); @@ -235,9 +236,9 @@ class UpdaterLegacyTest extends \Test\TestCase { } public function testRenameWithMountPoints() { - $storage2 = new \OC\Files\Storage\Temporary(array()); + $storage2 = new \OC\Files\Storage\Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage'); + Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage'); Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd'); $view = new View('/' . self::$user . '/files'); $this->assertTrue($cache2->inCache('foo.txt')); @@ -305,5 +306,4 @@ class UpdaterLegacyTest extends \Test\TestCase { $this->assertNotSame($rootCachedData['etag'], $cachedData['etag']); $this->assertEquals($time, $cachedData['mtime']); } - } diff --git a/tests/lib/Files/Cache/UpdaterTest.php b/tests/lib/Files/Cache/UpdaterTest.php index 8dc5893007b..4c99b24d9d6 100644 --- a/tests/lib/Files/Cache/UpdaterTest.php +++ b/tests/lib/Files/Cache/UpdaterTest.php @@ -10,7 +10,6 @@ namespace Test\Files\Cache; use OC\Files\Filesystem; use OC\Files\Storage\Temporary; -use OC\Files\View; /** * Class UpdaterTest @@ -45,7 +44,7 @@ class UpdaterTest extends \Test\TestCase { $this->loginAsUser(); - $this->storage = new Temporary(array()); + $this->storage = new Temporary([]); $this->updater = $this->storage->getUpdater(); $this->cache = $this->storage->getCache(); } @@ -220,9 +219,9 @@ class UpdaterTest extends \Test\TestCase { } public function testMoveCrossStorage() { - $storage2 = new Temporary(array()); + $storage2 = new Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/bar'); + Filesystem::mount($storage2, [], '/bar'); $this->storage->file_put_contents('foo.txt', 'qwerty'); $this->updater->update('foo.txt'); @@ -251,9 +250,9 @@ class UpdaterTest extends \Test\TestCase { } public function testMoveFolderCrossStorage() { - $storage2 = new Temporary(array()); + $storage2 = new Temporary([]); $cache2 = $storage2->getCache(); - Filesystem::mount($storage2, array(), '/bar'); + Filesystem::mount($storage2, [], '/bar'); $this->storage->mkdir('foo'); $this->storage->mkdir('foo/bar'); $this->storage->file_put_contents('foo/foo.txt', 'qwerty'); diff --git a/tests/lib/Files/Cache/WatcherTest.php b/tests/lib/Files/Cache/WatcherTest.php index 18f0ebe98a9..42115c1c477 100644 --- a/tests/lib/Files/Cache/WatcherTest.php +++ b/tests/lib/Files/Cache/WatcherTest.php @@ -20,7 +20,7 @@ class WatcherTest extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage[] $storages */ - private $storages = array(); + private $storages = []; protected function setUp(): void { parent::setUp(); @@ -42,14 +42,14 @@ class WatcherTest extends \Test\TestCase { /** * @medium */ - function testWatcher() { + public function testWatcher() { $storage = $this->getTestStorage(); $cache = $storage->getCache(); $updater = $storage->getWatcher(); $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); //set the mtime to the past so it can detect an mtime change - $cache->put('', array('storage_mtime' => 10)); + $cache->put('', ['storage_mtime' => 10]); $this->assertTrue($cache->inCache('folder/bar.txt')); $this->assertTrue($cache->inCache('folder/bar2.txt')); @@ -61,7 +61,7 @@ class WatcherTest extends \Test\TestCase { $cachedData = $cache->get('bar.test'); $this->assertEquals(3, $cachedData['size']); - $cache->put('bar.test', array('storage_mtime' => 10)); + $cache->put('bar.test', ['storage_mtime' => 10]); $storage->file_put_contents('bar.test', 'test data'); // make sure that PHP can read the new size correctly @@ -71,7 +71,7 @@ class WatcherTest extends \Test\TestCase { $cachedData = $cache->get('bar.test'); $this->assertEquals(9, $cachedData['size']); - $cache->put('folder', array('storage_mtime' => 10)); + $cache->put('folder', ['storage_mtime' => 10]); $storage->unlink('folder/bar2.txt'); $updater->checkUpdate('folder'); @@ -90,7 +90,7 @@ class WatcherTest extends \Test\TestCase { $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); //set the mtime to the past so it can detect an mtime change - $cache->put('', array('storage_mtime' => 10)); + $cache->put('', ['storage_mtime' => 10]); $storage->unlink('foo.txt'); $storage->rename('folder', 'foo.txt'); @@ -107,7 +107,7 @@ class WatcherTest extends \Test\TestCase { $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $storage->unlink('foo.txt'); $storage->rename('folder', 'foo.txt'); @@ -124,14 +124,14 @@ class WatcherTest extends \Test\TestCase { $updater = $storage->getWatcher(); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_NEVER); $storage->file_put_contents('foo.txt', 'q'); $this->assertFalse($updater->checkUpdate('foo.txt')); - $cache->put('foo.txt', array('storage_mtime' => 20)); + $cache->put('foo.txt', ['storage_mtime' => 20]); $storage->file_put_contents('foo.txt', 'w'); $this->assertFalse($updater->checkUpdate('foo.txt')); } @@ -142,14 +142,14 @@ class WatcherTest extends \Test\TestCase { $updater = $storage->getWatcher(); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); $storage->file_put_contents('foo.txt', 'q'); $this->assertTrue($updater->checkUpdate('foo.txt')); - $cache->put('foo.txt', array('storage_mtime' => 20)); + $cache->put('foo.txt', ['storage_mtime' => 20]); $storage->file_put_contents('foo.txt', 'w'); $this->assertFalse($updater->checkUpdate('foo.txt')); } @@ -160,14 +160,14 @@ class WatcherTest extends \Test\TestCase { $updater = $storage->getWatcher(); //set the mtime to the past so it can detect an mtime change - $cache->put('foo.txt', array('storage_mtime' => 10)); + $cache->put('foo.txt', ['storage_mtime' => 10]); $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ALWAYS); $storage->file_put_contents('foo.txt', 'q'); $this->assertTrue($updater->checkUpdate('foo.txt')); - $cache->put('foo.txt', array('storage_mtime' => 20)); + $cache->put('foo.txt', ['storage_mtime' => 20]); $storage->file_put_contents('foo.txt', 'w'); $this->assertTrue($updater->checkUpdate('foo.txt')); } @@ -177,7 +177,7 @@ class WatcherTest extends \Test\TestCase { * @return \OC\Files\Storage\Storage */ private function getTestStorage($scan = true) { - $storage = new \OC\Files\Storage\Temporary(array()); + $storage = new \OC\Files\Storage\Temporary([]); $textData = "dummy file data\n"; $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $storage->mkdir('folder'); diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php index 9c1a8c14101..f0943ba5a03 100644 --- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php +++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php @@ -31,10 +31,10 @@ class CacheJailTest extends CacheTest { $this->cache = new \OC\Files\Cache\Wrapper\CacheJail($this->sourceCache, 'foo'); } - function testSearchOutsideJail() { + public function testSearchOutsideJail() { $file1 = 'foo/foobar'; $file2 = 'folder/foobar'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; $this->sourceCache->put($file1, $data1); $this->sourceCache->put($file2, $data1); @@ -46,11 +46,11 @@ class CacheJailTest extends CacheTest { $this->assertEquals('foobar', $result[0]['path']); } - function testClearKeepEntriesOutsideJail() { + public function testClearKeepEntriesOutsideJail() { $file1 = 'foo/foobar'; $file2 = 'foo/foobar/asd'; $file3 = 'folder/foobar'; - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('foo', $data1); $this->sourceCache->put($file1, $data1); @@ -63,8 +63,8 @@ class CacheJailTest extends CacheTest { $this->assertTrue($this->sourceCache->inCache('folder/foobar')); } - function testGetById() { - $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + public function testGetById() { + $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $id = $this->sourceCache->put('foo/bar', $data1); // path from jailed foo of foo/bar is bar @@ -77,13 +77,13 @@ class CacheJailTest extends CacheTest { $this->assertEquals('foo/bar', $path); } - function testGetIncomplete() { + public function testGetIncomplete() { //not supported $this->addToAssertionCount(1); } - function testMoveFromJail() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + public function testMoveFromJail() { + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('source', $folderData); $this->sourceCache->put('source/foo', $folderData); @@ -98,8 +98,8 @@ class CacheJailTest extends CacheTest { $this->assertTrue($this->sourceCache->inCache('target/foo/bar')); } - function testMoveToJail() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + public function testMoveToJail() { + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('source', $folderData); $this->sourceCache->put('source/foo', $folderData); @@ -114,8 +114,8 @@ class CacheJailTest extends CacheTest { $this->assertTrue($this->sourceCache->inCache('target/foo/bar')); } - function testMoveBetweenJail() { - $folderData = array('size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory'); + public function testMoveBetweenJail() { + $folderData = ['size' => 100, 'mtime' => 50, 'mimetype' => 'httpd/unix-directory']; $this->sourceCache->put('source', $folderData); $this->sourceCache->put('source/foo', $folderData); diff --git a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php index 9883fc1da27..20c20974c07 100644 --- a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php +++ b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php @@ -36,12 +36,12 @@ class CachePermissionsMaskTest extends CacheTest { } public function maskProvider() { - return array( - array(Constants::PERMISSION_ALL), - array(Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE), - array(Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE), - array(Constants::PERMISSION_READ) - ); + return [ + [Constants::PERMISSION_ALL], + [Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE], + [Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE], + [Constants::PERMISSION_READ] + ]; } /** @@ -50,12 +50,12 @@ class CachePermissionsMaskTest extends CacheTest { */ public function testGetMasked($mask) { $cache = $this->getMaskedCached($mask); - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL]; $this->sourceCache->put('foo', $data); $result = $cache->get('foo'); $this->assertEquals($mask, $result['permissions']); - $data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE); + $data = ['size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain', 'permissions' => Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE]; $this->sourceCache->put('bar', $data); $result = $cache->get('bar'); $this->assertEquals($mask & ~Constants::PERMISSION_DELETE, $result['permissions']); diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index 2f61f634ffb..6f347a504cb 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -77,24 +77,24 @@ class UserMountCacheTest extends TestCase { ->getMock(); $storageCache->expects($this->any()) ->method('getNumericId') - ->will($this->returnValue($storageId)); + ->willReturn($storageId); $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') ->disableOriginalConstructor() ->getMock(); $cache->expects($this->any()) ->method('getId') - ->will($this->returnValue($rootId)); + ->willReturn($rootId); $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor() ->getMock(); $storage->expects($this->any()) ->method('getStorageCache') - ->will($this->returnValue($storageCache)); + ->willReturn($storageCache); $storage->expects($this->any()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); return [$storage, $rootId]; } @@ -401,7 +401,7 @@ class UserMountCacheTest extends TestCase { $mount1->expects($this->any()) ->method('getStorageRootId') - ->will($this->returnValue($folderId)); + ->willReturn($folderId); $this->cache->registerMounts($user1, [$mount1]); @@ -434,7 +434,7 @@ class UserMountCacheTest extends TestCase { $mount1->expects($this->any()) ->method('getStorageRootId') - ->will($this->returnValue($folderId)); + ->willReturn($folderId); $this->cache->registerMounts($user1, [$mount1]); @@ -481,11 +481,11 @@ class UserMountCacheTest extends TestCase { $mount1->expects($this->any()) ->method('getStorageRootId') - ->will($this->returnValue($rootId)); + ->willReturn($rootId); $mount1->expects($this->any()) ->method('getNumericStorageId') - ->will($this->returnValue(2)); + ->willReturn(2); $this->cache->registerMounts($user1, [$mount1]); diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php index d3b372fe137..39069ce4dfe 100644 --- a/tests/lib/Files/EtagTest.php +++ b/tests/lib/Files/EtagTest.php @@ -10,7 +10,6 @@ namespace Test\Files; use OC\Files\Filesystem; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Share; use OCA\Files_Sharing\AppInfo\Application; /** @@ -67,7 +66,7 @@ class EtagTest extends \Test\TestCase { Filesystem::file_put_contents('/folder/bar.txt', 'fgh'); Filesystem::file_put_contents('/folder/subfolder/qwerty.txt', 'jkl'); - $files = array('/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt'); + $files = ['/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt']; $originalEtags = $this->getEtags($files); $scanner = new \OC\Files\Utils\Scanner($user1, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger()); @@ -84,7 +83,7 @@ class EtagTest extends \Test\TestCase { * @param string[] $files */ private function getEtags($files) { - $etags = array(); + $etags = []; foreach ($files as $file) { $info = Filesystem::getFileInfo($file); $etags[$file] = $info['etag']; diff --git a/tests/lib/Files/FileInfoTest.php b/tests/lib/Files/FileInfoTest.php index 0037941b629..fd2b506beb9 100644 --- a/tests/lib/Files/FileInfoTest.php +++ b/tests/lib/Files/FileInfoTest.php @@ -8,11 +8,9 @@ namespace Test\Files; -use OC\AllConfig; use OC\Files\FileInfo; use OC\Files\Storage\Home; use OC\Files\Storage\Temporary; -use OC\User\User; use OCP\IConfig; use OCP\IUser; use Test\TestCase; diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php index 6d0362772ca..d9e6de898f0 100644 --- a/tests/lib/Files/FilesystemTest.php +++ b/tests/lib/Files/FilesystemTest.php @@ -46,7 +46,7 @@ class DummyMountProvider implements IMountProvider { * @param IStorageFactory $loader * @return \OCP\Files\Mount\IMountPoint[] */ - public function getMountsForUser(IUser $user, IStorageFactory $loader) { + public function getMountsForUser(IUser $user, IStorageFactory $loader) { return isset($this->mounts[$user->getUID()]) ? $this->mounts[$user->getUID()] : []; } } @@ -59,14 +59,13 @@ class DummyMountProvider implements IMountProvider { * @package Test\Files */ class FilesystemTest extends \Test\TestCase { - - const TEST_FILESYSTEM_USER1 = "test-filesystem-user1"; - const TEST_FILESYSTEM_USER2 = "test-filesystem-user1"; + public const TEST_FILESYSTEM_USER1 = "test-filesystem-user1"; + public const TEST_FILESYSTEM_USER2 = "test-filesystem-user1"; /** * @var array tmpDirs */ - private $tmpDirs = array(); + private $tmpDirs = []; /** * @return array @@ -74,7 +73,7 @@ class FilesystemTest extends \Test\TestCase { private function getStorageData() { $dir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->tmpDirs[] = $dir; - return array('datadir' => $dir); + return ['datadir' => $dir]; } protected function setUp(): void { @@ -225,29 +224,29 @@ class FilesystemTest extends \Test\TestCase { } public function isValidPathData() { - return array( - array('/', true), - array('/path', true), - array('/foo/bar', true), - array('/foo//bar/', true), - array('/foo////bar', true), - array('/foo//\///bar', true), - array('/foo/bar/.', true), - array('/foo/bar/./', true), - array('/foo/bar/./.', true), - array('/foo/bar/././', true), - array('/foo/bar/././..bar', true), - array('/foo/bar/././..bar/a', true), - array('/foo/bar/././..', false), - array('/foo/bar/././../', false), - array('/foo/bar/.././', false), - array('/foo/bar/../../', false), - array('/foo/bar/../..\\', false), - array('..', false), - array('../', false), - array('../foo/bar', false), - array('..\foo/bar', false), - ); + return [ + ['/', true], + ['/path', true], + ['/foo/bar', true], + ['/foo//bar/', true], + ['/foo////bar', true], + ['/foo//\///bar', true], + ['/foo/bar/.', true], + ['/foo/bar/./', true], + ['/foo/bar/./.', true], + ['/foo/bar/././', true], + ['/foo/bar/././..bar', true], + ['/foo/bar/././..bar/a', true], + ['/foo/bar/././..', false], + ['/foo/bar/././../', false], + ['/foo/bar/.././', false], + ['/foo/bar/../../', false], + ['/foo/bar/../..\\', false], + ['..', false], + ['../', false], + ['../foo/bar', false], + ['..\foo/bar', false], + ]; } /** @@ -258,18 +257,18 @@ class FilesystemTest extends \Test\TestCase { } public function isFileBlacklistedData() { - return array( - array('/etc/foo/bar/foo.txt', false), - array('\etc\foo/bar\foo.txt', false), - array('.htaccess', true), - array('.htaccess/', true), - array('.htaccess\\', true), - array('/etc/foo\bar/.htaccess\\', true), - array('/etc/foo\bar/.htaccess/', true), - array('/etc/foo\bar/.htaccess/foo', false), - array('//foo//bar/\.htaccess/', true), - array('\foo\bar\.HTAccess', true), - ); + return [ + ['/etc/foo/bar/foo.txt', false], + ['\etc\foo/bar\foo.txt', false], + ['.htaccess', true], + ['.htaccess/', true], + ['.htaccess\\', true], + ['/etc/foo\bar/.htaccess\\', true], + ['/etc/foo\bar/.htaccess/', true], + ['/etc/foo\bar/.htaccess/foo', false], + ['//foo//bar/\.htaccess/', true], + ['\foo\bar\.HTAccess', true], + ]; } /** @@ -299,12 +298,11 @@ class FilesystemTest extends \Test\TestCase { $userObj = \OC::$server->getUserManager()->get($user); \OC::$server->getUserSession()->setUser($userObj); \OC\Files\Filesystem::init($user, '/' . $user . '/files'); - } \OC_Hook::clear('OC_Filesystem'); \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); - \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', array(), '/'); + \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', [], '/'); $rootView = new \OC\Files\View(''); $rootView->mkdir('/' . $user); @@ -391,12 +389,14 @@ class FilesystemTest extends \Test\TestCase { $this->assertTrue($homeMount->instanceOfStorage('\OCP\Files\IHomeStorage')); if ($homeMount->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')) { $this->assertEquals('object::user:' . $userId, $homeMount->getId()); - } else if ($homeMount->instanceOfStorage('\OC\Files\Storage\Home')) { + } elseif ($homeMount->instanceOfStorage('\OC\Files\Storage\Home')) { $this->assertEquals('home::' . $userId, $homeMount->getId()); } $user = \OC::$server->getUserManager()->get($userId); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } } public function dummyHook($arguments) { @@ -425,7 +425,9 @@ class FilesystemTest extends \Test\TestCase { $this->assertTrue($storage->instanceOfStorage('\OCP\Files\IHomeStorage')); $this->assertEquals('cache', $internalPath); $user = \OC::$server->getUserManager()->get($userId); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } $config->setSystemValue('cache_path', $oldCachePath); } @@ -454,7 +456,9 @@ class FilesystemTest extends \Test\TestCase { $this->assertTrue($storage->instanceOfStorage('\OC\Files\Storage\Local')); $this->assertEquals('', $internalPath); $user = \OC::$server->getUserManager()->get($userId); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } $config->setSystemValue('cache_path', $oldCachePath); } diff --git a/tests/lib/Files/Mount/ManagerTest.php b/tests/lib/Files/Mount/ManagerTest.php index f3cdc4264e4..1e80ec17ea1 100644 --- a/tests/lib/Files/Mount/ManagerTest.php +++ b/tests/lib/Files/Mount/ManagerTest.php @@ -30,39 +30,39 @@ class ManagerTest extends \Test\TestCase { public function testFind() { $this->assertNull($this->manager->find('/')); - $rootMount = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/'); + $rootMount = new \OC\Files\Mount\MountPoint(new Temporary([]), '/'); $this->manager->addMount($rootMount); $this->assertEquals($rootMount, $this->manager->find('/')); $this->assertEquals($rootMount, $this->manager->find('/foo/bar')); - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount1 = new \OC\Files\Mount\MountPoint($storage, '/foo'); $this->manager->addMount($mount1); $this->assertEquals($rootMount, $this->manager->find('/')); $this->assertEquals($mount1, $this->manager->find('/foo/bar')); $this->assertEquals(1, count($this->manager->findIn('/'))); - $mount2 = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/bar'); + $mount2 = new \OC\Files\Mount\MountPoint(new Temporary([]), '/bar'); $this->manager->addMount($mount2); $this->assertEquals(2, count($this->manager->findIn('/'))); $id = $mount1->getStorageId(); - $this->assertEquals(array($mount1), $this->manager->findByStorageId($id)); + $this->assertEquals([$mount1], $this->manager->findByStorageId($id)); $mount3 = new \OC\Files\Mount\MountPoint($storage, '/foo/bar'); $this->manager->addMount($mount3); - $this->assertEquals(array($mount1, $mount3), $this->manager->findByStorageId($id)); + $this->assertEquals([$mount1, $mount3], $this->manager->findByStorageId($id)); } public function testLong() { - $storage = new LongId(array()); + $storage = new LongId([]); $mount = new \OC\Files\Mount\MountPoint($storage, '/foo'); $this->manager->addMount($mount); $id = $mount->getStorageId(); $storageId = $storage->getId(); - $this->assertEquals(array($mount), $this->manager->findByStorageId($id)); - $this->assertEquals(array($mount), $this->manager->findByStorageId($storageId)); - $this->assertEquals(array($mount), $this->manager->findByStorageId(md5($storageId))); + $this->assertEquals([$mount], $this->manager->findByStorageId($id)); + $this->assertEquals([$mount], $this->manager->findByStorageId($storageId)); + $this->assertEquals([$mount], $this->manager->findByStorageId(md5($storageId))); } } diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php index 9b63c507b5f..106a8f9a932 100644 --- a/tests/lib/Files/Mount/MountPointTest.php +++ b/tests/lib/Files/Mount/MountPointTest.php @@ -12,21 +12,19 @@ use OC\Files\Storage\StorageFactory; use OCP\Files\Storage; class DummyStorage { - } class MountPointTest extends \Test\TestCase { - public function testGetStorage() { $storage = $this->createMock(Storage::class); $storage->expects($this->once()) ->method('getId') - ->will($this->returnValue(123)); + ->willReturn(123); $loader = $this->createMock(StorageFactory::class); $loader->expects($this->once()) ->method('wrap') - ->will($this->returnValue($storage)); + ->willReturn($storage); $mountPoint = new \OC\Files\Mount\MountPoint( // just use this because a real class is needed @@ -51,7 +49,7 @@ class MountPointTest extends \Test\TestCase { ->will($this->throwException(new \Exception('Test storage init exception'))); $called = false; - $wrapper = function($mountPoint, $storage) use ($called) { + $wrapper = function ($mountPoint, $storage) use ($called) { $called = true; }; diff --git a/tests/lib/Files/Mount/MountTest.php b/tests/lib/Files/Mount/MountTest.php index f21095f2fa5..340e6931c1d 100644 --- a/tests/lib/Files/Mount/MountTest.php +++ b/tests/lib/Files/Mount/MountTest.php @@ -8,7 +8,6 @@ namespace Test\Files\Mount; - use OC\Files\Storage\StorageFactory; use OC\Files\Storage\Wrapper\Wrapper; @@ -31,7 +30,7 @@ class MountTest extends \Test\TestCase { $wrapper = function ($mountPoint, $storage) use (&$test) { $test->assertEquals('/foo/', $mountPoint); $test->assertInstanceOf('\OC\Files\Storage\Storage', $storage); - return new Wrapper(array('storage' => $storage)); + return new Wrapper(['storage' => $storage]); }; $loader = new StorageFactory(); @@ -40,7 +39,7 @@ class MountTest extends \Test\TestCase { $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') ->disableOriginalConstructor() ->getMock(); - $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', array(), $loader); + $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', [], $loader); $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage()); } } diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php index 2cdf9cbdc5a..3fa988c89d8 100644 --- a/tests/lib/Files/Node/FileTest.php +++ b/tests/lib/Files/Node/FileTest.php @@ -48,12 +48,12 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('file_get_contents') ->with('/bar/foo') - ->will($this->returnValue('bar')); + ->willReturn('bar'); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $this->assertEquals('bar', $node->getContent()); @@ -70,12 +70,12 @@ class FileTest extends NodeTest { $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => 0)))); + ->willReturn($this->getFileInfo(['permissions' => 0])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->getContent(); @@ -89,17 +89,17 @@ class FileTest extends NodeTest { $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $this->view->expects($this->once()) ->method('file_put_contents') ->with('/bar/foo', 'bar') - ->will($this->returnValue(true)); + ->willReturn(true); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->putContent('bar'); @@ -117,7 +117,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->putContent('bar'); @@ -132,7 +132,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('mimetype' => 'text/plain')))); + ->willReturn($this->getFileInfo(['mimetype' => 'text/plain'])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $this->assertEquals('text/plain', $node->getMimeType()); @@ -162,12 +162,12 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('fopen') ->with('/bar/foo', 'r') - ->will($this->returnValue($stream)); + ->willReturn($stream); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $fh = $node->fopen('r'); @@ -197,12 +197,12 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('fopen') ->with('/bar/foo', 'w') - ->will($this->returnValue($stream)); + ->willReturn($stream); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $fh = $node->fopen('w'); @@ -232,7 +232,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => 0)))); + ->willReturn($this->getFileInfo(['permissions' => 0])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('r'); @@ -257,7 +257,7 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_UPDATE)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_UPDATE])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('w'); @@ -282,11 +282,9 @@ class FileTest extends NodeTest { $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo'); $node->fopen('w'); } - - } diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index d33fb4f68f8..d2bbf65965a 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -19,7 +19,6 @@ use OC\Files\Node\Root; use OC\Files\Storage\Temporary; use OC\Files\Storage\Wrapper\Jail; use OC\Files\View; -use OC\User\User; use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\Files\Storage; @@ -59,15 +58,15 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $view->expects($this->any()) ->method('getDirectoryContent') ->with('/bar/foo') - ->will($this->returnValue(array( + ->willReturn([ new FileInfo('/bar/foo/asd', null, 'foo/asd', ['fileid' => 2, 'path' => '/bar/foo/asd', 'name' => 'asd', 'size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'], null), new FileInfo('/bar/foo/qwerty', null, 'foo/qwerty', ['fileid' => 3, 'path' => '/bar/foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'httpd/unix-directory'], null) - ))); + ]); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $children = $node->getDirectoryListing(); @@ -91,7 +90,7 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $root->expects($this->once()) ->method('get') @@ -112,14 +111,14 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $child = new \OC\Files\Node\Folder($root, $view, '/bar/foo/asd'); $root->expects($this->once()) ->method('get') ->with('/bar/foo/asd') - ->will($this->returnValue($child)); + ->willReturn($child); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $this->assertTrue($node->nodeExists('asd')); @@ -136,7 +135,7 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $root->expects($this->once()) ->method('get') @@ -158,17 +157,17 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $view->expects($this->once()) ->method('mkdir') ->with('/bar/foo/asd') - ->will($this->returnValue(true)); + ->willReturn(true); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $child = new \OC\Files\Node\Folder($root, $view, '/bar/foo/asd'); @@ -190,12 +189,12 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFolder('asd'); @@ -212,17 +211,17 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $view->expects($this->once()) ->method('touch') ->with('/bar/foo/asd') - ->will($this->returnValue(true)); + ->willReturn(true); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $child = new \OC\Files\Node\File($root, $view, '/bar/foo/asd'); @@ -244,12 +243,12 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFile('asd'); @@ -266,12 +265,12 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $view->expects($this->once()) ->method('free_space') ->with('/bar/foo') - ->will($this->returnValue(100)); + ->willReturn(100); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $this->assertEquals(100, $node->getFreeSpace()); @@ -288,39 +287,39 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn(''); $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock(); $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $mount = $this->createMock(IMountPoint::class); $mount->expects($this->once()) ->method('getStorage') - ->will($this->returnValue($storage)); + ->willReturn($storage); $mount->expects($this->once()) ->method('getInternalPath') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->will($this->returnValue(array( - array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - ))); + ->willReturn([ + ['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->will($this->returnValue(array())); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') ->with('/bar/foo') - ->will($this->returnValue($mount)); + ->willReturn($mount); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $result = $node->search('qw'); @@ -340,7 +339,7 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); /** @var \PHPUnit_Framework_MockObject_MockObject|Storage $storage */ $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn(''); @@ -349,32 +348,32 @@ class FolderTest extends NodeTest { $mount = $this->createMock(IMountPoint::class); $mount->expects($this->once()) ->method('getStorage') - ->will($this->returnValue($storage)); + ->willReturn($storage); $mount->expects($this->once()) ->method('getInternalPath') - ->will($this->returnValue('files')); + ->willReturn('files'); $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->will($this->returnValue(array( - array('fileid' => 3, 'path' => 'files/foo', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'), - array('fileid' => 3, 'path' => 'files_trashbin/foo2.d12345', 'name' => 'foo2.d12345', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'), - ))); + ->willReturn([ + ['fileid' => 3, 'path' => 'files/foo', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'], + ['fileid' => 3, 'path' => 'files_trashbin/foo2.d12345', 'name' => 'foo2.d12345', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'], + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('') - ->will($this->returnValue(array())); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') ->with('') - ->will($this->returnValue($mount)); + ->willReturn($mount); $result = $root->search('qw'); $this->assertEquals(1, count($result)); @@ -392,7 +391,7 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn(''); $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock(); @@ -400,31 +399,31 @@ class FolderTest extends NodeTest { $mount = $this->createMock(IMountPoint::class); $mount->expects($this->once()) ->method('getStorage') - ->will($this->returnValue($storage)); + ->willReturn($storage); $mount->expects($this->once()) ->method('getInternalPath') - ->will($this->returnValue('')); + ->willReturn(''); $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->will($this->returnValue(array( - array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - ))); + ->willReturn([ + ['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar') - ->will($this->returnValue(array())); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') ->with('/bar') - ->will($this->returnValue($mount)); + ->willReturn($mount); $node = new \OC\Files\Node\Folder($root, $view, '/bar'); $result = $node->search('qw'); @@ -443,7 +442,7 @@ class FolderTest extends NodeTest { ->getMock(); $root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn(''); $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock(); @@ -454,50 +453,50 @@ class FolderTest extends NodeTest { $mount = $this->createMock(IMountPoint::class); $mount->expects($this->once()) ->method('getStorage') - ->will($this->returnValue($storage)); + ->willReturn($storage); $mount->expects($this->once()) ->method('getInternalPath') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $subMount->expects($this->once()) ->method('getStorage') - ->will($this->returnValue($subStorage)); + ->willReturn($subStorage); $subMount->expects($this->once()) ->method('getMountPoint') - ->will($this->returnValue('/bar/foo/bar/')); + ->willReturn('/bar/foo/bar/'); $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $subStorage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($subCache)); + ->willReturn($subCache); $cache->expects($this->once()) ->method('search') ->with('%qw%') - ->will($this->returnValue(array( - array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - ))); + ->willReturn([ + ['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $subCache->expects($this->once()) ->method('search') ->with('%qw%') - ->will($this->returnValue(array( - array('fileid' => 4, 'path' => 'asd/qweasd', 'name' => 'qweasd', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain') - ))); + ->willReturn([ + ['fileid' => 4, 'path' => 'asd/qweasd', 'name' => 'qweasd', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'] + ]); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->will($this->returnValue(array($subMount))); + ->willReturn([$subMount]); $root->expects($this->once()) ->method('getMount') ->with('/bar/foo') - ->will($this->returnValue($mount)); + ->willReturn($mount); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); @@ -534,34 +533,34 @@ class FolderTest extends NodeTest { $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $this->userMountCache->expects($this->any()) ->method('getMountsForFileId') ->with(1) - ->will($this->returnValue([new CachedMountInfo( + ->willReturn([new CachedMountInfo( $this->user, 1, 0, '/bar/', 1, '' - )])); + )]); $cache->expects($this->once()) ->method('get') ->with(1) - ->will($this->returnValue($fileInfo)); + ->willReturn($fileInfo); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->will($this->returnValue(array())); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') ->with('/bar/foo') - ->will($this->returnValue($mount)); + ->willReturn($mount); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $result = $node->getById(1); @@ -588,29 +587,29 @@ class FolderTest extends NodeTest { $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $this->userMountCache->expects($this->any()) ->method('getMountsForFileId') ->with(1) - ->will($this->returnValue([new CachedMountInfo( + ->willReturn([new CachedMountInfo( $this->user, 1, 0, '/bar/', 1, '' - )])); + )]); $cache->expects($this->once()) ->method('get') ->with(1) - ->will($this->returnValue($fileInfo)); + ->willReturn($fileInfo); $root->expects($this->once()) ->method('getMount') ->with('/bar') - ->will($this->returnValue($mount)); + ->willReturn($mount); $node = new \OC\Files\Node\Folder($root, $view, '/bar'); $result = $node->getById(1); @@ -637,34 +636,34 @@ class FolderTest extends NodeTest { $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $this->userMountCache->expects($this->any()) ->method('getMountsForFileId') ->with(1) - ->will($this->returnValue([new CachedMountInfo( + ->willReturn([new CachedMountInfo( $this->user, 1, 0, '/bar/', 1, '' - )])); + )]); $cache->expects($this->once()) ->method('get') ->with(1) - ->will($this->returnValue($fileInfo)); + ->willReturn($fileInfo); $root->expects($this->once()) ->method('getMountsIn') ->with('/bar/foo') - ->will($this->returnValue(array())); + ->willReturn([]); $root->expects($this->once()) ->method('getMount') ->with('/bar/foo') - ->will($this->returnValue($mount)); + ->willReturn($mount); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $result = $node->getById(1); @@ -691,12 +690,12 @@ class FolderTest extends NodeTest { $storage->expects($this->exactly(2)) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $this->userMountCache->expects($this->any()) ->method('getMountsForFileId') ->with(1) - ->will($this->returnValue([ + ->willReturn([ new CachedMountInfo( $this->user, 1, @@ -713,26 +712,26 @@ class FolderTest extends NodeTest { 1, '' ) - ])); + ]); $storage->expects($this->any()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $cache->expects($this->any()) ->method('get') ->with(1) - ->will($this->returnValue($fileInfo)); + ->willReturn($fileInfo); $root->expects($this->any()) ->method('getMountsIn') ->with('/bar/foo') - ->will($this->returnValue(array($mount2))); + ->willReturn([$mount2]); $root->expects($this->once()) ->method('getMount') ->with('/bar/foo') - ->will($this->returnValue($mount1)); + ->willReturn($mount1); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $result = $node->getById(1); @@ -767,14 +766,14 @@ class FolderTest extends NodeTest { $view->expects($this->any()) ->method('file_exists') - ->will($this->returnCallback(function ($path) use ($existingFiles, $folderPath) { + ->willReturnCallback(function ($path) use ($existingFiles, $folderPath) { foreach ($existingFiles as $existing) { if ($folderPath . '/' . $existing === $path) { return true; } } return false; - })); + }); $node = new \OC\Files\Node\Folder($root, $view, $folderPath); $this->assertEquals($expected, $node->getNonExistingName($name)); @@ -802,7 +801,7 @@ class FolderTest extends NodeTest { $folderInfo->expects($this->any()) ->method('getMountPoint') - ->will($this->returnValue($mount)); + ->willReturn($mount); $cache = $storage->getCache(); @@ -866,7 +865,7 @@ class FolderTest extends NodeTest { $folderInfo->expects($this->any()) ->method('getMountPoint') - ->will($this->returnValue($mount)); + ->willReturn($mount); $cache = $storage->getCache(); @@ -932,7 +931,7 @@ class FolderTest extends NodeTest { $folderInfo->expects($this->any()) ->method('getMountPoint') - ->will($this->returnValue($mount)); + ->willReturn($mount); $cache = $storage->getCache(); diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php index 2a542a1097a..26cdf398d94 100644 --- a/tests/lib/Files/Node/IntegrationTest.php +++ b/tests/lib/Files/Node/IntegrationTest.php @@ -57,8 +57,8 @@ class IntegrationTest extends \Test\TestCase { $this->createMock(ILogger::class), $this->createMock(IUserManager::class) ); - $storage = new Temporary(array()); - $subStorage = new Temporary(array()); + $storage = new Temporary([]); + $subStorage = new Temporary([]); $this->storages[] = $storage; $this->storages[] = $subStorage; $this->root->mount($storage, '/'); diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index 7c8ddee6b5f..86643617959 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -11,14 +11,11 @@ namespace Test\Files\Node; use OC\Files\FileInfo; use OC\Files\Mount\Manager; use OC\Files\View; -use OCP\Files\Config\IUserMountCache; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\Storage; -use OCP\IConfig; use OCP\ILogger; -use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -69,22 +66,22 @@ abstract class NodeTest extends \Test\TestCase { * @param string $path * @return Node */ - protected abstract function createTestNode($root, $view, $path); + abstract protected function createTestNode($root, $view, $path); /** * @return string */ - protected abstract function getNodeClass(); + abstract protected function getNodeClass(); /** * @return string */ - protected abstract function getNonExistingNodeClass(); + abstract protected function getNonExistingNodeClass(); /** * @return string */ - protected abstract function getViewDeleteMethod(); + abstract protected function getViewDeleteMethod(); protected function getMockStorage() { $storage = $this->getMockBuilder(Storage::class) @@ -92,7 +89,7 @@ abstract class NodeTest extends \Test\TestCase { ->getMock(); $storage->expects($this->any()) ->method('getId') - ->will($this->returnValue('home::someuser')); + ->willReturn('home::someuser'); return $storage; } @@ -103,20 +100,20 @@ abstract class NodeTest extends \Test\TestCase { public function testDelete() { $this->root->expects($this->exactly(2)) ->method('emit') - ->will($this->returnValue(true)); + ->willReturn(true); $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $this->view->expects($this->once()) ->method($this->getViewDeleteMethod()) ->with('/bar/foo') - ->will($this->returnValue(true)); + ->willReturn(true); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $node->delete(); @@ -163,17 +160,17 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1, 'mimetype' => 'text/plain']))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1, 'mimetype' => 'text/plain'])); $this->view->expects($this->once()) ->method($this->getViewDeleteMethod()) ->with('/bar/foo') - ->will($this->returnValue(true)); + ->willReturn(true); $this->view->expects($this->any()) ->method('resolvePath') ->with('/bar/foo') - ->will($this->returnValue([null, 'foo'])); + ->willReturn([null, 'foo']); $node = $this->createTestNode($root, $this->view, '/bar/foo'); $node->delete(); @@ -186,12 +183,12 @@ abstract class NodeTest extends \Test\TestCase { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $node->delete(); @@ -201,20 +198,20 @@ abstract class NodeTest extends \Test\TestCase { public function testStat() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); - $stat = array( + $stat = [ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50, 'permissions' => 0 - ); + ]; $this->view->expects($this->once()) ->method('stat') ->with('/bar/foo') - ->will($this->returnValue($stat)); + ->willReturn($stat); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $this->assertEquals($stat, $node->stat()); @@ -223,19 +220,19 @@ abstract class NodeTest extends \Test\TestCase { public function testGetId() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($stat)); + ->willReturn($stat); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $this->assertEquals(1, $node->getId()); @@ -244,20 +241,20 @@ abstract class NodeTest extends \Test\TestCase { public function testGetSize() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($stat)); + ->willReturn($stat); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $this->assertEquals(100, $node->getSize()); @@ -266,19 +263,19 @@ abstract class NodeTest extends \Test\TestCase { public function testGetEtag() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($stat)); + ->willReturn($stat); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $this->assertEquals('qwerty', $node->getEtag()); @@ -287,19 +284,19 @@ abstract class NodeTest extends \Test\TestCase { public function testGetMTime() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); - $stat = $this->getFileInfo(array( + $stat = $this->getFileInfo([ 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - )); + ]); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($stat)); + ->willReturn($stat); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $this->assertEquals(50, $node->getMTime()); @@ -308,7 +305,7 @@ abstract class NodeTest extends \Test\TestCase { public function testGetStorage() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); /** * @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage */ @@ -319,7 +316,7 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->once()) ->method('resolvePath') ->with('/bar/foo') - ->will($this->returnValue(array($storage, 'foo'))); + ->willReturn([$storage, 'foo']); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); @@ -329,7 +326,7 @@ abstract class NodeTest extends \Test\TestCase { public function testGetPath() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $this->assertEquals('/bar/foo', $node->getPath()); @@ -338,7 +335,7 @@ abstract class NodeTest extends \Test\TestCase { public function testGetInternalPath() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); /** * @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage */ @@ -349,7 +346,7 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->once()) ->method('resolvePath') ->with('/bar/foo') - ->will($this->returnValue(array($storage, 'foo'))); + ->willReturn([$storage, 'foo']); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); @@ -359,7 +356,7 @@ abstract class NodeTest extends \Test\TestCase { public function testGetName() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $this->assertEquals('foo', $node->getName()); @@ -368,17 +365,17 @@ abstract class NodeTest extends \Test\TestCase { public function testTouchSetMTime() { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->view->expects($this->once()) ->method('touch') ->with('/bar/foo', 100) - ->will($this->returnValue(true)); + ->willReturn(true); $this->view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $node->touch(100); @@ -420,17 +417,17 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->once()) ->method('touch') ->with('/bar/foo', 100) - ->will($this->returnValue(true)); + ->willReturn(true); $this->view->expects($this->any()) ->method('resolvePath') ->with('/bar/foo') - ->will($this->returnValue(array(null, 'foo'))); + ->willReturn([null, 'foo']); $this->view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); $node = $this->createTestNode($root, $this->view, '/bar/foo'); $node->touch(100); @@ -443,12 +440,12 @@ abstract class NodeTest extends \Test\TestCase { $this->root->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $node->touch(100); @@ -466,11 +463,11 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('copy') ->with('/bar/foo', '/bar/asd') - ->will($this->returnValue(true)); + ->willReturn(true); $this->view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar'); @@ -478,10 +475,10 @@ abstract class NodeTest extends \Test\TestCase { $this->root->expects($this->exactly(2)) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['/bar/asd', $newNode], ['/bar', $parentNode] - ])); + ]); $target = $node->copy('/bar/asd'); $this->assertInstanceOf($this->getNodeClass(), $target); @@ -505,16 +502,16 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar'); $this->root->expects($this->once()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['/bar', $parentNode] - ])); + ]); $node->copy('/bar/asd'); } @@ -548,9 +545,9 @@ abstract class NodeTest extends \Test\TestCase { $this->root->expects($this->once()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['/bar', $parentNode] - ])); + ]); $node->copy('/bar/asd'); } @@ -559,18 +556,18 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('rename') ->with('/bar/foo', '/bar/asd') - ->will($this->returnValue(true)); + ->willReturn(true); $this->view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar'); $this->root->expects($this->any()) ->method('get') - ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]])); + ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $node]]); $target = $node->move('/bar/asd'); $this->assertInstanceOf($this->getNodeClass(), $target); @@ -602,11 +599,11 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method($viewMethod) ->with('/bar/foo', '/bar/asd') - ->will($this->returnValue(true)); + ->willReturn(true); $this->view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])); /** * @var \OC\Files\Node\File|\PHPUnit_Framework_MockObject_MockObject $node @@ -617,7 +614,7 @@ abstract class NodeTest extends \Test\TestCase { $root->expects($this->any()) ->method('get') - ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $targetTestNode]])); + ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $targetTestNode]]); $hooksRun = 0; @@ -665,7 +662,7 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); $this->view->expects($this->never()) ->method('rename'); @@ -676,7 +673,7 @@ abstract class NodeTest extends \Test\TestCase { $this->root->expects($this->once()) ->method('get') ->with('/bar') - ->will($this->returnValue($parentNode)); + ->willReturn($parentNode); $node->move('/bar/asd'); } @@ -716,7 +713,7 @@ abstract class NodeTest extends \Test\TestCase { $this->root->expects($this->once()) ->method('get') ->with('/bar') - ->will($this->returnValue($parentNode)); + ->willReturn($parentNode); $node->move('/bar/asd'); } @@ -728,18 +725,18 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('rename') ->with('/bar/foo', '/bar/asd') - ->will($this->returnValue(false)); + ->willReturn(false); $this->view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar'); $this->root->expects($this->any()) ->method('get') - ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]])); + ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $node]]); $node->move('/bar/asd'); } @@ -751,18 +748,18 @@ abstract class NodeTest extends \Test\TestCase { $this->view->expects($this->any()) ->method('copy') ->with('/bar/foo', '/bar/asd') - ->will($this->returnValue(false)); + ->willReturn(false); $this->view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]))); + ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1])); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar'); $this->root->expects($this->any()) ->method('get') - ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]])); + ->willReturnMap([['/bar', $parentNode], ['/bar/asd', $node]]); $node->copy('/bar/asd'); } diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index 5067236ec58..6c006d1cf62 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -13,9 +13,7 @@ use OC\Files\FileInfo; use OC\Files\Mount\Manager; use OC\Files\Node\Folder; use OC\Files\View; -use OCP\IConfig; use OCP\ILogger; -use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -79,7 +77,7 @@ class RootTest extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue($this->getFileInfo(array('fileid' => 10, 'path' => 'bar/foo', 'name', 'mimetype' => 'text/plain')))); + ->willReturn($this->getFileInfo(['fileid' => 10, 'path' => 'bar/foo', 'name', 'mimetype' => 'text/plain'])); $root->mount($storage, ''); $node = $root->get('/bar/foo'); @@ -115,7 +113,7 @@ class RootTest extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(false)); + ->willReturn(false); $root->mount($storage, ''); $root->get('/bar/foo'); diff --git a/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php b/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php index aa3b2519ec1..1a3477090b9 100644 --- a/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php +++ b/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl> * @@ -21,7 +23,6 @@ namespace Test\Files\ObjectStore; - use OCP\Files\ObjectStore\IObjectStore; class FailDeleteObjectStore implements IObjectStore { diff --git a/tests/lib/Files/ObjectStore/FailWriteObjectStore.php b/tests/lib/Files/ObjectStore/FailWriteObjectStore.php index 4310d8ba27c..ad2350ea36b 100644 --- a/tests/lib/Files/ObjectStore/FailWriteObjectStore.php +++ b/tests/lib/Files/ObjectStore/FailWriteObjectStore.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> * diff --git a/tests/lib/Files/ObjectStore/LocalTest.php b/tests/lib/Files/ObjectStore/LocalTest.php index 99aa23e065d..ceb21428e4b 100644 --- a/tests/lib/Files/ObjectStore/LocalTest.php +++ b/tests/lib/Files/ObjectStore/LocalTest.php @@ -32,5 +32,4 @@ class LocalTest extends ObjectStoreTest { $storage = new Temporary(); return new StorageObjectStore($storage); } - } diff --git a/tests/lib/Files/ObjectStore/MapperTest.php b/tests/lib/Files/ObjectStore/MapperTest.php index eef308af088..307096d8dbc 100644 --- a/tests/lib/Files/ObjectStore/MapperTest.php +++ b/tests/lib/Files/ObjectStore/MapperTest.php @@ -21,12 +21,10 @@ namespace Test\Files\ObjectStore; - use OC\Files\ObjectStore\Mapper; use OCP\IUser; class MapperTest extends \Test\TestCase { - public function dataGetBucket() { return [ ['user', 64, '17'], diff --git a/tests/lib/Files/ObjectStore/NoopScannerTest.php b/tests/lib/Files/ObjectStore/NoopScannerTest.php index 8b879e8ab37..7142fb6daf9 100644 --- a/tests/lib/Files/ObjectStore/NoopScannerTest.php +++ b/tests/lib/Files/ObjectStore/NoopScannerTest.php @@ -22,11 +22,11 @@ class NoopScannerTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = new \OC\Files\Storage\Temporary(array()); + $this->storage = new \OC\Files\Storage\Temporary([]); $this->scanner = new \OC\Files\ObjectStore\NoopScanner($this->storage); } - function testFile() { + public function testFile() { $data = "dummy file data\n"; $this->storage->file_put_contents('foo.txt', $data); @@ -46,7 +46,7 @@ class NoopScannerTest extends \Test\TestCase { $this->storage->file_put_contents('folder/bar.txt', $textData); } - function testFolder() { + public function testFolder() { $this->fillTestFolders(); $this->assertEquals( @@ -56,7 +56,7 @@ class NoopScannerTest extends \Test\TestCase { ); } - function testBackgroundScan() { + public function testBackgroundScan() { $this->fillTestFolders(); $this->storage->mkdir('folder2'); $this->storage->file_put_contents('folder2/bar.txt', 'foobar'); diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php index 5e8faed3347..5872056e42d 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php @@ -1,4 +1,6 @@ -<?php declare(strict_types=1); +<?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl> * diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php index b8c7b15e039..fa8ec535061 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php @@ -20,7 +20,6 @@ namespace Test\Files\ObjectStore; -use OC\Files\ObjectStore\ObjectStoreStorage; use OC\Files\ObjectStore\StorageObjectStore; use OC\Files\Storage\Temporary; use OCP\Files\ObjectStore\IObjectStore; @@ -57,7 +56,6 @@ class ObjectStoreStorageTest extends Storage { } public function testStat() { - $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $ctimeStart = time(); $this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile)); diff --git a/tests/lib/Files/ObjectStore/ObjectStoreTest.php b/tests/lib/Files/ObjectStore/ObjectStoreTest.php index 1383c0149a2..9300a9bdef6 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreTest.php @@ -31,7 +31,7 @@ abstract class ObjectStoreTest extends TestCase { */ abstract protected function getInstance(); - private function stringToStream($data) { + protected function stringToStream($data) { $stream = fopen('php://temp', 'w+'); fwrite($stream, $data); rewind($stream); @@ -49,7 +49,6 @@ abstract class ObjectStoreTest extends TestCase { $instance->deleteObject('1'); $this->assertEquals('foobar', stream_get_contents($result)); - } public function testDelete() { diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php index 91b24d8b615..c1e7948e3c4 100644 --- a/tests/lib/Files/ObjectStore/S3Test.php +++ b/tests/lib/Files/ObjectStore/S3Test.php @@ -25,20 +25,20 @@ use Icewind\Streams\Wrapper; use OC\Files\ObjectStore\S3; class MultiPartUploadS3 extends S3 { - function writeObject($urn, $stream) { + public function writeObject($urn, $stream) { $this->getConnection()->upload($this->bucket, $urn, $stream, 'private', [ - 'mup_threshold' => 1 + 'mup_threshold' => 1, ]); } } class NonSeekableStream extends Wrapper { public static function wrap($source) { - $context = stream_context_create(array( - 'nonseek' => array( - 'source' => $source - ) - )); + $context = stream_context_create([ + 'nonseek' => [ + 'source' => $source, + ], + ]); return Wrapper::wrapSource($source, $context, 'nonseek', self::class); } @@ -83,4 +83,20 @@ class S3Test extends ObjectStoreTest { $this->assertEquals(file_get_contents(__FILE__), stream_get_contents($result)); } + + public function testSeek() { + $data = file_get_contents(__FILE__); + + $instance = $this->getInstance(); + $instance->writeObject('seek', $this->stringToStream($data)); + + $read = $instance->readObject('seek'); + $this->assertEquals(substr($data, 0, 100), fread($read, 100)); + + fseek($read, 10); + $this->assertEquals(substr($data, 10, 100), fread($read, 100)); + + fseek($read, 100, SEEK_CUR); + $this->assertEquals(substr($data, 210, 100), fread($read, 100)); + } } diff --git a/tests/lib/Files/SimpleFS/InMemoryFileTest.php b/tests/lib/Files/SimpleFS/InMemoryFileTest.php index 195a5d04a8f..0ba1a9ddc9f 100644 --- a/tests/lib/Files/SimpleFS/InMemoryFileTest.php +++ b/tests/lib/Files/SimpleFS/InMemoryFileTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** diff --git a/tests/lib/Files/SimpleFS/SimpleFileTest.php b/tests/lib/Files/SimpleFS/SimpleFileTest.php index 07a7e79c7a3..b9a47c4d6e2 100644 --- a/tests/lib/Files/SimpleFS/SimpleFileTest.php +++ b/tests/lib/Files/SimpleFS/SimpleFileTest.php @@ -27,9 +27,8 @@ use OC\Files\SimpleFS\SimpleFile; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\NotFoundException; -use OCP\Files\NotPermittedException; -class SimpleFileTest extends \Test\TestCase { +class SimpleFileTest extends \Test\TestCase { /** @var File|\PHPUnit_Framework_MockObject_MockObject */ private $file; diff --git a/tests/lib/Files/SimpleFS/SimpleFolderTest.php b/tests/lib/Files/SimpleFS/SimpleFolderTest.php index b902cac77cc..50714b8356e 100644 --- a/tests/lib/Files/SimpleFS/SimpleFolderTest.php +++ b/tests/lib/Files/SimpleFS/SimpleFolderTest.php @@ -25,10 +25,7 @@ namespace Test\File\SimpleFS; use OC\Files\SimpleFS\SimpleFolder; use OC\Files\Storage\Temporary; -use OC\Files\View; -use OCP\Files\File; use OCP\Files\Folder; -use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use Test\Traits\MountProviderTrait; @@ -112,5 +109,4 @@ class SimpleFolderTest extends \Test\TestCase { $this->assertInstanceOf(ISimpleFile::class, $result[0]); $this->assertInstanceOf(ISimpleFile::class, $result[1]); } - } diff --git a/tests/lib/Files/Storage/CopyDirectoryTest.php b/tests/lib/Files/Storage/CopyDirectoryTest.php index d56cc37124d..25bdb016ead 100644 --- a/tests/lib/Files/Storage/CopyDirectoryTest.php +++ b/tests/lib/Files/Storage/CopyDirectoryTest.php @@ -44,7 +44,6 @@ class CopyDirectoryStorage extends StorageNoRecursiveCopy { * @package Test\Files\Storage */ class CopyDirectoryTest extends Storage { - protected function setUp(): void { parent::setUp(); $this->instance = new CopyDirectoryStorage([]); diff --git a/tests/lib/Files/Storage/HomeStorageQuotaTest.php b/tests/lib/Files/Storage/HomeStorageQuotaTest.php index 68fa4bb0bbb..177fe1b4f6c 100644 --- a/tests/lib/Files/Storage/HomeStorageQuotaTest.php +++ b/tests/lib/Files/Storage/HomeStorageQuotaTest.php @@ -30,7 +30,7 @@ class HomeStorageQuotaTest extends \Test\TestCase { /** * Tests that the home storage is not wrapped when no quota exists. */ - function testHomeStorageWrapperWithoutQuota() { + public function testHomeStorageWrapperWithoutQuota() { $user1 = $this->getUniqueID(); \OC::$server->getUserManager()->createUser($user1, 'test'); \OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', 'none'); @@ -45,7 +45,9 @@ class HomeStorageQuotaTest extends \Test\TestCase { // clean up \OC_User::setUserId(''); $user = \OC::$server->getUserManager()->get($user1); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } \OC::$server->getConfig()->deleteAllUserValues($user1); \OC_Util::tearDownFS(); } @@ -53,7 +55,7 @@ class HomeStorageQuotaTest extends \Test\TestCase { /** * Tests that the home storage is not wrapped when no quota exists. */ - function testHomeStorageWrapperWithQuota() { + public function testHomeStorageWrapperWithQuota() { $user1 = $this->getUniqueID(); \OC::$server->getUserManager()->createUser($user1, 'test'); \OC::$server->getConfig()->setUserValue($user1, 'files', 'quota', '1024'); @@ -73,9 +75,10 @@ class HomeStorageQuotaTest extends \Test\TestCase { // clean up \OC_User::setUserId(''); $user = \OC::$server->getUserManager()->get($user1); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } \OC::$server->getConfig()->deleteAllUserValues($user1); \OC_Util::tearDownFS(); } - } diff --git a/tests/lib/Files/Storage/HomeTest.php b/tests/lib/Files/Storage/HomeTest.php index 6075e9af293..d5feb40840f 100644 --- a/tests/lib/Files/Storage/HomeTest.php +++ b/tests/lib/Files/Storage/HomeTest.php @@ -73,7 +73,7 @@ class HomeTest extends Storage { $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $this->userId = $this->getUniqueID('user_'); $this->user = new DummyUser($this->userId, $this->tmpDir); - $this->instance = new \OC\Files\Storage\Home(array('user' => $this->user)); + $this->instance = new \OC\Files\Storage\Home(['user' => $this->user]); } protected function tearDown(): void { diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php index 23738a25c2a..46784811248 100644 --- a/tests/lib/Files/Storage/LocalTest.php +++ b/tests/lib/Files/Storage/LocalTest.php @@ -39,7 +39,7 @@ class LocalTest extends Storage { parent::setUp(); $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); + $this->instance = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); } protected function tearDown(): void { diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php index a25a3f74f9e..ecc2bb50538 100644 --- a/tests/lib/Files/Storage/Storage.php +++ b/tests/lib/Files/Storage/Storage.php @@ -80,13 +80,28 @@ abstract class Storage extends \Test\TestCase { $this->assertTrue($this->instance->isUpdatable('/' . $directory)); $dh = $this->instance->opendir('/'); - $content = array(); + $content = []; while ($file = readdir($dh)) { if ($file != '.' and $file != '..') { $content[] = $file; } } - $this->assertEquals(array($directory), $content); + $this->assertEquals([$directory], $content); + + $content = iterator_to_array($this->instance->getDirectoryContent('/')); + + $this->assertCount(1, $content); + $dirEntry = $content[0]; + unset($dirEntry['scan_permissions']); + unset($dirEntry['etag']); + $this->assertEquals([ + 'name' => $directory, + 'mimetype' => $this->instance->getMimeType($directory), + 'mtime' => $this->instance->filemtime($directory), + 'size' => -1, + 'storage_mtime' => $this->instance->filemtime($directory), + 'permissions' => $this->instance->getPermissions($directory), + ], $dirEntry); $this->assertFalse($this->instance->mkdir('/' . $directory)); //can't create existing folders $this->assertTrue($this->instance->rmdir('/' . $directory)); @@ -97,13 +112,13 @@ abstract class Storage extends \Test\TestCase { $this->assertFalse($this->instance->rmdir('/' . $directory)); //can't remove non existing folders $dh = $this->instance->opendir('/'); - $content = array(); + $content = []; while ($file = readdir($dh)) { if ($file != '.' and $file != '..') { $content[] = $file; } } - $this->assertEquals(array(), $content); + $this->assertEquals([], $content); } public function fileNameProvider() { @@ -128,14 +143,14 @@ abstract class Storage extends \Test\TestCase { ]; } - function loremFileProvider() { + public function loremFileProvider() { $root = \OC::$SERVERROOT . '/tests/data/'; - return array( + return [ // small file - array($root . 'lorem.txt'), + [$root . 'lorem.txt'], // bigger file (> 8 KB which is the standard PHP block size) - array($root . 'lorem-big.txt') - ); + [$root . 'lorem-big.txt'] + ]; } /** @@ -413,11 +428,11 @@ abstract class Storage extends \Test\TestCase { } public function hashProvider() { - return array( - array('Foobar', 'md5'), - array('Foobar', 'sha1'), - array('Foobar', 'sha256'), - ); + return [ + ['Foobar', 'md5'], + ['Foobar', 'sha1'], + ['Foobar', 'sha256'], + ]; } /** @@ -438,14 +453,14 @@ abstract class Storage extends \Test\TestCase { $this->assertEquals('data', $this->instance->file_get_contents('#foo/test.txt')); $dh = $this->instance->opendir('#foo'); - $content = array(); + $content = []; while ($file = readdir($dh)) { if ($file != '.' and $file != '..') { $content[] = $file; } } - $this->assertEquals(array('test.txt'), $content); + $this->assertEquals(['test.txt'], $content); } public function testCopyOverWriteFile() { diff --git a/tests/lib/Files/Storage/Wrapper/EncodingTest.php b/tests/lib/Files/Storage/Wrapper/EncodingTest.php index 9060ca2dac3..498d9f78248 100644 --- a/tests/lib/Files/Storage/Wrapper/EncodingTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncodingTest.php @@ -9,9 +9,8 @@ namespace Test\Files\Storage\Wrapper; class EncodingTest extends \Test\Files\Storage\Storage { - - const NFD_NAME = 'ümlaut'; - const NFC_NAME = 'ümlaut'; + public const NFD_NAME = 'ümlaut'; + public const NFC_NAME = 'ümlaut'; /** * @var \OC\Files\Storage\Temporary diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index a9d678e76e9..73de60e3652 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -110,7 +110,6 @@ class EncryptionTest extends Storage { private $dummySize = -1; protected function setUp(): void { - parent::setUp(); $mockModule = $this->buildMockModule(); @@ -148,7 +147,7 @@ class EncryptionTest extends Storage { $this->logger = $this->createMock(Log::class); - $this->sourceStorage = new Temporary(array()); + $this->sourceStorage = new Temporary([]); $this->keyStore = $this->getMockBuilder('\OC\Encryption\Keys\Storage') ->disableOriginalConstructor()->getMock(); @@ -174,7 +173,9 @@ class EncryptionTest extends Storage { ->disableOriginalConstructor()->getMock(); $this->cache->expects($this->any()) ->method('get') - ->willReturnCallback(function($path) {return ['encrypted' => false, 'path' => $path];}); + ->willReturnCallback(function ($path) { + return ['encrypted' => false, 'path' => $path]; + }); $this->mountManager = $this->createMock(\OC\Files\Mount\Manager::class); $this->mountManager->method('findByStorageId') @@ -244,7 +245,6 @@ class EncryptionTest extends Storage { * @param array $expected */ public function testGetMetaData($path, $metaData, $encrypted, $unencryptedSizeSet, $storedUnencryptedSize, $expected) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -253,7 +253,7 @@ class EncryptionTest extends Storage { $cache->expects($this->any()) ->method('get') ->willReturnCallback( - function($path) use ($encrypted) { + function ($path) use ($encrypted) { return ['encrypted' => $encrypted, 'path' => $path, 'size' => 0, 'fileid' => 1]; } ); @@ -273,7 +273,7 @@ class EncryptionTest extends Storage { ->setMethods(['getCache', 'verifyUnencryptedSize']) ->getMock(); - if($unencryptedSizeSet) { + if ($unencryptedSizeSet) { $this->invokePrivate($this->instance, 'unencryptedSize', [[$path => $storedUnencryptedSize]]); } @@ -298,10 +298,10 @@ class EncryptionTest extends Storage { } $result = $this->instance->getMetaData($path); - if(isset($expected['encrypted'])) { + if (isset($expected['encrypted'])) { $this->assertSame($expected['encrypted'], (bool)$result['encrypted']); - if(isset($expected['encryptedVersion'])) { + if (isset($expected['encryptedVersion'])) { $this->assertSame($expected['encryptedVersion'], $result['encryptedVersion']); } } @@ -352,7 +352,6 @@ class EncryptionTest extends Storage { $this->assertSame(42, $this->instance->filesize('/test.txt') ); - } /** @@ -387,7 +386,7 @@ class EncryptionTest extends Storage { $this->instance->expects($this->any())->method('fixUnencryptedSize') ->with('/test.txt', $encryptedSize, $unencryptedSize) ->willReturnCallback( - function() use ($failure, $expected) { + function () use ($failure, $expected) { if ($failure) { throw new \Exception(); } else { @@ -458,13 +457,13 @@ class EncryptionTest extends Storage { * @return array */ public function dataTestCopyAndRename() { - return array( - array('source', 'target', true, false, false), - array('source', 'target', true, true, false), - array('source', '/subFolder/target', true, false, false), - array('source', '/subFolder/target', true, true, true), - array('source', '/subFolder/target', false, true, false), - ); + return [ + ['source', 'target', true, false, false], + ['source', 'target', true, true, false], + ['source', '/subFolder/target', true, false, false], + ['source', '/subFolder/target', true, true, true], + ['source', '/subFolder/target', false, true, false], + ]; } public function testIsLocal() { @@ -512,16 +511,16 @@ class EncryptionTest extends Storage { } public function dataTestRmdir() { - return array( - array('/file.txt', true, true, true), - array('/file.txt', false, true, true), - array('/file.txt', true, false, true), - array('/file.txt', false, false, true), - array('/file.txt', true, true, false), - array('/file.txt', false, true, false), - array('/file.txt', true, false, false), - array('/file.txt', false, false, false), - ); + return [ + ['/file.txt', true, true, true], + ['/file.txt', false, true, true], + ['/file.txt', true, false, true], + ['/file.txt', false, false, true], + ['/file.txt', true, true, false], + ['/file.txt', false, true, false], + ['/file.txt', true, false, false], + ['/file.txt', false, false, false], + ]; } /** @@ -547,10 +546,10 @@ class EncryptionTest extends Storage { } public function dataTestCopyKeys() { - return array( - array(true, false), - array(false, true), - ); + return [ + [true, false], + [false, true], + ]; } /** @@ -561,7 +560,6 @@ class EncryptionTest extends Storage { * @param string $strippedPath */ public function testGetHeader($path, $strippedPathExists, $strippedPath) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -613,13 +611,13 @@ class EncryptionTest extends Storage { } public function dataTestGetHeader() { - return array( - array('/foo/bar.txt', false, '/foo/bar.txt'), - array('/foo/bar.txt.part', false, '/foo/bar.txt'), - array('/foo/bar.txt.ocTransferId7437493.part', false, '/foo/bar.txt'), - array('/foo/bar.txt.part', true, '/foo/bar.txt'), - array('/foo/bar.txt.ocTransferId7437493.part', true, '/foo/bar.txt'), - ); + return [ + ['/foo/bar.txt', false, '/foo/bar.txt'], + ['/foo/bar.txt.part', false, '/foo/bar.txt'], + ['/foo/bar.txt.ocTransferId7437493.part', false, '/foo/bar.txt'], + ['/foo/bar.txt.part', true, '/foo/bar.txt'], + ['/foo/bar.txt.ocTransferId7437493.part', true, '/foo/bar.txt'], + ]; } /** @@ -629,7 +627,6 @@ class EncryptionTest extends Storage { * @dataProvider dataTestGetHeaderAddLegacyModule */ public function testGetHeaderAddLegacyModule($header, $isEncrypted, $exists, $expected) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); @@ -645,7 +642,9 @@ class EncryptionTest extends Storage { ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('get') - ->willReturnCallback(function($path) use ($isEncrypted) {return ['encrypted' => $isEncrypted, 'path' => $path];}); + ->willReturnCallback(function ($path) use ($isEncrypted) { + return ['encrypted' => $isEncrypted, 'path' => $path]; + }); $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') ->setConstructorArgs( @@ -737,7 +736,7 @@ class EncryptionTest extends Storage { $storage2->expects($this->any()) ->method('fopen') - ->willReturnCallback(function($path, $mode) { + ->willReturnCallback(function ($path, $mode) { $temp = \OC::$server->getTempManager(); return fopen($temp->getTemporaryFile(), $mode); }); @@ -786,13 +785,13 @@ class EncryptionTest extends Storage { $storage2->expects($this->any()) ->method('fopen') - ->willReturnCallback(function($path, $mode) { + ->willReturnCallback(function ($path, $mode) { $temp = \OC::$server->getTempManager(); return fopen($temp->getTemporaryFile(), $mode); }); $storage2->method('getId') ->willReturn('stroage2'); - if($expectedEncrypted) { + if ($expectedEncrypted) { $cache = $this->createMock(ICache::class); $cache->expects($this->once()) ->method('get') @@ -816,7 +815,7 @@ class EncryptionTest extends Storage { $expectedCachePut = [ 'encrypted' => $expectedEncrypted, ]; - if($expectedEncrypted === true) { + if ($expectedEncrypted === true) { $expectedCachePut['encryptedVersion'] = 1; } @@ -839,8 +838,7 @@ class EncryptionTest extends Storage { * @param bool $copyResult * @param bool $encrypted */ - public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) { - + public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) { $sourceStorage = $this->createMock(\OC\Files\Storage\Storage::class); $targetStorage = $this->createMock(\OC\Files\Storage\Storage::class); @@ -1005,7 +1003,7 @@ class EncryptionTest extends Storage { ->method('getEncryptionModule') ->with($fullPath) ->willReturnCallback( - function() use ($encryptionModule) { + function () use ($encryptionModule) { if ($encryptionModule === false) { throw new ModuleDoesNotExistsException(); } @@ -1043,5 +1041,4 @@ class EncryptionTest extends Storage { [true, null, false, true], ]; } - } diff --git a/tests/lib/Files/Storage/Wrapper/JailTest.php b/tests/lib/Files/Storage/Wrapper/JailTest.php index cb7003cb7ea..6c8905af765 100644 --- a/tests/lib/Files/Storage/Wrapper/JailTest.php +++ b/tests/lib/Files/Storage/Wrapper/JailTest.php @@ -17,24 +17,24 @@ class JailTest extends \Test\Files\Storage\Storage { protected function setUp(): void { parent::setUp(); - $this->sourceStorage = new \OC\Files\Storage\Temporary(array()); + $this->sourceStorage = new \OC\Files\Storage\Temporary([]); $this->sourceStorage->mkdir('foo'); - $this->instance = new \OC\Files\Storage\Wrapper\Jail(array( + $this->instance = new \OC\Files\Storage\Wrapper\Jail([ 'storage' => $this->sourceStorage, 'root' => 'foo' - )); + ]); } protected function tearDown(): void { // test that nothing outside our jail is touched - $contents = array(); + $contents = []; $dh = $this->sourceStorage->opendir(''); while ($file = readdir($dh)) { if (!\OC\Files\Filesystem::isIgnoredDir($file)) { $contents[] = $file; } } - $this->assertEquals(array('foo'), $contents); + $this->assertEquals(['foo'], $contents); $this->sourceStorage->cleanUp(); parent::tearDown(); } diff --git a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php index bfdd3d3ddbb..1e69ee7165e 100644 --- a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php +++ b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php @@ -24,7 +24,7 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage { protected function setUp(): void { parent::setUp(); - $this->sourceStorage = new \OC\Files\Storage\Temporary(array()); + $this->sourceStorage = new \OC\Files\Storage\Temporary([]); $this->instance = $this->getMaskedStorage(Constants::PERMISSION_ALL); } @@ -34,10 +34,10 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage { } protected function getMaskedStorage($mask) { - return new \OC\Files\Storage\Wrapper\PermissionsMask(array( + return new \OC\Files\Storage\Wrapper\PermissionsMask([ 'storage' => $this->sourceStorage, 'mask' => $mask - )); + ]); } public function testMkdirNoCreate() { @@ -129,10 +129,10 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage { public function testScanNewFilesNested() { $storage = $this->getMaskedStorage(Constants::PERMISSION_READ + Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE); - $nestedStorage = new \OC\Files\Storage\Wrapper\PermissionsMask(array( + $nestedStorage = new \OC\Files\Storage\Wrapper\PermissionsMask([ 'storage' => $storage, 'mask' => Constants::PERMISSION_READ + Constants::PERMISSION_CREATE - )); + ]); $wrappedStorage = new Wrapper(['storage' => $nestedStorage]); $wrappedStorage->file_put_contents('foo', 'bar'); $wrappedStorage->getScanner()->scan(''); diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php index 0061ca3910e..65cfe30eb1c 100644 --- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php +++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php @@ -31,8 +31,8 @@ class QuotaTest extends \Test\Files\Storage\Storage { parent::setUp(); $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); - $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); - $this->instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 10000000)); + $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); + $this->instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 10000000]); } protected function tearDown(): void { @@ -44,10 +44,10 @@ class QuotaTest extends \Test\Files\Storage\Storage { * @param integer $limit */ protected function getLimitedStorage($limit) { - $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); + $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); $storage->mkdir('files'); $storage->getScanner()->scan(''); - return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $limit)); + return new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => $limit]); } public function testFilePutContentsNotEnoughSpace() { @@ -70,7 +70,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { public function testFreeSpaceWithUsedSpace() { $instance = $this->getLimitedStorage(9); $instance->getCache()->put( - '', array('size' => 3) + '', ['size' => 3] ); $this->assertEquals(6, $instance->free_space('')); } @@ -82,12 +82,12 @@ class QuotaTest extends \Test\Files\Storage\Storage { ->getMock(); $storage->expects($this->any()) ->method('free_space') - ->will($this->returnValue(-2)); + ->willReturn(-2); $storage->getScanner()->scan(''); - $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 9)); + $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 9]); $instance->getCache()->put( - '', array('size' => 3) + '', ['size' => 3] ); $this->assertEquals(6, $instance->free_space('')); } @@ -95,7 +95,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { public function testFreeSpaceWithUsedSpaceAndEncryption() { $instance = $this->getLimitedStorage(9); $instance->getCache()->put( - '', array('size' => 7) + '', ['size' => 7] ); $this->assertEquals(2, $instance->free_space('')); } @@ -138,9 +138,9 @@ class QuotaTest extends \Test\Files\Storage\Storage { ->getMock(); $failStorage->expects($this->any()) ->method('fopen') - ->will($this->returnValue(false)); + ->willReturn(false); - $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $failStorage, 'quota' => 1000)); + $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $failStorage, 'quota' => 1000]); $this->assertFalse($instance->fopen('failedfopen', 'r')); } @@ -189,16 +189,16 @@ class QuotaTest extends \Test\Files\Storage\Storage { $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')->disableOriginalConstructor()->getMock(); $storage->expects($this->once()) ->method('getCache') - ->will($this->returnValue($cache)); + ->willReturn($cache); $storage->expects($this->once()) ->method('free_space') - ->will($this->returnValue(2048)); + ->willReturn(2048); $cache->expects($this->once()) ->method('get') ->with('files') - ->will($this->returnValue(new CacheEntry(['size' => 50]))); + ->willReturn(new CacheEntry(['size' => 50])); - $instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 1024, 'root' => 'files')); + $instance = new \OC\Files\Storage\Wrapper\Quota(['storage' => $storage, 'quota' => 1024, 'root' => 'files']); $this->assertEquals(1024 - 50, $instance->free_space('')); } diff --git a/tests/lib/Files/Storage/Wrapper/WrapperTest.php b/tests/lib/Files/Storage/Wrapper/WrapperTest.php index 2477b361bc1..b9bb54e09b2 100644 --- a/tests/lib/Files/Storage/Wrapper/WrapperTest.php +++ b/tests/lib/Files/Storage/Wrapper/WrapperTest.php @@ -18,8 +18,8 @@ class WrapperTest extends \Test\Files\Storage\Storage { parent::setUp(); $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); - $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); - $this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage)); + $storage = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir]); + $this->instance = new \OC\Files\Storage\Wrapper\Wrapper(['storage' => $storage]); } protected function tearDown(): void { diff --git a/tests/lib/Files/Stream/DummyEncryptionWrapper.php b/tests/lib/Files/Stream/DummyEncryptionWrapper.php index 599abf894ef..e66fae3d15d 100644 --- a/tests/lib/Files/Stream/DummyEncryptionWrapper.php +++ b/tests/lib/Files/Stream/DummyEncryptionWrapper.php @@ -32,5 +32,4 @@ class DummyEncryptionWrapper extends \OC\Files\Stream\Encryption { protected function parentStreamSeek($position) { return false; } - } diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index fd5e8c6ca9d..bedce1b6f6d 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -59,7 +59,7 @@ class EncryptionTest extends \Test\TestCase { 'fileid' => 5, 'encryptedVersion' => 2, ]); - $cache->expects($this->any())->method('get')->willReturn($entry ); + $cache->expects($this->any())->method('get')->willReturn($entry); $cache->expects($this->any())->method('update')->with(5, ['encrypted' => 3, 'encryptedVersion' => 3]); @@ -99,10 +99,10 @@ class EncryptionTest extends \Test\TestCase { $fileMock->expects($this->never())->method('getAccessList'); } else { $fileMock->expects($this->once())->method('getAccessList') - ->will($this->returnCallback(function ($sharePath) use ($expectedSharePath) { + ->willReturnCallback(function ($sharePath) use ($expectedSharePath) { $this->assertSame($expectedSharePath, $sharePath); - return array(); - })); + return []; + }); } $utilMock = $this->getMockBuilder('\OC\Encryption\Util') ->disableOriginalConstructor()->getMock(); @@ -138,7 +138,7 @@ class EncryptionTest extends \Test\TestCase { $fullPathP->setAccessible(false); $header = $stream->getProperty('header'); $header->setAccessible(true); - $header->setValue($streamWrapper, array()); + $header->setValue($streamWrapper, []); $header->setAccessible(false); $this->invokePrivate($streamWrapper, 'signed', [true]); @@ -205,9 +205,9 @@ class EncryptionTest extends \Test\TestCase { $fileName = tempnam("/tmp", "FOO"); $stream = $this->getStream($fileName, 'w+', 0); $this->assertEquals(6, fwrite($stream, 'foobar')); - $this->assertEquals(TRUE, rewind($stream)); + $this->assertEquals(true, rewind($stream)); $this->assertEquals('foobar', fread($stream, 100)); - $this->assertEquals(TRUE, rewind($stream)); + $this->assertEquals(true, rewind($stream)); $this->assertEquals(3, fwrite($stream, 'bar')); fclose($stream); @@ -216,7 +216,7 @@ class EncryptionTest extends \Test\TestCase { fclose($stream); unlink($fileName); -} + } public function testSeek() { $fileName = tempnam("/tmp", "FOO"); @@ -240,7 +240,7 @@ class EncryptionTest extends \Test\TestCase { unlink($fileName); } - function dataFilesProvider() { + public function dataFilesProvider() { return [ ['lorem-big.txt'], ['block-aligned.txt'], @@ -252,7 +252,6 @@ class EncryptionTest extends \Test\TestCase { * @dataProvider dataFilesProvider */ public function testWriteReadBigFile($testFile) { - $expectedData = file_get_contents(\OC::$SERVERROOT . '/tests/data/' . $testFile); // write it $fileName = tempnam("/tmp", "FOO"); @@ -290,7 +289,6 @@ class EncryptionTest extends \Test\TestCase { * @dataProvider dataFilesProvider */ public function testWriteToNonSeekableStorage($testFile) { - $wrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption') ->setMethods(['parentSeekStream'])->getMock(); $wrapper->expects($this->any())->method('parentSeekStream')->willReturn(false); @@ -324,7 +322,6 @@ class EncryptionTest extends \Test\TestCase { $this->assertEquals($expectedData, $data); unlink($fileName); - } /** @@ -342,7 +339,7 @@ class EncryptionTest extends \Test\TestCase { $encryptionModule->expects($this->any())->method('end')->willReturn(''); $encryptionModule->expects($this->any())->method('isReadable')->willReturn(true); $encryptionModule->expects($this->any())->method('needDetailedAccessList')->willReturn(false); - $encryptionModule->expects($this->any())->method('encrypt')->willReturnCallback(function($data) { + $encryptionModule->expects($this->any())->method('encrypt')->willReturnCallback(function ($data) { // simulate different block size by adding some padding to the data if (isset($data[6125])) { return str_pad($data, 8192, 'X'); @@ -350,7 +347,7 @@ class EncryptionTest extends \Test\TestCase { // last block return $data; }); - $encryptionModule->expects($this->any())->method('decrypt')->willReturnCallback(function($data) { + $encryptionModule->expects($this->any())->method('decrypt')->willReturnCallback(function ($data) { if (isset($data[8191])) { return substr($data, 0, 6126); } diff --git a/tests/lib/Files/Stream/HashWrapperTest.php b/tests/lib/Files/Stream/HashWrapperTest.php new file mode 100644 index 00000000000..e4bee18070d --- /dev/null +++ b/tests/lib/Files/Stream/HashWrapperTest.php @@ -0,0 +1,57 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace Test\Files\Stream; + +use OC\Files\Stream\HashWrapper; +use Test\TestCase; + +class HashWrapperTest extends TestCase { + /** + * @dataProvider hashProvider + */ + public function testHashStream($data, string $algo, string $hash) { + if (!is_resource($data)) { + $tmpData = fopen('php://temp', 'r+'); + if ($data !== null) { + fwrite($tmpData, $data); + rewind($tmpData); + } + $data = $tmpData; + } + + $wrapper = HashWrapper::wrap($data, $algo, function ($result) use ($hash) { + $this->assertEquals($hash, $result); + }); + stream_get_contents($wrapper); + } + + public function hashProvider() { + return [ + ['foo', 'md5', 'acbd18db4cc2f85cedef654fccc4a4d8'], + ['foo', 'sha1', '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'], + ['foo', 'sha256', '2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae'], + [str_repeat('foo', 8192), 'md5', '96684d2b796a2c54a026b5d60f9de819'], + ]; + } +} diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php index 01f11bf39c8..a7ac6c8057d 100644 --- a/tests/lib/Files/Type/DetectionTest.php +++ b/tests/lib/Files/Type/DetectionTest.php @@ -71,7 +71,7 @@ class DetectionTest extends \Test\TestCase { public function dataDetectContent(): array { return [ ['/', 'httpd/unix-directory'], -// ['/data.tar.gz', 'application/x-gzip'], TODO: fix as it fails hard on php7.4 now + // ['/data.tar.gz', 'application/x-gzip'], TODO: fix as it fails hard on php7.4 now ['/data.zip', 'application/zip'], ['/testimage.mp3', 'audio/mpeg'], ['/testimage.png', 'image/png'], @@ -240,14 +240,14 @@ class DetectionTest extends \Test\TestCase { [$this->equalTo('core'), $this->equalTo('filetypes/my-type.png')], [$this->equalTo('core'), $this->equalTo('filetypes/my.png')] ) - ->will($this->returnCallback( - function($appName, $file) { + ->willReturnCallback( + function ($appName, $file) { if ($file === 'filetypes/my.png') { return 'my.svg'; } throw new \RuntimeException(); } - )); + ); $detection = new Detection($urlGenerator, $logger, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('my-type'); @@ -271,14 +271,14 @@ class DetectionTest extends \Test\TestCase { [$this->equalTo('core'), $this->equalTo('filetypes/foo.png')], [$this->equalTo('core'), $this->equalTo('filetypes/file.png')] ) - ->will($this->returnCallback( - function($appName, $file) { + ->willReturnCallback( + function ($appName, $file) { if ($file === 'filetypes/file.png') { return 'file.svg'; } throw new \RuntimeException(); } - )); + ); $detection = new Detection($urlGenerator, $logger, $confDir->url(), $confDir->url()); $mimeType = $detection->mimeTypeIcon('foo-bar'); diff --git a/tests/lib/Files/Type/LoaderTest.php b/tests/lib/Files/Type/LoaderTest.php index a99c80dac47..ccd37cbb655 100644 --- a/tests/lib/Files/Type/LoaderTest.php +++ b/tests/lib/Files/Type/LoaderTest.php @@ -89,5 +89,4 @@ class LoaderTest extends \Test\TestCase { $this->assertEquals($mimetypeId, $mimetypeId2); } - } diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php index 44422cd97d1..376e72e6811 100644 --- a/tests/lib/Files/Utils/ScannerTest.php +++ b/tests/lib/Files/Utils/ScannerTest.php @@ -21,7 +21,7 @@ class TestScanner extends \OC\Files\Utils\Scanner { /** * @var \OC\Files\Mount\MountPoint[] $mounts */ - private $mounts = array(); + private $mounts = []; /** * @param \OC\Files\Mount\MountPoint $mount @@ -63,7 +63,7 @@ class ScannerTest extends \Test\TestCase { } public function testReuseExistingRoot() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); @@ -85,7 +85,7 @@ class ScannerTest extends \Test\TestCase { } public function testReuseExistingFile() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); @@ -112,18 +112,18 @@ class ScannerTest extends \Test\TestCase { $mountProvider = $this->createMock(IMountProvider::class); - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, '/' . $uid . '/files/foo'); $mountProvider->expects($this->any()) ->method('getMountsForUser') - ->will($this->returnCallback(function (IUser $user, IStorageFactory $storageFactory) use ($mount, $uid) { + ->willReturnCallback(function (IUser $user, IStorageFactory $storageFactory) use ($mount, $uid) { if ($user->getUID() === $uid) { return [$mount]; } else { return []; } - })); + }); \OC::$server->getMountProviderCollection()->registerProvider($mountProvider); $cache = $storage->getCache(); @@ -169,7 +169,7 @@ class ScannerTest extends \Test\TestCase { } public function testPropagateEtag() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); @@ -199,9 +199,9 @@ class ScannerTest extends \Test\TestCase { $sharedStorage->expects($this->any()) ->method('instanceOfStorage') - ->will($this->returnValueMap([ + ->willReturnMap([ [SharedStorage::class, true], - ])); + ]); $sharedStorage->expects($this->never()) ->method('getScanner'); @@ -213,7 +213,7 @@ class ScannerTest extends \Test\TestCase { } public function testShallow() { - $storage = new Temporary(array()); + $storage = new Temporary([]); $mount = new MountPoint($storage, ''); Filesystem::getMountManager()->addMount($mount); $cache = $storage->getCache(); @@ -241,5 +241,4 @@ class ScannerTest extends \Test\TestCase { $this->assertTrue($cache->inCache('folder/bar.txt')); $this->assertFalse($cache->inCache('folder/subfolder/foobar.txt')); } - } diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 57050059375..9dbe2a4e10e 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -15,6 +15,7 @@ use OC\Files\Storage\Common; use OC\Files\Storage\Temporary; use OC\Files\Stream\Quota; use OC\Files\View; +use OCP\Constants; use OCP\Files\Config\IMountProvider; use OCP\Files\FileInfo; use OCP\Files\Storage\IStorage; @@ -803,7 +804,6 @@ class ViewTest extends \Test\TestCase { } public function xtestLongPath() { - $storage = new Temporary([]); Filesystem::mount($storage, [], '/'); @@ -1169,11 +1169,11 @@ class ViewTest extends \Test\TestCase { $storage2->expects($this->any()) ->method('fopen') - ->will($this->returnCallback(function ($path, $mode) use ($storage2) { + ->willReturnCallback(function ($path, $mode) use ($storage2) { /** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Files\Storage\Temporary $storage2 */ $source = fopen($storage2->getSourcePath($path), $mode); return Quota::wrap($source, 9); - })); + }); $storage1->mkdir('sub'); $storage1->file_put_contents('foo.txt', '0123456789ABCDEFGH'); @@ -1209,7 +1209,6 @@ class ViewTest extends \Test\TestCase { // second file not moved/copied $this->assertFalse($storage2->file_exists('dirtomove/indir2.txt')); $this->assertFalse($storage2->getCache()->get('dirtomove/indir2.txt')); - } public function testDeleteFailKeepCache() { @@ -1220,7 +1219,7 @@ class ViewTest extends \Test\TestCase { ->getMock(); $storage->expects($this->once()) ->method('unlink') - ->will($this->returnValue(false)); + ->willReturn(false); $scanner = $storage->getScanner(); $cache = $storage->getCache(); $storage->file_put_contents('foo.txt', 'asd'); @@ -1540,7 +1539,6 @@ class ViewTest extends \Test\TestCase { $this->assertFalse($this->isFileLocked($view, '/test//sub', ILockingProvider::LOCK_SHARED)); $this->assertFalse($this->isFileLocked($view, '/test//sub', ILockingProvider::LOCK_EXCLUSIVE)); - } public function hookPathProvider() { @@ -1597,7 +1595,7 @@ class ViewTest extends \Test\TestCase { $mountProvider = $this->createMock(IMountProvider::class); $mountProvider->expects($this->any()) ->method('getMountsForUser') - ->will($this->returnValue($mounts)); + ->willReturn($mounts); $mountProviderCollection = \OC::$server->getMountProviderCollection(); $mountProviderCollection->registerProvider($mountProvider); @@ -1611,17 +1609,17 @@ class ViewTest extends \Test\TestCase { public function testMountPointMove() { self::loginAsUser($this->user); - list($mount1, $mount2) = $this->createTestMovableMountPoints([ + [$mount1, $mount2] = $this->createTestMovableMountPoints([ $this->user . '/files/mount1', $this->user . '/files/mount2', ]); $mount1->expects($this->once()) ->method('moveMount') - ->will($this->returnValue(true)); + ->willReturn(true); $mount2->expects($this->once()) ->method('moveMount') - ->will($this->returnValue(true)); + ->willReturn(true); $view = new View('/' . $this->user . '/files/'); $view->mkdir('sub'); @@ -1636,7 +1634,7 @@ class ViewTest extends \Test\TestCase { public function testMoveMountPointIntoAnother() { self::loginAsUser($this->user); - list($mount1, $mount2) = $this->createTestMovableMountPoints([ + [$mount1, $mount2] = $this->createTestMovableMountPoints([ $this->user . '/files/mount1', $this->user . '/files/mount2', ]); @@ -1659,7 +1657,7 @@ class ViewTest extends \Test\TestCase { public function testMoveMountPointIntoSharedFolder() { self::loginAsUser($this->user); - list($mount1) = $this->createTestMovableMountPoints([ + [$mount1] = $this->createTestMovableMountPoints([ $this->user . '/files/mount1', ]); @@ -1846,13 +1844,13 @@ class ViewTest extends \Test\TestCase { $storage->expects($this->once()) ->method($operation) - ->will($this->returnCallback( + ->willReturnCallback( function () use ($view, $lockedPath, &$lockTypeDuring) { $lockTypeDuring = $this->getFileLockType($view, $lockedPath); return true; } - )); + ); $this->assertNull($this->getFileLockType($view, $lockedPath), 'File not locked before operation'); @@ -1890,13 +1888,13 @@ class ViewTest extends \Test\TestCase { $storage->expects($this->once()) ->method('fopen') - ->will($this->returnCallback( + ->willReturnCallback( function () use ($view, $path, &$lockTypeDuring) { $lockTypeDuring = $this->getFileLockType($view, $path); return fopen('php://temp', 'r+'); } - )); + ); $this->connectMockHooks('write', $view, $path, $lockTypePre, $lockTypePost); @@ -1929,13 +1927,13 @@ class ViewTest extends \Test\TestCase { $storage->expects($this->once()) ->method('fopen') - ->will($this->returnCallback( + ->willReturnCallback( function () use ($view, $path, &$lockTypeDuring) { $lockTypeDuring = $this->getFileLockType($view, $path); return fopen('php://temp', 'r+'); } - )); + ); $this->connectMockHooks('write', $view, $path, $lockTypePre, $lockTypePost); @@ -1990,11 +1988,11 @@ class ViewTest extends \Test\TestCase { $storage->expects($this->once()) ->method($operation) - ->will($this->returnCallback( + ->willReturnCallback( function () { throw new \Exception('Simulated exception'); } - )); + ); $thrown = false; try { @@ -2097,12 +2095,21 @@ class ViewTest extends \Test\TestCase { /** @var Temporary|\PHPUnit_Framework_MockObject_MockObject $storage */ $storage = $this->getMockBuilder(Temporary::class) - ->setMethods([$operation, 'filemtime']) + ->setMethods([$operation, 'getMetaData', 'filemtime']) ->getMock(); $storage->expects($this->any()) + ->method('getMetaData') + ->will($this->returnValue([ + 'mtime' => 1885434487, + 'etag' => '', + 'mimetype' => 'text/plain', + 'permissions' => Constants::PERMISSION_ALL, + 'size' => 3 + ])); + $storage->expects($this->any()) ->method('filemtime') - ->will($this->returnValue(123456789)); + ->willReturn(123456789); $sourcePath = 'original.txt'; $targetPath = 'target.txt'; @@ -2113,14 +2120,14 @@ class ViewTest extends \Test\TestCase { $storage->expects($this->once()) ->method($operation) - ->will($this->returnCallback( + ->willReturnCallback( function () use ($view, $sourcePath, $targetPath, &$lockTypeSourceDuring, &$lockTypeTargetDuring) { $lockTypeSourceDuring = $this->getFileLockType($view, $sourcePath); $lockTypeTargetDuring = $this->getFileLockType($view, $targetPath); return true; } - )); + ); $this->connectMockHooks($operation, $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost); $this->connectMockHooks($operation, $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost); @@ -2166,11 +2173,11 @@ class ViewTest extends \Test\TestCase { $storage->expects($this->once()) ->method('copy') - ->will($this->returnCallback( + ->willReturnCallback( function () { throw new \Exception(); } - )); + ); $this->connectMockHooks('copy', $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost); $this->connectMockHooks('copy', $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost); @@ -2277,12 +2284,21 @@ class ViewTest extends \Test\TestCase { ->getMock(); /** @var Temporary|\PHPUnit_Framework_MockObject_MockObject $storage2 */ $storage2 = $this->getMockBuilder(Temporary::class) - ->setMethods([$storageOperation, 'filemtime']) + ->setMethods([$storageOperation, 'getMetaData', 'filemtime']) ->getMock(); $storage2->expects($this->any()) + ->method('getMetaData') + ->will($this->returnValue([ + 'mtime' => 1885434487, + 'etag' => '', + 'mimetype' => 'text/plain', + 'permissions' => Constants::PERMISSION_ALL, + 'size' => 3 + ])); + $storage2->expects($this->any()) ->method('filemtime') - ->will($this->returnValue(123456789)); + ->willReturn(123456789); $sourcePath = 'original.txt'; $targetPath = 'substorage/target.txt'; @@ -2296,14 +2312,14 @@ class ViewTest extends \Test\TestCase { ->method($storageOperation); $storage2->expects($this->once()) ->method($storageOperation) - ->will($this->returnCallback( + ->willReturnCallback( function () use ($view, $sourcePath, $targetPath, &$lockTypeSourceDuring, &$lockTypeTargetDuring) { $lockTypeSourceDuring = $this->getFileLockType($view, $sourcePath); $lockTypeTargetDuring = $this->getFileLockType($view, $targetPath); return true; } - )); + ); $this->connectMockHooks($viewOperation, $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost); $this->connectMockHooks($viewOperation, $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost); @@ -2331,7 +2347,7 @@ class ViewTest extends \Test\TestCase { public function testLockMoveMountPoint() { self::loginAsUser('test'); - list($mount) = $this->createTestMovableMountPoints([ + [$mount] = $this->createTestMovableMountPoints([ $this->user . '/files/substorage', ]); @@ -2343,7 +2359,7 @@ class ViewTest extends \Test\TestCase { $mount->expects($this->once()) ->method('moveMount') - ->will($this->returnCallback( + ->willReturnCallback( function ($target) use ($mount, $view, $sourcePath, $targetPath, &$lockTypeSourceDuring, &$lockTypeTargetDuring, &$lockTypeSharedRootDuring) { $lockTypeSourceDuring = $this->getFileLockType($view, $sourcePath, true); $lockTypeTargetDuring = $this->getFileLockType($view, $targetPath, true); @@ -2354,7 +2370,7 @@ class ViewTest extends \Test\TestCase { return true; } - )); + ); $this->connectMockHooks('rename', $view, $sourcePath, $lockTypeSourcePre, $lockTypeSourcePost, true); $this->connectMockHooks('rename', $view, $targetPath, $lockTypeTargetPre, $lockTypeTargetPost, true); @@ -2408,18 +2424,18 @@ class ViewTest extends \Test\TestCase { $eventHandler->expects($this->any()) ->method('preCallback') - ->will($this->returnCallback( + ->willReturnCallback( function () use ($view, $path, $onMountPoint, &$lockTypePre) { $lockTypePre = $this->getFileLockType($view, $path, $onMountPoint); } - )); + ); $eventHandler->expects($this->any()) ->method('postCallback') - ->will($this->returnCallback( + ->willReturnCallback( function () use ($view, $path, $onMountPoint, &$lockTypePost) { $lockTypePost = $this->getFileLockType($view, $path, $onMountPoint); } - )); + ); if ($hookType !== null) { Util::connectHook( @@ -2450,7 +2466,7 @@ class ViewTest extends \Test\TestCase { private function getFileLockType(View $view, $path, $onMountPoint = false) { if ($this->isFileLocked($view, $path, ILockingProvider::LOCK_EXCLUSIVE, $onMountPoint)) { return ILockingProvider::LOCK_EXCLUSIVE; - } else if ($this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED, $onMountPoint)) { + } elseif ($this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED, $onMountPoint)) { return ILockingProvider::LOCK_SHARED; } return null; @@ -2553,6 +2569,7 @@ class ViewTest extends \Test\TestCase { $fh = tmpfile(); fwrite($fh, 'fooo'); rewind($fh); + clearstatcache(); $view->file_put_contents('', $fh); $this->assertEquals('fooo', $view->file_get_contents('')); $data = $view->getFileInfo('.'); diff --git a/tests/lib/GlobalScale/ConfigTest.php b/tests/lib/GlobalScale/ConfigTest.php index 5aaed1ed5bd..2f2e1c21855 100644 --- a/tests/lib/GlobalScale/ConfigTest.php +++ b/tests/lib/GlobalScale/ConfigTest.php @@ -21,7 +21,6 @@ namespace Test\GlobalScale; - use OC\GlobalScale\Config; use OCP\IConfig; use Test\TestCase; @@ -42,7 +41,6 @@ class ConfigTest extends TestCase { * @return Config|\PHPUnit_Framework_MockObject_MockObject */ public function getInstance($mockMethods = []) { - if (!empty($mockMethods)) { return $this->getMockBuilder(Config::class) ->setConstructorArgs([$this->config]) @@ -90,5 +88,4 @@ class ConfigTest extends TestCase { [false, 'internal', false] ]; } - } diff --git a/tests/lib/Group/Backend.php b/tests/lib/Group/Backend.php index f702d94b2b4..541ed78719b 100644 --- a/tests/lib/Group/Backend.php +++ b/tests/lib/Group/Backend.php @@ -108,15 +108,15 @@ abstract class Backend extends \Test\TestCase { $this->assertFalse($this->backend->addToGroup($user1, $group1)); - $this->assertEquals(array($user1), $this->backend->usersInGroup($group1)); - $this->assertEquals(array(), $this->backend->usersInGroup($group2)); + $this->assertEquals([$user1], $this->backend->usersInGroup($group1)); + $this->assertEquals([], $this->backend->usersInGroup($group2)); - $this->assertEquals(array($group1), $this->backend->getUserGroups($user1)); - $this->assertEquals(array(), $this->backend->getUserGroups($user2)); + $this->assertEquals([$group1], $this->backend->getUserGroups($user1)); + $this->assertEquals([], $this->backend->getUserGroups($user2)); $this->backend->deleteGroup($group1); - $this->assertEquals(array(), $this->backend->getUserGroups($user1)); - $this->assertEquals(array(), $this->backend->usersInGroup($group1)); + $this->assertEquals([], $this->backend->getUserGroups($user1)); + $this->assertEquals([], $this->backend->usersInGroup($group1)); $this->assertFalse($this->backend->inGroup($user1, $group1)); } diff --git a/tests/lib/Group/DatabaseTest.php b/tests/lib/Group/DatabaseTest.php index 4af8b1cd430..586d77e0ec0 100644 --- a/tests/lib/Group/DatabaseTest.php +++ b/tests/lib/Group/DatabaseTest.php @@ -31,7 +31,7 @@ namespace Test\Group; * @group DB */ class DatabaseTest extends Backend { - private $groups = array(); + private $groups = []; /** * get a new unique group name diff --git a/tests/lib/Group/Dummy.php b/tests/lib/Group/Dummy.php index 3be04159938..d687b6a3dda 100644 --- a/tests/lib/Group/Dummy.php +++ b/tests/lib/Group/Dummy.php @@ -1,24 +1,24 @@ <?php /** -* ownCloud -* -* @author Robin Appelman -* @copyright 2012 Robin Appelman icewind@owncloud.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * ownCloud + * + * @author Robin Appelman + * @copyright 2012 Robin Appelman icewind@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ namespace Test\Group; diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php index 61e4b39c8f3..b85496620b8 100644 --- a/tests/lib/Group/GroupTest.php +++ b/tests/lib/Group/GroupTest.php @@ -10,8 +10,6 @@ namespace Test\Group; use OC\User\User; -use OCP\IConfig; -use OCP\IURLGenerator; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -56,11 +54,11 @@ class GroupTest extends \Test\TestCase { $user3 = $this->newUser('user3', $backend); $userManager->expects($this->any()) ->method('get') - ->will($this->returnValueMap(array( - array('user1', $user1), - array('user2', $user2), - array('user3', $user3) - ))); + ->willReturnMap([ + ['user1', $user1], + ['user2', $user2], + ['user3', $user3] + ]); return $userManager; } @@ -69,12 +67,12 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('usersInGroup') ->with('group1') - ->will($this->returnValue(array('user1', 'user2'))); + ->willReturn(['user1', 'user2']); $users = $group->getUsers(); @@ -93,17 +91,17 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1, $backend2], $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('usersInGroup') ->with('group1') - ->will($this->returnValue(array('user1', 'user2'))); + ->willReturn(['user1', 'user2']); $backend2->expects($this->once()) ->method('usersInGroup') ->with('group1') - ->will($this->returnValue(array('user2', 'user3'))); + ->willReturn(['user2', 'user3']); $users = $group->getUsers(); @@ -124,12 +122,12 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertTrue($group->inGroup($this->newUser('user1', $userBackend))); } @@ -145,17 +143,17 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1, $backend2], $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(false)); + ->willReturn(false); $backend2->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertTrue($group->inGroup($this->newUser('user1', $userBackend))); } @@ -168,15 +166,15 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(false)); + ->willReturn(false); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('addToGroup') @@ -193,15 +191,15 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->never()) ->method('addToGroup'); @@ -217,15 +215,15 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('removeFromGroup') @@ -242,15 +240,15 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(false)); + ->willReturn(false); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->never()) ->method('removeFromGroup'); @@ -269,15 +267,15 @@ class GroupTest extends \Test\TestCase { $userBackend = $this->getMockBuilder('\OC\User\Backend') ->disableOriginalConstructor() ->getMock(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1, $backend2], $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(true)); + ->willReturn(true); $backend1->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend1->expects($this->once()) ->method('removeFromGroup') @@ -286,10 +284,10 @@ class GroupTest extends \Test\TestCase { $backend2->expects($this->once()) ->method('inGroup') ->with('user1', 'group1') - ->will($this->returnValue(true)); + ->willReturn(true); $backend2->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend2->expects($this->once()) ->method('removeFromGroup') @@ -303,12 +301,12 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('usersInGroup') ->with('group1', '2') - ->will($this->returnValue(array('user2'))); + ->willReturn(['user2']); $users = $group->searchUsers('2'); @@ -325,16 +323,16 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1, $backend2], $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('usersInGroup') ->with('group1', '2') - ->will($this->returnValue(array('user2'))); + ->willReturn(['user2']); $backend2->expects($this->once()) ->method('usersInGroup') ->with('group1', '2') - ->will($this->returnValue(array('user2'))); + ->willReturn(['user2']); $users = $group->searchUsers('2'); @@ -348,12 +346,12 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('usersInGroup') ->with('group1', 'user', 1, 1) - ->will($this->returnValue(array('user2'))); + ->willReturn(['user2']); $users = $group->searchUsers('user', 1, 1); @@ -370,16 +368,16 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1, $backend2], $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('usersInGroup') ->with('group1', 'user', 2, 1) - ->will($this->returnValue(array('user2'))); + ->willReturn(['user2']); $backend2->expects($this->once()) ->method('usersInGroup') ->with('group1', 'user', 2, 1) - ->will($this->returnValue(array('user1'))); + ->willReturn(['user1']); $users = $group->searchUsers('user', 2, 1); @@ -395,16 +393,16 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1], $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('countUsersInGroup') ->with('group1', '2') - ->will($this->returnValue(3)); + ->willReturn(3); $backend1->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $users = $group->count('2'); @@ -419,23 +417,23 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1, $backend2), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1, $backend2], $this->dispatcher, $userManager); $backend1->expects($this->once()) ->method('countUsersInGroup') ->with('group1', '2') - ->will($this->returnValue(3)); + ->willReturn(3); $backend1->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend2->expects($this->once()) ->method('countUsersInGroup') ->with('group1', '2') - ->will($this->returnValue(4)); + ->willReturn(4); $backend2->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $users = $group->count('2'); @@ -447,13 +445,13 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend1), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend1], $this->dispatcher, $userManager); $backend1->expects($this->never()) ->method('countUsersInGroup'); $backend1->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(false)); + ->willReturn(false); $users = $group->count('2'); @@ -465,14 +463,14 @@ class GroupTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $group = new \OC\Group\Group('group1', array($backend), $this->dispatcher, $userManager); + $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); $backend->expects($this->once()) ->method('deleteGroup') ->with('group1'); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $group->delete(); } diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php index d5f8baa3fa1..ff1d6e641ea 100644 --- a/tests/lib/Group/ManagerTest.php +++ b/tests/lib/Group/ManagerTest.php @@ -52,10 +52,10 @@ class ManagerTest extends TestCase { $mockUser = $this->createMock(IUser::class); $mockUser->expects($this->any()) ->method('getUID') - ->will($this->returnValue($userId)); + ->willReturn($userId); $mockUser->expects($this->any()) ->method('getDisplayName') - ->will($this->returnValue($userId)); + ->willReturn($userId); return $mockUser; } @@ -91,9 +91,9 @@ class ManagerTest extends TestCase { ->getMock(); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function($actions) use ($implementedActions) { + ->willReturnCallback(function ($actions) use ($implementedActions) { return (bool)($actions & $implementedActions); - })); + }); return $backend; } @@ -105,7 +105,7 @@ class ManagerTest extends TestCase { $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -129,7 +129,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(false)); + ->willReturn(false); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -157,7 +157,7 @@ class ManagerTest extends TestCase { $backend1->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(false)); + ->willReturn(false); /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC\Group\Backend $backend2 @@ -166,7 +166,7 @@ class ManagerTest extends TestCase { $backend2->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); @@ -184,15 +184,15 @@ class ManagerTest extends TestCase { $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnCallback(function () use (&$backendGroupCreated) { + ->willReturnCallback(function () use (&$backendGroupCreated) { return $backendGroupCreated; - })); + }); $backend->expects($this->once()) ->method('createGroup') - ->will($this->returnCallback(function () use (&$backendGroupCreated) { + ->willReturnCallback(function () use (&$backendGroupCreated) { $backendGroupCreated = true; return true; - })); + }); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -236,7 +236,7 @@ class ManagerTest extends TestCase { $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->never()) ->method('createGroup'); @@ -255,11 +255,11 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getGroups') ->with('1') - ->will($this->returnValue(array('group1'))); + ->willReturn(['group1']); $backend->expects($this->once()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -278,10 +278,10 @@ class ManagerTest extends TestCase { $backend1->expects($this->once()) ->method('getGroups') ->with('1') - ->will($this->returnValue(array('group1'))); + ->willReturn(['group1']); $backend1->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC\Group\Backend $backend2 @@ -290,10 +290,10 @@ class ManagerTest extends TestCase { $backend2->expects($this->once()) ->method('getGroups') ->with('1') - ->will($this->returnValue(array('group12', 'group1'))); + ->willReturn(['group12', 'group1']); $backend2->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); @@ -315,10 +315,10 @@ class ManagerTest extends TestCase { $backend1->expects($this->once()) ->method('getGroups') ->with('1', 2, 1) - ->will($this->returnValue(array('group1'))); + ->willReturn(['group1']); $backend1->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC\Group\Backend $backend2 @@ -327,10 +327,10 @@ class ManagerTest extends TestCase { $backend2->expects($this->once()) ->method('getGroups') ->with('1', 2, 1) - ->will($this->returnValue(array('group12'))); + ->willReturn(['group12']); $backend2->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); @@ -350,11 +350,11 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getGroups') ->with('1') - ->will($this->returnValue(['group1'])); + ->willReturn(['group1']); $backend->expects($this->once()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(false)); + ->willReturn(false); /** @var \OC\User\Manager $userManager */ $userManager = $this->createMock(Manager::class); @@ -374,11 +374,11 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(array('group1'))); + ->willReturn(['group1']); $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -390,17 +390,15 @@ class ManagerTest extends TestCase { } public function testGetUserGroupIds() { - /** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Group\Manager $manager */ - $manager = $this->getMockBuilder(\OC\Group\Manager::class) - ->disableOriginalConstructor() - ->setMethods(['getUserGroups']) - ->getMock(); - $manager->expects($this->once()) - ->method('getUserGroups') - ->willReturn([ - '123' => '123', - 'abc' => 'abc', - ]); + /** + * @var \PHPUnit_Framework_MockObject_MockObject | \OC\Group\Backend $backend + */ + $backend = $this->getTestBackend(); + $backend->method('getUserGroups') + ->willReturn(['123', 'abc']); + + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager->addBackend($backend); /** @var \OC\User\User|\PHPUnit_Framework_MockObject_MockObject $user */ $user = $this->createMock(IUser::class); @@ -421,11 +419,11 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(array('group1'))); + ->willReturn(['group1']); $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(false)); + ->willReturn(false); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -448,10 +446,10 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(array('group1', 'admin', 'group2'))); + ->willReturn(['group1', 'admin', 'group2']); $backend->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -467,10 +465,10 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(array('group1', 'admin', 'group2'))); + ->willReturn(['group1', 'admin', 'group2']); $backend->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -486,10 +484,10 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(array('group1', 'group2'))); + ->willReturn(['group1', 'group2']); $backend->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -505,10 +503,10 @@ class ManagerTest extends TestCase { $backend1->expects($this->once()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(array('group1'))); + ->willReturn(['group1']); $backend1->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC\Group\Backend $backend2 @@ -517,10 +515,10 @@ class ManagerTest extends TestCase { $backend2->expects($this->once()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(array('group1', 'group2'))); + ->willReturn(['group1', 'group2']); $backend1->expects($this->any()) ->method('groupExists') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend1); @@ -542,44 +540,44 @@ class ManagerTest extends TestCase { $backend->expects($this->exactly(1)) ->method('groupExists') ->with('testgroup') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->any()) ->method('inGroup') - ->will($this->returnCallback(function($uid, $gid) { - switch($uid) { - case 'user1' : return false; - case 'user2' : return true; - case 'user3' : return false; + ->willReturnCallback(function ($uid, $gid) { + switch ($uid) { + case 'user1': return false; + case 'user2': return true; + case 'user3': return false; case 'user33': return true; default: return null; } - })); + }); $this->userManager->expects($this->any()) ->method('searchDisplayName') ->with('user3') - ->will($this->returnCallback(function($search, $limit, $offset) { - switch($offset) { - case 0 : return ['user3' => $this->getTestUser('user3'), - 'user33' => $this->getTestUser('user33')]; - case 2 : return []; + ->willReturnCallback(function ($search, $limit, $offset) { + switch ($offset) { + case 0: return ['user3' => $this->getTestUser('user3'), + 'user33' => $this->getTestUser('user33')]; + case 2: return []; } return null; - })); + }); $this->userManager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function($uid) { - switch($uid) { - case 'user1' : return $this->getTestUser('user1'); - case 'user2' : return $this->getTestUser('user2'); - case 'user3' : return $this->getTestUser('user3'); + ->willReturnCallback(function ($uid) { + switch ($uid) { + case 'user1': return $this->getTestUser('user1'); + case 'user2': return $this->getTestUser('user2'); + case 'user3': return $this->getTestUser('user3'); case 'user33': return $this->getTestUser('user33'); default: return null; } - })); + }); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -600,46 +598,46 @@ class ManagerTest extends TestCase { $backend->expects($this->exactly(1)) ->method('groupExists') ->with('testgroup') - ->will($this->returnValue(true)); + ->willReturn(true); - $backend->expects($this->any()) + $backend->expects($this->any()) ->method('inGroup') - ->will($this->returnCallback(function($uid, $gid) { - switch($uid) { - case 'user1' : return false; - case 'user2' : return true; - case 'user3' : return false; + ->willReturnCallback(function ($uid, $gid) { + switch ($uid) { + case 'user1': return false; + case 'user2': return true; + case 'user3': return false; case 'user33': return true; case 'user333': return true; default: return null; } - })); + }); $this->userManager->expects($this->any()) ->method('searchDisplayName') ->with('user3') - ->will($this->returnCallback(function($search, $limit, $offset) { - switch($offset) { - case 0 : return ['user3' => $this->getTestUser('user3'), - 'user33' => $this->getTestUser('user33')]; - case 2 : return ['user333' => $this->getTestUser('user333')]; + ->willReturnCallback(function ($search, $limit, $offset) { + switch ($offset) { + case 0: return ['user3' => $this->getTestUser('user3'), + 'user33' => $this->getTestUser('user33')]; + case 2: return ['user333' => $this->getTestUser('user333')]; } return null; - })); + }); $this->userManager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function($uid) { - switch($uid) { - case 'user1' : return $this->getTestUser('user1'); - case 'user2' : return $this->getTestUser('user2'); - case 'user3' : return $this->getTestUser('user3'); + ->willReturnCallback(function ($uid) { + switch ($uid) { + case 'user1': return $this->getTestUser('user1'); + case 'user2': return $this->getTestUser('user2'); + case 'user3': return $this->getTestUser('user3'); case 'user33': return $this->getTestUser('user33'); case 'user333': return $this->getTestUser('user333'); default: return null; } - })); + }); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -661,28 +659,28 @@ class ManagerTest extends TestCase { $backend->expects($this->exactly(1)) ->method('groupExists') ->with('testgroup') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->any()) ->method('inGroup') - ->will($this->returnCallback(function($uid) { - switch($uid) { - case 'user1' : return false; - case 'user2' : return true; - case 'user3' : return false; + ->willReturnCallback(function ($uid) { + switch ($uid) { + case 'user1': return false; + case 'user2': return true; + case 'user3': return false; case 'user33': return true; case 'user333': return true; default: return null; } - })); + }); $this->userManager->expects($this->any()) ->method('searchDisplayName') ->with('user3') - ->will($this->returnCallback(function($search, $limit, $offset) { - switch($offset) { - case 0 : + ->willReturnCallback(function ($search, $limit, $offset) { + switch ($offset) { + case 0: return [ 'user3' => $this->getTestUser('user3'), 'user33' => $this->getTestUser('user33'), @@ -690,20 +688,20 @@ class ManagerTest extends TestCase { ]; } return null; - })); + }); $this->userManager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function($uid) { - switch($uid) { - case 'user1' : return $this->getTestUser('user1'); - case 'user2' : return $this->getTestUser('user2'); - case 'user3' : return $this->getTestUser('user3'); + ->willReturnCallback(function ($uid) { + switch ($uid) { + case 'user1': return $this->getTestUser('user1'); + case 'user2': return $this->getTestUser('user2'); + case 'user3': return $this->getTestUser('user3'); case 'user33': return $this->getTestUser('user33'); case 'user333': return $this->getTestUser('user333'); default: return null; } - })); + }); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -725,25 +723,25 @@ class ManagerTest extends TestCase { $backend->expects($this->exactly(1)) ->method('groupExists') ->with('testgroup') - ->will($this->returnValue(true)); + ->willReturn(true); - $backend->expects($this->once()) + $backend->expects($this->once()) ->method('usersInGroup') ->with('testgroup', '', -1, 0) - ->will($this->returnValue(array('user2', 'user33'))); + ->willReturn(['user2', 'user33']); $this->userManager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function($uid) { - switch($uid) { - case 'user1' : return $this->getTestUser('user1'); - case 'user2' : return $this->getTestUser('user2'); - case 'user3' : return $this->getTestUser('user3'); + ->willReturnCallback(function ($uid) { + switch ($uid) { + case 'user1': return $this->getTestUser('user1'); + case 'user2': return $this->getTestUser('user2'); + case 'user3': return $this->getTestUser('user3'); case 'user33': return $this->getTestUser('user33'); default: return null; } - })); + }); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -764,25 +762,25 @@ class ManagerTest extends TestCase { $backend->expects($this->exactly(1)) ->method('groupExists') ->with('testgroup') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('usersInGroup') ->with('testgroup', '', 1, 0) - ->will($this->returnValue(array('user2'))); + ->willReturn(['user2']); $this->userManager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function($uid) { - switch($uid) { - case 'user1' : return $this->getTestUser('user1'); - case 'user2' : return $this->getTestUser('user2'); - case 'user3' : return $this->getTestUser('user3'); + ->willReturnCallback(function ($uid) { + switch ($uid) { + case 'user1': return $this->getTestUser('user1'); + case 'user2': return $this->getTestUser('user2'); + case 'user3': return $this->getTestUser('user3'); case 'user33': return $this->getTestUser('user33'); default: return null; } - })); + }); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -803,25 +801,25 @@ class ManagerTest extends TestCase { $backend->expects($this->exactly(1)) ->method('groupExists') ->with('testgroup') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('usersInGroup') ->with('testgroup', '', 1, 1) - ->will($this->returnValue(array('user33'))); + ->willReturn(['user33']); $this->userManager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function($uid) { - switch($uid) { - case 'user1' : return $this->getTestUser('user1'); - case 'user2' : return $this->getTestUser('user2'); - case 'user3' : return $this->getTestUser('user3'); + ->willReturnCallback(function ($uid) { + switch ($uid) { + case 'user1': return $this->getTestUser('user1'); + case 'user2': return $this->getTestUser('user2'); + case 'user3': return $this->getTestUser('user3'); case 'user33': return $this->getTestUser('user33'); default: return null; } - })); + }); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -843,13 +841,13 @@ class ManagerTest extends TestCase { $backend->expects($this->any()) ->method('getUserGroups') ->with('user1') - ->will($this->returnCallback(function () use (&$expectedGroups) { + ->willReturnCallback(function () use (&$expectedGroups) { return $expectedGroups; - })); + }); $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -857,7 +855,7 @@ class ManagerTest extends TestCase { // prime cache $user1 = $this->getTestUser('user1'); $groups = $manager->getUserGroups($user1); - $this->assertEquals(array(), $groups); + $this->assertEquals([], $groups); // add user $group = $manager->get('group1'); @@ -880,19 +878,19 @@ class ManagerTest extends TestCase { $backend->expects($this->any()) ->method('getUserGroups') ->with('user1') - ->will($this->returnCallback(function () use (&$expectedGroups) { + ->willReturnCallback(function () use (&$expectedGroups) { return $expectedGroups; - })); + }); $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('inGroup') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('removeFromGroup') - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -907,7 +905,7 @@ class ManagerTest extends TestCase { // remove user $group = $manager->get('group1'); $group->removeUser($user1); - $expectedGroups = array(); + $expectedGroups = []; // check result $groups = $manager->getUserGroups($user1); @@ -922,7 +920,7 @@ class ManagerTest extends TestCase { $backend->expects($this->any()) ->method('getUserGroups') ->with('user1') - ->will($this->returnValue(null)); + ->willReturn(null); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -945,10 +943,10 @@ class ManagerTest extends TestCase { ); $backend->expects($this->any()) ->method('getGroupDetails') - ->will($this->returnValueMap([ + ->willReturnMap([ ['group1', ['gid' => 'group1', 'displayName' => 'Group One']], ['group2', ['gid' => 'group2']], - ])); + ]); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); $manager->addBackend($backend); @@ -965,5 +963,4 @@ class ManagerTest extends TestCase { $this->assertEquals('group2', $group->getGID()); $this->assertEquals('group2', $group->getDisplayName()); } - } diff --git a/tests/lib/Group/MetaDataTest.php b/tests/lib/Group/MetaDataTest.php index 4332a6f036f..ebd9cd79f23 100644 --- a/tests/lib/Group/MetaDataTest.php +++ b/tests/lib/Group/MetaDataTest.php @@ -83,7 +83,7 @@ class MetaDataTest extends \Test\TestCase { $this->groupManager->expects($this->once()) ->method('search') ->with('') - ->will($this->returnValue($groups)); + ->willReturn($groups); list($adminGroups, $ordinaryGroups) = $this->groupMetadata->get(); @@ -103,7 +103,7 @@ class MetaDataTest extends \Test\TestCase { $this->groupManager->expects($this->once()) ->method('search') ->with('') - ->will($this->returnValue($groups)); + ->willReturn($groups); list($adminGroups, $ordinaryGroups) = $this->groupMetadata->get(); @@ -121,7 +121,7 @@ class MetaDataTest extends \Test\TestCase { $this->groupManager->expects($this->once()) ->method('search') ->with('') - ->will($this->returnValue($groups)); + ->willReturn($groups); //two calls, if caching fails call counts for group and groupmanager //are exceeded @@ -137,7 +137,7 @@ class MetaDataTest extends \Test\TestCase { ->expects($this->once()) ->method('search') ->with('Foo') - ->will($this->returnValue(['DummyValue'])); + ->willReturn(['DummyValue']); $expected = ['DummyValue']; $this->assertSame($expected, $this->invokePrivate($this->groupMetadata, 'getGroups', ['Foo'])); diff --git a/tests/lib/HelperStorageTest.php b/tests/lib/HelperStorageTest.php index 7b2fb665733..4166d606366 100644 --- a/tests/lib/HelperStorageTest.php +++ b/tests/lib/HelperStorageTest.php @@ -7,6 +7,7 @@ */ namespace Test; + use OC\Files\Storage\Temporary; /** @@ -46,11 +47,13 @@ class HelperStorageTest extends \Test\TestCase { $this->storageMock = null; } \OC\Files\Filesystem::tearDown(); - \OC\Files\Filesystem::mount($this->storage, array(), '/'); + \OC\Files\Filesystem::mount($this->storage, [], '/'); \OC_User::setUserId(''); $user = \OC::$server->getUserManager()->get($this->user); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } \OC::$server->getConfig()->deleteAllUserValues($this->user); parent::tearDown(); @@ -71,16 +74,16 @@ class HelperStorageTest extends \Test\TestCase { $this->storageMock->expects($this->once()) ->method('free_space') - ->will($this->returnValue(12)); + ->willReturn(12); return $this->storageMock; } /** * Test getting the storage info */ - function testGetStorageInfo() { + public function testGetStorageInfo() { $homeStorage = $this->getStorageMock(12); - \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); + \OC\Files\Filesystem::mount($homeStorage, [], '/' . $this->user . '/files'); $homeStorage->file_put_contents('test.txt', '01234'); $storageInfo = \OC_Helper::getStorageInfo(''); @@ -92,16 +95,16 @@ class HelperStorageTest extends \Test\TestCase { /** * Test getting the storage info, ignoring extra mount points */ - function testGetStorageInfoExcludingExtStorage() { + public function testGetStorageInfoExcludingExtStorage() { $homeStorage = $this->getStorageMock(12); - \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); + \OC\Files\Filesystem::mount($homeStorage, [], '/' . $this->user . '/files'); $homeStorage->file_put_contents('test.txt', '01234'); - $extStorage = new \OC\Files\Storage\Temporary(array()); + $extStorage = new \OC\Files\Storage\Temporary([]); $extStorage->file_put_contents('extfile.txt', 'abcdefghijklmnopq'); $extStorage->getScanner()->scan(''); // update root size - \OC\Files\Filesystem::mount($extStorage, array(), '/' . $this->user . '/files/ext'); + \OC\Files\Filesystem::mount($extStorage, [], '/' . $this->user . '/files/ext'); $storageInfo = \OC_Helper::getStorageInfo(''); $this->assertEquals(12, $storageInfo['free']); @@ -112,16 +115,16 @@ class HelperStorageTest extends \Test\TestCase { /** * Test getting the storage info, including extra mount points */ - function testGetStorageInfoIncludingExtStorage() { - $homeStorage = new \OC\Files\Storage\Temporary(array()); - \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); + public function testGetStorageInfoIncludingExtStorage() { + $homeStorage = new \OC\Files\Storage\Temporary([]); + \OC\Files\Filesystem::mount($homeStorage, [], '/' . $this->user . '/files'); $homeStorage->file_put_contents('test.txt', '01234'); - $extStorage = new \OC\Files\Storage\Temporary(array()); + $extStorage = new \OC\Files\Storage\Temporary([]); $extStorage->file_put_contents('extfile.txt', 'abcdefghijklmnopq'); $extStorage->getScanner()->scan(''); // update root size - \OC\Files\Filesystem::mount($extStorage, array(), '/' . $this->user . '/files/ext'); + \OC\Files\Filesystem::mount($extStorage, [], '/' . $this->user . '/files/ext'); $config = \OC::$server->getConfig(); $oldConfig = $config->getSystemValue('quota_include_external_storage', false); @@ -143,16 +146,16 @@ class HelperStorageTest extends \Test\TestCase { * when user has no quota set, even when quota ext storage option * was set */ - function testGetStorageInfoIncludingExtStorageWithNoUserQuota() { + public function testGetStorageInfoIncludingExtStorageWithNoUserQuota() { $homeStorage = $this->getStorageMock(12); - \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); + \OC\Files\Filesystem::mount($homeStorage, [], '/' . $this->user . '/files'); $homeStorage->file_put_contents('test.txt', '01234'); - $extStorage = new \OC\Files\Storage\Temporary(array()); + $extStorage = new \OC\Files\Storage\Temporary([]); $extStorage->file_put_contents('extfile.txt', 'abcdefghijklmnopq'); $extStorage->getScanner()->scan(''); // update root size - \OC\Files\Filesystem::mount($extStorage, array(), '/' . $this->user . '/files/ext'); + \OC\Files\Filesystem::mount($extStorage, [], '/' . $this->user . '/files/ext'); $config = \OC::$server->getConfig(); $oldConfig = $config->getSystemValue('quota_include_external_storage', false); @@ -170,16 +173,16 @@ class HelperStorageTest extends \Test\TestCase { /** * Test getting the storage info with quota enabled */ - function testGetStorageInfoWithQuota() { + public function testGetStorageInfoWithQuota() { $homeStorage = $this->getStorageMock(12); $homeStorage->file_put_contents('test.txt', '01234'); $homeStorage = new \OC\Files\Storage\Wrapper\Quota( - array( + [ 'storage' => $homeStorage, 'quota' => 7 - ) + ] ); - \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); + \OC\Files\Filesystem::mount($homeStorage, [], '/' . $this->user . '/files'); $storageInfo = \OC_Helper::getStorageInfo(''); $this->assertEquals(2, $storageInfo['free']); @@ -190,16 +193,16 @@ class HelperStorageTest extends \Test\TestCase { /** * Test getting the storage info when data exceeds quota */ - function testGetStorageInfoWhenSizeExceedsQuota() { + public function testGetStorageInfoWhenSizeExceedsQuota() { $homeStorage = $this->getStorageMock(12); $homeStorage->file_put_contents('test.txt', '0123456789'); $homeStorage = new \OC\Files\Storage\Wrapper\Quota( - array( + [ 'storage' => $homeStorage, 'quota' => 7 - ) + ] ); - \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); + \OC\Files\Filesystem::mount($homeStorage, [], '/' . $this->user . '/files'); $storageInfo = \OC_Helper::getStorageInfo(''); $this->assertEquals(0, $storageInfo['free']); @@ -212,16 +215,16 @@ class HelperStorageTest extends \Test\TestCase { * Test getting the storage info when the remaining * free storage space is less than the quota */ - function testGetStorageInfoWhenFreeSpaceLessThanQuota() { + public function testGetStorageInfoWhenFreeSpaceLessThanQuota() { $homeStorage = $this->getStorageMock(12); $homeStorage->file_put_contents('test.txt', '01234'); $homeStorage = new \OC\Files\Storage\Wrapper\Quota( - array( + [ 'storage' => $homeStorage, 'quota' => 18 - ) + ] ); - \OC\Files\Filesystem::mount($homeStorage, array(), '/' . $this->user . '/files'); + \OC\Files\Filesystem::mount($homeStorage, [], '/' . $this->user . '/files'); $storageInfo = \OC_Helper::getStorageInfo(''); $this->assertEquals(12, $storageInfo['free']); diff --git a/tests/lib/HookHelper.php b/tests/lib/HookHelper.php index f1cce831477..5e040724d90 100644 --- a/tests/lib/HookHelper.php +++ b/tests/lib/HookHelper.php @@ -62,45 +62,45 @@ class HookHelper { } public static function createCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_create, 'params' => $params - ); + ]; } public static function updateCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_update, 'params' => $params - ); + ]; } public static function writeCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_write, 'params' => $params - ); + ]; } public static function postCreateCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_post_create, 'params' => $params - ); + ]; } public static function postUpdateCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_post_update, 'params' => $params - ); + ]; } public static function postWriteCallback($params) { - self::$hookCalls[] = array( + self::$hookCalls[] = [ 'signal' => Filesystem::signal_post_write, 'params' => $params - ); + ]; } /** diff --git a/tests/lib/Hooks/BasicEmitterTest.php b/tests/lib/Hooks/BasicEmitterTest.php index 1f88dee1032..01ae4d4f28b 100644 --- a/tests/lib/Hooks/BasicEmitterTest.php +++ b/tests/lib/Hooks/BasicEmitterTest.php @@ -16,7 +16,7 @@ namespace Test\Hooks; * @package Test\Hooks */ class DummyEmitter extends \OC\Hooks\BasicEmitter { - public function emitEvent($scope, $method, $arguments = array()) { + public function emitEvent($scope, $method, $arguments = []) { $this->emit($scope, $method, $arguments); } } @@ -64,7 +64,7 @@ class BasicEmitterTest extends \Test\TestCase { public function testStaticCallback() { $this->expectException(\Test\Hooks\EmittedException::class); - $this->emitter->listen('Test', 'test', array('\Test\Hooks\BasicEmitterTest', 'staticCallBack')); + $this->emitter->listen('Test', 'test', ['\Test\Hooks\BasicEmitterTest', 'staticCallBack']); $this->emitter->emitEvent('Test', 'test'); } @@ -72,7 +72,7 @@ class BasicEmitterTest extends \Test\TestCase { public function testNonStaticCallback() { $this->expectException(\Test\Hooks\EmittedException::class); - $this->emitter->listen('Test', 'test', array($this, 'nonStaticCallBack')); + $this->emitter->listen('Test', 'test', [$this, 'nonStaticCallBack']); $this->emitter->emitEvent('Test', 'test'); } @@ -134,7 +134,7 @@ class BasicEmitterTest extends \Test\TestCase { throw new EmittedException; } }); - $this->emitter->emitEvent('Test', 'test', array('foo', 'bar')); + $this->emitter->emitEvent('Test', 'test', ['foo', 'bar']); } @@ -146,7 +146,7 @@ class BasicEmitterTest extends \Test\TestCase { throw new EmittedException; } }); - $this->emitter->emitEvent('Test', 'test', array('foo' => 'foo', 'bar' => 'bar')); + $this->emitter->emitEvent('Test', 'test', ['foo' => 'foo', 'bar' => 'bar']); } public function testRemoveAllSpecified() { diff --git a/tests/lib/Hooks/ForwardingEmitterTest.php b/tests/lib/Hooks/ForwardingEmitterTest.php index ea8ee5c4121..0c073b95573 100644 --- a/tests/lib/Hooks/ForwardingEmitterTest.php +++ b/tests/lib/Hooks/ForwardingEmitterTest.php @@ -7,10 +7,11 @@ */ namespace Test\Hooks; + use OC\Hooks\PublicEmitter; class DummyForwardingEmitter extends \OC\Hooks\ForwardingEmitter { - public function emitEvent($scope, $method, $arguments = array()) { + public function emitEvent($scope, $method, $arguments = []) { $this->emit($scope, $method, $arguments); } diff --git a/tests/lib/Hooks/LegacyEmitterTest.php b/tests/lib/Hooks/LegacyEmitterTest.php index 32c923d8013..e6b751c1f74 100644 --- a/tests/lib/Hooks/LegacyEmitterTest.php +++ b/tests/lib/Hooks/LegacyEmitterTest.php @@ -16,7 +16,7 @@ namespace Test\Hooks; * @package Test\Hooks */ class DummyLegacyEmitter extends \OC\Hooks\LegacyEmitter { - public function emitEvent($scope, $method, $arguments = array()) { + public function emitEvent($scope, $method, $arguments = []) { $this->emit($scope, $method, $arguments); } } @@ -39,8 +39,9 @@ class LegacyEmitterTest extends BasicEmitterTest { } public static function staticLegacyArgumentsCallBack($arguments) { - if ($arguments['foo'] == 'foo' and $arguments['bar'] == 'bar') + if ($arguments['foo'] == 'foo' and $arguments['bar'] == 'bar') { self::$emitted = true; + } } public function testLegacyHook() { @@ -51,7 +52,7 @@ class LegacyEmitterTest extends BasicEmitterTest { public function testLegacyArguments() { \OC_Hook::connect('Test', 'test', '\Test\Hooks\LegacyEmitterTest', 'staticLegacyArgumentsCallBack'); - $this->emitter->emitEvent('Test', 'test', array('foo' => 'foo', 'bar' => 'bar')); + $this->emitter->emitEvent('Test', 'test', ['foo' => 'foo', 'bar' => 'bar']); $this->assertEquals(true, self::$emitted); } } diff --git a/tests/lib/Http/Client/ClientServiceTest.php b/tests/lib/Http/Client/ClientServiceTest.php index 02f331483de..b1bc5a188ce 100644 --- a/tests/lib/Http/Client/ClientServiceTest.php +++ b/tests/lib/Http/Client/ClientServiceTest.php @@ -13,6 +13,7 @@ use OC\Http\Client\Client; use OC\Http\Client\ClientService; use OCP\ICertificateManager; use OCP\IConfig; +use OCP\ILogger; /** * Class ClientServiceTest @@ -23,10 +24,11 @@ class ClientServiceTest extends \Test\TestCase { $config = $this->createMock(IConfig::class); /** @var ICertificateManager $certificateManager */ $certificateManager = $this->createMock(ICertificateManager::class); + $logger = $this->createMock(ILogger::class); - $clientService = new ClientService($config, $certificateManager); + $clientService = new ClientService($config, $logger, $certificateManager); $this->assertEquals( - new Client($config, $certificateManager, new GuzzleClient()), + new Client($config, $logger, $certificateManager, new GuzzleClient()), $clientService->newClient() ); } diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index 73cfb0bb6ca..a0c4d75c1bd 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -11,33 +11,38 @@ namespace Test\Http\Client; use GuzzleHttp\Psr7\Response; use OC\Http\Client\Client; use OC\Security\CertificateManager; +use OCP\Http\Client\LocalServerException; use OCP\ICertificateManager; use OCP\IConfig; +use OCP\ILogger; +use PHPUnit\Framework\MockObject\MockObject; /** * Class ClientTest */ class ClientTest extends \Test\TestCase { - /** @var \GuzzleHttp\Client|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \GuzzleHttp\Client|MockObject */ private $guzzleClient; - /** @var CertificateManager|\PHPUnit_Framework_MockObject_MockObject */ + /** @var CertificateManager|MockObject */ private $certificateManager; /** @var Client */ private $client; - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IConfig|MockObject */ private $config; + /** @var ILogger|MockObject */ + private $logger; /** @var array */ private $defaultRequestOptions; protected function setUp(): void { parent::setUp(); $this->config = $this->createMock(IConfig::class); - $this->guzzleClient = $this->getMockBuilder(\GuzzleHttp\Client::class) - ->disableOriginalConstructor() - ->getMock(); + $this->logger = $this->createMock(ILogger::class); + $this->guzzleClient = $this->createMock(\GuzzleHttp\Client::class); $this->certificateManager = $this->createMock(ICertificateManager::class); $this->client = new Client( $this->config, + $this->logger, $this->certificateManager, $this->guzzleClient ); @@ -63,7 +68,15 @@ class ClientTest extends \Test\TestCase { ->method('getSystemValue') ->with('proxyuserpwd', null) ->willReturn(null); - $this->assertSame('foo', self::invokePrivate($this->client, 'getProxyUri')); + $this->config + ->expects($this->at(2)) + ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn([]); + $this->assertEquals([ + 'http' => 'foo', + 'https' => 'foo' + ], self::invokePrivate($this->client, 'getProxyUri')); } public function testGetProxyUriProxyHostWithPassword(): void { @@ -87,20 +100,184 @@ class ClientTest extends \Test\TestCase { }) ) ->willReturn('username:password'); - $this->assertSame('username:password@foo', self::invokePrivate($this->client, 'getProxyUri')); + $this->config + ->expects($this->at(2)) + ->method('getSystemValue') + ->with( + $this->equalTo('proxyexclude'), + $this->callback(function ($input) { + return $input === []; + }) + ) + ->willReturn([]); + $this->assertEquals([ + 'http' => 'username:password@foo', + 'https' => 'username:password@foo' + ], self::invokePrivate($this->client, 'getProxyUri')); } - private function setUpDefaultRequestOptions(): void { + public function testGetProxyUriProxyHostWithPasswordAndExclude(): void { $this->config ->expects($this->at(0)) ->method('getSystemValue') - ->with('proxy', null) + ->with( + $this->equalTo('proxy'), + $this->callback(function ($input) { + return $input === ''; + }) + ) ->willReturn('foo'); $this->config ->expects($this->at(1)) ->method('getSystemValue') + ->with( + $this->equalTo('proxyuserpwd'), + $this->callback(function ($input) { + return $input === ''; + }) + ) + ->willReturn('username:password'); + $this->config + ->expects($this->at(2)) + ->method('getSystemValue') + ->with( + $this->equalTo('proxyexclude'), + $this->callback(function ($input) { + return $input === []; + }) + ) + ->willReturn(['bar']); + $this->assertEquals([ + 'http' => 'username:password@foo', + 'https' => 'username:password@foo', + 'no' => ['bar'] + ], self::invokePrivate($this->client, 'getProxyUri')); + } + + public function dataPreventLocalAddress():array { + return [ + ['localhost/foo.bar'], + ['localHost/foo.bar'], + ['random-host/foo.bar'], + ['[::1]/bla.blub'], + ['[::]/bla.blub'], + ['192.168.0.1'], + ['172.16.42.1'], + ['[fdf8:f53b:82e4::53]/secret.ics'], + ['[fe80::200:5aee:feaa:20a2]/secret.ics'], + ['[0:0:0:0:0:0:10.0.0.1]/secret.ics'], + ['[0:0:0:0:0:ffff:127.0.0.0]/secret.ics'], + ['10.0.0.1'], + ['another-host.local'], + ['service.localhost'], + ['!@#$'], // test invalid url + ]; + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddress(string $uri): void { + $this->expectException(LocalServerException::class); + self::invokePrivate($this->client, 'preventLocalAddress', ['http://' . $uri, []]); + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddressDisabledByGlobalConfig(string $uri): void { + $this->config->expects($this->once()) + ->method('getSystemValueBool') + ->with('allow_local_remote_servers', false) + ->willReturn(true); + +// $this->expectException(LocalServerException::class); + + self::invokePrivate($this->client, 'preventLocalAddress', ['http://' . $uri, []]); + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddressDisabledByOption(string $uri): void { + $this->config->expects($this->never()) + ->method('getSystemValueBool'); + +// $this->expectException(LocalServerException::class); + + self::invokePrivate($this->client, 'preventLocalAddress', ['http://' . $uri, [ + 'nextcloud' => ['allow_local_address' => true], + ]]); + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddressOnGet(string $uri): void { + $this->expectException(LocalServerException::class); + $this->client->get('http://' . $uri); + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddressOnHead(string $uri): void { + $this->expectException(LocalServerException::class); + $this->client->head('http://' . $uri); + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddressOnPost(string $uri): void { + $this->expectException(LocalServerException::class); + $this->client->post('http://' . $uri); + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddressOnPut(string $uri): void { + $this->expectException(LocalServerException::class); + $this->client->put('http://' . $uri); + } + + /** + * @dataProvider dataPreventLocalAddress + * @param string $uri + */ + public function testPreventLocalAddressOnDelete(string $uri): void { + $this->expectException(LocalServerException::class); + $this->client->delete('http://' . $uri); + } + + private function setUpDefaultRequestOptions(): void { + $this->config->expects($this->once()) + ->method('getSystemValueBool') + ->with('allow_local_remote_servers', false) + ->willReturn(true); + $this->config + ->expects($this->at(1)) + ->method('getSystemValue') + ->with('proxy', null) + ->willReturn('foo'); + $this->config + ->expects($this->at(2)) + ->method('getSystemValue') ->with('proxyuserpwd', null) ->willReturn(null); + $this->config + ->expects($this->at(3)) + ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn([]); $this->certificateManager ->expects($this->once()) ->method('getAbsoluteBundlePath') @@ -109,9 +286,13 @@ class ClientTest extends \Test\TestCase { $this->defaultRequestOptions = [ 'verify' => '/my/path.crt', - 'proxy' => 'foo', + 'proxy' => [ + 'http' => 'foo', + 'https' => 'foo' + ], 'headers' => [ 'User-Agent' => 'Nextcloud Server Crawler', + 'Accept-Encoding' => 'gzip', ], 'timeout' => 30, ]; @@ -131,7 +312,10 @@ class ClientTest extends \Test\TestCase { $options = array_merge($this->defaultRequestOptions, [ 'verify' => false, - 'proxy' => 'bar', + 'proxy' => [ + 'http' => 'bar', + 'https' => 'bar' + ], ]); $this->guzzleClient->method('request') @@ -154,7 +338,10 @@ class ClientTest extends \Test\TestCase { $options = array_merge($this->defaultRequestOptions, [ 'verify' => false, - 'proxy' => 'bar', + 'proxy' => [ + 'http' => 'bar', + 'https' => 'bar' + ], ]); $this->guzzleClient->method('request') @@ -177,7 +364,10 @@ class ClientTest extends \Test\TestCase { $options = array_merge($this->defaultRequestOptions, [ 'verify' => false, - 'proxy' => 'bar', + 'proxy' => [ + 'http' => 'bar', + 'https' => 'bar' + ], ]); $this->guzzleClient->method('request') @@ -200,7 +390,10 @@ class ClientTest extends \Test\TestCase { $options = array_merge($this->defaultRequestOptions, [ 'verify' => false, - 'proxy' => 'bar', + 'proxy' => [ + 'http' => 'bar', + 'https' => 'bar' + ], ]); $this->guzzleClient->method('request') @@ -223,7 +416,10 @@ class ClientTest extends \Test\TestCase { $options = array_merge($this->defaultRequestOptions, [ 'verify' => false, - 'proxy' => 'bar', + 'proxy' => [ + 'http' => 'bar', + 'https' => 'bar' + ], ]); $this->guzzleClient->method('request') @@ -246,7 +442,10 @@ class ClientTest extends \Test\TestCase { $options = array_merge($this->defaultRequestOptions, [ 'verify' => false, - 'proxy' => 'bar', + 'proxy' => [ + 'http' => 'bar', + 'https' => 'bar' + ], ]); $this->guzzleClient->method('request') @@ -268,9 +467,9 @@ class ClientTest extends \Test\TestCase { $this->assertEquals([ 'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt', - 'proxy' => null, 'headers' => [ - 'User-Agent' => 'Nextcloud Server Crawler' + 'User-Agent' => 'Nextcloud Server Crawler', + 'Accept-Encoding' => 'gzip', ], 'timeout' => 30, ], self::invokePrivate($this->client, 'buildRequestOptions', [[]])); @@ -287,6 +486,11 @@ class ClientTest extends \Test\TestCase { ->method('getSystemValue') ->with('proxyuserpwd', null) ->willReturn(null); + $this->config + ->expects($this->at(2)) + ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn([]); $this->certificateManager ->expects($this->once()) ->method('getAbsoluteBundlePath') @@ -295,9 +499,50 @@ class ClientTest extends \Test\TestCase { $this->assertEquals([ 'verify' => '/my/path.crt', - 'proxy' => 'foo', + 'proxy' => [ + 'http' => 'foo', + 'https' => 'foo' + ], 'headers' => [ - 'User-Agent' => 'Nextcloud Server Crawler' + 'User-Agent' => 'Nextcloud Server Crawler', + 'Accept-Encoding' => 'gzip', + ], + 'timeout' => 30, + ], self::invokePrivate($this->client, 'buildRequestOptions', [[]])); + } + + public function testSetDefaultOptionsWithProxyAndExclude(): void { + $this->config + ->expects($this->at(0)) + ->method('getSystemValue') + ->with('proxy', null) + ->willReturn('foo'); + $this->config + ->expects($this->at(1)) + ->method('getSystemValue') + ->with('proxyuserpwd', null) + ->willReturn(null); + $this->config + ->expects($this->at(2)) + ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn(['bar']); + $this->certificateManager + ->expects($this->once()) + ->method('getAbsoluteBundlePath') + ->with(null) + ->willReturn('/my/path.crt'); + + $this->assertEquals([ + 'verify' => '/my/path.crt', + 'proxy' => [ + 'http' => 'foo', + 'https' => 'foo', + 'no' => ['bar'] + ], + 'headers' => [ + 'User-Agent' => 'Nextcloud Server Crawler', + 'Accept-Encoding' => 'gzip', ], 'timeout' => 30, ], self::invokePrivate($this->client, 'buildRequestOptions', [[]])); diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php index 34fcf0e004d..5b83c4ac57f 100644 --- a/tests/lib/ImageTest.php +++ b/tests/lib/ImageTest.php @@ -344,12 +344,12 @@ class ImageTest extends \Test\TestCase { $this->assertEquals($expected[1], $img->height()); } - function convertDataProvider() { - return array( - array( 'image/gif'), - array( 'image/jpeg'), - array( 'image/png'), - ); + public function convertDataProvider() { + return [ + [ 'image/gif'], + [ 'image/jpeg'], + [ 'image/png'], + ]; } /** diff --git a/tests/lib/InfoXmlTest.php b/tests/lib/InfoXmlTest.php index 0d528dbb652..9dbeadf45d3 100644 --- a/tests/lib/InfoXmlTest.php +++ b/tests/lib/InfoXmlTest.php @@ -21,7 +21,6 @@ namespace Test; - /** * Class InfoXmlTest * @@ -29,7 +28,6 @@ namespace Test; * @package Test */ class InfoXmlTest extends TestCase { - public function dataApps() { return [ ['admin_audit'], diff --git a/tests/lib/InitialStateServiceTest.php b/tests/lib/InitialStateServiceTest.php index 2a97f07ac21..2afa257d3be 100644 --- a/tests/lib/InitialStateServiceTest.php +++ b/tests/lib/InitialStateServiceTest.php @@ -84,7 +84,7 @@ class InitialStateServiceTest extends TestCase { * @dataProvider staticData */ public function testLazyData($value) { - $this->service->provideLazyInitialState('test', 'key', function() use ($value) { + $this->service->provideLazyInitialState('test', 'key', function () use ($value) { return $value; }); $data = $this->service->getInitialStates(); @@ -94,5 +94,4 @@ class InitialStateServiceTest extends TestCase { $data ); } - } diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php index 4530784e8e2..9c3c40c267e 100644 --- a/tests/lib/InstallerTest.php +++ b/tests/lib/InstallerTest.php @@ -8,8 +8,6 @@ namespace Test; - -use OC\App\AppStore\Bundles\Bundle; use OC\App\AppStore\Fetcher\AppFetcher; use OC\Archive\ZIP; use OC\Installer; @@ -26,7 +24,6 @@ use OCP\ITempManager; * @group DB */ class InstallerTest extends TestCase { - private static $appid = 'testapp'; private $appstore; /** @var AppFetcher|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php index 586a42ff547..f1cd7467169 100644 --- a/tests/lib/IntegrityCheck/CheckerTest.php +++ b/tests/lib/IntegrityCheck/CheckerTest.php @@ -62,13 +62,13 @@ class CheckerTest extends TestCase { $this->mimeTypeDetector = $this->createMock(\OC\Files\Type\Detection::class); $this->config->method('getAppValue') - ->will($this->returnArgument(2)); + ->willReturnArgument(2); $this->cacheFactory ->expects($this->any()) ->method('createDistributed') ->with('oc.integritycheck.checker') - ->will($this->returnValue(new NullCache())); + ->willReturn(new NullCache()); $this->checker = new Checker( $this->environmentHelper, @@ -140,7 +140,7 @@ class CheckerTest extends TestCase { ->method('file_put_contents') ->with( $this->equalTo(\OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json'), - $this->callback(function($signature) use ($expectedSignatureFileData) { + $this->callback(function ($signature) use ($expectedSignatureFileData) { $expectedArray = json_decode($expectedSignatureFileData, true); $actualArray = json_decode($signature, true); $this->assertEquals($expectedArray, $actualArray); @@ -161,17 +161,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\IntegrityCheck\Exceptions\InvalidSignatureException', - 'message' => 'Signature data not found.', + 'class' => 'OC\IntegrityCheck\Exceptions\InvalidSignatureException', + 'message' => 'Signature data not found.', ], ]; $this->assertSame($expected, $this->checker->verifyAppSignature('SomeApp')); @@ -181,18 +181,18 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->once()) ->method('getAppPath') ->with('SomeApp') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -207,14 +207,14 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( '/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $this->assertSame([], $this->checker->verifyAppSignature('SomeApp')); } @@ -223,18 +223,18 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->once()) ->method('getAppPath') ->with('SomeApp') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "tampered", @@ -249,20 +249,20 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( '/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ - 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', - 'message' => 'Signature could not get verified.', - ], + 'EXCEPTION' => [ + 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'message' => 'Signature could not get verified.', + ], ]; $this->assertEquals($expected, $this->checker->verifyAppSignature('SomeApp')); } @@ -271,18 +271,18 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->once()) ->method('getAppPath') ->with('SomeApp') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -297,33 +297,33 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( '/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ 'INVALID_HASH' => [ 'AnotherFile.txt' => [ - 'expected' => '1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112', - 'current' => '7322348ba269c6d5522efe02f424fa3a0da319a7cd9c33142a5afe32a2d9af2da3a411f086fcfc96ff4301ea566f481dba0960c2abeef3594c4d930462f6584c', + 'expected' => '1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112', + 'current' => '7322348ba269c6d5522efe02f424fa3a0da319a7cd9c33142a5afe32a2d9af2da3a411f086fcfc96ff4301ea566f481dba0960c2abeef3594c4d930462f6584c', ], ], 'FILE_MISSING' => [ 'subfolder/file.txt' => [ - 'expected' => '410738545fb623c0a5c8a71f561e48ea69e3ada0981a455e920a5ae9bf17c6831ae654df324f9328ff8453de179276ae51931cca0fa71fe8ccde6c083ca0574b', - 'current' => '', + 'expected' => '410738545fb623c0a5c8a71f561e48ea69e3ada0981a455e920a5ae9bf17c6831ae654df324f9328ff8453de179276ae51931cca0fa71fe8ccde6c083ca0574b', + 'current' => '', ], ], 'EXTRA_FILE' => [ 'UnecessaryFile' => [ - 'expected' => '', - 'current' => 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', + 'expected' => '', + 'current' => 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', ], ], @@ -335,12 +335,12 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->never()) @@ -360,35 +360,35 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( '/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ - 'INVALID_HASH' => [ - 'AnotherFile.txt' => [ - 'expected' => '1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112', - 'current' => '7322348ba269c6d5522efe02f424fa3a0da319a7cd9c33142a5afe32a2d9af2da3a411f086fcfc96ff4301ea566f481dba0960c2abeef3594c4d930462f6584c', - ], + 'INVALID_HASH' => [ + 'AnotherFile.txt' => [ + 'expected' => '1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112', + 'current' => '7322348ba269c6d5522efe02f424fa3a0da319a7cd9c33142a5afe32a2d9af2da3a411f086fcfc96ff4301ea566f481dba0960c2abeef3594c4d930462f6584c', ], - 'FILE_MISSING' => [ - 'subfolder/file.txt' => [ - 'expected' => '410738545fb623c0a5c8a71f561e48ea69e3ada0981a455e920a5ae9bf17c6831ae654df324f9328ff8453de179276ae51931cca0fa71fe8ccde6c083ca0574b', - 'current' => '', - ], + ], + 'FILE_MISSING' => [ + 'subfolder/file.txt' => [ + 'expected' => '410738545fb623c0a5c8a71f561e48ea69e3ada0981a455e920a5ae9bf17c6831ae654df324f9328ff8453de179276ae51931cca0fa71fe8ccde6c083ca0574b', + 'current' => '', ], - 'EXTRA_FILE' => [ - 'UnecessaryFile' => [ - 'expected' => '', - 'current' => 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', - ], + ], + 'EXTRA_FILE' => [ + 'UnecessaryFile' => [ + 'expected' => '', + 'current' => 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', ], + ], ]; $this->assertSame($expected, $this->checker->verifyAppSignature('SomeApp', \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/')); @@ -398,18 +398,18 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->once()) ->method('getAppPath') ->with('SomeApp') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -422,20 +422,20 @@ class CheckerTest extends TestCase { ->expects($this->at(0)) ->method('file_get_contents') ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//appinfo/signature.json') - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( '/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ - 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', - 'message' => 'Certificate is not valid for required scope. (Requested: SomeApp, current: CN=AnotherScope)', - ], + 'EXCEPTION' => [ + 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'message' => 'Certificate is not valid for required scope. (Requested: SomeApp, current: CN=AnotherScope)', + ], ]; $this->assertSame($expected, $this->checker->verifyAppSignature('SomeApp')); } @@ -444,18 +444,18 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->once()) ->method('getAppPath') ->with('SomeApp') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -468,14 +468,14 @@ class CheckerTest extends TestCase { ->expects($this->at(0)) ->method('file_get_contents') ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/app//appinfo/signature.json') - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( '/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $this->assertSame([], $this->checker->verifyAppSignature('SomeApp')); } @@ -540,17 +540,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $this->fileAccessHelper ->expects($this->once()) ->method('file_put_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json', - $this->callback(function($signature) use ($expectedSignatureFileData) { - $expectedArray = json_decode($expectedSignatureFileData, true); - $actualArray = json_decode($signature, true); - $this->assertEquals($expectedArray, $actualArray); - return true; + $this->callback(function ($signature) use ($expectedSignatureFileData) { + $expectedArray = json_decode($expectedSignatureFileData, true); + $actualArray = json_decode($signature, true); + $this->assertEquals($expectedArray, $actualArray); + return true; }) ); @@ -575,13 +575,13 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessUnmodified/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessUnmodified/'); $this->fileAccessHelper ->expects($this->once()) ->method('file_put_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessUnmodified//core/signature.json', - $this->callback(function($signature) use ($expectedSignatureFileData) { + $this->callback(function ($signature) use ($expectedSignatureFileData) { $expectedArray = json_decode($expectedSignatureFileData, true); $actualArray = json_decode($signature, true); $this->assertEquals($expectedArray, $actualArray); @@ -611,7 +611,7 @@ class CheckerTest extends TestCase { ->method('file_put_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithInvalidModifiedContent//core/signature.json', - $this->callback(function($signature) use ($expectedSignatureFileData) { + $this->callback(function ($signature) use ($expectedSignatureFileData) { $expectedArray = json_decode($expectedSignatureFileData, true); $actualArray = json_decode($signature, true); $this->assertEquals($expectedArray, $actualArray); @@ -640,13 +640,13 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent'); $this->fileAccessHelper ->expects($this->once()) ->method('file_put_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/core/signature.json', - $this->callback(function($signature) use ($expectedSignatureFileData) { + $this->callback(function ($signature) use ($expectedSignatureFileData) { $expectedArray = json_decode($expectedSignatureFileData, true); $actualArray = json_decode($signature, true); $this->assertEquals($expectedArray, $actualArray); @@ -667,12 +667,12 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $expected = [ 'EXCEPTION' => [ @@ -687,17 +687,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -712,14 +712,14 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $this->assertSame([], $this->checker->verifyCoreSignature()); } @@ -728,17 +728,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent'); $signatureDataFile = '{ "hashes": { ".htaccess": "7e6a7a4d8ee4f3fbc45dd579407c643471575a9d127d1c75f6d0a49e80766c3c587104b2139ef76d2a4bffce3f45777900605aaa49519c9532909b71e5030227", @@ -753,14 +753,14 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/htaccessWithValidModifiedContent/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $this->assertSame([], $this->checker->verifyCoreSignature()); } @@ -769,232 +769,232 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->mimeTypeDetector ->expects($this->once()) ->method('getOnlyDefaultAliases') ->willReturn( - array ( - '_comment' => 'Array of mimetype aliases.', - '_comment2' => 'Any changes you make here will be overwritten on an update of Nextcloud.', - '_comment3' => 'Put any custom mappings in a new file mimetypealiases.json in the config/ folder of Nextcloud', - '_comment4' => 'After any change to mimetypealiases.json run:', - '_comment5' => './occ maintenance:mimetype:update-js', - '_comment6' => 'Otherwise your update won\'t propagate through the system.', - 'application/coreldraw' => 'image', - 'application/epub+zip' => 'text', - 'application/font-sfnt' => 'image', - 'application/font-woff' => 'image', - 'application/gpx+xml' => 'location', - 'application/illustrator' => 'image', - 'application/javascript' => 'text/code', - 'application/json' => 'text/code', - 'application/msaccess' => 'file', - 'application/msexcel' => 'x-office/spreadsheet', - 'application/msonenote' => 'x-office/document', - 'application/mspowerpoint' => 'x-office/presentation', - 'application/msword' => 'x-office/document', - 'application/octet-stream' => 'file', - 'application/postscript' => 'image', - 'application/rss+xml' => 'application/xml', - 'application/vnd.android.package-archive' => 'package/x-generic', - 'application/vnd.lotus-wordpro' => 'x-office/document', - 'application/vnd.garmin.tcx+xml' => 'location', - 'application/vnd.google-earth.kml+xml' => 'location', - 'application/vnd.google-earth.kmz' => 'location', - 'application/vnd.ms-excel' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-fontobject' => 'image', - 'application/vnd.ms-powerpoint' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-visio.drawing.macroEnabled.12' => 'application/vnd.visio', - 'application/vnd.ms-visio.drawing' => 'application/vnd.visio', - 'application/vnd.ms-visio.stencil.macroEnabled.12' => 'application/vnd.visio', - 'application/vnd.ms-visio.stencil' => 'application/vnd.visio', - 'application/vnd.ms-visio.template.macroEnabled.12' => 'application/vnd.visio', - 'application/vnd.ms-visio.template' => 'application/vnd.visio', - 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document', - 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document', - 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', - 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', - 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', - 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', - 'application/vnd.oasis.opendocument.text' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document', - 'application/vnd.visio' => 'x-office/document', - 'application/vnd.wordperfect' => 'x-office/document', - 'application/x-7z-compressed' => 'package/x-generic', - 'application/x-bzip2' => 'package/x-generic', - 'application/x-cbr' => 'text', - 'application/x-compressed' => 'package/x-generic', - 'application/x-dcraw' => 'image', - 'application/x-deb' => 'package/x-generic', - 'application/x-fictionbook+xml' => 'text', - 'application/x-font' => 'image', - 'application/x-gimp' => 'image', - 'application/x-gzip' => 'package/x-generic', - 'application/x-iwork-keynote-sffkey' => 'x-office/presentation', - 'application/x-iwork-numbers-sffnumbers' => 'x-office/spreadsheet', - 'application/x-iwork-pages-sffpages' => 'x-office/document', - 'application/x-mobipocket-ebook' => 'text', - 'application/x-perl' => 'text/code', - 'application/x-photoshop' => 'image', - 'application/x-php' => 'text/code', - 'application/x-rar-compressed' => 'package/x-generic', - 'application/x-tar' => 'package/x-generic', - 'application/x-tex' => 'text', - 'application/xml' => 'text/html', - 'application/yaml' => 'text/code', - 'application/zip' => 'package/x-generic', - 'database' => 'file', - 'httpd/unix-directory' => 'dir', - 'text/css' => 'text/code', - 'text/csv' => 'x-office/spreadsheet', - 'text/html' => 'text/code', - 'text/x-c' => 'text/code', - 'text/x-c++src' => 'text/code', - 'text/x-h' => 'text/code', - 'text/x-java-source' => 'text/code', - 'text/x-ldif' => 'text/code', - 'text/x-python' => 'text/code', - 'text/x-shellscript' => 'text/code', - 'web' => 'text/code', - 'application/internet-shortcut' => 'link', - )); + [ + '_comment' => 'Array of mimetype aliases.', + '_comment2' => 'Any changes you make here will be overwritten on an update of Nextcloud.', + '_comment3' => 'Put any custom mappings in a new file mimetypealiases.json in the config/ folder of Nextcloud', + '_comment4' => 'After any change to mimetypealiases.json run:', + '_comment5' => './occ maintenance:mimetype:update-js', + '_comment6' => 'Otherwise your update won\'t propagate through the system.', + 'application/coreldraw' => 'image', + 'application/epub+zip' => 'text', + 'application/font-sfnt' => 'image', + 'application/font-woff' => 'image', + 'application/gpx+xml' => 'location', + 'application/illustrator' => 'image', + 'application/javascript' => 'text/code', + 'application/json' => 'text/code', + 'application/msaccess' => 'file', + 'application/msexcel' => 'x-office/spreadsheet', + 'application/msonenote' => 'x-office/document', + 'application/mspowerpoint' => 'x-office/presentation', + 'application/msword' => 'x-office/document', + 'application/octet-stream' => 'file', + 'application/postscript' => 'image', + 'application/rss+xml' => 'application/xml', + 'application/vnd.android.package-archive' => 'package/x-generic', + 'application/vnd.lotus-wordpro' => 'x-office/document', + 'application/vnd.garmin.tcx+xml' => 'location', + 'application/vnd.google-earth.kml+xml' => 'location', + 'application/vnd.google-earth.kmz' => 'location', + 'application/vnd.ms-excel' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-fontobject' => 'image', + 'application/vnd.ms-powerpoint' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-visio.drawing.macroEnabled.12' => 'application/vnd.visio', + 'application/vnd.ms-visio.drawing' => 'application/vnd.visio', + 'application/vnd.ms-visio.stencil.macroEnabled.12' => 'application/vnd.visio', + 'application/vnd.ms-visio.stencil' => 'application/vnd.visio', + 'application/vnd.ms-visio.template.macroEnabled.12' => 'application/vnd.visio', + 'application/vnd.ms-visio.template' => 'application/vnd.visio', + 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document', + 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document', + 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', + 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', + 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', + 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', + 'application/vnd.oasis.opendocument.text' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document', + 'application/vnd.visio' => 'x-office/document', + 'application/vnd.wordperfect' => 'x-office/document', + 'application/x-7z-compressed' => 'package/x-generic', + 'application/x-bzip2' => 'package/x-generic', + 'application/x-cbr' => 'text', + 'application/x-compressed' => 'package/x-generic', + 'application/x-dcraw' => 'image', + 'application/x-deb' => 'package/x-generic', + 'application/x-fictionbook+xml' => 'text', + 'application/x-font' => 'image', + 'application/x-gimp' => 'image', + 'application/x-gzip' => 'package/x-generic', + 'application/x-iwork-keynote-sffkey' => 'x-office/presentation', + 'application/x-iwork-numbers-sffnumbers' => 'x-office/spreadsheet', + 'application/x-iwork-pages-sffpages' => 'x-office/document', + 'application/x-mobipocket-ebook' => 'text', + 'application/x-perl' => 'text/code', + 'application/x-photoshop' => 'image', + 'application/x-php' => 'text/code', + 'application/x-rar-compressed' => 'package/x-generic', + 'application/x-tar' => 'package/x-generic', + 'application/x-tex' => 'text', + 'application/xml' => 'text/html', + 'application/yaml' => 'text/code', + 'application/zip' => 'package/x-generic', + 'database' => 'file', + 'httpd/unix-directory' => 'dir', + 'text/css' => 'text/code', + 'text/csv' => 'x-office/spreadsheet', + 'text/html' => 'text/code', + 'text/x-c' => 'text/code', + 'text/x-c++src' => 'text/code', + 'text/x-h' => 'text/code', + 'text/x-java-source' => 'text/code', + 'text/x-ldif' => 'text/code', + 'text/x-python' => 'text/code', + 'text/x-shellscript' => 'text/code', + 'web' => 'text/code', + 'application/internet-shortcut' => 'link', + ]); $this->mimeTypeDetector ->expects($this->once()) ->method('getAllAliases') ->willReturn( - array ( - '_comment' => 'Array of mimetype aliases.', - '_comment2' => 'Any changes you make here will be overwritten on an update of Nextcloud.', - '_comment3' => 'Put any custom mappings in a new file mimetypealiases.json in the config/ folder of Nextcloud', - '_comment4' => 'After any change to mimetypealiases.json run:', - '_comment5' => './occ maintenance:mimetype:update-js', - '_comment6' => 'Otherwise your update won\'t propagate through the system.', - 'application/coreldraw' => 'image', - 'application/test' => 'image', - 'application/epub+zip' => 'text', - 'application/font-sfnt' => 'image', - 'application/font-woff' => 'image', - 'application/gpx+xml' => 'location', - 'application/illustrator' => 'image', - 'application/javascript' => 'text/code', - 'application/json' => 'text/code', - 'application/msaccess' => 'file', - 'application/msexcel' => 'x-office/spreadsheet', - 'application/msonenote' => 'x-office/document', - 'application/mspowerpoint' => 'x-office/presentation', - 'application/msword' => 'x-office/document', - 'application/octet-stream' => 'file', - 'application/postscript' => 'image', - 'application/rss+xml' => 'application/xml', - 'application/vnd.android.package-archive' => 'package/x-generic', - 'application/vnd.lotus-wordpro' => 'x-office/document', - 'application/vnd.garmin.tcx+xml' => 'location', - 'application/vnd.google-earth.kml+xml' => 'location', - 'application/vnd.google-earth.kmz' => 'location', - 'application/vnd.ms-excel' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet', - 'application/vnd.ms-fontobject' => 'image', - 'application/vnd.ms-powerpoint' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation', - 'application/vnd.ms-visio.drawing.macroEnabled.12' => 'application/vnd.visio', - 'application/vnd.ms-visio.drawing' => 'application/vnd.visio', - 'application/vnd.ms-visio.stencil.macroEnabled.12' => 'application/vnd.visio', - 'application/vnd.ms-visio.stencil' => 'application/vnd.visio', - 'application/vnd.ms-visio.template.macroEnabled.12' => 'application/vnd.visio', - 'application/vnd.ms-visio.template' => 'application/vnd.visio', - 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document', - 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document', - 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', - 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', - 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', - 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', - 'application/vnd.oasis.opendocument.text' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', - 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document', - 'application/vnd.visio' => 'x-office/document', - 'application/vnd.wordperfect' => 'x-office/document', - 'application/x-7z-compressed' => 'package/x-generic', - 'application/x-bzip2' => 'package/x-generic', - 'application/x-cbr' => 'text', - 'application/x-compressed' => 'package/x-generic', - 'application/x-dcraw' => 'image', - 'application/x-deb' => 'package/x-generic', - 'application/x-fictionbook+xml' => 'text', - 'application/x-font' => 'image', - 'application/x-gimp' => 'image', - 'application/x-gzip' => 'package/x-generic', - 'application/x-iwork-keynote-sffkey' => 'x-office/presentation', - 'application/x-iwork-numbers-sffnumbers' => 'x-office/spreadsheet', - 'application/x-iwork-pages-sffpages' => 'x-office/document', - 'application/x-mobipocket-ebook' => 'text', - 'application/x-perl' => 'text/code', - 'application/x-photoshop' => 'image', - 'application/x-php' => 'text/code', - 'application/x-rar-compressed' => 'package/x-generic', - 'application/x-tar' => 'package/x-generic', - 'application/x-tex' => 'text', - 'application/xml' => 'text/html', - 'application/yaml' => 'text/code', - 'application/zip' => 'package/x-generic', - 'database' => 'file', - 'httpd/unix-directory' => 'dir', - 'text/css' => 'text/code', - 'text/csv' => 'x-office/spreadsheet', - 'text/html' => 'text/code', - 'text/x-c' => 'text/code', - 'text/x-c++src' => 'text/code', - 'text/x-h' => 'text/code', - 'text/x-java-source' => 'text/code', - 'text/x-ldif' => 'text/code', - 'text/x-python' => 'text/code', - 'text/x-shellscript' => 'text/code', - 'web' => 'text/code', - 'application/internet-shortcut' => 'link', - )); + [ + '_comment' => 'Array of mimetype aliases.', + '_comment2' => 'Any changes you make here will be overwritten on an update of Nextcloud.', + '_comment3' => 'Put any custom mappings in a new file mimetypealiases.json in the config/ folder of Nextcloud', + '_comment4' => 'After any change to mimetypealiases.json run:', + '_comment5' => './occ maintenance:mimetype:update-js', + '_comment6' => 'Otherwise your update won\'t propagate through the system.', + 'application/coreldraw' => 'image', + 'application/test' => 'image', + 'application/epub+zip' => 'text', + 'application/font-sfnt' => 'image', + 'application/font-woff' => 'image', + 'application/gpx+xml' => 'location', + 'application/illustrator' => 'image', + 'application/javascript' => 'text/code', + 'application/json' => 'text/code', + 'application/msaccess' => 'file', + 'application/msexcel' => 'x-office/spreadsheet', + 'application/msonenote' => 'x-office/document', + 'application/mspowerpoint' => 'x-office/presentation', + 'application/msword' => 'x-office/document', + 'application/octet-stream' => 'file', + 'application/postscript' => 'image', + 'application/rss+xml' => 'application/xml', + 'application/vnd.android.package-archive' => 'package/x-generic', + 'application/vnd.lotus-wordpro' => 'x-office/document', + 'application/vnd.garmin.tcx+xml' => 'location', + 'application/vnd.google-earth.kml+xml' => 'location', + 'application/vnd.google-earth.kmz' => 'location', + 'application/vnd.ms-excel' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.addin.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.sheet.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-excel.template.macroEnabled.12' => 'x-office/spreadsheet', + 'application/vnd.ms-fontobject' => 'image', + 'application/vnd.ms-powerpoint' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.addin.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.presentation.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-powerpoint.template.macroEnabled.12' => 'x-office/presentation', + 'application/vnd.ms-visio.drawing.macroEnabled.12' => 'application/vnd.visio', + 'application/vnd.ms-visio.drawing' => 'application/vnd.visio', + 'application/vnd.ms-visio.stencil.macroEnabled.12' => 'application/vnd.visio', + 'application/vnd.ms-visio.stencil' => 'application/vnd.visio', + 'application/vnd.ms-visio.template.macroEnabled.12' => 'application/vnd.visio', + 'application/vnd.ms-visio.template' => 'application/vnd.visio', + 'application/vnd.ms-word.document.macroEnabled.12' => 'x-office/document', + 'application/vnd.ms-word.template.macroEnabled.12' => 'x-office/document', + 'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation', + 'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation', + 'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet', + 'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet', + 'application/vnd.oasis.opendocument.text' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-master' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-template' => 'x-office/document', + 'application/vnd.oasis.opendocument.text-web' => 'x-office/document', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.presentationml.template' => 'x-office/presentation', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.template' => 'x-office/spreadsheet', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document', + 'application/vnd.visio' => 'x-office/document', + 'application/vnd.wordperfect' => 'x-office/document', + 'application/x-7z-compressed' => 'package/x-generic', + 'application/x-bzip2' => 'package/x-generic', + 'application/x-cbr' => 'text', + 'application/x-compressed' => 'package/x-generic', + 'application/x-dcraw' => 'image', + 'application/x-deb' => 'package/x-generic', + 'application/x-fictionbook+xml' => 'text', + 'application/x-font' => 'image', + 'application/x-gimp' => 'image', + 'application/x-gzip' => 'package/x-generic', + 'application/x-iwork-keynote-sffkey' => 'x-office/presentation', + 'application/x-iwork-numbers-sffnumbers' => 'x-office/spreadsheet', + 'application/x-iwork-pages-sffpages' => 'x-office/document', + 'application/x-mobipocket-ebook' => 'text', + 'application/x-perl' => 'text/code', + 'application/x-photoshop' => 'image', + 'application/x-php' => 'text/code', + 'application/x-rar-compressed' => 'package/x-generic', + 'application/x-tar' => 'package/x-generic', + 'application/x-tex' => 'text', + 'application/xml' => 'text/html', + 'application/yaml' => 'text/code', + 'application/zip' => 'package/x-generic', + 'database' => 'file', + 'httpd/unix-directory' => 'dir', + 'text/css' => 'text/code', + 'text/csv' => 'x-office/spreadsheet', + 'text/html' => 'text/code', + 'text/x-c' => 'text/code', + 'text/x-c++src' => 'text/code', + 'text/x-h' => 'text/code', + 'text/x-java-source' => 'text/code', + 'text/x-ldif' => 'text/code', + 'text/x-python' => 'text/code', + 'text/x-shellscript' => 'text/code', + 'web' => 'text/code', + 'application/internet-shortcut' => 'link', + ]); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified'); $signatureDataFile = '{ "hashes": { "mimetypelist.js": "dc48de7ad4baa030c5e563350c9a80b274bad783f6f5adbf1595ecef6c6a32e52890a24cb26cddb0aa20193ba52c001150c68d8bfb567f0aed566f4029a190a3" @@ -1008,34 +1008,33 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified/core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/mimetypeListModified/resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $this->assertSame([], $this->checker->verifyCoreSignature()); - } public function testVerifyCoreSignatureWithValidSignatureDataAndNotAlphabeticOrder() { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -1050,14 +1049,14 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $this->assertSame([], $this->checker->verifyCoreSignature()); } @@ -1066,17 +1065,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "tampered", @@ -1091,20 +1090,20 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ - 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', - 'message' => 'Signature could not get verified.', - ] + 'EXCEPTION' => [ + 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'message' => 'Signature could not get verified.', + ] ]; $this->assertSame($expected, $this->checker->verifyCoreSignature()); } @@ -1113,17 +1112,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -1138,34 +1137,34 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/appWithInvalidData//resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ - 'INVALID_HASH' => [ - 'AnotherFile.txt' => [ - 'expected' => '1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112', - 'current' => '7322348ba269c6d5522efe02f424fa3a0da319a7cd9c33142a5afe32a2d9af2da3a411f086fcfc96ff4301ea566f481dba0960c2abeef3594c4d930462f6584c', - ], + 'INVALID_HASH' => [ + 'AnotherFile.txt' => [ + 'expected' => '1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112', + 'current' => '7322348ba269c6d5522efe02f424fa3a0da319a7cd9c33142a5afe32a2d9af2da3a411f086fcfc96ff4301ea566f481dba0960c2abeef3594c4d930462f6584c', ], - 'FILE_MISSING' => [ - 'subfolder/file.txt' => [ - 'expected' => '410738545fb623c0a5c8a71f561e48ea69e3ada0981a455e920a5ae9bf17c6831ae654df324f9328ff8453de179276ae51931cca0fa71fe8ccde6c083ca0574b', - 'current' => '', - ], + ], + 'FILE_MISSING' => [ + 'subfolder/file.txt' => [ + 'expected' => '410738545fb623c0a5c8a71f561e48ea69e3ada0981a455e920a5ae9bf17c6831ae654df324f9328ff8453de179276ae51931cca0fa71fe8ccde6c083ca0574b', + 'current' => '', ], - 'EXTRA_FILE' => [ - 'UnecessaryFile' => [ - 'expected' => '', - 'current' => 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', - ], + ], + 'EXTRA_FILE' => [ + 'UnecessaryFile' => [ + 'expected' => '', + 'current' => 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', ], + ], ]; $this->assertSame($expected, $this->checker->verifyCoreSignature()); @@ -1175,17 +1174,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -1200,20 +1199,20 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ - 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', - 'message' => 'Certificate is not valid.', - ] + 'EXCEPTION' => [ + 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'message' => 'Certificate is not valid.', + ] ]; $this->assertSame($expected, $this->checker->verifyCoreSignature()); } @@ -1222,17 +1221,17 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->environmentHelper ->expects($this->any()) ->method('getServerRoot') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/app/')); + ->willReturn(\OC::$SERVERROOT . '/tests/data/integritycheck/app/'); $signatureDataFile = '{ "hashes": { "AnotherFile.txt": "1570ca9420e37629de4328f48c51da29840ddeaa03ae733da4bf1d854b8364f594aac560601270f9e1797ed4cd57c1aea87bf44cf4245295c94f2e935a2f0112", @@ -1247,20 +1246,20 @@ class CheckerTest extends TestCase { ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//core/signature.json' ) - ->will($this->returnValue($signatureDataFile)); + ->willReturn($signatureDataFile); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') ->with( \OC::$SERVERROOT . '/tests/data/integritycheck/app//resources/codesigning/root.crt' ) - ->will($this->returnValue(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt'))); + ->willReturn(file_get_contents(__DIR__ .'/../../data/integritycheck/root.crt')); $expected = [ - 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', - 'message' => 'Certificate is not valid for required scope. (Requested: core, current: CN=SomeApp)', - ] + 'EXCEPTION' => [ + 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'message' => 'Certificate is not valid for required scope. (Requested: core, current: CN=SomeApp)', + ] ]; $this->assertSame($expected, $this->checker->verifyCoreSignature()); } @@ -1289,17 +1288,17 @@ class CheckerTest extends TestCase { $this->appLocator ->expects($this->at(0)) ->method('getAllApps') - ->will($this->returnValue([ + ->willReturn([ 'files', 'calendar', 'contacts', 'dav', - ])); + ]); $this->appManager ->expects($this->at(0)) ->method('isShipped') ->with('files') - ->will($this->returnValue(true)); + ->willReturn(true); $this->checker ->expects($this->at(1)) ->method('verifyAppSignature') @@ -1308,17 +1307,17 @@ class CheckerTest extends TestCase { ->expects($this->at(1)) ->method('isShipped') ->with('calendar') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->at(1)) ->method('getAppPath') ->with('calendar') - ->will($this->returnValue('/apps/calendar')); + ->willReturn('/apps/calendar'); $this->fileAccessHelper ->expects($this->at(0)) ->method('file_exists') ->with('/apps/calendar/appinfo/signature.json') - ->will($this->returnValue(true)); + ->willReturn(true); $this->checker ->expects($this->at(2)) ->method('verifyAppSignature') @@ -1327,22 +1326,22 @@ class CheckerTest extends TestCase { ->expects($this->at(2)) ->method('isShipped') ->with('contacts') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appLocator ->expects($this->at(2)) ->method('getAppPath') ->with('contacts') - ->will($this->returnValue('/apps/contacts')); + ->willReturn('/apps/contacts'); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_exists') ->with('/apps/contacts/appinfo/signature.json') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(3)) ->method('isShipped') ->with('dav') - ->will($this->returnValue(true)); + ->willReturn(true); $this->checker ->expects($this->at(3)) ->method('verifyAppSignature') @@ -1359,12 +1358,12 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue('stable')); + ->willReturn('stable'); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(true)); + ->willReturn(true); $expected = []; $this->assertSame($expected, $this->checker->verifyAppSignature('SomeApp')); @@ -1389,12 +1388,12 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue($channel)); + ->willReturn($channel); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertSame($isCodeSigningEnforced, $this->checker->isCodeCheckEnforced()); } @@ -1407,12 +1406,12 @@ class CheckerTest extends TestCase { $this->environmentHelper ->expects($this->once()) ->method('getChannel') - ->will($this->returnValue($channel)); + ->willReturn($channel); $this->config ->expects($this->any()) ->method('getSystemValue') ->with('integrity.check.disabled', false) - ->will($this->returnValue(true)); + ->willReturn(true); $this->assertFalse(self::invokePrivate($this->checker, 'isCodeCheckEnforced')); } diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index c75bfba5b99..7e1fb8c8886 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -419,7 +419,7 @@ class FactoryTest extends TestCase { ->willReturn($availableLanguages); $factory->expects($this->any()) - ->method('respectDefaultLanguage')->willReturnCallback(function($app, $lang) { + ->method('respectDefaultLanguage')->willReturnCallback(function ($app, $lang) { return $lang; }); @@ -510,15 +510,15 @@ class FactoryTest extends TestCase { $this->config->expects($this->any()) ->method('getSystemValue') - ->will($this->returnCallback(function($var, $default) use ($defaultLang) { + ->willReturnCallback(function ($var, $default) use ($defaultLang) { if ($var === 'installed') { return true; - } else if ($var === 'default_language') { + } elseif ($var === 'default_language') { return $defaultLang; } else { return $default; } - })); + }); if ($loggedIn) { $user = $this->getMockBuilder(IUser::class) @@ -549,22 +549,21 @@ class FactoryTest extends TestCase { $factory = $this->getFactory(['languageExists', 'findAvailableLanguages', 'respectDefaultLanguage']); $factory->expects($this->any()) ->method('languageExists') - ->will($this->returnCallback(function ($app, $lang) use ($availableLang) { + ->willReturnCallback(function ($app, $lang) use ($availableLang) { return in_array($lang, $availableLang); - })); + }); $factory->expects($this->any()) ->method('findAvailableLanguages') - ->will($this->returnCallback(function ($app) use ($availableLang) { + ->willReturnCallback(function ($app) use ($availableLang) { return $availableLang; - })); + }); $factory->expects($this->any()) - ->method('respectDefaultLanguage')->willReturnCallback(function($app, $lang) { - return $lang; + ->method('respectDefaultLanguage')->willReturnCallback(function ($app, $lang) { + return $lang; }); $lang = $factory->findLanguage(null); $this->assertSame($expected, $lang); - } public function dataTestRespectDefaultLanguage() { @@ -611,11 +610,11 @@ class FactoryTest extends TestCase { public function testGetLanguageIterator(bool $hasSession, IUser $iUserMock = null) { $factory = $this->getFactory(); - if($iUserMock === null) { + if ($iUserMock === null) { $matcher = $this->userSession->expects($this->once()) ->method('getUser'); - if($hasSession) { + if ($hasSession) { $matcher->willReturn($this->createMock(IUser::class)); } else { $this->expectException(\RuntimeException::class); @@ -625,5 +624,4 @@ class FactoryTest extends TestCase { $iterator = $factory->getLanguageIterator($iUserMock); $this->assertInstanceOf(ILanguageIterator::class, $iterator); } - } diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php index dd0fa000b7e..0de09386fba 100644 --- a/tests/lib/L10N/L10nTest.php +++ b/tests/lib/L10N/L10nTest.php @@ -8,7 +8,6 @@ namespace Test\L10N; - use DateTime; use OC\L10N\Factory; use OC\L10N\L10N; @@ -78,39 +77,39 @@ class L10nTest extends TestCase { } public function localizationData() { - return array( + return [ // timestamp as string - array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', '1234567890'), - array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', '1234567890'), - array('February 13, 2009', 'en', 'en_US', 'date', '1234567890'), - array('13. Februar 2009', 'de', 'de_DE', 'date', '1234567890'), - array('11:31:30 PM GMT+0', 'en', 'en_US', 'time', '1234567890'), - array('23:31:30 GMT+0', 'de', 'de_DE', 'time', '1234567890'), + ['February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', '1234567890'], + ['13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', '1234567890'], + ['February 13, 2009', 'en', 'en_US', 'date', '1234567890'], + ['13. Februar 2009', 'de', 'de_DE', 'date', '1234567890'], + ['11:31:30 PM GMT+0', 'en', 'en_US', 'time', '1234567890'], + ['23:31:30 GMT+0', 'de', 'de_DE', 'time', '1234567890'], // timestamp as int - array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', 1234567890), - array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', 1234567890), - array('February 13, 2009', 'en', 'en_US', 'date', 1234567890), - array('13. Februar 2009', 'de', 'de_DE', 'date', 1234567890), - array('11:31:30 PM GMT+0', 'en', 'en_US', 'time', 1234567890), - array('23:31:30 GMT+0', 'de', 'de_DE', 'time', 1234567890), + ['February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', 1234567890], + ['13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', 1234567890], + ['February 13, 2009', 'en', 'en_US', 'date', 1234567890], + ['13. Februar 2009', 'de', 'de_DE', 'date', 1234567890], + ['11:31:30 PM GMT+0', 'en', 'en_US', 'time', 1234567890], + ['23:31:30 GMT+0', 'de', 'de_DE', 'time', 1234567890], // DateTime object - array('February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', new DateTime('@1234567890')), - array('13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', new DateTime('@1234567890')), - array('February 13, 2009', 'en', 'en_US', 'date', new DateTime('@1234567890')), - array('13. Februar 2009', 'de', 'de_DE', 'date', new DateTime('@1234567890')), - array('11:31:30 PM GMT+0', 'en', 'en_US', 'time', new DateTime('@1234567890')), - array('23:31:30 GMT+0', 'de', 'de_DE', 'time', new DateTime('@1234567890')), + ['February 13, 2009 at 11:31:30 PM GMT+0', 'en', 'en_US', 'datetime', new DateTime('@1234567890')], + ['13. Februar 2009 um 23:31:30 GMT+0', 'de', 'de_DE', 'datetime', new DateTime('@1234567890')], + ['February 13, 2009', 'en', 'en_US', 'date', new DateTime('@1234567890')], + ['13. Februar 2009', 'de', 'de_DE', 'date', new DateTime('@1234567890')], + ['11:31:30 PM GMT+0', 'en', 'en_US', 'time', new DateTime('@1234567890')], + ['23:31:30 GMT+0', 'de', 'de_DE', 'time', new DateTime('@1234567890')], // en_GB - array('13 February 2009 at 23:31:30 GMT+0', 'en_GB', 'en_GB', 'datetime', new DateTime('@1234567890')), - array('13 February 2009', 'en_GB', 'en_GB', 'date', new DateTime('@1234567890')), - array('23:31:30 GMT+0', 'en_GB', 'en_GB', 'time', new DateTime('@1234567890')), - array('13 February 2009 at 23:31:30 GMT+0', 'en-GB', 'en_GB', 'datetime', new DateTime('@1234567890')), - array('13 February 2009', 'en-GB', 'en_GB', 'date', new DateTime('@1234567890')), - array('23:31:30 GMT+0', 'en-GB', 'en_GB', 'time', new DateTime('@1234567890')), - ); + ['13 February 2009 at 23:31:30 GMT+0', 'en_GB', 'en_GB', 'datetime', new DateTime('@1234567890')], + ['13 February 2009', 'en_GB', 'en_GB', 'date', new DateTime('@1234567890')], + ['23:31:30 GMT+0', 'en_GB', 'en_GB', 'time', new DateTime('@1234567890')], + ['13 February 2009 at 23:31:30 GMT+0', 'en-GB', 'en_GB', 'datetime', new DateTime('@1234567890')], + ['13 February 2009', 'en-GB', 'en_GB', 'date', new DateTime('@1234567890')], + ['23:31:30 GMT+0', 'en-GB', 'en_GB', 'time', new DateTime('@1234567890')], + ]; } /** @@ -122,10 +121,10 @@ class L10nTest extends TestCase { } public function firstDayData() { - return array( - array(1, 'de', 'de_DE'), - array(0, 'en', 'en_US'), - ); + return [ + [1, 'de', 'de_DE'], + [0, 'en', 'en_US'], + ]; } /** @@ -140,10 +139,10 @@ class L10nTest extends TestCase { } public function jsDateData() { - return array( - array('dd.MM.yy', 'de', 'de_DE'), - array('M/d/yy', 'en', 'en_US'), - ); + return [ + ['dd.MM.yy', 'de', 'de_DE'], + ['M/d/yy', 'en', 'en_US'], + ]; } /** diff --git a/tests/lib/LargeFileHelperGetFileSizeTest.php b/tests/lib/LargeFileHelperGetFileSizeTest.php index 530615f46b4..3ad8f5b8806 100644 --- a/tests/lib/LargeFileHelperGetFileSizeTest.php +++ b/tests/lib/LargeFileHelperGetFileSizeTest.php @@ -9,9 +9,9 @@ namespace Test; /** -* Tests whether LargeFileHelper is able to determine file size at all. -* Large files are not considered yet. -*/ + * Tests whether LargeFileHelper is able to determine file size at all. + * Large files are not considered yet. + */ class LargeFileHelperGetFileSizeTest extends TestCase { /** @var string */ protected $filename; diff --git a/tests/lib/LegacyHelperTest.php b/tests/lib/LegacyHelperTest.php index 21d5dbc8bab..5c640e91284 100644 --- a/tests/lib/LegacyHelperTest.php +++ b/tests/lib/LegacyHelperTest.php @@ -27,34 +27,32 @@ class LegacyHelperTest extends \Test\TestCase { /** * @dataProvider humanFileSizeProvider */ - public function testHumanFileSize($expected, $input) - { + public function testHumanFileSize($expected, $input) { $result = OC_Helper::humanFileSize($input); $this->assertEquals($expected, $result); } - public function humanFileSizeProvider() - { - return array( - array('0 B', 0), - array('1 KB', 1024), - array('9.5 MB', 10000000), - array('1.3 GB', 1395864371), - array('465.7 GB', 500000000000), - array('454.7 TB', 500000000000000), - array('444.1 PB', 500000000000000000), - ); + public function humanFileSizeProvider() { + return [ + ['0 B', 0], + ['1 KB', 1024], + ['9.5 MB', 10000000], + ['1.3 GB', 1395864371], + ['465.7 GB', 500000000000], + ['454.7 TB', 500000000000000], + ['444.1 PB', 500000000000000000], + ]; } /** * @dataProvider providesComputerFileSize */ - function testComputerFileSize($expected, $input) { + public function testComputerFileSize($expected, $input) { $result = OC_Helper::computerFileSize($input); $this->assertEquals($expected, $result); } - function providesComputerFileSize(){ + public function providesComputerFileSize() { return [ [0.0, "0 B"], [1024.0, "1 KB"], @@ -65,37 +63,37 @@ class LegacyHelperTest extends \Test\TestCase { ]; } - function testMb_array_change_key_case() { - $arrayStart = array( + public function testMb_array_change_key_case() { + $arrayStart = [ "Foo" => "bar", "Bar" => "foo", - ); - $arrayResult = array( + ]; + $arrayResult = [ "foo" => "bar", "bar" => "foo", - ); + ]; $result = OC_Helper::mb_array_change_key_case($arrayStart); $expected = $arrayResult; $this->assertEquals($result, $expected); - $arrayStart = array( + $arrayStart = [ "foo" => "bar", "bar" => "foo", - ); - $arrayResult = array( + ]; + $arrayResult = [ "FOO" => "bar", "BAR" => "foo", - ); + ]; $result = OC_Helper::mb_array_change_key_case($arrayStart, MB_CASE_UPPER); $expected = $arrayResult; $this->assertEquals($result, $expected); } - function testRecursiveArraySearch() { - $haystack = array( + public function testRecursiveArraySearch() { + $haystack = [ "Foo" => "own", "Bar" => "Cloud", - ); + ]; $result = OC_Helper::recursiveArraySearch($haystack, "own"); $expected = "Foo"; @@ -105,63 +103,63 @@ class LegacyHelperTest extends \Test\TestCase { $this->assertFalse($result); } - function testBuildNotExistingFileNameForView() { + public function testBuildNotExistingFileNameForView() { $viewMock = $this->createMock(View::class); $this->assertEquals('/filename', OC_Helper::buildNotExistingFileNameForView('/', 'filename', $viewMock)); $this->assertEquals('dir/filename.ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename.ext exists + ->willReturn(true); // filename.ext exists $this->assertEquals('dir/filename (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename.ext exists + ->willReturn(true); // filename.ext exists $viewMock->expects($this->at(1)) ->method('file_exists') - ->will($this->returnValue(true)); // filename (2).ext exists + ->willReturn(true); // filename (2).ext exists $this->assertEquals('dir/filename (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename (1).ext exists + ->willReturn(true); // filename (1).ext exists $this->assertEquals('dir/filename (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (1).ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename (2).ext exists + ->willReturn(true); // filename (2).ext exists $this->assertEquals('dir/filename (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (2).ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename (2).ext exists + ->willReturn(true); // filename (2).ext exists $viewMock->expects($this->at(1)) ->method('file_exists') - ->will($this->returnValue(true)); // filename (3).ext exists + ->willReturn(true); // filename (3).ext exists $this->assertEquals('dir/filename (4).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (2).ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename(1).ext exists + ->willReturn(true); // filename(1).ext exists $this->assertEquals('dir/filename(2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1).ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename(1) (1).ext exists + ->willReturn(true); // filename(1) (1).ext exists $this->assertEquals('dir/filename(1) (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (1).ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename(1) (1).ext exists + ->willReturn(true); // filename(1) (1).ext exists $viewMock->expects($this->at(1)) ->method('file_exists') - ->will($this->returnValue(true)); // filename(1) (2).ext exists + ->willReturn(true); // filename(1) (2).ext exists $this->assertEquals('dir/filename(1) (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (1).ext', $viewMock)); $viewMock->expects($this->at(0)) ->method('file_exists') - ->will($this->returnValue(true)); // filename(1) (2) (3).ext exists + ->willReturn(true); // filename(1) (2) (3).ext exists $this->assertEquals('dir/filename(1) (2) (4).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (2) (3).ext', $viewMock)); } @@ -169,7 +167,6 @@ class LegacyHelperTest extends \Test\TestCase { * @dataProvider streamCopyDataProvider */ public function testStreamCopy($expectedCount, $expectedResult, $source, $target) { - if (is_string($source)) { $source = fopen($source, 'r'); } @@ -191,13 +188,13 @@ class LegacyHelperTest extends \Test\TestCase { } - function streamCopyDataProvider() { - return array( - array(0, false, false, false), - array(0, false, \OC::$SERVERROOT . '/tests/data/lorem.txt', false), - array(filesize(\OC::$SERVERROOT . '/tests/data/lorem.txt'), true, \OC::$SERVERROOT . '/tests/data/lorem.txt', \OC::$SERVERROOT . '/tests/data/lorem-copy.txt'), - array(3670, true, \OC::$SERVERROOT . '/tests/data/testimage.png', \OC::$SERVERROOT . '/tests/data/testimage-copy.png'), - ); + public function streamCopyDataProvider() { + return [ + [0, false, false, false], + [0, false, \OC::$SERVERROOT . '/tests/data/lorem.txt', false], + [filesize(\OC::$SERVERROOT . '/tests/data/lorem.txt'), true, \OC::$SERVERROOT . '/tests/data/lorem.txt', \OC::$SERVERROOT . '/tests/data/lorem-copy.txt'], + [3670, true, \OC::$SERVERROOT . '/tests/data/testimage.png', \OC::$SERVERROOT . '/tests/data/testimage-copy.png'], + ]; } /** @@ -234,7 +231,7 @@ class LegacyHelperTest extends \Test\TestCase { * @return mixed * @deprecated Please extend \Test\TestCase and use self::invokePrivate() then */ - public static function invokePrivate($object, $methodName, array $parameters = array()) { + public static function invokePrivate($object, $methodName, array $parameters = []) { return parent::invokePrivate($object, $methodName, $parameters); } } diff --git a/tests/lib/Lock/DBLockingProviderTest.php b/tests/lib/Lock/DBLockingProviderTest.php index 73a7b6c3f83..ac58538284c 100644 --- a/tests/lib/Lock/DBLockingProviderTest.php +++ b/tests/lib/Lock/DBLockingProviderTest.php @@ -54,9 +54,9 @@ class DBLockingProviderTest extends LockingProvider { $this->timeFactory = $this->createMock(ITimeFactory::class); $this->timeFactory->expects($this->any()) ->method('getTime') - ->will($this->returnCallback(function () { + ->willReturnCallback(function () { return $this->currentTime; - })); + }); parent::setUp(); } diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php index 5bdf3b44ba0..c0349814570 100644 --- a/tests/lib/Lockdown/Filesystem/NullStorageTest.php +++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php @@ -31,7 +31,7 @@ use OC\Lockdown\Filesystem\NullStorage; use OCP\Files\Storage; use Test\TestCase; -class NullStorageTest extends TestCase { +class NullStorageTest extends TestCase { /** @var NullStorage */ private $storage; diff --git a/tests/lib/Lockdown/LockdownManagerTest.php b/tests/lib/Lockdown/LockdownManagerTest.php index 7b52994d381..2f9a410b7e3 100644 --- a/tests/lib/Lockdown/LockdownManagerTest.php +++ b/tests/lib/Lockdown/LockdownManagerTest.php @@ -32,7 +32,7 @@ class LockdownManagerTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->sessionCallback = function() { + $this->sessionCallback = function () { return $this->createMock(ISession::class); }; } diff --git a/tests/lib/Log/FileTest.php b/tests/lib/Log/FileTest.php index 0bbcdc0a23c..937b3c75448 100644 --- a/tests/lib/Log/FileTest.php +++ b/tests/lib/Log/FileTest.php @@ -24,8 +24,7 @@ use Test\TestCase; /** * Class FileTest */ -class FileTest extends TestCase -{ +class FileTest extends TestCase { private $restore_logfile; private $restore_logdateformat; @@ -47,7 +46,7 @@ class FileTest extends TestCase $config->getValue("logfile", $this->restore_logfile); } else { $config->deleteValue("logfile"); - } + } if (isset($this->restore_logdateformat)) { $config->getValue("logdateformat", $this->restore_logdateformat); } else { @@ -75,8 +74,5 @@ class FileTest extends TestCase $values = (array) json_decode($line); $microseconds = $values['time']; $this->assertNotEquals(0, $microseconds); - } - - } diff --git a/tests/lib/Log/LogFactoryTest.php b/tests/lib/Log/LogFactoryTest.php index 37dbf1d97b8..e4725a3bc1a 100644 --- a/tests/lib/Log/LogFactoryTest.php +++ b/tests/lib/Log/LogFactoryTest.php @@ -23,13 +23,13 @@ */ namespace Test\Log; + use OC\Log\Errorlog; use OC\Log\File; use OC\Log\LogFactory; use OC\Log\Syslog; use OC\Log\Systemdlog; use OC\SystemConfig; -use OCP\IConfig; use OCP\IServerContainer; use Test\TestCase; diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php index fa4e481ac48..5ed7b4c9b38 100644 --- a/tests/lib/LoggerTest.php +++ b/tests/lib/LoggerTest.php @@ -37,9 +37,9 @@ class LoggerTest extends TestCase implements IWriter { public function testInterpolation() { $logger = $this->logger; - $logger->warning('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); + $logger->warning('{Message {nothing} {user} {foo.bar} a}', ['user' => 'Bob', 'foo.bar' => 'Bar']); - $expected = array('2 {Message {nothing} Bob Bar a}'); + $expected = ['2 {Message {nothing} Bob Bar a}']; $this->assertEquals($expected, $this->getLogs()); } @@ -96,7 +96,7 @@ class LoggerTest extends TestCase implements IWriter { $this->logger->logException($e); $logLines = $this->getLogs(); - foreach($logLines as $logLine) { + foreach ($logLines as $logLine) { if (is_array($logLine)) { $logLine = json_encode($logLine); } @@ -118,7 +118,7 @@ class LoggerTest extends TestCase implements IWriter { $this->logger->logException($e); $logLines = $this->getLogs(); - foreach($logLines as $logLine) { + foreach ($logLines as $logLine) { if (is_array($logLine)) { $logLine = json_encode($logLine); } @@ -140,7 +140,7 @@ class LoggerTest extends TestCase implements IWriter { $this->logger->logException($e); $logLines = $this->getLogs(); - foreach($logLines as $logLine) { + foreach ($logLines as $logLine) { if (is_array($logLine)) { $logLine = json_encode($logLine); } @@ -162,7 +162,7 @@ class LoggerTest extends TestCase implements IWriter { $this->logger->logException($e); $logLines = $this->getLogs(); - foreach($logLines as $logLine) { + foreach ($logLines as $logLine) { if (is_array($logLine)) { $logLine = json_encode($logLine); } @@ -176,7 +176,7 @@ class LoggerTest extends TestCase implements IWriter { * @dataProvider userAndPasswordData */ public function testDetectclosure(string $user, string $password): void { - $a = function($user, $password) { + $a = function ($user, $password) { throw new \Exception('test'); }; $this->registry->expects($this->once()) @@ -189,7 +189,7 @@ class LoggerTest extends TestCase implements IWriter { } $logLines = $this->getLogs(); - foreach($logLines as $logLine) { + foreach ($logLines as $logLine) { if (is_array($logLine)) { $logLine = json_encode($logLine); } diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php index d48826ff5c5..a900b1fe47d 100644 --- a/tests/lib/Mail/EMailTemplateTest.php +++ b/tests/lib/Mail/EMailTemplateTest.php @@ -27,6 +27,7 @@ use OC\Mail\EMailTemplate; use OCP\Defaults; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\L10N\IFactory; use Test\TestCase; class EMailTemplateTest extends TestCase { @@ -34,7 +35,7 @@ class EMailTemplateTest extends TestCase { private $defaults; /** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */ private $urlGenerator; - /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IFactory|\PHPUnit_Framework_MockObject_MockObject */ private $l10n; /** @var EMailTemplate */ private $emailTemplate; @@ -44,7 +45,11 @@ class EMailTemplateTest extends TestCase { $this->defaults = $this->createMock(Defaults::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); - $this->l10n = $this->createMock(IL10N::class); + $this->l10n = $this->createMock(IFactory::class); + + $this->l10n->method('get') + ->with('lib', '') + ->willReturn($this->createMock(IL10N::class)); $this->emailTemplate = new EMailTemplate( $this->defaults, @@ -227,6 +232,4 @@ class EMailTemplateTest extends TestCase { $expectedTXT = file_get_contents(\OC::$SERVERROOT . '/tests/data/emails/new-account-email-custom-text-alternative.txt'); $this->assertSame($expectedTXT, $this->emailTemplate->renderText()); } - - } diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php index 3a08cd9acf2..9e7f6a4134c 100644 --- a/tests/lib/Mail/MailerTest.php +++ b/tests/lib/Mail/MailerTest.php @@ -1,6 +1,9 @@ <?php /** * Copyright (c) 2014-2015 Lukas Reschke <lukas@owncloud.com> + * + * @author Arne Hamann <github@arne.email> + * * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. @@ -10,12 +13,17 @@ namespace Test\Mail; use OC\Mail\EMailTemplate; use OC\Mail\Mailer; +use OC\Mail\Message; use OCP\Defaults; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; use OCP\IURLGenerator; +use OCP\L10N\IFactory; +use OCP\Mail\Events\BeforeMessageSent; use Test\TestCase; +use Swift_SwiftException; class MailerTest extends TestCase { /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ @@ -30,6 +38,9 @@ class MailerTest extends TestCase { private $l10n; /** @var Mailer */ private $mailer; + /** @var IEventDispatcher */ + private $dispatcher; + protected function setUp(): void { parent::setUp(); @@ -39,12 +50,15 @@ class MailerTest extends TestCase { $this->logger = $this->createMock(ILogger::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->l10n = $this->createMock(IL10N::class); + $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->mailer = new Mailer( $this->config, $this->logger, $this->defaults, $this->urlGenerator, - $this->l10n + $this->l10n, + $this->dispatcher, + $this->createMock(IFactory::class) ); } @@ -67,10 +81,10 @@ class MailerTest extends TestCase { $this->config ->expects($this->exactly(2)) ->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['mail_smtpmode', 'smtp', 'sendmail'], ['mail_sendmailmode', 'smtp', $sendmailMode], - ])); + ]); $path = \OC_Helper::findBinaryPath('sendmail'); if ($path === null) { @@ -90,10 +104,10 @@ class MailerTest extends TestCase { $this->config ->expects($this->exactly(2)) ->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['mail_smtpmode', 'smtp', 'qmail'], ['mail_sendmailmode', 'smtp', $sendmailMode], - ])); + ]); $this->assertEquals(new \Swift_SendmailTransport('/var/qmail/bin/sendmail' . $binaryParam), self::invokePrivate($this->mailer, 'getSendMailInstance')); } @@ -107,26 +121,41 @@ class MailerTest extends TestCase { public function testGetInstanceSendmail() { $this->config ->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['mail_smtpmode', 'smtp', 'sendmail'], ['mail_sendmailmode', 'smtp', 'smtp'], - ])); + ]); $mailer = self::invokePrivate($this->mailer, 'getInstance'); $this->assertInstanceOf(\Swift_Mailer::class, $mailer); $this->assertInstanceOf(\Swift_SendmailTransport::class, $mailer->getTransport()); } + public function testEvents() { + $message = $this->createMock(Message::class); + + $event = new BeforeMessageSent($message); + $this->dispatcher->expects($this->at(0)) + ->method('dispatchTyped') + ->with($this->equalTo($event)); + + # We do not care at this point about errors in Swiftmailer + try { + $this->mailer->send($message); + } catch (Swift_SwiftException $e) { + } + } + public function testCreateMessage() { $this->config ->expects($this->any()) ->method('getSystemValue') ->with('mail_send_plaintext_only', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->assertInstanceOf('\OC\Mail\Message', $this->mailer->createMessage()); } - + public function testSendInvalidMailException() { $this->expectException(\Exception::class); @@ -134,7 +163,7 @@ class MailerTest extends TestCase { ->disableOriginalConstructor()->getMock(); $message->expects($this->once()) ->method('getSwiftMessage') - ->will($this->returnValue(new \Swift_Message())); + ->willReturn(new \Swift_Message()); $this->mailer->send($message); } @@ -170,22 +199,21 @@ class MailerTest extends TestCase { public function testStreamingOptions() { $this->config->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['mail_smtpmode', 'smtp', 'smtp'], ['mail_smtpstreamoptions', [], ['foo' => 1]] - ])); + ]); $mailer = self::invokePrivate($this->mailer, 'getInstance'); $this->assertEquals(1, count($mailer->getTransport()->getStreamOptions())); $this->assertTrue(isset($mailer->getTransport()->getStreamOptions()['foo'])); - } public function testStreamingOptionsWrongType() { $this->config->method('getSystemValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['mail_smtpmode', 'smtp', 'smtp'], ['mail_smtpstreamoptions', [], 'bar'] - ])); + ]); $mailer = self::invokePrivate($this->mailer, 'getInstance'); $this->assertEquals(0, count($mailer->getTransport()->getStreamOptions())); } diff --git a/tests/lib/Mail/MessageTest.php b/tests/lib/Mail/MessageTest.php index e0a0f468a50..2172a327234 100644 --- a/tests/lib/Mail/MessageTest.php +++ b/tests/lib/Mail/MessageTest.php @@ -23,12 +23,22 @@ class MessageTest extends TestCase { * @return array */ public function mailAddressProvider() { - return array( - array(array('lukas@owncloud.com' => 'Lukas Reschke'), array('lukas@owncloud.com' => 'Lukas Reschke')), - array(array('lukas@owncloud.com' => 'Lukas Reschke', 'lukas@öwnclöüd.com', 'lukäs@owncloud.örg' => 'Lükäs Réschke'), - array('lukas@owncloud.com' => 'Lukas Reschke', 'lukas@xn--wncld-iuae2c.com', 'lukäs@owncloud.xn--rg-eka' => 'Lükäs Réschke')), - array(array('lukas@öwnclöüd.com'), array('lukas@xn--wncld-iuae2c.com')) - ); + return [ + [['lukas@owncloud.com' => 'Lukas Reschke'], ['lukas@owncloud.com' => 'Lukas Reschke']], + [['lukas@owncloud.com' => 'Lukas Reschke', 'lukas@öwnclöüd.com', 'lukäs@owncloud.örg' => 'Lükäs Réschke'], + ['lukas@owncloud.com' => 'Lukas Reschke', 'lukas@xn--wncld-iuae2c.com', 'lukäs@owncloud.xn--rg-eka' => 'Lükäs Réschke']], + [['lukas@öwnclöüd.com'], ['lukas@xn--wncld-iuae2c.com']], + ]; + } + + /** + * @return array + */ + public function getMailAddressProvider() { + return [ + [null, []], + [['lukas@owncloud.com' => 'Lukas Reschke'], ['lukas@owncloud.com' => 'Lukas Reschke']], + ]; } protected function setUp(): void { @@ -48,24 +58,31 @@ class MessageTest extends TestCase { * @param string $expected */ public function testConvertAddresses($unconverted, $expected) { - $this->assertSame($expected, self::invokePrivate($this->message, 'convertAddresses', array($unconverted))); + $this->assertSame($expected, self::invokePrivate($this->message, 'convertAddresses', [$unconverted])); } public function testSetFrom() { $this->swiftMessage ->expects($this->once()) ->method('setFrom') - ->with(array('lukas@owncloud.com')); - $this->message->setFrom(array('lukas@owncloud.com')); + ->with(['lukas@owncloud.com']); + $this->message->setFrom(['lukas@owncloud.com']); } - public function testGetFrom() { + + /** + * @dataProvider getMailAddressProvider + * + * @param $swiftresult + * @param $return + */ + public function testGetFrom($swiftresult, $return) { $this->swiftMessage ->expects($this->once()) ->method('getFrom') - ->will($this->returnValue(array('lukas@owncloud.com'))); + ->willReturn($swiftresult); - $this->assertSame(array('lukas@owncloud.com'), $this->message->getFrom()); + $this->assertSame($return, $this->message->getFrom()); } public function testSetReplyTo() { @@ -89,51 +106,60 @@ class MessageTest extends TestCase { $this->swiftMessage ->expects($this->once()) ->method('setTo') - ->with(array('lukas@owncloud.com')); - $this->message->setTo(array('lukas@owncloud.com')); + ->with(['lukas@owncloud.com']); + $this->message->setTo(['lukas@owncloud.com']); } - public function testGetTo() { + /** + * @dataProvider getMailAddressProvider + */ + public function testGetTo($swiftresult,$return) { $this->swiftMessage ->expects($this->once()) ->method('getTo') - ->will($this->returnValue(array('lukas@owncloud.com'))); + ->willReturn($swiftresult); - $this->assertSame(array('lukas@owncloud.com'), $this->message->getTo()); + $this->assertSame($return, $this->message->getTo()); } public function testSetCc() { $this->swiftMessage ->expects($this->once()) ->method('setCc') - ->with(array('lukas@owncloud.com')); - $this->message->setCc(array('lukas@owncloud.com')); + ->with(['lukas@owncloud.com']); + $this->message->setCc(['lukas@owncloud.com']); } - public function testGetCc() { + /** + * @dataProvider getMailAddressProvider + */ + public function testGetCc($swiftresult,$return) { $this->swiftMessage ->expects($this->once()) ->method('getCc') - ->will($this->returnValue(array('lukas@owncloud.com'))); + ->willReturn($swiftresult); - $this->assertSame(array('lukas@owncloud.com'), $this->message->getCc()); + $this->assertSame($return, $this->message->getCc()); } public function testSetBcc() { $this->swiftMessage ->expects($this->once()) ->method('setBcc') - ->with(array('lukas@owncloud.com')); - $this->message->setBcc(array('lukas@owncloud.com')); + ->with(['lukas@owncloud.com']); + $this->message->setBcc(['lukas@owncloud.com']); } - public function testGetBcc() { + /** + * @dataProvider getMailAddressProvider + */ + public function testGetBcc($swiftresult,$return) { $this->swiftMessage ->expects($this->once()) ->method('getBcc') - ->will($this->returnValue(array('lukas@owncloud.com'))); + ->willReturn($swiftresult); - $this->assertSame(array('lukas@owncloud.com'), $this->message->getBcc()); + $this->assertSame($return, $this->message->getBcc()); } public function testSetSubject() { @@ -149,7 +175,7 @@ class MessageTest extends TestCase { $this->swiftMessage ->expects($this->once()) ->method('getSubject') - ->will($this->returnValue('Fancy Subject')); + ->willReturn('Fancy Subject'); $this->assertSame('Fancy Subject', $this->message->getSubject()); } @@ -167,7 +193,7 @@ class MessageTest extends TestCase { $this->swiftMessage ->expects($this->once()) ->method('getBody') - ->will($this->returnValue('Fancy Body')); + ->willReturn('Fancy Body'); $this->assertSame('Fancy Body', $this->message->getPlainBody()); } @@ -226,5 +252,4 @@ class MessageTest extends TestCase { $message->useTemplate($template); } - } diff --git a/tests/lib/Memcache/APCuTest.php b/tests/lib/Memcache/APCuTest.php index 199acbe263b..704f9f1c433 100644 --- a/tests/lib/Memcache/APCuTest.php +++ b/tests/lib/Memcache/APCuTest.php @@ -13,7 +13,7 @@ class APCuTest extends Cache { protected function setUp(): void { parent::setUp(); - if(!\OC\Memcache\APCu::isAvailable()) { + if (!\OC\Memcache\APCu::isAvailable()) { $this->markTestSkipped('The APCu extension is not available.'); return; } diff --git a/tests/lib/Memcache/CasTraitTest.php b/tests/lib/Memcache/CasTraitTest.php index 2f0ef939aa7..61972153886 100644 --- a/tests/lib/Memcache/CasTraitTest.php +++ b/tests/lib/Memcache/CasTraitTest.php @@ -33,27 +33,27 @@ class CasTraitTest extends TestCase { $mock->expects($this->any()) ->method('set') - ->will($this->returnCallback(function ($key, $value, $ttl) use ($sourceCache) { + ->willReturnCallback(function ($key, $value, $ttl) use ($sourceCache) { return $sourceCache->set($key, $value, $ttl); - })); + }); $mock->expects($this->any()) ->method('get') - ->will($this->returnCallback(function ($key) use ($sourceCache) { + ->willReturnCallback(function ($key) use ($sourceCache) { return $sourceCache->get($key); - })); + }); $mock->expects($this->any()) ->method('add') - ->will($this->returnCallback(function ($key, $value, $ttl) use ($sourceCache) { + ->willReturnCallback(function ($key, $value, $ttl) use ($sourceCache) { return $sourceCache->add($key, $value, $ttl); - })); + }); $mock->expects($this->any()) ->method('remove') - ->will($this->returnCallback(function ($key) use ($sourceCache) { + ->willReturnCallback(function ($key) use ($sourceCache) { return $sourceCache->remove($key); - })); + }); return $mock; } diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php index cf4da7839c4..19edf4aa3dd 100644 --- a/tests/lib/Memcache/FactoryTest.php +++ b/tests/lib/Memcache/FactoryTest.php @@ -61,10 +61,10 @@ class Test_Factory_Unavailable_Cache2 extends NullCache { } class FactoryTest extends \Test\TestCase { - const AVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Available_Cache1'; - const AVAILABLE2 = '\\Test\\Memcache\\Test_Factory_Available_Cache2'; - const UNAVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache1'; - const UNAVAILABLE2 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache2'; + public const AVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Available_Cache1'; + public const AVAILABLE2 = '\\Test\\Memcache\\Test_Factory_Available_Cache2'; + public const UNAVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache1'; + public const UNAVAILABLE2 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache2'; public function cacheAvailabilityProvider() { return [ diff --git a/tests/lib/Memcache/MemcachedTest.php b/tests/lib/Memcache/MemcachedTest.php index 96b88992665..340ce85b9aa 100644 --- a/tests/lib/Memcache/MemcachedTest.php +++ b/tests/lib/Memcache/MemcachedTest.php @@ -10,7 +10,7 @@ namespace Test\Memcache; class MemcachedTest extends Cache { - static public function setUpBeforeClass(): void { + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); if (!\OC\Memcache\Memcached::isAvailable()) { diff --git a/tests/lib/Memcache/RedisTest.php b/tests/lib/Memcache/RedisTest.php index e6a940599d7..e7bb9c29d36 100644 --- a/tests/lib/Memcache/RedisTest.php +++ b/tests/lib/Memcache/RedisTest.php @@ -10,7 +10,7 @@ namespace Test\Memcache; class RedisTest extends Cache { - static public function setUpBeforeClass(): void { + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); if (!\OC\Memcache\Redis::isAvailable()) { @@ -23,7 +23,7 @@ class RedisTest extends Cache { $errorOccurred = false; set_error_handler( - function($errno, $errstr) { + function ($errno, $errstr) { throw new \RuntimeException($errstr, 123456789); }, E_WARNING diff --git a/tests/lib/MemoryInfoTest.php b/tests/lib/MemoryInfoTest.php index 489ef51d373..8feb4b6332d 100644 --- a/tests/lib/MemoryInfoTest.php +++ b/tests/lib/MemoryInfoTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** diff --git a/tests/lib/NaturalSortTest.php b/tests/lib/NaturalSortTest.php index 50c2d0be9f0..f8e7f31a285 100644 --- a/tests/lib/NaturalSortTest.php +++ b/tests/lib/NaturalSortTest.php @@ -13,24 +13,22 @@ class NaturalSortTest extends \Test\TestCase { /** * @dataProvider naturalSortDataProvider */ - public function testNaturalSortCompare($array, $sorted) - { - if(!class_exists('Collator')) { + public function testNaturalSortCompare($array, $sorted) { + if (!class_exists('Collator')) { $this->markTestSkipped('The intl module is not available, natural sorting might not work as expected.'); return; } $comparator = \OC\NaturalSort::getInstance(); - usort($array, array($comparator, 'compare')); + usort($array, [$comparator, 'compare']); $this->assertEquals($sorted, $array); } /** - * @dataProvider defaultCollatorDataProvider - */ - public function testDefaultCollatorCompare($array, $sorted) - { + * @dataProvider defaultCollatorDataProvider + */ + public function testDefaultCollatorCompare($array, $sorted) { $comparator = new \OC\NaturalSort(new \OC\NaturalSort_DefaultCollator()); - usort($array, array($comparator, 'compare')); + usort($array, [$comparator, 'compare']); $this->assertEquals($sorted, $array); } @@ -39,30 +37,29 @@ class NaturalSortTest extends \Test\TestCase { * Must provide the same result as in core/js/tests/specs/coreSpec.js * @return array test cases */ - public function naturalSortDataProvider() - { - return array( + public function naturalSortDataProvider() { + return [ // different casing - array( + [ // unsorted - array( + [ 'aaa', 'bbb', 'BBB', 'AAA' - ), + ], // sorted - array( + [ 'aaa', 'AAA', 'bbb', 'BBB' - ) - ), + ] + ], // numbers - array( + [ // unsorted - array( + [ '124.txt', 'abc1', '123.txt', @@ -85,9 +82,9 @@ class NaturalSortTest extends \Test\TestCase { 'zz', '15.txt', '15b.txt', - ), + ], // sorted - array( + [ '15.txt', '15b.txt', '123.txt', @@ -110,12 +107,12 @@ class NaturalSortTest extends \Test\TestCase { 'z', 'za', 'zz', - ) - ), + ] + ], // chinese characters - array( + [ // unsorted - array( + [ '十.txt', '一.txt', '二.txt', @@ -134,9 +131,9 @@ class NaturalSortTest extends \Test\TestCase { '莫.txt', '啊.txt', '123.txt', - ), + ], // sorted - array( + [ '123.txt', 'abc.txt', '一.txt', @@ -155,12 +152,12 @@ class NaturalSortTest extends \Test\TestCase { '波.txt', '破.txt', '莫.txt', - ) - ), + ] + ], // with umlauts - array( + [ // unsorted - array( + [ 'öh.txt', 'Äh.txt', 'oh.txt', @@ -171,9 +168,9 @@ class NaturalSortTest extends \Test\TestCase { 'uh.txt', 'üh.txt', 'äh.txt', - ), + ], // sorted - array( + [ 'ah.txt', 'äh.txt', 'Äh.txt', @@ -184,40 +181,39 @@ class NaturalSortTest extends \Test\TestCase { 'üh.txt', 'Üh.txt', 'Üh 2.txt', - ) - ), - ); + ] + ], + ]; } /** - * Data provider for natural sorting with \OC\NaturalSort_DefaultCollator. - * Must provide the same result as in core/js/tests/specs/coreSpec.js - * @return array test cases - */ - public function defaultCollatorDataProvider() - { - return array( + * Data provider for natural sorting with \OC\NaturalSort_DefaultCollator. + * Must provide the same result as in core/js/tests/specs/coreSpec.js + * @return array test cases + */ + public function defaultCollatorDataProvider() { + return [ // different casing - array( + [ // unsorted - array( + [ 'aaa', 'bbb', 'BBB', 'AAA' - ), + ], // sorted - array( + [ 'aaa', 'AAA', 'bbb', 'BBB' - ) - ), + ] + ], // numbers - array( + [ // unsorted - array( + [ '124.txt', 'abc1', '123.txt', @@ -240,9 +236,9 @@ class NaturalSortTest extends \Test\TestCase { 'zz', '15.txt', '15b.txt', - ), + ], // sorted - array( + [ '15.txt', '15b.txt', '123.txt', @@ -265,8 +261,8 @@ class NaturalSortTest extends \Test\TestCase { 'z', 'za', 'zz', - ) - ), - ); + ] + ], + ]; } } diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php index 74cb3948c5e..4f1cabc3cba 100644 --- a/tests/lib/NavigationManagerTest.php +++ b/tests/lib/NavigationManagerTest.php @@ -206,7 +206,6 @@ class NavigationManagerTest extends TestCase { * @dataProvider providesNavigationConfig */ public function testWithAppManager($expected, $navigation, $isAdmin = false) { - $l = $this->createMock(IL10N::class); $l->expects($this->any())->method('t')->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); @@ -228,9 +227,9 @@ class NavigationManagerTest extends TestCase { $this->userSession->expects($this->any())->method('getUser')->willReturn($user); $this->userSession->expects($this->any())->method('isLoggedIn')->willReturn(true); $this->appManager->expects($this->once()) - ->method('getEnabledAppsForUser') - ->with($user) - ->willReturn(['test']); + ->method('getEnabledAppsForUser') + ->with($user) + ->willReturn(['test']); $this->groupManager->expects($this->any())->method('isAdmin')->willReturn($isAdmin); $subadmin = $this->createMock(SubAdmin::class); $subadmin->expects($this->any())->method('isSubAdmin')->with($user)->willReturn(false); diff --git a/tests/lib/Notification/ActionTest.php b/tests/lib/Notification/ActionTest.php index 1923f2305e1..6016760c24f 100644 --- a/tests/lib/Notification/ActionTest.php +++ b/tests/lib/Notification/ActionTest.php @@ -21,7 +21,6 @@ namespace Test\Notification; - use OC\Notification\Action; use OCP\Notification\IAction; use Test\TestCase; diff --git a/tests/lib/Notification/DummyApp.php b/tests/lib/Notification/DummyApp.php index 680fb44d009..b1281f6b7a0 100644 --- a/tests/lib/Notification/DummyApp.php +++ b/tests/lib/Notification/DummyApp.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace Test\Notification; - use OCP\Notification\IApp; use OCP\Notification\INotification; diff --git a/tests/lib/Notification/DummyNotifier.php b/tests/lib/Notification/DummyNotifier.php index 849fb3c275f..92c1ddfb310 100644 --- a/tests/lib/Notification/DummyNotifier.php +++ b/tests/lib/Notification/DummyNotifier.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> @@ -22,7 +23,6 @@ declare(strict_types=1); namespace Test\Notification; - use OCP\Notification\AlreadyProcessedException; use OCP\Notification\INotification; use OCP\Notification\INotifier; diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php index 6ca83b4b367..57c7557e86c 100644 --- a/tests/lib/Notification/ManagerTest.php +++ b/tests/lib/Notification/ManagerTest.php @@ -23,10 +23,8 @@ namespace Test\Notification; use OC\Notification\Manager; use OCP\ILogger; -use OCP\Notification\IApp; use OCP\Notification\IManager; use OCP\Notification\INotification; -use OCP\Notification\INotifier; use OCP\RichObjectStrings\IValidator; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -48,7 +46,6 @@ class ManagerTest extends TestCase { } public function testRegisterApp() { - $this->assertEquals([], self::invokePrivate($this->manager, 'getApps')); $this->manager->registerApp(DummyApp::class); diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php index c70fa1ec7df..f8d80a0ab56 100644 --- a/tests/lib/Notification/NotificationTest.php +++ b/tests/lib/Notification/NotificationTest.php @@ -1,5 +1,6 @@ <?php -declare (strict_types = 1); + +declare(strict_types = 1); /** * @author Joas Schilling <nickvergessen@owncloud.com> * @@ -22,7 +23,6 @@ declare (strict_types = 1); namespace Test\Notification; - use OC\Notification\Notification; use OCP\Notification\IAction; use OCP\Notification\INotification; diff --git a/tests/lib/OCS/DiscoveryServiceTest.php b/tests/lib/OCS/DiscoveryServiceTest.php index 710d683841f..d5baa1be2e2 100644 --- a/tests/lib/OCS/DiscoveryServiceTest.php +++ b/tests/lib/OCS/DiscoveryServiceTest.php @@ -21,7 +21,6 @@ namespace Test\OCS; - use OC\OCS\DiscoveryService; use OCP\Http\Client\IClientService; use OCP\ICacheFactory; @@ -94,5 +93,4 @@ class DiscoveryServiceTest extends TestCase { [['services' => ['myService' => ['endpoints' => ['foo' => '/bar</foo']]]], 'myService', []], ]; } - } diff --git a/tests/lib/OCS/ProviderTest.php b/tests/lib/OCS/ProviderTest.php index 7ee802e54fb..3a78793f91d 100644 --- a/tests/lib/OCS/ProviderTest.php +++ b/tests/lib/OCS/ProviderTest.php @@ -44,22 +44,22 @@ class ProviderTest extends \Test\TestCase { ->expects($this->at(0)) ->method('isEnabledForUser') ->with('files_sharing') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(1)) ->method('isEnabledForUser') ->with('federation') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(2)) ->method('isEnabledForUser') ->with('activity') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(3)) ->method('isEnabledForUser') ->with('provisioning_api') - ->will($this->returnValue(false)); + ->willReturn(false); $expected = new \OCP\AppFramework\Http\JSONResponse( [ @@ -85,22 +85,22 @@ class ProviderTest extends \Test\TestCase { ->expects($this->at(0)) ->method('isEnabledForUser') ->with('files_sharing') - ->will($this->returnValue(true)); + ->willReturn(true); $this->appManager ->expects($this->at(1)) ->method('isEnabledForUser') ->with('federation') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(2)) ->method('isEnabledForUser') ->with('activity') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(3)) ->method('isEnabledForUser') ->with('provisioning_api') - ->will($this->returnValue(false)); + ->willReturn(false); $expected = new \OCP\AppFramework\Http\JSONResponse( [ @@ -139,22 +139,22 @@ class ProviderTest extends \Test\TestCase { ->expects($this->at(0)) ->method('isEnabledForUser') ->with('files_sharing') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(1)) ->method('isEnabledForUser') ->with('federation') - ->will($this->returnValue(true)); + ->willReturn(true); $this->appManager ->expects($this->at(2)) ->method('isEnabledForUser') ->with('activity') - ->will($this->returnValue(false)); + ->willReturn(false); $this->appManager ->expects($this->at(3)) ->method('isEnabledForUser') ->with('provisioning_api') - ->will($this->returnValue(false)); + ->willReturn(false); $expected = new \OCP\AppFramework\Http\JSONResponse( [ @@ -187,7 +187,7 @@ class ProviderTest extends \Test\TestCase { $this->appManager ->expects($this->any()) ->method('isEnabledForUser') - ->will($this->returnValue(true)); + ->willReturn(true); $expected = new \OCP\AppFramework\Http\JSONResponse( [ diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php index 09c4a16f87a..cd9f6ef0399 100644 --- a/tests/lib/Preview/BackgroundCleanupJobTest.php +++ b/tests/lib/Preview/BackgroundCleanupJobTest.php @@ -22,11 +22,13 @@ namespace Test\Preview; -use OC\Files\AppData\Factory; use OC\Preview\BackgroundCleanupJob; +use OC\Preview\Storage\Root; use OC\PreviewManager; -use OC\SystemConfig; +use OCP\Files\File; +use OCP\Files\IMimeTypeLoader; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\IDBConnection; use Test\Traits\MountProviderTrait; use Test\Traits\UserTrait; @@ -39,7 +41,6 @@ use Test\Traits\UserTrait; * @package Test\Preview */ class BackgroundCleanupJobTest extends \Test\TestCase { - use MountProviderTrait; use UserTrait; @@ -49,9 +50,6 @@ class BackgroundCleanupJobTest extends \Test\TestCase { /** @var bool */ private $trashEnabled; - /** @var Factory */ - private $appDataFactory; - /** @var IDBConnection */ private $connection; @@ -61,6 +59,9 @@ class BackgroundCleanupJobTest extends \Test\TestCase { /** @var IRootFolder */ private $rootFolder; + /** @var IMimeTypeLoader */ + private $mimeTypeLoader; + protected function setUp(): void { parent::setUp(); @@ -78,13 +79,10 @@ class BackgroundCleanupJobTest extends \Test\TestCase { $this->trashEnabled = $appManager->isEnabledForUser('files_trashbin', $this->userId); $appManager->disableApp('files_trashbin'); - $this->appDataFactory = new Factory( - \OC::$server->getRootFolder(), - \OC::$server->getSystemConfig() - ); $this->connection = \OC::$server->getDatabaseConnection(); $this->previewManager = \OC::$server->getPreviewManager(); $this->rootFolder = \OC::$server->getRootFolder(); + $this->mimeTypeLoader = \OC::$server->getMimeTypeLoader(); } protected function tearDown(): void { @@ -98,6 +96,13 @@ class BackgroundCleanupJobTest extends \Test\TestCase { parent::tearDown(); } + private function getRoot(): Root { + return new Root( + \OC::$server->getRootFolder(), + \OC::$server->getSystemConfig() + ); + } + private function setup11Previews(): array { $userFolder = $this->rootFolder->getUserFolder($this->userId); @@ -112,52 +117,89 @@ class BackgroundCleanupJobTest extends \Test\TestCase { return $files; } + private function countPreviews(Root $previewRoot, array $fileIds): int { + $i = 0; + + foreach ($fileIds as $fileId) { + try { + $previewRoot->getFolder((string)$fileId); + } catch (NotFoundException $e) { + continue; + } + + $i++; + } + + return $i; + } + public function testCleanupSystemCron() { $files = $this->setup11Previews(); + $fileIds = array_map(function (File $f) { + return $f->getId(); + }, $files); - $preview = $this->appDataFactory->get('preview'); - - $previews = $preview->getDirectoryListing(); - $this->assertCount(11, $previews); + $root = $this->getRoot(); - $job = new BackgroundCleanupJob($this->connection, $this->appDataFactory, true); + $this->assertSame(11, $this->countPreviews($root, $fileIds)); + $job = new BackgroundCleanupJob($this->connection, $root, $this->mimeTypeLoader, true); $job->run([]); foreach ($files as $file) { $file->delete(); } - $this->assertCount(11, $previews); + $root = $this->getRoot(); + $this->assertSame(11, $this->countPreviews($root, $fileIds)); $job->run([]); - $previews = $preview->getDirectoryListing(); - $this->assertCount(0, $previews); + $root = $this->getRoot(); + $this->assertSame(0, $this->countPreviews($root, $fileIds)); } public function testCleanupAjax() { $files = $this->setup11Previews(); + $fileIds = array_map(function (File $f) { + return $f->getId(); + }, $files); - $preview = $this->appDataFactory->get('preview'); - - $previews = $preview->getDirectoryListing(); - $this->assertCount(11, $previews); + $root = $this->getRoot(); - $job = new BackgroundCleanupJob($this->connection, $this->appDataFactory, false); + $this->assertSame(11, $this->countPreviews($root, $fileIds)); + $job = new BackgroundCleanupJob($this->connection, $root, $this->mimeTypeLoader, false); $job->run([]); foreach ($files as $file) { $file->delete(); } - $this->assertCount(11, $previews); + $root = $this->getRoot(); + $this->assertSame(11, $this->countPreviews($root, $fileIds)); $job->run([]); - $previews = $preview->getDirectoryListing(); - $this->assertCount(1, $previews); + $root = $this->getRoot(); + $this->assertSame(1, $this->countPreviews($root, $fileIds)); + $job->run([]); + + $root = $this->getRoot(); + $this->assertSame(0, $this->countPreviews($root, $fileIds)); + } + + public function testOldPreviews() { + $appdata = \OC::$server->getAppDataDir('preview'); + + $f1 = $appdata->newFolder('123456781'); + $f1->newFile('foo.jpg', 'foo'); + $f2 = $appdata->newFolder('123456782'); + $f2->newFile('foo.jpg', 'foo'); + + $appdata = \OC::$server->getAppDataDir('preview'); + $this->assertSame(2, count($appdata->getDirectoryListing())); + $job = new BackgroundCleanupJob($this->connection, $this->getRoot(), $this->mimeTypeLoader, true); $job->run([]); - $previews = $preview->getDirectoryListing(); - $this->assertCount(0, $previews); + $appdata = \OC::$server->getAppDataDir('preview'); + $this->assertSame(0, count($appdata->getDirectoryListing())); } } diff --git a/tests/lib/Preview/BitmapTest.php b/tests/lib/Preview/BitmapTest.php index 952f72b276a..554e499ee84 100644 --- a/tests/lib/Preview/BitmapTest.php +++ b/tests/lib/Preview/BitmapTest.php @@ -29,7 +29,6 @@ namespace Test\Preview; * @package Test\Preview */ class BitmapTest extends Provider { - protected function setUp(): void { parent::setUp(); @@ -39,5 +38,4 @@ class BitmapTest extends Provider { $this->height = 1707; $this->provider = new \OC\Preview\Postscript; } - } diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php index cfb78a05da5..3a46447632d 100644 --- a/tests/lib/Preview/GeneratorTest.php +++ b/tests/lib/Preview/GeneratorTest.php @@ -33,7 +33,6 @@ use OCP\Files\SimpleFS\ISimpleFolder; use OCP\IConfig; use OCP\IImage; use OCP\IPreview; -use OCP\Preview\IProvider; use OCP\Preview\IProviderV2; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -113,7 +112,7 @@ class GeneratorTest extends \Test\TestCase { ->method('dispatch') ->with( $this->equalTo(IPreview::EVENT), - $this->callback(function(GenericEvent $event) use ($file) { + $this->callback(function (GenericEvent $event) use ($file) { return $event->getSubject() === $file && $event->getArgument('width') === 100 && $event->getArgument('height') === 100; @@ -147,9 +146,9 @@ class GeneratorTest extends \Test\TestCase { ->willReturn($previewFolder); $this->config->method('getSystemValue') - ->will($this->returnCallback(function($key, $defult) { + ->willReturnCallback(function ($key, $defult) { return $defult; - })); + }); $invalidProvider = $this->createMock(IProviderV2::class); $invalidProvider->method('isAvailable') @@ -169,20 +168,20 @@ class GeneratorTest extends \Test\TestCase { ]); $this->helper->method('getProvider') - ->will($this->returnCallback(function($provider) use ($invalidProvider, $validProvider, $unavailableProvider) { + ->willReturnCallback(function ($provider) use ($invalidProvider, $validProvider, $unavailableProvider) { if ($provider === 'wrongProvider') { $this->fail('Wrongprovider should not be constructed!'); - } else if ($provider === 'brokenProvider') { + } elseif ($provider === 'brokenProvider') { return false; - } else if ($provider === 'invalidProvider') { + } elseif ($provider === 'invalidProvider') { return $invalidProvider; - } else if ($provider === 'validProvider') { + } elseif ($provider === 'validProvider') { return $validProvider; - } else if ($provider === 'unavailableProvider') { + } elseif ($provider === 'unavailableProvider') { return $unavailableProvider; } $this->fail('Unexpected provider requested'); - })); + }); $image = $this->createMock(IImage::class); $image->method('width')->willReturn(2048); @@ -191,13 +190,13 @@ class GeneratorTest extends \Test\TestCase { $image->method('dataMimeType')->willReturn('image/png'); $this->helper->method('getThumbnail') - ->will($this->returnCallback(function ($provider, $file, $x, $y) use ($invalidProvider, $validProvider, $image) { + ->willReturnCallback(function ($provider, $file, $x, $y) use ($invalidProvider, $validProvider, $image) { if ($provider === $validProvider) { return $image; } else { return false; } - })); + }); $image->method('data') ->willReturn('my data'); @@ -211,14 +210,14 @@ class GeneratorTest extends \Test\TestCase { $previewFolder->method('getDirectoryListing') ->willReturn([]); $previewFolder->method('newFile') - ->will($this->returnCallback(function($filename) use ($maxPreview, $previewFile) { + ->willReturnCallback(function ($filename) use ($maxPreview, $previewFile) { if ($filename === '2048-2048-max.png') { return $maxPreview; - } else if ($filename === '256-256.png') { + } elseif ($filename === '256-256.png') { return $previewFile; } $this->fail('Unexpected file'); - })); + }); $maxPreview->expects($this->once()) ->method('putContent') @@ -228,19 +227,11 @@ class GeneratorTest extends \Test\TestCase { ->with($this->equalTo('256-256.png')) ->willThrowException(new NotFoundException()); - $image = $this->createMock(IImage::class); + $image = $this->getMockImage(2048, 2048, 'my resized data'); $this->helper->method('getImage') ->with($this->equalTo($maxPreview)) ->willReturn($image); - $image->expects($this->once()) - ->method('resize') - ->with(256); - $image->method('data') - ->willReturn('my resized data'); - $image->method('valid')->willReturn(true); - $image->method('dataMimeType')->willReturn('image/png'); - $previewFile->expects($this->once()) ->method('putContent') ->with('my resized data'); @@ -249,7 +240,7 @@ class GeneratorTest extends \Test\TestCase { ->method('dispatch') ->with( $this->equalTo(IPreview::EVENT), - $this->callback(function(GenericEvent $event) use ($file) { + $this->callback(function (GenericEvent $event) use ($file) { return $event->getSubject() === $file && $event->getArgument('width') === 100 && $event->getArgument('height') === 100; @@ -275,7 +266,7 @@ class GeneratorTest extends \Test\TestCase { ->method('dispatch') ->with( $this->equalTo(IPreview::EVENT), - $this->callback(function(GenericEvent $event) use ($file) { + $this->callback(function (GenericEvent $event) use ($file) { return $event->getSubject() === $file && $event->getArgument('width') === 0 && $event->getArgument('height') === 0 && @@ -315,7 +306,7 @@ class GeneratorTest extends \Test\TestCase { ->method('dispatch') ->with( $this->equalTo(IPreview::EVENT), - $this->callback(function(GenericEvent $event) use ($file) { + $this->callback(function (GenericEvent $event) use ($file) { return $event->getSubject() === $file && $event->getArgument('width') === 100 && $event->getArgument('height') === 100; @@ -326,6 +317,27 @@ class GeneratorTest extends \Test\TestCase { $this->generator->getPreview($file, 100, 100); } + private function getMockImage($width, $height, $data = null) { + $image = $this->createMock(IImage::class); + $image->method('height')->willReturn($width); + $image->method('width')->willReturn($height); + $image->method('valid')->willReturn(true); + $image->method('dataMimeType')->willReturn('image/png'); + $image->method('data')->willReturn($data); + + $image->method('resizeCopy')->willReturnCallback(function ($size) use ($data) { + return $this->getMockImage($size, $size, $data); + }); + $image->method('preciseResizeCopy')->willReturnCallback(function ($width, $height) use ($data) { + return $this->getMockImage($width, $height, $data); + }); + $image->method('cropCopy')->willReturnCallback(function ($x, $y, $width, $height) use ($data) { + return $this->getMockImage($width, $height, $data); + }); + + return $image; + } + public function dataSize() { return [ [1024, 2048, 512, 512, false, IPreview::MODE_FILL, 256, 512], @@ -410,14 +422,10 @@ class GeneratorTest extends \Test\TestCase { ->with($this->equalTo($filename)) ->willThrowException(new NotFoundException()); - $image = $this->createMock(IImage::class); + $image = $this->getMockImage($maxX, $maxY); $this->helper->method('getImage') ->with($this->equalTo($maxPreview)) ->willReturn($image); - $image->method('height')->willReturn($maxY); - $image->method('width')->willReturn($maxX); - $image->method('valid')->willReturn(true); - $image->method('dataMimeType')->willReturn('image/png'); $preview = $this->createMock(ISimpleFile::class); $previewFolder->method('newFile') @@ -428,7 +436,7 @@ class GeneratorTest extends \Test\TestCase { ->method('dispatch') ->with( $this->equalTo(IPreview::EVENT), - $this->callback(function(GenericEvent $event) use ($file, $reqX, $reqY, $crop, $mode) { + $this->callback(function (GenericEvent $event) use ($file, $reqX, $reqY, $crop, $mode) { return $event->getSubject() === $file && $event->getArgument('width') === $reqX && $event->getArgument('height') === $reqY && diff --git a/tests/lib/Preview/HEICTest.php b/tests/lib/Preview/HEICTest.php index f75ae3192a1..18571dc52ea 100644 --- a/tests/lib/Preview/HEICTest.php +++ b/tests/lib/Preview/HEICTest.php @@ -29,9 +29,8 @@ namespace Test\Preview; * @package Test\Preview */ class HEICTest extends Provider { - protected function setUp(): void { - if ( !in_array("HEIC", \Imagick::queryFormats("HEI*")) ) { + if (!in_array("HEIC", \Imagick::queryFormats("HEI*"))) { $this->markTestSkipped('ImageMagick is not HEIC aware. Skipping tests'); } else { parent::setUp(); @@ -42,7 +41,5 @@ class HEICTest extends Provider { $this->height = 1050; $this->provider = new \OC\Preview\HEIC; } - } - } diff --git a/tests/lib/Preview/ImageTest.php b/tests/lib/Preview/ImageTest.php index 40267538804..d58e4ca91ba 100644 --- a/tests/lib/Preview/ImageTest.php +++ b/tests/lib/Preview/ImageTest.php @@ -29,7 +29,6 @@ namespace Test\Preview; * @package Test\Preview */ class ImageTest extends Provider { - protected function setUp(): void { parent::setUp(); @@ -39,5 +38,4 @@ class ImageTest extends Provider { $this->height = 1050; $this->provider = new \OC\Preview\JPEG(); } - } diff --git a/tests/lib/Preview/MP3Test.php b/tests/lib/Preview/MP3Test.php index 15915ac2578..6e841e29ec4 100644 --- a/tests/lib/Preview/MP3Test.php +++ b/tests/lib/Preview/MP3Test.php @@ -29,7 +29,6 @@ namespace Test\Preview; * @package Test\Preview */ class MP3Test extends Provider { - protected function setUp(): void { parent::setUp(); @@ -39,5 +38,4 @@ class MP3Test extends Provider { $this->height = 200; $this->provider = new \OC\Preview\MP3; } - } diff --git a/tests/lib/Preview/MovieTest.php b/tests/lib/Preview/MovieTest.php index 2415102a83d..767ce130ae4 100644 --- a/tests/lib/Preview/MovieTest.php +++ b/tests/lib/Preview/MovieTest.php @@ -29,7 +29,6 @@ namespace Test\Preview; * @package Test\Preview */ class MovieTest extends Provider { - protected function setUp(): void { $avconvBinary = \OC_Helper::findBinaryPath('avconv'); $ffmpegBinary = ($avconvBinary) ? null : \OC_Helper::findBinaryPath('ffmpeg'); @@ -49,5 +48,4 @@ class MovieTest extends Provider { $this->markTestSkipped('No Movie provider present'); } } - } diff --git a/tests/lib/Preview/OfficeTest.php b/tests/lib/Preview/OfficeTest.php index 555b3f77747..c37e5b95a75 100644 --- a/tests/lib/Preview/OfficeTest.php +++ b/tests/lib/Preview/OfficeTest.php @@ -29,7 +29,6 @@ namespace Test\Preview; * @package Test\Preview */ class OfficeTest extends Provider { - protected function setUp(): void { $libreofficeBinary = \OC_Helper::findBinaryPath('libreoffice'); $openofficeBinary = ($libreofficeBinary) ? null : \OC_Helper::findBinaryPath('openoffice'); @@ -46,5 +45,4 @@ class OfficeTest extends Provider { $this->markTestSkipped('No Office provider present'); } } - } diff --git a/tests/lib/Preview/SVGTest.php b/tests/lib/Preview/SVGTest.php index 73ccbc0b136..e48018a301b 100644 --- a/tests/lib/Preview/SVGTest.php +++ b/tests/lib/Preview/SVGTest.php @@ -29,7 +29,6 @@ namespace Test\Preview; * @package Test\Preview */ class SVGTest extends Provider { - protected function setUp(): void { $checkImagick = new \Imagick(); if (count($checkImagick->queryFormats('SVG')) === 1) { @@ -44,5 +43,4 @@ class SVGTest extends Provider { $this->markTestSkipped('No SVG provider present'); } } - } diff --git a/tests/lib/Preview/TXTTest.php b/tests/lib/Preview/TXTTest.php index e4c6e76c47f..785fe8c2526 100644 --- a/tests/lib/Preview/TXTTest.php +++ b/tests/lib/Preview/TXTTest.php @@ -29,7 +29,6 @@ namespace Test\Preview; * @package Test\Preview */ class TXTTest extends Provider { - protected function setUp(): void { parent::setUp(); @@ -40,5 +39,4 @@ class TXTTest extends Provider { $this->height = 200; $this->provider = new \OC\Preview\TXT; } - } diff --git a/tests/lib/PublicNamespace/UtilTest.php b/tests/lib/PublicNamespace/UtilTest.php index 7892501aaa0..9699d7a0ed2 100644 --- a/tests/lib/PublicNamespace/UtilTest.php +++ b/tests/lib/PublicNamespace/UtilTest.php @@ -21,9 +21,8 @@ namespace Test\PublicNamespace; - class UtilTest extends \Test\TestCase { - /** + /** * @dataProvider channelProvider * * @param string $channel diff --git a/tests/lib/Remote/InstanceTest.php b/tests/lib/Remote/InstanceTest.php index 0adb608d875..3ec7451263d 100644 --- a/tests/lib/Remote/InstanceTest.php +++ b/tests/lib/Remote/InstanceTest.php @@ -21,7 +21,6 @@ namespace Test\Remote; - use OC\Memcache\ArrayCache; use OC\Remote\Instance; use OCP\ICache; diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php index 5ff13beba76..b724891cda7 100644 --- a/tests/lib/Repair/CleanTagsTest.php +++ b/tests/lib/Repair/CleanTagsTest.php @@ -7,6 +7,7 @@ */ namespace Test\Repair; + use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IUserManager; use OCP\Migration\IOutput; diff --git a/tests/lib/Repair/ClearFrontendCachesTest.php b/tests/lib/Repair/ClearFrontendCachesTest.php index ea33d331c4d..9acd1f4df17 100644 --- a/tests/lib/Repair/ClearFrontendCachesTest.php +++ b/tests/lib/Repair/ClearFrontendCachesTest.php @@ -22,6 +22,7 @@ */ namespace Test\Repair; + use OC\Template\JSCombiner; use OC\Template\SCSSCacher; use OCP\ICache; diff --git a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php index 218a59caa3b..30df6474b80 100644 --- a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php +++ b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php @@ -73,9 +73,9 @@ class ClearGeneratedAvatarCacheTest extends \Test\TestCase { */ public function testShouldRun($from, $expected) { $this->config->expects($this->any()) - ->method('getSystemValue') - ->with('version', '0.0.0.0') - ->willReturn($from); + ->method('getSystemValue') + ->with('version', '0.0.0.0') + ->willReturn($from); $this->assertEquals($expected, $this->invokePrivate($this->repair, 'shouldRun')); } diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index 1baaf89e0a0..23e6b2dad5f 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -8,7 +8,6 @@ namespace Test\Repair; - use OC\Repair\RepairInvalidShares; use OC\Share\Constants; use OCP\IConfig; @@ -40,7 +39,7 @@ class RepairInvalidSharesTest extends TestCase { $config->expects($this->any()) ->method('getSystemValue') ->with('version') - ->will($this->returnValue('12.0.0.0')); + ->willReturn('12.0.0.0'); $this->connection = \OC::$server->getDatabaseConnection(); $this->deleteAllShares(); diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index 013e170cc9d..e6c6fdebf42 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -46,7 +46,7 @@ class RepairMimeTypesTest extends \Test\TestCase { $config->expects($this->any()) ->method('getSystemValue') ->with('version') - ->will($this->returnValue('11.0.0.0')); + ->willReturn('11.0.0.0'); $this->storage = new \OC\Files\Storage\Temporary([]); @@ -87,7 +87,6 @@ class RepairMimeTypesTest extends \Test\TestCase { ] ); } - } private function checkEntries($entries) { diff --git a/tests/lib/Repair/RepairSqliteAutoincrementTest.php b/tests/lib/Repair/RepairSqliteAutoincrementTest.php index c7008179a0d..c740384fc0f 100644 --- a/tests/lib/Repair/RepairSqliteAutoincrementTest.php +++ b/tests/lib/Repair/RepairSqliteAutoincrementTest.php @@ -7,6 +7,7 @@ */ namespace Test\Repair; + use OCP\Migration\IOutput; /** @@ -65,7 +66,7 @@ class RepairSqliteAutoincrementTest extends \Test\TestCase { protected function checkAutoincrement() { $this->connection->executeUpdate('INSERT INTO ' . $this->tableName . ' ("text") VALUES ("test")'); $insertId = $this->connection->lastInsertId(); - $this->connection->executeUpdate('DELETE FROM ' . $this->tableName . ' WHERE "someid" = ?', array($insertId)); + $this->connection->executeUpdate('DELETE FROM ' . $this->tableName . ' WHERE "someid" = ?', [$insertId]); // insert again $this->connection->executeUpdate('INSERT INTO ' . $this->tableName . ' ("text") VALUES ("test2")'); diff --git a/tests/lib/RepairStepTest.php b/tests/lib/RepairStepTest.php index 433a161e8fa..9a569f8af6d 100644 --- a/tests/lib/RepairStepTest.php +++ b/tests/lib/RepairStepTest.php @@ -25,8 +25,7 @@ class RepairStepTest implements IRepairStep { public function run(\OCP\Migration\IOutput $out) { if ($this->warning) { $out->warning('Simulated warning'); - } - else { + } else { $out->info('Simulated info'); } } @@ -59,29 +58,27 @@ class RepairTest extends TestCase { } public function testRunRepairStep() { - $this->repair->addStep(new TestRepairStep(false)); $this->repair->run(); $this->assertEquals( - array( + [ 'step: Test Name', 'info: Simulated info', - ), + ], $this->outputArray ); } public function testRunRepairStepThatFail() { - $this->repair->addStep(new TestRepairStep(true)); $this->repair->run(); $this->assertEquals( - array( + [ 'step: Test Name', 'warning: Simulated warning', - ), + ], $this->outputArray ); } @@ -93,7 +90,7 @@ class RepairTest extends TestCase { ->will($this->throwException(new \Exception())); $mock->expects($this->any()) ->method('getName') - ->will($this->returnValue('Exception Test')); + ->willReturn('Exception Test'); $this->repair->addStep($mock); $this->repair->addStep(new TestRepairStep(false)); @@ -101,17 +98,16 @@ class RepairTest extends TestCase { $thrown = false; try { $this->repair->run(); - } - catch (\Exception $e) { + } catch (\Exception $e) { $thrown = true; } $this->assertTrue($thrown); // jump out after exception $this->assertEquals( - array( + [ 'step: Exception Test', - ), + ], $this->outputArray ); } @@ -122,12 +118,12 @@ class RepairTest extends TestCase { $this->repair->run(); $this->assertEquals( - array( + [ 'step: Test Name', 'warning: Simulated warning', 'step: Test Name', 'info: Simulated info', - ), + ], $this->outputArray ); } diff --git a/tests/lib/RichObjectStrings/DefinitionsTest.php b/tests/lib/RichObjectStrings/DefinitionsTest.php index 829689704e7..a17585079f2 100644 --- a/tests/lib/RichObjectStrings/DefinitionsTest.php +++ b/tests/lib/RichObjectStrings/DefinitionsTest.php @@ -21,12 +21,10 @@ namespace Test\RichObjectStrings; - use OCP\RichObjectStrings\Definitions; use Test\TestCase; class DefinitionsTest extends TestCase { - public function dataGetDefinition() { $definitions = new Definitions(); $testsuite = []; @@ -88,6 +86,5 @@ class DefinitionsTest extends TestCase { $this->assertNotEquals('', $data['description'], 'Description of parameter ' . $parameter . ' must not be empty'); $this->assertArrayHasKey('example', $data); $this->assertNotEquals('', $data['example'], 'Example of parameter ' . $parameter . ' must not be empty'); - } } diff --git a/tests/lib/RichObjectStrings/ValidatorTest.php b/tests/lib/RichObjectStrings/ValidatorTest.php index 0c344248f77..45c6f745bdd 100644 --- a/tests/lib/RichObjectStrings/ValidatorTest.php +++ b/tests/lib/RichObjectStrings/ValidatorTest.php @@ -21,13 +21,11 @@ namespace Test\RichObjectStrings; - use OC\RichObjectStrings\Validator; use OCP\RichObjectStrings\Definitions; use Test\TestCase; class ValidatorTest extends TestCase { - public function test() { $v = new Validator(new Definitions()); $v->validate('test', []); @@ -51,5 +49,4 @@ class ValidatorTest extends TestCase { ]); $this->addToAssertionCount(2); } - } diff --git a/tests/lib/Security/Bruteforce/ThrottlerTest.php b/tests/lib/Security/Bruteforce/ThrottlerTest.php index 048540fb5a5..1c58849c9f8 100644 --- a/tests/lib/Security/Bruteforce/ThrottlerTest.php +++ b/tests/lib/Security/Bruteforce/ThrottlerTest.php @@ -185,7 +185,7 @@ class ThrottlerTest extends TestCase { ->willReturn($enabled); $this->config->method('getAppValue') - ->will($this->returnCallback(function($app, $key, $default) use ($whitelists) { + ->willReturnCallback(function ($app, $key, $default) use ($whitelists) { if ($app !== 'bruteForce') { return $default; } @@ -193,7 +193,7 @@ class ThrottlerTest extends TestCase { return $whitelists[$key]; } return $default; - })); + }); $this->assertSame( ($enabled === false) ? true : $isWhiteListed, diff --git a/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php b/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php index 01227ec359a..ef894bb56f3 100644 --- a/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php +++ b/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php index 009613fbe32..2fc7a53e78d 100644 --- a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php +++ b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php @@ -21,12 +21,9 @@ namespace Test\Security\CSP; - use OC\Security\CSP\ContentSecurityPolicyManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\Security\CSP\AddContentSecurityPolicyEvent; -use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; @@ -82,7 +79,7 @@ class ContentSecurityPolicyManagerTest extends TestCase { } public function testGetDefaultPolicyWithPoliciesViaEvent() { - $this->dispatcher->addListener(AddContentSecurityPolicyEvent::class, function(AddContentSecurityPolicyEvent $e) { + $this->dispatcher->addListener(AddContentSecurityPolicyEvent::class, function (AddContentSecurityPolicyEvent $e) { $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $policy->addAllowedFontDomain('mydomain.com'); $policy->addAllowedImageDomain('anotherdomain.de'); @@ -90,7 +87,7 @@ class ContentSecurityPolicyManagerTest extends TestCase { $e->addPolicy($policy); }); - $this->dispatcher->addListener(AddContentSecurityPolicyEvent::class, function(AddContentSecurityPolicyEvent $e) { + $this->dispatcher->addListener(AddContentSecurityPolicyEvent::class, function (AddContentSecurityPolicyEvent $e) { $policy = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $policy->addAllowedFontDomain('example.com'); $policy->addAllowedImageDomain('example.org'); @@ -99,7 +96,7 @@ class ContentSecurityPolicyManagerTest extends TestCase { $e->addPolicy($policy); }); - $this->dispatcher->addListener(AddContentSecurityPolicyEvent::class, function(AddContentSecurityPolicyEvent $e) { + $this->dispatcher->addListener(AddContentSecurityPolicyEvent::class, function (AddContentSecurityPolicyEvent $e) { $policy = new \OCP\AppFramework\Http\EmptyContentSecurityPolicy(); $policy->addAllowedChildSrcDomain('childdomain'); $policy->addAllowedFontDomain('anotherFontDomain'); @@ -122,5 +119,4 @@ class ContentSecurityPolicyManagerTest extends TestCase { $this->assertEquals($expected, $this->contentSecurityPolicyManager->getDefaultPolicy()); $this->assertSame($expectedStringPolicy, $this->contentSecurityPolicyManager->getDefaultPolicy()->buildPolicy()); } - } diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php index 346ace943d9..783eb35eef9 100644 --- a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php +++ b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php @@ -27,7 +27,7 @@ use OC\Security\CSRF\CsrfToken; use OC\Security\CSRF\CsrfTokenManager; use Test\TestCase; -class ContentSecurityPolicyNonceManagerTest extends TestCase { +class ContentSecurityPolicyNonceManagerTest extends TestCase { /** @var CsrfTokenManager */ private $csrfTokenManager; /** @var Request */ diff --git a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php index 5ab15c73bf2..10ab0f00c94 100644 --- a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php +++ b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php @@ -32,7 +32,6 @@ class CsrfTokenGeneratorTest extends \Test\TestCase { $this->random = $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor()->getMock(); $this->csrfTokenGenerator = new \OC\Security\CSRF\CsrfTokenGenerator($this->random); - } public function testGenerateTokenWithCustomNumber() { diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php index 136c3160413..d64c41c79e7 100644 --- a/tests/lib/Security/CertificateManagerTest.php +++ b/tests/lib/Security/CertificateManagerTest.php @@ -8,7 +8,6 @@ namespace Test\Security; -use OC\Files\Storage\Temporary; use OC\Files\View; use OC\Security\CertificateManager; use OCP\IConfig; @@ -77,13 +76,13 @@ class CertificateManagerTest extends \Test\TestCase { $this->assertEquals($expected, $actual); } - function testListCertificates() { + public function testListCertificates() { // Test empty certificate bundle - $this->assertSame(array(), $this->certificateManager->listCertificates()); + $this->assertSame([], $this->certificateManager->listCertificates()); // Add some certificates $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); - $certificateStore = array(); + $certificateStore = []; $certificateStore[] = new \OC\Security\Certificate(file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); $this->assertEqualsArrays($certificateStore, $this->certificateManager->listCertificates()); @@ -94,7 +93,7 @@ class CertificateManagerTest extends \Test\TestCase { } - function testAddInvalidCertificate() { + public function testAddInvalidCertificate() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Certificate could not get parsed.'); @@ -116,23 +115,23 @@ class CertificateManagerTest extends \Test\TestCase { * @dataProvider dangerousFileProvider * @param string $filename */ - function testAddDangerousFile($filename) { + public function testAddDangerousFile($filename) { $this->expectException(\Exception::class); $this->expectExceptionMessage('Filename is not valid'); $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/expiredCertificate.crt'), $filename); } - function testRemoveDangerousFile() { + public function testRemoveDangerousFile() { $this->assertFalse($this->certificateManager->removeCertificate('../../foo.txt')); } - function testRemoveExistingFile() { + public function testRemoveExistingFile() { $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); $this->assertTrue($this->certificateManager->removeCertificate('GoodCertificate')); } - function testGetCertificateBundle() { + public function testGetCertificateBundle() { $this->assertSame('/' . $this->username . '/files_external/rootcerts.crt', $this->certificateManager->getCertificateBundle()); } @@ -146,14 +145,13 @@ class CertificateManagerTest extends \Test\TestCase { * @param int $targetBundleExists * @param bool $expected */ - function testNeedRebundling($uid, + public function testNeedRebundling($uid, $CaBundleMtime, $systemWideMtime, $targetBundleMtime, $targetBundleExists, $expected ) { - $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $config = $this->createMock(IConfig::class); @@ -178,11 +176,10 @@ class CertificateManagerTest extends \Test\TestCase { if ($uid !== null && $targetBundleExists) { $certificateManager->expects($this->at(2))->method('getCertificateBundle') ->with(null)->willReturn('SystemBundlePath'); - } $view->expects($this->any())->method('filemtime') - ->willReturnCallback(function($path) use ($systemWideMtime, $targetBundleMtime) { + ->willReturnCallback(function ($path) use ($systemWideMtime, $targetBundleMtime) { if ($path === 'SystemBundlePath') { return $systemWideMtime; } elseif ($path === 'targetBundlePath') { @@ -195,10 +192,9 @@ class CertificateManagerTest extends \Test\TestCase { $this->assertSame($expected, $this->invokePrivate($certificateManager, 'needsRebundling', [$uid]) ); - } - function dataTestNeedRebundling() { + public function dataTestNeedRebundling() { return [ //values: uid, CaBundleMtime, systemWideMtime, targetBundleMtime, targetBundleExists, expected diff --git a/tests/lib/Security/CertificateTest.php b/tests/lib/Security/CertificateTest.php index 986554cf967..223fb226904 100644 --- a/tests/lib/Security/CertificateTest.php +++ b/tests/lib/Security/CertificateTest.php @@ -53,7 +53,7 @@ class CertificateTest extends \Test\TestCase { } - function testCertificateStartingWithFileReference() { + public function testCertificateStartingWithFileReference() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Certificate could not get parsed.'); diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php index 0b93c704b5c..9c1a0cb9291 100644 --- a/tests/lib/Security/CredentialsManagerTest.php +++ b/tests/lib/Security/CredentialsManagerTest.php @@ -27,6 +27,9 @@ use OCP\IDBConnection; use OCP\ILogger; use OCP\Security\ICrypto; +/** + * @group DB + */ class CredentialsManagerTest extends \Test\TestCase { /** @var ICrypto */ @@ -54,7 +57,7 @@ class CredentialsManagerTest extends \Test\TestCase { $result->expects($this->any()) ->method('fetch') - ->will($this->returnValue($row)); + ->willReturn($row); return $result; } @@ -107,4 +110,33 @@ class CredentialsManagerTest extends \Test\TestCase { $this->manager->retrieve($userId, $identifier); } + /** + * @dataProvider credentialsProvider + */ + public function testWithDB($userId, $identifier) { + $credentialsManager = \OC::$server->getCredentialsManager(); + + $secrets = 'Open Sesame'; + + $credentialsManager->store($userId, $identifier, $secrets); + $received = $credentialsManager->retrieve($userId, $identifier); + + $this->assertSame($secrets, $received); + + $removedRows = $credentialsManager->delete($userId, $identifier); + $this->assertSame(1, $removedRows); + } + + public function credentialsProvider() { + return [ + [ + 'alice', + 'privateCredentials' + ], + [ + '', + 'systemCredentials', + ], + ]; + } } diff --git a/tests/lib/Security/CryptoTest.php b/tests/lib/Security/CryptoTest.php index a2c8055750b..dbdf6f6a195 100644 --- a/tests/lib/Security/CryptoTest.php +++ b/tests/lib/Security/CryptoTest.php @@ -11,14 +11,12 @@ namespace Test\Security; use OC\Security\Crypto; class CryptoTest extends \Test\TestCase { - - public function defaultEncryptionProvider() - { - return array( - array('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'), - array(''), - array('我看这本书。 我看這本書') - ); + public function defaultEncryptionProvider() { + return [ + ['Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'], + [''], + ['我看这本书。 我看這本書'] + ]; } /** @var Crypto */ @@ -26,19 +24,19 @@ class CryptoTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->crypto = new Crypto(\OC::$server->getConfig(), \OC::$server->getSecureRandom()); + $this->crypto = new Crypto(\OC::$server->getConfig()); } /** * @dataProvider defaultEncryptionProvider */ - function testDefaultEncrypt($stringToEncrypt) { + public function testDefaultEncrypt($stringToEncrypt) { $ciphertext = $this->crypto->encrypt($stringToEncrypt); $this->assertEquals($stringToEncrypt, $this->crypto->decrypt($ciphertext)); } - - function testWrongPassword() { + + public function testWrongPassword() { $this->expectException(\Exception::class); $this->expectExceptionMessage('HMAC does not match.'); @@ -47,14 +45,14 @@ class CryptoTest extends \Test\TestCase { $this->crypto->decrypt($ciphertext, 'A wrong password!'); } - function testLaterDecryption() { + public function testLaterDecryption() { $stringToEncrypt = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'; $encryptedString = '44a35023cca2e7a6125e06c29fc4b2ad9d8a33d0873a8b45b0de4ef9284f260c6c46bf25dc62120644c59b8bafe4281ddc47a70c35ae6c29ef7a63d79eefacc297e60b13042ac582733598d0a6b4de37311556bb5c480fd2633de4e6ebafa868c2d1e2d80a5d24f9660360dba4d6e0c8|lhrFgK0zd9U160Wo|a75e57ab701f9124e1113543fd1dc596f21e20d456a0d1e813d5a8aaec9adcb11213788e96598b67fe9486a9f0b99642c18296d0175db44b1ae426e4e91080ee'; $this->assertEquals($stringToEncrypt, $this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd')); } - - function testWrongIV() { + + public function testWrongIV() { $this->expectException(\Exception::class); $this->expectExceptionMessage('HMAC does not match.'); @@ -62,12 +60,19 @@ class CryptoTest extends \Test\TestCase { $this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd'); } - - function testWrongParameters() { + + public function testWrongParameters() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Authenticated ciphertext could not be decoded.'); $encryptedString = '1|2'; $this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd'); } + + public function testLegacy() { + $cipherText = 'e16599188e3d212f5c7f17fdc2abca46|M1WfLAxbcAmITeD6|509457885d6ca5e6c3bfd3741852687a7f2bffce197f8d5ae97b65818b15a1b7f616b68326ff312371540f4ca8ac55f8e2de4aa13aab3474bd3431e51214e3ee'; + $password = 'mypass'; + + $this->assertSame('legacy test', $this->crypto->decrypt($cipherText, $password)); + } } diff --git a/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php b/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php index 75525c306ca..6e6433adbeb 100644 --- a/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php +++ b/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> diff --git a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php index 179bd6630ba..b8f558719dc 100644 --- a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php +++ b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php @@ -1,4 +1,5 @@ <?php + declare(strict_types=1); /** * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> @@ -24,14 +25,10 @@ declare(strict_types=1); namespace Test\Security\CSP; -use OC\Security\CSP\ContentSecurityPolicyManager; use OC\Security\FeaturePolicy\FeaturePolicyManager; use OCP\AppFramework\Http\FeaturePolicy; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Security\CSP\AddContentSecurityPolicyEvent; use OCP\Security\FeaturePolicy\AddFeaturePolicyEvent; -use PHPUnit\Framework\MockObject\MockObject; -use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; @@ -54,7 +51,7 @@ class FeaturePolicyManagerTest extends TestCase { } public function testGetDefaultPolicyWithPoliciesViaEvent() { - $this->dispatcher->addListener(AddFeaturePolicyEvent::class, function(AddFeaturePolicyEvent $e) { + $this->dispatcher->addListener(AddFeaturePolicyEvent::class, function (AddFeaturePolicyEvent $e) { $policy = new FeaturePolicy(); $policy->addAllowedMicrophoneDomain('mydomain.com'); $policy->addAllowedPaymentDomain('mypaymentdomain.com'); @@ -62,7 +59,7 @@ class FeaturePolicyManagerTest extends TestCase { $e->addPolicy($policy); }); - $this->dispatcher->addListener(AddFeaturePolicyEvent::class, function(AddFeaturePolicyEvent $e) { + $this->dispatcher->addListener(AddFeaturePolicyEvent::class, function (AddFeaturePolicyEvent $e) { $policy = new FeaturePolicy(); $policy->addAllowedPaymentDomain('mydomainother.com'); $policy->addAllowedGeoLocationDomain('mylocation.here'); @@ -70,7 +67,7 @@ class FeaturePolicyManagerTest extends TestCase { $e->addPolicy($policy); }); - $this->dispatcher->addListener(AddFeaturePolicyEvent::class, function(AddFeaturePolicyEvent $e) { + $this->dispatcher->addListener(AddFeaturePolicyEvent::class, function (AddFeaturePolicyEvent $e) { $policy = new FeaturePolicy(); $policy->addAllowedAutoplayDomain('youtube.com'); @@ -89,5 +86,4 @@ class FeaturePolicyManagerTest extends TestCase { $this->assertEquals($expected, $this->manager->getDefaultPolicy()); $this->assertSame($expectedStringPolicy, $this->manager->getDefaultPolicy()->buildPolicy()); } - } diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php index 76f880c1c12..e1faef2f69b 100644 --- a/tests/lib/Security/HasherTest.php +++ b/tests/lib/Security/HasherTest.php @@ -19,8 +19,7 @@ class HasherTest extends \Test\TestCase { /** * @return array */ - public function versionHashProvider() - { + public function versionHashProvider() { return [ ['asf32äà$$a.|3', null], ['asf32äà$$a.|3|5', null], @@ -30,8 +29,7 @@ class HasherTest extends \Test\TestCase { ]; } - public function hashProviders70_71(): array - { + public function hashProviders70_71(): array { return [ // Valid SHA1 strings ['password', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', true], @@ -115,6 +113,11 @@ class HasherTest extends \Test\TestCase { $this->config = $this->createMock(IConfig::class); + $this->config->method('getSystemValueInt') + ->willReturnCallback(function ($name, $default) { + return $default; + }); + $this->hasher = new Hasher($this->config); } @@ -140,7 +143,7 @@ class HasherTest extends \Test\TestCase { ->expects($this->any()) ->method('getSystemValue') ->willReturnCallback(function ($key, $default) { - if($key === 'passwordsalt') { + if ($key === 'passwordsalt') { return '6Wow67q1wZQZpUUeI6G2LsWUu4XKx'; } return $default; @@ -259,6 +262,5 @@ class HasherTest extends \Test\TestCase { $info = password_get_info($relativePath['hash']); $this->assertEquals(PASSWORD_BCRYPT, $info['algo']); - } } diff --git a/tests/lib/Security/IdentityProof/ManagerTest.php b/tests/lib/Security/IdentityProof/ManagerTest.php index aff6d3ed5c7..5fd1d709c2f 100644 --- a/tests/lib/Security/IdentityProof/ManagerTest.php +++ b/tests/lib/Security/IdentityProof/ManagerTest.php @@ -33,10 +33,9 @@ use OCP\ILogger; use OCP\IUser; use OCP\Security\ICrypto; use PHPUnit\Framework\MockObject\MockObject; -use SebastianBergmann\Comparator\MockObjectComparator; use Test\TestCase; -class ManagerTest extends TestCase { +class ManagerTest extends TestCase { /** @var Factory|MockObject */ private $factory; /** @var IAppData|MockObject */ @@ -215,7 +214,6 @@ class ManagerTest extends TestCase { ->willReturn($key); $this->assertSame($key, $manager->getSystemKey()); - } diff --git a/tests/lib/Security/IdentityProof/SignerTest.php b/tests/lib/Security/IdentityProof/SignerTest.php index 884065e6a1a..913ab7c15f5 100644 --- a/tests/lib/Security/IdentityProof/SignerTest.php +++ b/tests/lib/Security/IdentityProof/SignerTest.php @@ -200,6 +200,4 @@ gQIDAQAB $this->assertFalse($this->signer->verify($data)); } - - } diff --git a/tests/lib/Security/Normalizer/IpAddressTest.php b/tests/lib/Security/Normalizer/IpAddressTest.php index 97a8737ea9e..16be71cb225 100644 --- a/tests/lib/Security/Normalizer/IpAddressTest.php +++ b/tests/lib/Security/Normalizer/IpAddressTest.php @@ -25,7 +25,6 @@ use OC\Security\Normalizer\IpAddress; use Test\TestCase; class IpAddressTest extends TestCase { - public function subnetDataProvider() { return [ [ diff --git a/tests/lib/Security/RateLimiting/LimiterTest.php b/tests/lib/Security/RateLimiting/LimiterTest.php index 20b35029050..ea74f476f3c 100644 --- a/tests/lib/Security/RateLimiting/LimiterTest.php +++ b/tests/lib/Security/RateLimiting/LimiterTest.php @@ -24,10 +24,7 @@ namespace Test\Security\RateLimiting; use OC\Security\RateLimiting\Backend\IBackend; use OC\Security\RateLimiting\Limiter; use OCP\AppFramework\Utility\ITimeFactory; -use OCP\ICacheFactory; -use OCP\IRequest; use OCP\IUser; -use OCP\IUserSession; use Test\TestCase; class LimiterTest extends TestCase { diff --git a/tests/lib/Security/SecureRandomTest.php b/tests/lib/Security/SecureRandomTest.php index 71839115a3c..0ffd7ae7c14 100644 --- a/tests/lib/Security/SecureRandomTest.php +++ b/tests/lib/Security/SecureRandomTest.php @@ -11,25 +11,24 @@ namespace Test\Security; use OC\Security\SecureRandom; class SecureRandomTest extends \Test\TestCase { - public function stringGenerationProvider() { - return array( - array(0, 0), - array(1, 1), - array(128, 128), - array(256, 256), - array(1024, 1024), - array(2048, 2048), - array(64000, 64000), - ); + return [ + [0, 0], + [1, 1], + [128, 128], + [256, 256], + [1024, 1024], + [2048, 2048], + [64000, 64000], + ]; } public static function charCombinations() { - return array( - array('CHAR_LOWER', '[a-z]'), - array('CHAR_UPPER', '[A-Z]'), - array('CHAR_DIGITS', '[0-9]'), - ); + return [ + ['CHAR_LOWER', '[a-z]'], + ['CHAR_UPPER', '[A-Z]'], + ['CHAR_DIGITS', '[0-9]'], + ]; } /** @var SecureRandom */ @@ -43,7 +42,7 @@ class SecureRandomTest extends \Test\TestCase { /** * @dataProvider stringGenerationProvider */ - function testGetLowStrengthGeneratorLength($length, $expectedLength) { + public function testGetLowStrengthGeneratorLength($length, $expectedLength) { $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); @@ -52,7 +51,7 @@ class SecureRandomTest extends \Test\TestCase { /** * @dataProvider stringGenerationProvider */ - function testMediumLowStrengthGeneratorLength($length, $expectedLength) { + public function testMediumLowStrengthGeneratorLength($length, $expectedLength) { $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); @@ -61,7 +60,7 @@ class SecureRandomTest extends \Test\TestCase { /** * @dataProvider stringGenerationProvider */ - function testUninitializedGenerate($length, $expectedLength) { + public function testUninitializedGenerate($length, $expectedLength) { $this->assertEquals($expectedLength, strlen($this->rng->generate($length))); } diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php index f3ee14dead1..2796dead0e2 100644 --- a/tests/lib/Security/TrustedDomainHelperTest.php +++ b/tests/lib/Security/TrustedDomainHelperTest.php @@ -34,11 +34,11 @@ class TrustedDomainHelperTest extends \Test\TestCase { $this->config->expects($this->at(0)) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('')); + ->willReturn(''); $this->config->expects($this->at(1)) ->method('getSystemValue') ->with('trusted_domains') - ->will($this->returnValue($trustedDomains)); + ->willReturn($trustedDomains); $trustedDomainHelper = new TrustedDomainHelper($this->config); $this->assertEquals($result, $trustedDomainHelper->isTrustedDomain($testDomain)); @@ -122,7 +122,7 @@ class TrustedDomainHelperTest extends \Test\TestCase { $this->config->expects($this->at(0)) ->method('getSystemValue') ->with('overwritehost') - ->will($this->returnValue('myproxyhost')); + ->willReturn('myproxyhost'); $trustedDomainHelper = new TrustedDomainHelper($this->config); $this->assertTrue($trustedDomainHelper->isTrustedDomain('myproxyhost')); diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php index fbedad61fd7..ada25247393 100644 --- a/tests/lib/ServerTest.php +++ b/tests/lib/ServerTest.php @@ -23,6 +23,7 @@ */ namespace Test; + use OC\App\AppStore\Fetcher\AppFetcher; use OC\App\AppStore\Fetcher\CategoryFetcher; diff --git a/tests/lib/Session/MemoryTest.php b/tests/lib/Session/MemoryTest.php index 79053ccb1c8..fab7292ae00 100644 --- a/tests/lib/Session/MemoryTest.php +++ b/tests/lib/Session/MemoryTest.php @@ -10,7 +10,6 @@ namespace Test\Session; class MemoryTest extends Session { - protected function setUp(): void { parent::setUp(); $this->instance = new \OC\Session\Memory($this->getUniqueID()); @@ -22,5 +21,4 @@ class MemoryTest extends Session { $this->instance->getId(); } - } diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index bce547c9a29..a0d341266e8 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -24,7 +24,6 @@ namespace OCA\Settings\Tests\AppInfo; use OC\Settings\Manager; -use OCA\Settings\Admin\Sharing; use OCP\IDBConnection; use OCP\IL10N; use OCP\ILogger; @@ -96,7 +95,7 @@ class ManagerTest extends TestCase { $this->l10n ->expects($this->any()) ->method('t') - ->will($this->returnArgument(0)); + ->willReturnArgument(0); $this->assertEquals([], $this->manager->getPersonalSections()); } @@ -195,7 +194,7 @@ class ManagerTest extends TestCase { $this->l10n ->expects($this->any()) ->method('t') - ->will($this->returnArgument(0)); + ->willReturnArgument(0); $this->manager->registerSection('personal', \OCA\WorkflowEngine\Settings\Section::class); $this->manager->registerSection('admin', \OCA\WorkflowEngine\Settings\Section::class); diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php index 7ab3eb78539..0890b70dfcd 100644 --- a/tests/lib/SetupTest.php +++ b/tests/lib/SetupTest.php @@ -56,17 +56,17 @@ class SetupTest extends \Test\TestCase { $this->config ->expects($this->once()) ->method('getValue') - ->will($this->returnValue( + ->willReturn( ['sqlite', 'mysql', 'oci'] - )); + ); $this->setupClass ->expects($this->once()) ->method('is_callable') - ->will($this->returnValue(false)); + ->willReturn(false); $this->setupClass ->expects($this->any()) ->method('getAvailableDbDriversForPdo') - ->will($this->returnValue(['sqlite'])); + ->willReturn(['sqlite']); $result = $this->setupClass->getSupportedDatabases(); $expectedResult = [ 'sqlite' => 'SQLite' @@ -79,17 +79,17 @@ class SetupTest extends \Test\TestCase { $this->config ->expects($this->once()) ->method('getValue') - ->will($this->returnValue( + ->willReturn( ['sqlite', 'mysql', 'oci', 'pgsql'] - )); + ); $this->setupClass ->expects($this->any()) ->method('is_callable') - ->will($this->returnValue(false)); + ->willReturn(false); $this->setupClass ->expects($this->any()) ->method('getAvailableDbDriversForPdo') - ->will($this->returnValue([])); + ->willReturn([]); $result = $this->setupClass->getSupportedDatabases(); $this->assertSame([], $result); @@ -99,17 +99,17 @@ class SetupTest extends \Test\TestCase { $this->config ->expects($this->once()) ->method('getValue') - ->will($this->returnValue( + ->willReturn( ['sqlite', 'mysql', 'pgsql', 'oci'] - )); + ); $this->setupClass ->expects($this->any()) ->method('is_callable') - ->will($this->returnValue(true)); + ->willReturn(true); $this->setupClass ->expects($this->any()) ->method('getAvailableDbDriversForPdo') - ->will($this->returnValue(['sqlite', 'mysql', 'pgsql'])); + ->willReturn(['sqlite', 'mysql', 'pgsql']); $result = $this->setupClass->getSupportedDatabases(); $expectedResult = [ 'sqlite' => 'SQLite', @@ -128,7 +128,7 @@ class SetupTest extends \Test\TestCase { $this->config ->expects($this->once()) ->method('getValue') - ->will($this->returnValue('NotAnArray')); + ->willReturn('NotAnArray'); $this->setupClass->getSupportedDatabases(); } @@ -143,7 +143,7 @@ class SetupTest extends \Test\TestCase { $this->config ->expects($this->once()) ->method('getValue') - ->will($this->returnValue($url)); + ->willReturn($url); \OC::$CLI = true; try { diff --git a/tests/lib/Share/Backend.php b/tests/lib/Share/Backend.php index 13a86bfae30..18443a4e247 100644 --- a/tests/lib/Share/Backend.php +++ b/tests/lib/Share/Backend.php @@ -1,31 +1,30 @@ <?php /** -* ownCloud -* -* @author Michael Gapczynski -* @copyright 2012 Michael Gapczynski mtgap@owncloud.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -*/ + * ownCloud + * + * @author Michael Gapczynski + * @copyright 2012 Michael Gapczynski mtgap@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ namespace Test\Share; class Backend implements \OCP\Share_Backend { - - const FORMAT_SOURCE = 0; - const FORMAT_TARGET = 1; - const FORMAT_PERMISSIONS = 2; + public const FORMAT_SOURCE = 0; + public const FORMAT_TARGET = 1; + public const FORMAT_PERMISSIONS = 2; private $testItem1 = 'test.txt'; private $testItem2 = 'share.txt'; @@ -49,7 +48,7 @@ class Backend implements \OCP\Share_Backend { $shares = \OC\Share\Share::getItemsSharedWithUser('test', $shareWith); - $knownTargets = array(); + $knownTargets = []; foreach ($shares as $share) { $knownTargets[] = $share['item_target']; } @@ -66,20 +65,19 @@ class Backend implements \OCP\Share_Backend { $i++; } $target = $name.$append.$ext; - } return $target; } public function formatItems($items, $format, $parameters = null) { - $testItems = array(); + $testItems = []; foreach ($items as $item) { if ($format === self::FORMAT_SOURCE) { $testItems[] = $item['item_source']; - } else if ($format === self::FORMAT_TARGET) { + } elseif ($format === self::FORMAT_TARGET) { $testItems[] = $item['item_target']; - } else if ($format === self::FORMAT_PERMISSIONS) { + } elseif ($format === self::FORMAT_PERMISSIONS) { $testItems[] = $item['permissions']; } } @@ -89,5 +87,4 @@ class Backend implements \OCP\Share_Backend { public function isShareTypeAllowed($shareType) { return true; } - } diff --git a/tests/lib/Share/HelperTest.php b/tests/lib/Share/HelperTest.php index dc2d26509e3..44bd70e7e29 100644 --- a/tests/lib/Share/HelperTest.php +++ b/tests/lib/Share/HelperTest.php @@ -1,23 +1,23 @@ <?php /** -* ownCloud -* -* @author Bjoern Schiessle -* @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -*/ + * ownCloud + * + * @author Bjoern Schiessle + * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ namespace Test\Share; @@ -26,26 +26,25 @@ namespace Test\Share; * Class Helper */ class HelperTest extends \Test\TestCase { - public function expireDateProvider() { - return array( + return [ // no default expire date, we take the users expire date - array(array('defaultExpireDateSet' => false), 2000000000, 2000010000, 2000010000), + [['defaultExpireDateSet' => false], 2000000000, 2000010000, 2000010000], // no default expire date and no user defined expire date, return false - array(array('defaultExpireDateSet' => false), 2000000000, null, false), + [['defaultExpireDateSet' => false], 2000000000, null, false], // unenforced expire data and no user defined expire date, return false (because the default is not enforced) - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false), 2000000000, null, false), + [['defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false], 2000000000, null, false], // enforced expire date and no user defined expire date, take default expire date - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true), 2000000000, null, 2000086400), + [['defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true], 2000000000, null, 2000086400], // unenforced expire date and user defined date > default expire date, take users expire date - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false), 2000000000, 2000100000, 2000100000), + [['defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false], 2000000000, 2000100000, 2000100000], // unenforced expire date and user expire date < default expire date, take users expire date - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false), 2000000000, 2000010000, 2000010000), + [['defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => false], 2000000000, 2000010000, 2000010000], // enforced expire date and user expire date < default expire date, take users expire date - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true), 2000000000, 2000010000, 2000010000), + [['defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true], 2000000000, 2000010000, 2000010000], // enforced expire date and users expire date > default expire date, take default expire date - array(array('defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true), 2000000000, 2000100000, 2000086400), - ); + [['defaultExpireDateSet' => true, 'expireAfterDays' => 1, 'enforceExpireDate' => true], 2000000000, 2000100000, 2000086400], + ]; } /** @@ -101,21 +100,21 @@ class HelperTest extends \Test\TestCase { } public function dataTestSplitUserRemoteError() { - return array( + return [ // Invalid path - array('user@'), + ['user@'], // Invalid user - array('@server'), - array('us/er@server'), - array('us:er@server'), + ['@server'], + ['us/er@server'], + ['us:er@server'], // Invalid splitting - array('user'), - array(''), - array('us/erserver'), - array('us:erserver'), - ); + ['user'], + [''], + ['us/erserver'], + ['us:erserver'], + ]; } /** diff --git a/tests/lib/Share/SearchResultSorterTest.php b/tests/lib/Share/SearchResultSorterTest.php index 7feccdd82f5..63c3aead62e 100644 --- a/tests/lib/Share/SearchResultSorterTest.php +++ b/tests/lib/Share/SearchResultSorterTest.php @@ -1,23 +1,23 @@ <?php /** -* ownCloud -* -* @author Arthur Schiwon -* @copyright 2014 Arthur Schiwon <blizzz@owncloud.com> -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -*/ + * ownCloud + * + * @author Arthur Schiwon + * @copyright 2014 Arthur Schiwon <blizzz@owncloud.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ namespace Test\Share; @@ -26,14 +26,14 @@ class SearchResultSorterTest extends \Test\TestCase { $search = 'lin'; $sorter = new \OC\Share\SearchResultSorter($search, 'foobar'); - $result = array( - array('foobar' => 'woot'), - array('foobar' => 'linux'), - array('foobar' => 'Linus'), - array('foobar' => 'Bicyclerepairwoman'), - ); + $result = [ + ['foobar' => 'woot'], + ['foobar' => 'linux'], + ['foobar' => 'Linus'], + ['foobar' => 'Bicyclerepairwoman'], + ]; - usort($result, array($sorter, 'sort')); + usort($result, [$sorter, 'sort']); $this->assertTrue($result[0]['foobar'] === 'Linus'); $this->assertTrue($result[1]['foobar'] === 'linux'); $this->assertTrue($result[2]['foobar'] === 'Bicyclerepairwoman'); diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php index af05d0c4bdd..fce963ec43a 100644 --- a/tests/lib/Share/ShareTest.php +++ b/tests/lib/Share/ShareTest.php @@ -1,29 +1,29 @@ <?php /** -* ownCloud -* -* @author Michael Gapczynski -* @copyright 2012 Michael Gapczynski mtgap@owncloud.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -*/ + * ownCloud + * + * @author Michael Gapczynski + * @copyright 2012 Michael Gapczynski mtgap@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ namespace Test\Share; + use OC\Share\Share; use OCP\IGroup; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; @@ -33,7 +33,6 @@ use OCP\IUserManager; * @group DB */ class ShareTest extends \Test\TestCase { - protected $itemType; /** @var IUser */ @@ -115,7 +114,7 @@ class ShareTest extends \Test\TestCase { protected function tearDown(): void { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?'); - $query->execute(array('test')); + $query->execute(['test']); \OC::$server->getConfig()->setAppValue('core', 'shareapi_allow_resharing', $this->resharing); $this->user1->delete(); @@ -141,37 +140,37 @@ class ShareTest extends \Test\TestCase { $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (' .' `item_type`, `item_source`, `item_target`, `share_type`,' .' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)'); - $args = array('test', 99, 'target1', \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), $this->user1->getUID()); + $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), $this->user1->getUID()]; $query->execute($args); - $args = array('test', 99, 'target2', \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), $this->user1->getUID()); + $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), $this->user1->getUID()]; $query->execute($args); - $args = array('test', 99, 'target3', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user2->getUID()); + $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user2->getUID()]; $query->execute($args); - $args = array('test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user4->getUID()); + $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user4->getUID()]; $query->execute($args); - $args = array('test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user6->getUID(), $this->user4->getUID()); + $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user6->getUID(), $this->user4->getUID()]; $query->execute($args); $result1 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user2->getUID(), $this->user1->getUID()); $this->assertSame(1, count($result1)); - $this->verifyResult($result1, array('target1')); + $this->verifyResult($result1, ['target1']); $result2 = \OCP\Share::getItemSharedWithUser('test', 99, null, $this->user1->getUID()); $this->assertSame(2, count($result2)); - $this->verifyResult($result2, array('target1', 'target2')); + $this->verifyResult($result2, ['target1', 'target2']); $result3 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user3->getUID()); $this->assertSame(2, count($result3)); - $this->verifyResult($result3, array('target3', 'target4')); + $this->verifyResult($result3, ['target3', 'target4']); $result4 = \OCP\Share::getItemSharedWithUser('test', 99, null, null); $this->assertSame(5, count($result4)); // 5 because target4 appears twice - $this->verifyResult($result4, array('target1', 'target2', 'target3', 'target4')); + $this->verifyResult($result4, ['target1', 'target2', 'target3', 'target4']); $result6 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user6->getUID(), null); $this->assertSame(1, count($result6)); - $this->verifyResult($result6, array('target4')); + $this->verifyResult($result6, ['target4']); } public function testGetItemSharedWithUserFromGroupShare() { @@ -181,32 +180,32 @@ class ShareTest extends \Test\TestCase { $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (' .' `item_type`, `item_source`, `item_target`, `share_type`,' .' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)'); - $args = array('test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()); + $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()]; $query->execute($args); - $args = array('test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()); + $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()]; $query->execute($args); - $args = array('test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()); + $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()]; $query->execute($args); - $args = array('test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()); + $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()]; $query->execute($args); // user2 is in group1 and group2 $result1 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user2->getUID(), $this->user1->getUID()); $this->assertSame(2, count($result1)); - $this->verifyResult($result1, array('target1', 'target2')); + $this->verifyResult($result1, ['target1', 'target2']); $result2 = \OCP\Share::getItemSharedWithUser('test', 99, null, $this->user1->getUID()); $this->assertSame(2, count($result2)); - $this->verifyResult($result2, array('target1', 'target2')); + $this->verifyResult($result2, ['target1', 'target2']); // user3 is in group1 and group2 $result3 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user3->getUID()); $this->assertSame(3, count($result3)); - $this->verifyResult($result3, array('target1', 'target3', 'target4')); + $this->verifyResult($result3, ['target1', 'target3', 'target4']); $result4 = \OCP\Share::getItemSharedWithUser('test', 99, null, null); $this->assertSame(4, count($result4)); - $this->verifyResult($result4, array('target1', 'target2', 'target3', 'target4')); + $this->verifyResult($result4, ['target1', 'target2', 'target3', 'target4']); $result6 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user6->getUID(), null); $this->assertSame(0, count($result6)); @@ -227,18 +226,18 @@ class ShareTest extends \Test\TestCase { * @param string $url * @param string $expectedResult */ - function testRemoveProtocolFromUrl($url, $expectedResult) { + public function testRemoveProtocolFromUrl($url, $expectedResult) { $share = new \OC\Share\Share(); - $result = self::invokePrivate($share, 'removeProtocolFromUrl', array($url)); + $result = self::invokePrivate($share, 'removeProtocolFromUrl', [$url]); $this->assertSame($expectedResult, $result); } - function urls() { - return array( - array('http://owncloud.org', 'owncloud.org'), - array('https://owncloud.org', 'owncloud.org'), - array('owncloud.org', 'owncloud.org'), - ); + public function urls() { + return [ + ['http://owncloud.org', 'owncloud.org'], + ['https://owncloud.org', 'owncloud.org'], + ['owncloud.org', 'owncloud.org'], + ]; } /** @@ -246,15 +245,13 @@ class ShareTest extends \Test\TestCase { * @param array $ungrouped * @param array $grouped */ - function testGroupItems($ungrouped, $grouped) { - + public function testGroupItems($ungrouped, $grouped) { $result = DummyShareClass::groupItemsTest($ungrouped); $this->compareArrays($grouped, $result); - } - function compareArrays($result, $expectedResult) { + public function compareArrays($result, $expectedResult) { foreach ($expectedResult as $key => $value) { if (is_array($value)) { $this->compareArrays($result[$key], $value); @@ -264,58 +261,58 @@ class ShareTest extends \Test\TestCase { } } - function dataProviderTestGroupItems() { - return array( + public function dataProviderTestGroupItems() { + return [ // one array with one share - array( - array( // input - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1')), - array( // expected result - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1'))), + [ + [ // input + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1']], + [ // expected result + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1']]], // two shares both point to the same source - array( - array( // input - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), - ), - array( // expected result - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1', - 'grouped' => array( - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), - ) - ), - ) - ), + [ + [ // input + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'], + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'], + ], + [ // expected result + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1', + 'grouped' => [ + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'], + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'], + ] + ], + ] + ], // two shares both point to the same source but with different targets - array( - array( // input - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'), - ), - array( // expected result - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'), - ) - ), + [ + [ // input + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'], + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'], + ], + [ // expected result + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'], + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'], + ] + ], // three shares two point to the same source - array( - array( // input - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'), - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), - ), - array( // expected result - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1', - 'grouped' => array( - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'), - array('item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'), - ) - ), - array('item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'), - ) - ), - ); + [ + [ // input + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'], + ['item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'], + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'], + ], + [ // expected result + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1', + 'grouped' => [ + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'], + ['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'], + ] + ], + ['item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'], + ] + ], + ]; } } @@ -326,7 +323,7 @@ class DummyShareClass extends \OC\Share\Share { } class DummyHookListener { - static $shareType = null; + public static $shareType = null; public static function listen($params) { self::$shareType = $params['shareType']; diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index ff3cafbdf7c..6f8a96fab19 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -125,17 +125,39 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share'); - if ($shareType) $qb->setValue('share_type', $qb->expr()->literal($shareType)); - if ($sharedWith) $qb->setValue('share_with', $qb->expr()->literal($sharedWith)); - if ($sharedBy) $qb->setValue('uid_initiator', $qb->expr()->literal($sharedBy)); - if ($shareOwner) $qb->setValue('uid_owner', $qb->expr()->literal($shareOwner)); - if ($itemType) $qb->setValue('item_type', $qb->expr()->literal($itemType)); - if ($fileSource) $qb->setValue('file_source', $qb->expr()->literal($fileSource)); - if ($fileTarget) $qb->setValue('file_target', $qb->expr()->literal($fileTarget)); - if ($permissions) $qb->setValue('permissions', $qb->expr()->literal($permissions)); - if ($token) $qb->setValue('token', $qb->expr()->literal($token)); - if ($expiration) $qb->setValue('expiration', $qb->createNamedParameter($expiration, IQueryBuilder::PARAM_DATE)); - if ($parent) $qb->setValue('parent', $qb->expr()->literal($parent)); + if ($shareType) { + $qb->setValue('share_type', $qb->expr()->literal($shareType)); + } + if ($sharedWith) { + $qb->setValue('share_with', $qb->expr()->literal($sharedWith)); + } + if ($sharedBy) { + $qb->setValue('uid_initiator', $qb->expr()->literal($sharedBy)); + } + if ($shareOwner) { + $qb->setValue('uid_owner', $qb->expr()->literal($shareOwner)); + } + if ($itemType) { + $qb->setValue('item_type', $qb->expr()->literal($itemType)); + } + if ($fileSource) { + $qb->setValue('file_source', $qb->expr()->literal($fileSource)); + } + if ($fileTarget) { + $qb->setValue('file_target', $qb->expr()->literal($fileTarget)); + } + if ($permissions) { + $qb->setValue('permissions', $qb->expr()->literal($permissions)); + } + if ($token) { + $qb->setValue('token', $qb->expr()->literal($token)); + } + if ($expiration) { + $qb->setValue('expiration', $qb->createNamedParameter($expiration, IQueryBuilder::PARAM_DATE)); + } + if ($parent) { + $qb->setValue('parent', $qb->expr()->literal($parent)); + } $this->assertEquals(1, $qb->execute()); return$qb->getLastInsertId(); @@ -143,7 +165,7 @@ class DefaultShareProviderTest extends \Test\TestCase { - + public function testGetShareByIdNotExist() { $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class); @@ -179,9 +201,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap([ + ->willReturnMap([ ['shareOwner', $shareOwnerFolder], - ])); + ]); $share = $this->provider->getShareById($id); @@ -301,9 +323,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap([ - ['shareOwner', $shareOwnerFolder], - ])); + ->willReturnMap([ + ['shareOwner', $shareOwnerFolder], + ]); $share = $this->provider->getShareById($id); @@ -334,13 +356,13 @@ class DefaultShareProviderTest extends \Test\TestCase { $node = $this->createMock(Folder::class); $node->method('getId')->willReturn(42); - $this->rootFolder->method('getUserFolder')->with('user0')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user0')->willReturnSelf(); $this->rootFolder->method('getById')->willReturn([$node]); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user0', $user0], ['user1', $user1], - ])); + ]); $this->groupManager->method('get')->with('group0')->willReturn($group0); $share = $this->provider->getShareById($id, 'user1'); @@ -384,9 +406,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap([ - ['shareOwner', $shareOwnerFolder], - ])); + ->willReturnMap([ + ['shareOwner', $shareOwnerFolder], + ]); $share = $this->provider->getShareById($id); @@ -599,9 +621,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap([ + ->willReturnMap([ ['shareOwner', $ownerFolder], - ])); + ]); $share = $this->createMock(IShare::class); $share->method('getId')->willReturn($id); @@ -647,10 +669,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $userFolder = $this->createMock(Folder::class); $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap([ + ->willReturnMap([ ['sharedBy', $userFolder], ['shareOwner', $ownerFolder], - ])); + ]); $userFolder->method('getById') ->with(100) @@ -703,10 +725,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $userFolder = $this->createMock(Folder::class); $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap([ + ->willReturnMap([ ['sharedBy', $userFolder], ['shareOwner', $ownerFolder], - ])); + ]); $userFolder->method('getById') ->with(100) @@ -743,7 +765,6 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame('/path/to/image.svg', $share->getSharedWithAvatar()); $this->assertSame(null, $share2->getSharedWithDisplayName()); $this->assertSame(null, $share2->getSharedWithAvatar()); - } public function testCreateLinkShare() { @@ -760,10 +781,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $userFolder = $this->createMock(Folder::class); $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap([ - ['sharedBy', $userFolder], - ['shareOwner', $ownerFolder], - ])); + ->willReturnMap([ + ['sharedBy', $userFolder], + ['shareOwner', $ownerFolder], + ]); $userFolder->method('getById') ->with(100) @@ -822,7 +843,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $file = $this->createMock(File::class); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); $share = $this->provider->getShareByToken('secrettoken'); @@ -835,7 +856,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame(null, $share->getSharedWith()); } - + public function testGetShareByTokenNotFound() { $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class); @@ -913,7 +934,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals(1, $qb->execute()); $file = $this->createMock(File::class); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]); $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_USER, null, 1 , 0); @@ -964,15 +985,11 @@ class DefaultShareProviderTest extends \Test\TestCase { $id = $qb->getLastInsertId(); $groups = []; - foreach(range(0, 100) as $i) { - $group = $this->createMock(IGroup::class); - $group->method('getGID')->willReturn('group'.$i); - $groups[] = $group; + foreach (range(0, 100) as $i) { + $groups[] = 'group'.$i; } - $group = $this->createMock(IGroup::class); - $group->method('getGID')->willReturn('sharedWith'); - $groups[] = $group; + $groups[] = 'sharedWith'; $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('sharedWith'); @@ -986,11 +1003,10 @@ class DefaultShareProviderTest extends \Test\TestCase { ['shareOwner', $owner], ['sharedBy', $initiator], ]); - $this->groupManager->method('getUserGroups')->with($user)->willReturn($groups); - $this->groupManager->method('get')->with('sharedWith')->willReturn($group); + $this->groupManager->method('getUserGroupIds')->with($user)->willReturn($groups); $file = $this->createMock(File::class); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]); $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1); @@ -1061,9 +1077,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ]); $this->assertEquals(1, $qb->execute()); - $group = $this->createMock(IGroup::class); - $group->method('getGID')->willReturn('sharedWith'); - $groups = [$group]; + $groups = ['sharedWith']; $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('user'); @@ -1077,11 +1091,10 @@ class DefaultShareProviderTest extends \Test\TestCase { ['shareOwner', $owner], ['sharedBy', $initiator], ]); - $this->groupManager->method('getUserGroups')->with($user)->willReturn($groups); - $this->groupManager->method('get')->with('sharedWith')->willReturn($group); + $this->groupManager->method('getUserGroupIds')->with($user)->willReturn($groups); $file = $this->createMock(File::class); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]); $share = $this->provider->getSharedWith('user', \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); @@ -1124,7 +1137,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $file = $this->createMock(File::class); $file->method('getId')->willReturn($fileId2); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId2)->willReturn([$file]); $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_USER, $file, -1, 0); @@ -1161,15 +1174,11 @@ class DefaultShareProviderTest extends \Test\TestCase { ['user1', $user1], ]); - $group0 = $this->createMock(IGroup::class); - $group0->method('getGID')->willReturn('group0'); - - $this->groupManager->method('get')->with('group0')->willReturn($group0); - $this->groupManager->method('getUserGroups')->with($user0)->willReturn([$group0]); + $this->groupManager->method('getUserGroupIds')->with($user0)->willReturn(['group0']); $node = $this->createMock(Folder::class); $node->method('getId')->willReturn($fileId2); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with($fileId2)->willReturn([$node]); $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0); @@ -1220,19 +1229,15 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals(1, $qb->execute()); $file = $this->createMock(File::class); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with($deletedFileId)->willReturn([$file]); $groups = []; - foreach(range(0, 100) as $i) { - $group = $this->createMock(IGroup::class); - $group->method('getGID')->willReturn('group'.$i); - $groups[] = $group; + foreach (range(0, 100) as $i) { + $groups[] = 'group'.$i; } - $group = $this->createMock(IGroup::class); - $group->method('getGID')->willReturn('sharedWith'); - $groups[] = $group; + $groups[] = 'sharedWith'; $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('sharedWith'); @@ -1246,8 +1251,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ['shareOwner', $owner], ['sharedBy', $initiator], ]); - $this->groupManager->method('getUserGroups')->with($user)->willReturn($groups); - $this->groupManager->method('get')->with('sharedWith')->willReturn($group); + $this->groupManager->method('getUserGroupIds')->with($user)->willReturn($groups); $share = $this->provider->getSharedWith('sharedWith', $shareType, null, 1 , 0); $this->assertCount(0, $share); @@ -1285,7 +1289,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals(1, $qb->execute()); $file = $this->createMock(File::class); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0); @@ -1335,7 +1339,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $file = $this->createMock(File::class); $file->method('getId')->willReturn(42); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0); @@ -1385,7 +1389,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $file = $this->createMock(File::class); $file->method('getId')->willReturn(42); - $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf(); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0); @@ -1431,10 +1435,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $user1->method('getUID')->willReturn('user1'); $user2 = $this->createMock(IUser::class); $user2->method('getUID')->willReturn('user2'); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user1', $user1], ['user2', $user2], - ])); + ]); $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'); @@ -1444,7 +1448,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $file = $this->createMock(File::class); $file->method('getId')->willReturn(1); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with(1)->willReturn([$file]); $share = $this->provider->getShareById($id); @@ -1502,10 +1506,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $user1->method('getUID')->willReturn('user1'); $user2 = $this->createMock(IUser::class); $user2->method('getUID')->willReturn('user2'); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user1', $user1], ['user2', $user2], - ])); + ]); $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'); @@ -1515,7 +1519,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $file = $this->createMock(File::class); $file->method('getId')->willReturn(1); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with(1)->willReturn([$file]); $share = $this->provider->getShareById($id); @@ -1538,7 +1542,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals('user2', $share2['share_with']); } - + public function testDeleteFromSelfGroupUserNotInGroup() { $this->expectException(\OC\Share20\Exception\ProviderException::class); $this->expectExceptionMessage('Recipient not in receiving group'); @@ -1562,10 +1566,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $user1->method('getUID')->willReturn('user1'); $user2 = $this->createMock(IUser::class); $user2->method('getUID')->willReturn('user2'); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user1', $user1], ['user2', $user2], - ])); + ]); $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'); @@ -1575,7 +1579,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $file = $this->createMock(File::class); $file->method('getId')->willReturn(1); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with(1)->willReturn([$file]); $share = $this->provider->getShareById($id); @@ -1583,7 +1587,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->provider->deleteFromSelf($share, 'user2'); } - + public function testDeleteFromSelfGroupDoesNotExist() { $this->expectException(\OC\Share20\Exception\ProviderException::class); $this->expectExceptionMessage('Group "group" does not exist'); @@ -1607,17 +1611,17 @@ class DefaultShareProviderTest extends \Test\TestCase { $user1->method('getUID')->willReturn('user1'); $user2 = $this->createMock(IUser::class); $user2->method('getUID')->willReturn('user2'); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user1', $user1], ['user2', $user2], - ])); + ]); $this->groupManager->method('get')->with('group')->willReturn(null); $file = $this->createMock(File::class); $file->method('getId')->willReturn(1); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with(1)->willReturn([$file]); $share = $this->provider->getShareById($id); @@ -1647,15 +1651,15 @@ class DefaultShareProviderTest extends \Test\TestCase { $user2 = $this->createMock(IUser::class); $user2->method('getUID')->willReturn('user2'); $user2->method('getDisplayName')->willReturn('user2'); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user1', $user1], ['user2', $user2], - ])); + ]); $file = $this->createMock(File::class); $file->method('getId')->willReturn(1); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with(1)->willReturn([$file]); $share = $this->provider->getShareById($id); @@ -1674,7 +1678,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertCount(0, $shares); } - + public function testDeleteFromSelfUserNotRecipient() { $this->expectException(\OC\Share20\Exception\ProviderException::class); $this->expectExceptionMessage('Recipient does not match'); @@ -1701,15 +1705,15 @@ class DefaultShareProviderTest extends \Test\TestCase { $user2->method('getUID')->willReturn('user2'); $user2->method('getDisplayName')->willReturn('user2'); $user3 = $this->createMock(IUser::class); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user1', $user1], ['user2', $user2], - ])); + ]); $file = $this->createMock(File::class); $file->method('getId')->willReturn(1); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with(1)->willReturn([$file]); $share = $this->provider->getShareById($id); @@ -1717,7 +1721,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->provider->deleteFromSelf($share, $user3); } - + public function testDeleteFromSelfLink() { $this->expectException(\OC\Share20\Exception\ProviderException::class); $this->expectExceptionMessage('Invalid shareType'); @@ -1739,14 +1743,14 @@ class DefaultShareProviderTest extends \Test\TestCase { $user1 = $this->createMock(IUser::class); $user1->method('getUID')->willReturn('user1'); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user1', $user1], - ])); + ]); $file = $this->createMock(File::class); $file->method('getId')->willReturn(1); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->with(1)->willReturn([$file]); $share = $this->provider->getShareById($id); @@ -1759,17 +1763,17 @@ class DefaultShareProviderTest extends \Test\TestCase { 'file', 42, 'target', 31, null, null); $users = []; - for($i = 0; $i < 6; $i++) { + for ($i = 0; $i < 6; $i++) { $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('user'.$i); $user->method('getDisplayName')->willReturn('user' . $i); $users['user'.$i] = $user; } - $this->userManager->method('get')->will( - $this->returnCallback(function($userId) use ($users) { + $this->userManager->method('get')->willReturnCallback( + function ($userId) use ($users) { return $users[$userId]; - }) + } ); $file1 = $this->createMock(File::class); @@ -1782,10 +1786,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $folder2 = $this->createMock(Folder::class); $folder2->method('getById')->with(43)->willReturn([$file2]); - $this->rootFolder->method('getUserFolder')->will($this->returnValueMap([ + $this->rootFolder->method('getUserFolder')->willReturnMap([ ['user2', $folder1], ['user5', $folder2], - ])); + ]); $share = $this->provider->getShareById($id); @@ -1817,16 +1821,16 @@ class DefaultShareProviderTest extends \Test\TestCase { 'file', 42, 'target', 31, null, null); $users = []; - for($i = 0; $i < 6; $i++) { + for ($i = 0; $i < 6; $i++) { $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('user'.$i); $users['user'.$i] = $user; } - $this->userManager->method('get')->will( - $this->returnCallback(function($userId) use ($users) { + $this->userManager->method('get')->willReturnCallback( + function ($userId) use ($users) { return $users[$userId]; - }) + } ); $file1 = $this->createMock(File::class); @@ -1839,10 +1843,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $folder2 = $this->createMock(Folder::class); $folder2->method('getById')->with(43)->willReturn([$file2]); - $this->rootFolder->method('getUserFolder')->will($this->returnValueMap([ + $this->rootFolder->method('getUserFolder')->willReturnMap([ ['user2', $folder1], ['user5', $folder2], - ])); + ]); $share = $this->provider->getShareById($id); @@ -1883,16 +1887,16 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals(1, $qb->execute()); $users = []; - for($i = 0; $i < 6; $i++) { + for ($i = 0; $i < 6; $i++) { $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('user'.$i); $users['user'.$i] = $user; } - $this->userManager->method('get')->will( - $this->returnCallback(function($userId) use ($users) { + $this->userManager->method('get')->willReturnCallback( + function ($userId) use ($users) { return $users[$userId]; - }) + } ); $file1 = $this->createMock(File::class); @@ -1905,10 +1909,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $folder2 = $this->createMock(Folder::class); $folder2->method('getById')->with(43)->willReturn([$file2]); - $this->rootFolder->method('getUserFolder')->will($this->returnValueMap([ + $this->rootFolder->method('getUserFolder')->willReturnMap([ ['user2', $folder1], ['user5', $folder2], - ])); + ]); $share = $this->provider->getShareById($id); @@ -1940,29 +1944,29 @@ class DefaultShareProviderTest extends \Test\TestCase { 'file', 42, 'target', 31, null, null); $users = []; - for($i = 0; $i < 6; $i++) { + for ($i = 0; $i < 6; $i++) { $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('user'.$i); $users['user'.$i] = $user; } - $this->userManager->method('get')->will( - $this->returnCallback(function($userId) use ($users) { + $this->userManager->method('get')->willReturnCallback( + function ($userId) use ($users) { return $users[$userId]; - }) + } ); $groups = []; - for($i = 0; $i < 2; $i++) { + for ($i = 0; $i < 2; $i++) { $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'.$i); $groups['group'.$i] = $group; } - $this->groupManager->method('get')->will( - $this->returnCallback(function($groupId) use ($groups) { + $this->groupManager->method('get')->willReturnCallback( + function ($groupId) use ($groups) { return $groups[$groupId]; - }) + } ); $file1 = $this->createMock(File::class); @@ -1975,10 +1979,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $folder2 = $this->createMock(Folder::class); $folder2->method('getById')->with(43)->willReturn([$file2]); - $this->rootFolder->method('getUserFolder')->will($this->returnValueMap([ + $this->rootFolder->method('getUserFolder')->willReturnMap([ ['user2', $folder1], ['user5', $folder2], - ])); + ]); $share = $this->provider->getShareById($id); @@ -2018,29 +2022,29 @@ class DefaultShareProviderTest extends \Test\TestCase { 'file', 42, 'mytarget2', 0, null, null, $id); $users = []; - for($i = 0; $i < 6; $i++) { + for ($i = 0; $i < 6; $i++) { $user = $this->createMock(IUser::class); $user->method('getUID')->willReturn('user'.$i); $users['user'.$i] = $user; } - $this->userManager->method('get')->will( - $this->returnCallback(function($userId) use ($users) { + $this->userManager->method('get')->willReturnCallback( + function ($userId) use ($users) { return $users[$userId]; - }) + } ); $groups = []; - for($i = 0; $i < 2; $i++) { + for ($i = 0; $i < 2; $i++) { $group = $this->createMock(IGroup::class); $group->method('getGID')->willReturn('group'.$i); $groups['group'.$i] = $group; } - $this->groupManager->method('get')->will( - $this->returnCallback(function($groupId) use ($groups) { + $this->groupManager->method('get')->willReturnCallback( + function ($groupId) use ($groups) { return $groups[$groupId]; - }) + } ); $file1 = $this->createMock(File::class); @@ -2053,10 +2057,10 @@ class DefaultShareProviderTest extends \Test\TestCase { $folder2 = $this->createMock(Folder::class); $folder2->method('getById')->with(43)->willReturn([$file2]); - $this->rootFolder->method('getUserFolder')->will($this->returnValueMap([ + $this->rootFolder->method('getUserFolder')->willReturnMap([ ['user2', $folder1], ['user5', $folder2], - ])); + ]); $share = $this->provider->getShareById($id); @@ -2118,15 +2122,15 @@ class DefaultShareProviderTest extends \Test\TestCase { $user1->method('getUID')->willReturn('user1'); $user1->method('getDisplayName')->willReturn('user1'); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user0', $user0], ['user1', $user1], - ])); + ]); $file = $this->createMock(File::class); $file->method('getId')->willReturn(42); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->willReturn([$file]); $share = $this->provider->getShareById($id, null); @@ -2153,15 +2157,15 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->groupManager->method('get')->with('group0')->willReturn($group0); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['user0', $user0], ['user1', $user1], - ])); + ]); $folder = $this->createMock(Folder::class); $folder->method('getId')->willReturn(42); - $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf(); $this->rootFolder->method('getById')->willReturn([$folder]); $share = $this->provider->getShareById($id, 'user0'); @@ -2845,7 +2849,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder ->method('getUserFolder') - ->will($this->returnValueMap( + ->willReturnMap( [ ['shareOwner1', $shareOwner1Folder], ['shareOwner2', $shareOwner2Folder], @@ -2853,7 +2857,7 @@ class DefaultShareProviderTest extends \Test\TestCase { ['shareOwner4', $shareOwner4Folder], ['shareOwner5', $shareOwner5Folder], ] - )); + ); $shares = iterator_to_array($this->provider->getAllShares()); $this->assertEquals(4, count($shares)); diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php index 14fe32323c1..2b062e592ba 100644 --- a/tests/lib/Share20/LegacyHooksTest.php +++ b/tests/lib/Share20/LegacyHooksTest.php @@ -281,10 +281,10 @@ class LegacyHooksTest extends TestCase { ->expects($this->exactly(1)) ->method('preShare') ->with($expected) - ->will($this->returnCallback(function ($data) { + ->willReturnCallback(function ($data) { $data['run'] = false; $data['error'] = 'I error'; - })); + }); $event = new GenericEvent($share); $this->eventDispatcher->dispatch('OCP\Share::preShare', $event); diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 314038fe13b..615b5358c9e 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -105,7 +105,6 @@ class ManagerTest extends \Test\TestCase { protected $defaults; protected function setUp(): void { - $this->logger = $this->createMock(ILogger::class); $this->config = $this->createMock(IConfig::class); $this->secureRandom = $this->createMock(ISecureRandom::class); @@ -123,9 +122,9 @@ class ManagerTest extends \Test\TestCase { $this->l10nFactory = $this->createMock(IFactory::class); $this->l = $this->createMock(IL10N::class); $this->l->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { - return vsprintf($text, $parameters); - })); + ->willReturnCallback(function ($text, $parameters = []) { + return vsprintf($text, $parameters); + }); $this->factory = new DummyFactory(\OC::$server); @@ -233,7 +232,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCP\Share::preUnshare', - $this->callBack(function(GenericEvent $e) use ($share) { + $this->callBack(function (GenericEvent $e) use ($share) { return $e->getSubject() === $share; }) ); @@ -241,7 +240,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCP\Share::postUnshare', - $this->callBack(function(GenericEvent $e) use ($share) { + $this->callBack(function (GenericEvent $e) use ($share) { return $e->getSubject() === $share && $e->getArgument('deletedShares') === [$share]; }) @@ -279,7 +278,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCP\Share::preUnshare', - $this->callBack(function(GenericEvent $e) use ($share) { + $this->callBack(function (GenericEvent $e) use ($share) { return $e->getSubject() === $share; }) ); @@ -287,7 +286,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCP\Share::postUnshare', - $this->callBack(function(GenericEvent $e) use ($share) { + $this->callBack(function (GenericEvent $e) use ($share) { return $e->getSubject() === $share && $e->getArgument('deletedShares') === [$share]; }) @@ -334,11 +333,11 @@ class ManagerTest extends \Test\TestCase { $this->defaultProvider ->method('getChildren') - ->will($this->returnValueMap([ + ->willReturnMap([ [$share1, [$share2]], [$share2, [$share3]], [$share3, []], - ])); + ]); $this->defaultProvider ->method('delete') @@ -348,7 +347,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCP\Share::preUnshare', - $this->callBack(function(GenericEvent $e) use ($share1) { + $this->callBack(function (GenericEvent $e) use ($share1) { return $e->getSubject() === $share1; }) ); @@ -356,7 +355,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCP\Share::postUnshare', - $this->callBack(function(GenericEvent $e) use ($share1, $share2, $share3) { + $this->callBack(function (GenericEvent $e) use ($share1, $share2, $share3) { return $e->getSubject() === $share1 && $e->getArgument('deletedShares') === [$share3, $share2, $share1]; }) @@ -391,7 +390,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCP\Share::postUnshareFromSelf', - $this->callBack(function(GenericEvent $e) use ($share) { + $this->callBack(function (GenericEvent $e) use ($share) { return $e->getSubject() === $share; }) ); @@ -423,12 +422,12 @@ class ManagerTest extends \Test\TestCase { $this->defaultProvider ->expects($this->exactly(4)) ->method('getChildren') - ->will($this->returnCallback(function($_share) use ($share, $shares) { + ->willReturnCallback(function ($_share) use ($share, $shares) { if ($_share === $share) { return $shares; } return []; - })); + }); $this->defaultProvider ->expects($this->exactly(3)) @@ -483,29 +482,29 @@ class ManagerTest extends \Test\TestCase { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Passwords are enforced for link shares'); - $this->config->method('getAppValue')->will($this->returnValueMap([ + $this->config->method('getAppValue')->willReturnMap([ ['core', 'shareapi_enforce_links_password', 'no', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'verifyPassword', [null]); } public function testVerifyPasswordNull() { - $this->config->method('getAppValue')->will($this->returnValueMap([ - ['core', 'shareapi_enforce_links_password', 'no', 'no'], - ])); + $this->config->method('getAppValue')->willReturnMap([ + ['core', 'shareapi_enforce_links_password', 'no', 'no'], + ]); $result = self::invokePrivate($this->manager, 'verifyPassword', [null]); $this->assertNull($result); } public function testVerifyPasswordHook() { - $this->config->method('getAppValue')->will($this->returnValueMap([ - ['core', 'shareapi_enforce_links_password', 'no', 'no'], - ])); + $this->config->method('getAppValue')->willReturnMap([ + ['core', 'shareapi_enforce_links_password', 'no', 'no'], + ]); $this->eventDispatcher->expects($this->once())->method('dispatch') - ->willReturnCallback(function(Event $event) { + ->willReturnCallback(function (Event $event) { $this->assertInstanceOf(ValidatePasswordPolicyEvent::class, $event); /** @var ValidatePasswordPolicyEvent $event */ $this->assertSame('password', $event->getPassword()); @@ -521,12 +520,12 @@ class ManagerTest extends \Test\TestCase { $this->expectException(\Exception::class); $this->expectExceptionMessage('password not accepted'); - $this->config->method('getAppValue')->will($this->returnValueMap([ - ['core', 'shareapi_enforce_links_password', 'no', 'no'], - ])); + $this->config->method('getAppValue')->willReturnMap([ + ['core', 'shareapi_enforce_links_password', 'no', 'no'], + ]); $this->eventDispatcher->expects($this->once())->method('dispatch') - ->willReturnCallback(function(Event $event) { + ->willReturnCallback(function (Event $event) { $this->assertInstanceOf(ValidatePasswordPolicyEvent::class, $event); /** @var ValidatePasswordPolicyEvent $event */ $this->assertSame('password', $event->getPassword()); @@ -697,14 +696,14 @@ class ManagerTest extends \Test\TestCase { public function testGeneralChecks($share, $exceptionMessage, $exception) { $thrown = null; - $this->userManager->method('userExists')->will($this->returnValueMap([ + $this->userManager->method('userExists')->willReturnMap([ ['user0', true], ['user1', true], - ])); + ]); - $this->groupManager->method('groupExists')->will($this->returnValueMap([ + $this->groupManager->method('groupExists')->willReturnMap([ ['group0', true], - ])); + ]); $userFolder = $this->createMock(Folder::class); $userFolder->method('getPath')->willReturn('myrootfolder'); @@ -720,7 +719,7 @@ class ManagerTest extends \Test\TestCase { } catch (\OCP\Share\Exceptions\GenericShareException $e) { $this->assertEquals($exceptionMessage, $e->getHint()); $thrown = true; - } catch(\InvalidArgumentException $e) { + } catch (\InvalidArgumentException $e) { $this->assertEquals($exceptionMessage, $e->getMessage()); $thrown = true; } @@ -735,10 +734,10 @@ class ManagerTest extends \Test\TestCase { $thrown = null; - $this->userManager->method('userExists')->will($this->returnValueMap([ + $this->userManager->method('userExists')->willReturnMap([ ['user0', true], ['user1', true], - ])); + ]); $userFolder = $this->createMock(Folder::class); $userFolder->method('isSubNode')->with($userFolder)->willReturn(false); @@ -779,10 +778,10 @@ class ManagerTest extends \Test\TestCase { $share->setProviderId('foo')->setId('bar'); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_default_expire_date', 'no', 'yes'], ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); } @@ -792,9 +791,9 @@ class ManagerTest extends \Test\TestCase { $share->setProviderId('foo')->setId('bar'); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); @@ -805,11 +804,12 @@ class ManagerTest extends \Test\TestCase { $share = $this->manager->newShare(); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_expire_after_n_days', '7', '3'], ['core', 'shareapi_default_expire_date', 'no', 'yes'], - ])); + ['core', 'link_defaultExpDays', 3, '3'], + ]); $expected = new \DateTime(); $expected->setTime(0,0,0); @@ -830,10 +830,10 @@ class ManagerTest extends \Test\TestCase { $share->setExpirationDate($future); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_expire_after_n_days', '7', '3'], - ])); + ]); try { self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); @@ -858,10 +858,10 @@ class ManagerTest extends \Test\TestCase { $share->setExpirationDate($future); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_expire_after_n_days', '7', '3'], - ])); + ]); $hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); @@ -921,10 +921,10 @@ class ManagerTest extends \Test\TestCase { $share->setExpirationDate($future); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_default_expire_date', 'no', 'yes'], ['core', 'shareapi_expire_after_n_days', '7', '3'], - ])); + ]); $hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); @@ -946,9 +946,9 @@ class ManagerTest extends \Test\TestCase { $hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); - $hookListner->expects($this->once())->method('listener')->will($this->returnCallback(function ($data) { + $hookListner->expects($this->once())->method('listener')->willReturnCallback(function ($data) { $data['expirationDate']->sub(new \DateInterval('P2D')); - })); + }); $share = $this->manager->newShare(); $share->setExpirationDate($nextWeek); @@ -973,10 +973,10 @@ class ManagerTest extends \Test\TestCase { $hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); - $hookListner->expects($this->once())->method('listener')->will($this->returnCallback(function ($data) { + $hookListner->expects($this->once())->method('listener')->willReturnCallback(function ($data) { $data['accepted'] = false; $data['message'] = 'Invalid date!'; - })); + }); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); } @@ -987,10 +987,10 @@ class ManagerTest extends \Test\TestCase { $share->setId('42')->setProviderId('foo'); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_default_expire_date', 'no', 'yes'], ['core', 'shareapi_expire_after_n_days', '7', '6'], - ])); + ]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); @@ -1010,23 +1010,23 @@ class ManagerTest extends \Test\TestCase { $this->groupManager ->method('getUserGroupIds') - ->will( - $this->returnValueMap([ + ->willReturnMap( + [ [$sharedBy, ['group1']], [$sharedWith, ['group2']], - ]) + ] ); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['sharedBy', $sharedBy], ['sharedWith', $sharedWith], - ])); + ]); $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_only_share_with_group_members', 'no', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'userCreateChecks', [$share]); } @@ -1043,23 +1043,23 @@ class ManagerTest extends \Test\TestCase { $this->groupManager ->method('getUserGroupIds') - ->will( - $this->returnValueMap([ + ->willReturnMap( + [ [$sharedBy, ['group1', 'group3']], [$sharedWith, ['group2', 'group3']], - ]) + ] ); - $this->userManager->method('get')->will($this->returnValueMap([ + $this->userManager->method('get')->willReturnMap([ ['sharedBy', $sharedBy], ['sharedWith', $sharedWith], - ])); + ]); $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_only_share_with_group_members', 'no', 'yes'], - ])); + ]); $this->defaultProvider ->method('getSharesByPath') @@ -1096,7 +1096,7 @@ class ManagerTest extends \Test\TestCase { } - public function testUserCreateChecksIdenticalPathSharedViaGroup() { + public function testUserCreateChecksIdenticalPathSharedViaGroup() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Path is already shared with this user'); @@ -1137,7 +1137,7 @@ class ManagerTest extends \Test\TestCase { self::invokePrivate($this->manager, 'userCreateChecks', [$share]); } - public function testUserCreateChecksIdenticalPathSharedViaDeletedGroup() { + public function testUserCreateChecksIdenticalPathSharedViaDeletedGroup() { $share = $this->manager->newShare(); $sharedWith = $this->createMock(IUser::class); @@ -1215,9 +1215,9 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_allow_group_sharing', 'yes', 'no'], - ])); + ]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); } @@ -1240,10 +1240,10 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_only_share_with_group_members', 'no', 'yes'], ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); } @@ -1263,10 +1263,10 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_only_share_with_group_members', 'no', 'yes'], ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], - ])); + ]); $this->assertNull($this->invokePrivate($this->manager, 'groupCreateChecks', [$share])); } @@ -1292,10 +1292,10 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_only_share_with_group_members', 'no', 'yes'], ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); $this->addToAssertionCount(1); @@ -1325,9 +1325,9 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); } @@ -1349,9 +1349,9 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_allow_group_sharing', 'yes', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'groupCreateChecks', [$share]); $this->addToAssertionCount(1); @@ -1366,27 +1366,9 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_allow_links', 'yes', 'no'], - ])); - - self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); - } - - - public function testLinkCreateChecksSharePermissions() { - $this->expectException(\Exception::class); - $this->expectExceptionMessage('Link shares can’t have reshare permissions'); - - $share = $this->manager->newShare(); - - $share->setPermissions(\OCP\Constants::PERMISSION_SHARE); - - $this->config - ->method('getAppValue') - ->will($this->returnValueMap([ - ['core', 'shareapi_allow_links', 'yes', 'yes'], - ])); + ]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); } @@ -1402,10 +1384,10 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_allow_links', 'yes', 'yes'], ['core', 'shareapi_allow_public_upload', 'yes', 'no'] - ])); + ]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); } @@ -1417,10 +1399,10 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_allow_links', 'yes', 'yes'], ['core', 'shareapi_allow_public_upload', 'yes', 'yes'] - ])); + ]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); $this->addToAssertionCount(1); @@ -1433,10 +1415,10 @@ class ManagerTest extends \Test\TestCase { $this->config ->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_allow_links', 'yes', 'yes'], ['core', 'shareapi_allow_public_upload', 'yes', 'no'] - ])); + ]); self::invokePrivate($this->manager, 'linkCreateChecks', [$share]); $this->addToAssertionCount(1); @@ -1525,10 +1507,10 @@ class ManagerTest extends \Test\TestCase { $user = $this->createMock(IUser::class); $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_exclude_groups', 'no', $excludeGroups], ['core', 'shareapi_exclude_groups_list', '', $groupList], - ])); + ]); if ($setList !== null) { $this->config->expects($this->once()) @@ -1573,9 +1555,9 @@ class ManagerTest extends \Test\TestCase { */ public function testCanShare($expected, $sharingEnabled, $disabledForUser) { $this->config->method('getAppValue') - ->will($this->returnValueMap([ + ->willReturnMap([ ['core', 'shareapi_enabled', 'yes', $sharingEnabled], - ])); + ]); $manager = $this->createManagerMock() ->setMethods(['sharingDisabledForUser']) @@ -1627,10 +1609,12 @@ class ManagerTest extends \Test\TestCase { ->willReturn(true); $manager->expects($this->once()) ->method('generalCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('userCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('pathCreateChecks') ->with($path); @@ -1639,7 +1623,7 @@ class ManagerTest extends \Test\TestCase { ->expects($this->once()) ->method('create') ->with($share) - ->will($this->returnArgument(0)); + ->willReturnArgument(0); $share->expects($this->once()) ->method('setShareOwner') @@ -1680,10 +1664,12 @@ class ManagerTest extends \Test\TestCase { ->willReturn(true); $manager->expects($this->once()) ->method('generalCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('groupCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('pathCreateChecks') ->with($path); @@ -1692,7 +1678,7 @@ class ManagerTest extends \Test\TestCase { ->expects($this->once()) ->method('create') ->with($share) - ->will($this->returnArgument(0)); + ->willReturnArgument(0); $share->expects($this->once()) ->method('setShareOwner') @@ -1743,10 +1729,12 @@ class ManagerTest extends \Test\TestCase { ->willReturn(true); $manager->expects($this->once()) ->method('generalCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('linkCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('pathCreateChecks') ->with($path); @@ -1773,16 +1761,16 @@ class ManagerTest extends \Test\TestCase { ->expects($this->once()) ->method('create') ->with($share) - ->will($this->returnCallback(function(Share $share) { + ->willReturnCallback(function (Share $share) { return $share->setId(42); - })); + }); // Pre share $this->eventDispatcher->expects($this->at(0)) ->method('dispatch') ->with( $this->equalTo('OCP\Share::preShare'), - $this->callback(function(GenericEvent $e) use ($path, $date) { + $this->callback(function (GenericEvent $e) use ($path, $date) { /** @var IShare $share */ $share = $e->getSubject(); @@ -1801,7 +1789,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( $this->equalTo('OCP\Share::postShare'), - $this->callback(function(GenericEvent $e) use ($path, $date) { + $this->callback(function (GenericEvent $e) use ($path, $date) { /** @var IShare $share */ $share = $e->getSubject(); @@ -1862,7 +1850,8 @@ class ManagerTest extends \Test\TestCase { ->willReturn(true); $manager->expects($this->once()) ->method('generalCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->never()) ->method('linkCreateChecks'); $manager->expects($this->once()) @@ -1882,16 +1871,16 @@ class ManagerTest extends \Test\TestCase { ->expects($this->once()) ->method('create') ->with($share) - ->will($this->returnCallback(function(Share $share) { + ->willReturnCallback(function (Share $share) { return $share->setId(42); - })); + }); // Pre share $this->eventDispatcher->expects($this->at(0)) ->method('dispatch') ->with( $this->equalTo('OCP\Share::preShare'), - $this->callback(function(GenericEvent $e) use ($path) { + $this->callback(function (GenericEvent $e) use ($path) { /** @var IShare $share */ $share = $e->getSubject(); @@ -1910,7 +1899,7 @@ class ManagerTest extends \Test\TestCase { ->method('dispatch') ->with( $this->equalTo('OCP\Share::postShare'), - $this->callback(function(GenericEvent $e) use ($path) { + $this->callback(function (GenericEvent $e) use ($path) { /** @var IShare $share */ $share = $e->getSubject(); @@ -1972,10 +1961,12 @@ class ManagerTest extends \Test\TestCase { ->willReturn(true); $manager->expects($this->once()) ->method('generalCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('userCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('pathCreateChecks') ->with($path); @@ -1993,10 +1984,10 @@ class ManagerTest extends \Test\TestCase { ->with( $this->equalTo('OCP\Share::preShare'), $this->isInstanceOf(GenericEvent::class) - )->will($this->returnCallback(function($name, GenericEvent $e) { - $e->setArgument('error', 'I won\'t let you share!'); - $e->stopPropagation(); - }) + )->willReturnCallback(function ($name, GenericEvent $e) { + $e->setArgument('error', 'I won\'t let you share!'); + $e->stopPropagation(); + } ); $manager->createShare($share); @@ -2050,10 +2041,12 @@ class ManagerTest extends \Test\TestCase { ->willReturn(true); $manager->expects($this->once()) ->method('generalCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('userCreateChecks') - ->with($share);; + ->with($share); + ; $manager->expects($this->once()) ->method('pathCreateChecks') ->with($path); @@ -2062,7 +2055,7 @@ class ManagerTest extends \Test\TestCase { ->expects($this->once()) ->method('create') ->with($share) - ->will($this->returnArgument(0)); + ->willReturnArgument(0); $share->expects($this->once()) ->method('setShareOwner') @@ -2145,22 +2138,22 @@ class ManagerTest extends \Test\TestCase { */ $this->defaultProvider ->method('getSharesBy') - ->will($this->returnCallback(function($uid, $type, $node, $reshares, $limit, $offset) use (&$shares2) { + ->willReturnCallback(function ($uid, $type, $node, $reshares, $limit, $offset) use (&$shares2) { return array_slice($shares2, $offset, $limit); - })); + }); /* * Simulate the deleteShare call. */ $manager->method('deleteShare') - ->will($this->returnCallback(function($share) use (&$shares2) { - for($i = 0; $i < count($shares2); $i++) { + ->willReturnCallback(function ($share) use (&$shares2) { + for ($i = 0; $i < count($shares2); $i++) { if ($shares2[$i]->getId() === $share->getId()) { array_splice($shares2, $i, 1); break; } } - })); + }); $res = $manager->getSharesBy('user', \OCP\Share::SHARE_TYPE_LINK, $node, true, 3, 0); @@ -2255,13 +2248,13 @@ class ManagerTest extends \Test\TestCase { $factory->expects($this->any()) ->method('getProviderForType') - ->will($this->returnCallback(function($shareType) use ($roomShareProvider) { + ->willReturnCallback(function ($shareType) use ($roomShareProvider) { if ($shareType !== \OCP\Share::SHARE_TYPE_ROOM) { throw new Exception\ProviderException(); } return $roomShareProvider; - })); + }); $roomShareProvider->expects($this->once()) ->method('getShareByToken') @@ -2409,9 +2402,9 @@ class ManagerTest extends \Test\TestCase { $this->config ->expects($this->at(1)) ->method('getAppValue') - ->will($this->returnValueMap([ - ['core', 'shareapi_allow_public_upload', 'yes', 'no'], - ])); + ->willReturnMap([ + ['core', 'shareapi_allow_public_upload', 'yes', 'no'], + ]); $this->defaultProvider->expects($this->once()) ->method('getShareByToken') @@ -2464,11 +2457,11 @@ class ManagerTest extends \Test\TestCase { ->setPassword('passwordHash'); $this->hasher->method('verify')->with('password', 'passwordHash', '') - ->will($this->returnCallback(function($pass, $hash, &$newHash) { + ->willReturnCallback(function ($pass, $hash, &$newHash) { $newHash = 'newHash'; return true; - })); + }); $this->defaultProvider->expects($this->once()) ->method('update') @@ -2563,7 +2556,6 @@ class ManagerTest extends \Test\TestCase { } public function testUpdateShareUser() { - $this->userManager->expects($this->any())->method('userExists')->willReturn(true); $manager = $this->createManagerMock() @@ -2607,7 +2599,7 @@ class ManagerTest extends \Test\TestCase { \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); $hookListner->expects($this->never())->method('post'); - $this->rootFolder->method('getUserFolder')->with('newUser')->will($this->returnSelf()); + $this->rootFolder->method('getUserFolder')->with('newUser')->willReturnSelf(); $this->rootFolder->method('getRelativePath')->with('/newUser/files/myPath')->willReturn('/myPath'); $hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); @@ -3294,7 +3286,7 @@ class ManagerTest extends \Test\TestCase { $share->setSharedWith('recipient'); - $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0)); + $this->defaultProvider->method('move')->with($share, 'recipient')->willReturnArgument(0); $this->manager->moveShare($share, 'recipient'); $this->addToAssertionCount(1); @@ -3352,7 +3344,7 @@ class ManagerTest extends \Test\TestCase { $this->groupManager->method('get')->with('group')->willReturn($group); $this->userManager->method('get')->with('recipient')->willReturn($recipient); - $this->defaultProvider->method('move')->with($share, 'recipient')->will($this->returnArgument(0)); + $this->defaultProvider->method('move')->with($share, 'recipient')->willReturnArgument(0); $this->manager->moveShare($share, 'recipient'); $this->addToAssertionCount(1); @@ -3362,7 +3354,6 @@ class ManagerTest extends \Test\TestCase { * @dataProvider dataTestShareProviderExists */ public function testShareProviderExists($shareType, $expected) { - $factory = $this->getMockBuilder('OCP\Share\IProviderFactory')->getMock(); $factory->expects($this->any())->method('getProviderForType') ->willReturnCallback(function ($id) { @@ -3580,7 +3571,6 @@ class ManagerTest extends \Test\TestCase { $this->assertSame($expected['public'], $result['public']); $this->assertSame($expected['remote'], $result['remote']); $this->assertSame($expected['users'], $result['users']); - } public function testGetAccessListWithCurrentAccess() { @@ -3706,7 +3696,6 @@ class ManagerTest extends \Test\TestCase { $this->assertSame($expected['public'], $result['public']); $this->assertSame($expected['remote'], $result['remote']); $this->assertSame($expected['users'], $result['users']); - } public function testGetAllShares() { @@ -3741,12 +3730,12 @@ class ManagerTest extends \Test\TestCase { $share4 = $this->createMock(IShare::class); $this->defaultProvider->method('getAllShares') - ->willReturnCallback(function() use ($share1, $share2) { + ->willReturnCallback(function () use ($share1, $share2) { yield $share1; yield $share2; }); $extraProvider->method('getAllShares') - ->willReturnCallback(function() use ($share3, $share4) { + ->willReturnCallback(function () use ($share3, $share4) { yield $share3; yield $share4; }); @@ -3768,7 +3757,6 @@ class DummyFactory implements IProviderFactory { protected $provider; public function __construct(\OCP\IServerContainer $serverContainer) { - } /** diff --git a/tests/lib/SubAdminTest.php b/tests/lib/SubAdminTest.php index b2c15894391..06c319d1f48 100644 --- a/tests/lib/SubAdminTest.php +++ b/tests/lib/SubAdminTest.php @@ -84,11 +84,11 @@ class SubAdminTest extends \Test\TestCase { } protected function tearDown(): void { - foreach($this->users as $user) { + foreach ($this->users as $user) { $user->delete(); } - foreach($this->groups as $group) { + foreach ($this->groups as $group) { $group->delete(); } @@ -113,7 +113,7 @@ class SubAdminTest extends \Test\TestCase { ->fetch(); $this->assertEquals( [ - 'gid' => $this->groups[0]->getGID(), + 'gid' => $this->groups[0]->getGID(), 'uid' => $this->users[0]->getUID() ], $result); @@ -242,14 +242,13 @@ class SubAdminTest extends \Test\TestCase { $this->groupManager->get('admin')->addUser($this->users[1]); $this->assertFalse($subAdmin->isUserAccessible($this->users[0], $this->users[1])); - } public function testPostDeleteUser() { $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn); $user = array_shift($this->users); - foreach($this->groups as $group) { + foreach ($this->groups as $group) { $subAdmin->createSubAdmin($user, $group); } @@ -261,7 +260,7 @@ class SubAdminTest extends \Test\TestCase { $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn); $group = array_shift($this->groups); - foreach($this->users as $user) { + foreach ($this->users as $user) { $subAdmin->createSubAdmin($user, $group); } @@ -295,5 +294,4 @@ class SubAdminTest extends \Test\TestCase { $subAdmin->deleteSubAdmin($u, $g); $this->assertEquals(2, $count); } - } diff --git a/tests/lib/Support/CrashReport/RegistryTest.php b/tests/lib/Support/CrashReport/RegistryTest.php index c45848b6186..d85b006509e 100644 --- a/tests/lib/Support/CrashReport/RegistryTest.php +++ b/tests/lib/Support/CrashReport/RegistryTest.php @@ -94,5 +94,4 @@ class RegistryTest extends TestCase { $this->registry->register($reporter2); $this->registry->delegateMessage($message); } - } diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php index a5a54fce09f..698c2582b83 100644 --- a/tests/lib/SystemTag/SystemTagManagerTest.php +++ b/tests/lib/SystemTag/SystemTagManagerTest.php @@ -6,7 +6,7 @@ * later. * See the COPYING-README file. * -*/ + */ namespace Test\SystemTag; @@ -15,7 +15,6 @@ use OC\SystemTag\SystemTagObjectMapper; use OCP\IDBConnection; use OCP\IGroupManager; use OCP\IUser; -use OCP\IUserManager; use OCP\SystemTag\ISystemTag; use OCP\SystemTag\ISystemTagManager; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -439,13 +438,13 @@ class SystemTagManagerTest extends TestCase { $user = $this->getMockBuilder(IUser::class)->getMock(); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('test')); + ->willReturn('test'); $tag1 = $this->tagManager->createTag('one', $userVisible, $userAssignable); $this->groupManager->expects($this->any()) ->method('isAdmin') ->with('test') - ->will($this->returnValue($isAdmin)); + ->willReturn($isAdmin); $this->assertEquals($expectedResult, $this->tagManager->canUserSeeTag($tag1, $user)); } @@ -486,18 +485,18 @@ class SystemTagManagerTest extends TestCase { $user = $this->getMockBuilder(IUser::class)->getMock(); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('test')); + ->willReturn('test'); $tag1 = $this->tagManager->createTag('one', $userVisible, $userAssignable); $this->tagManager->setTagGroups($tag1, $tagGroupIds); $this->groupManager->expects($this->any()) ->method('isAdmin') ->with('test') - ->will($this->returnValue($isAdmin)); + ->willReturn($isAdmin); $this->groupManager->expects($this->any()) ->method('getUserGroupIds') ->with($user) - ->will($this->returnValue($userGroupIds)); + ->willReturn($userGroupIds); $this->assertEquals($expectedResult, $this->tagManager->canUserAssignTag($tag1, $user)); } @@ -538,5 +537,4 @@ class SystemTagManagerTest extends TestCase { $this->assertEquals($tag1->isUserVisible(), $tag2->isUserVisible()); $this->assertEquals($tag1->isUserAssignable(), $tag2->isUserAssignable()); } - } diff --git a/tests/lib/SystemTag/SystemTagObjectMapperTest.php b/tests/lib/SystemTag/SystemTagObjectMapperTest.php index f0e535b0f67..a5158bbee68 100644 --- a/tests/lib/SystemTag/SystemTagObjectMapperTest.php +++ b/tests/lib/SystemTag/SystemTagObjectMapperTest.php @@ -6,7 +6,7 @@ * later. * See the COPYING-README file. * -*/ + */ namespace Test\SystemTag; @@ -88,7 +88,7 @@ class SystemTagObjectMapperTest extends TestCase { $this->tagManager->expects($this->any()) ->method('getTagsByIds') - ->will($this->returnCallback(function($tagIds) { + ->willReturnCallback(function ($tagIds) { $result = []; if (in_array(1, $tagIds)) { $result[1] = $this->tag1; @@ -100,7 +100,7 @@ class SystemTagObjectMapperTest extends TestCase { $result[3] = $this->tag3; } return $result; - })); + }); $this->tagMapper->assignTags('1', 'testtype', $this->tag1->getId()); $this->tagMapper->assignTags('1', 'testtype', $this->tag2->getId()); diff --git a/tests/lib/TagsTest.php b/tests/lib/TagsTest.php index db0a77f68f0..fd6283d2f27 100644 --- a/tests/lib/TagsTest.php +++ b/tests/lib/TagsTest.php @@ -1,26 +1,27 @@ <?php /** -* ownCloud -* -* @author Thomas Tanghus -* @copyright 2012-13 Thomas Tanghus (thomas@tanghus.net) -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * ownCloud + * + * @author Thomas Tanghus + * @copyright 2012-13 Thomas Tanghus (thomas@tanghus.net) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ namespace Test; + use OCP\IUser; use OCP\IUserSession; @@ -30,13 +31,12 @@ use OCP\IUserSession; * @group DB */ class TagsTest extends \Test\TestCase { - protected $objectType; /** @var \OCP\IUser */ protected $user; /** @var \OCP\IUserSession */ protected $userSession; - protected $backupGlobals = FALSE; + protected $backupGlobals = false; /** @var \OC\Tagging\TagMapper */ protected $tagMapper; /** @var \OCP\ITagManager */ @@ -57,12 +57,11 @@ class TagsTest extends \Test\TestCase { $this->userSession ->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->objectType = $this->getUniqueID('type_'); $this->tagMapper = new \OC\Tagging\TagMapper(\OC::$server->getDatabaseConnection()); $this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession); - } protected function tearDown(): void { @@ -78,13 +77,13 @@ class TagsTest extends \Test\TestCase { $this->userSession ->expects($this->any()) ->method('getUser') - ->will($this->returnValue(null)); + ->willReturn(null); $this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession); $this->assertNull($this->tagMgr->load($this->objectType)); } public function testInstantiateWithDefaults() { - $defaultTags = array('Friends', 'Family', 'Work', 'Other'); + $defaultTags = ['Friends', 'Family', 'Work', 'Other']; $tagger = $this->tagMgr->load($this->objectType, $defaultTags); @@ -92,11 +91,11 @@ class TagsTest extends \Test\TestCase { } public function testAddTags() { - $tags = array('Friends', 'Family', 'Work', 'Other'); + $tags = ['Friends', 'Family', 'Work', 'Other']; $tagger = $this->tagMgr->load($this->objectType); - foreach($tags as $tag) { + foreach ($tags as $tag) { $result = $tagger->add($tag); $this->assertGreaterThan(0, $result, 'add() returned an ID <= 0'); $this->assertTrue((bool)$result); @@ -109,24 +108,24 @@ class TagsTest extends \Test\TestCase { } public function testAddMultiple() { - $tags = array('Friends', 'Family', 'Work', 'Other'); + $tags = ['Friends', 'Family', 'Work', 'Other']; $tagger = $this->tagMgr->load($this->objectType); - foreach($tags as $tag) { + foreach ($tags as $tag) { $this->assertFalse($tagger->hasTag($tag)); } $result = $tagger->addMultiple($tags); $this->assertTrue((bool)$result); - foreach($tags as $tag) { + foreach ($tags as $tag) { $this->assertTrue($tagger->hasTag($tag)); } $tagMaps = $tagger->getTags(); $this->assertCount(4, $tagMaps, 'Not all tags added'); - foreach($tagMaps as $tagMap) { + foreach ($tagMaps as $tagMap) { $this->assertEquals(null, $tagMap['id']); } @@ -142,14 +141,14 @@ class TagsTest extends \Test\TestCase { $this->assertTrue((bool)$result); $tagMaps = $tagger->getTags(); - foreach($tagMaps as $tagMap) { + foreach ($tagMaps as $tagMap) { $this->assertNotEquals(null, $tagMap['id']); } // Reload the tagger. $tagger = $this->tagMgr->load($this->objectType); - foreach($tags as $tag) { + foreach ($tags as $tag) { $this->assertTrue($tagger->hasTag($tag)); } @@ -169,37 +168,37 @@ class TagsTest extends \Test\TestCase { } public function testGetTagsForObjects() { - $defaultTags = array('Friends', 'Family', 'Work', 'Other'); + $defaultTags = ['Friends', 'Family', 'Work', 'Other']; $tagger = $this->tagMgr->load($this->objectType, $defaultTags); $tagger->tagAs(1, 'Friends'); $tagger->tagAs(1, 'Other'); $tagger->tagAs(2, 'Family'); - $tags = $tagger->getTagsForObjects(array(1)); + $tags = $tagger->getTagsForObjects([1]); $this->assertEquals(1, count($tags)); $tags = current($tags); sort($tags); - $this->assertSame(array('Friends', 'Other'), $tags); + $this->assertSame(['Friends', 'Other'], $tags); - $tags = $tagger->getTagsForObjects(array(1, 2)); + $tags = $tagger->getTagsForObjects([1, 2]); $this->assertEquals(2, count($tags)); $tags1 = $tags[1]; sort($tags1); - $this->assertSame(array('Friends', 'Other'), $tags1); - $this->assertSame(array('Family'), $tags[2]); + $this->assertSame(['Friends', 'Other'], $tags1); + $this->assertSame(['Family'], $tags[2]); $this->assertEquals( - array(), - $tagger->getTagsForObjects(array(4)) + [], + $tagger->getTagsForObjects([4]) ); $this->assertEquals( - array(), - $tagger->getTagsForObjects(array(4, 5)) + [], + $tagger->getTagsForObjects([4, 5]) ); } public function testGetTagsForObjectsMassiveResults() { - $defaultTags = array('tag1'); + $defaultTags = ['tag1']; $tagger = $this->tagMgr->load($this->objectType, $defaultTags); $tagData = $tagger->getTags(); $tagId = $tagData[0]['id']; @@ -213,9 +212,9 @@ class TagsTest extends \Test\TestCase { ); // insert lots of entries - $idsArray = array(); - for($i = 1; $i <= 1500; $i++) { - $statement->execute(array($i, $tagId, $tagType)); + $idsArray = []; + for ($i = 1; $i <= 1500; $i++) { + $statement->execute([$i, $tagId, $tagType]); $idsArray[] = $i; } @@ -224,7 +223,7 @@ class TagsTest extends \Test\TestCase { } public function testDeleteTags() { - $defaultTags = array('Friends', 'Family', 'Work', 'Other'); + $defaultTags = ['Friends', 'Family', 'Work', 'Other']; $tagger = $this->tagMgr->load($this->objectType, $defaultTags); $this->assertEquals(4, count($tagger->getTags())); @@ -232,12 +231,12 @@ class TagsTest extends \Test\TestCase { $tagger->delete('family'); $this->assertEquals(3, count($tagger->getTags())); - $tagger->delete(array('Friends', 'Work', 'Other')); + $tagger->delete(['Friends', 'Work', 'Other']); $this->assertEquals(0, count($tagger->getTags())); } public function testRenameTag() { - $defaultTags = array('Friends', 'Family', 'Wrok', 'Other'); + $defaultTags = ['Friends', 'Family', 'Wrok', 'Other']; $tagger = $this->tagMgr->load($this->objectType, $defaultTags); $this->assertTrue($tagger->rename('Wrok', 'Work')); @@ -248,11 +247,11 @@ class TagsTest extends \Test\TestCase { } public function testTagAs() { - $objids = array(1, 2, 3, 4, 5, 6, 7, 8, 9); + $objids = [1, 2, 3, 4, 5, 6, 7, 8, 9]; $tagger = $this->tagMgr->load($this->objectType); - foreach($objids as $id) { + foreach ($objids as $id) { $this->assertTrue($tagger->tagAs($id, 'Family')); } @@ -261,16 +260,16 @@ class TagsTest extends \Test\TestCase { } /** - * @depends testTagAs - */ + * @depends testTagAs + */ public function testUnTag() { - $objIds = array(1, 2, 3, 4, 5, 6, 7, 8, 9); + $objIds = [1, 2, 3, 4, 5, 6, 7, 8, 9]; // Is this "legal"? $this->testTagAs(); $tagger = $this->tagMgr->load($this->objectType); - foreach($objIds as $id) { + foreach ($objIds as $id) { $this->assertTrue(in_array($id, $tagger->getIdsForTag('Family'))); $tagger->unTag($id, 'Family'); $this->assertFalse(in_array($id, $tagger->getIdsForTag('Family'))); @@ -283,9 +282,9 @@ class TagsTest extends \Test\TestCase { public function testFavorite() { $tagger = $this->tagMgr->load($this->objectType); $this->assertTrue($tagger->addToFavorites(1)); - $this->assertEquals(array(1), $tagger->getFavorites()); + $this->assertEquals([1], $tagger->getFavorites()); $this->assertTrue($tagger->removeFromFavorites(1)); - $this->assertEquals(array(), $tagger->getFavorites()); + $this->assertEquals([], $tagger->getFavorites()); } public function testShareTags() { @@ -318,9 +317,8 @@ class TagsTest extends \Test\TestCase { \OC\Share\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); \OC_User::setUserId($otherUserId); - $otherTagger = $otherTagMgr->load('test', array(), true); // Update tags, load shared ones. + $otherTagger = $otherTagMgr->load('test', [], true); // Update tags, load shared ones. $this->assertTrue($otherTagger->hasTag($testTag)); $this->assertContains(1, $otherTagger->getIdsForTag($testTag)); } - } diff --git a/tests/lib/TempManagerTest.php b/tests/lib/TempManagerTest.php index 6262bd5a00a..a1b5e732b40 100644 --- a/tests/lib/TempManagerTest.php +++ b/tests/lib/TempManagerTest.php @@ -17,13 +17,12 @@ class NullLogger extends Log { //disable original constructor } - public function log(int $level, string $message, array $context = array()) { + public function log(int $level, string $message, array $context = []) { //noop } } class TempManagerTest extends \Test\TestCase { - protected $baseDir = null; protected function setUp(): void { diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php index 7c9f3585038..01f2285670e 100644 --- a/tests/lib/Template/CSSResourceLocatorTest.php +++ b/tests/lib/Template/CSSResourceLocatorTest.php @@ -69,8 +69,8 @@ class CSSResourceLocatorTest extends \Test\TestCase { private function cssResourceLocator() { /** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */ - $factory = $this->createMock(Factory::class); - $factory->method('get')->with('css')->willReturn($this->appData); + $factory = $this->createMock(Factory::class); + $factory->method('get')->with('css')->willReturn($this->appData); $scssCacher = new SCSSCacher( $this->logger, $factory, @@ -85,14 +85,14 @@ class CSSResourceLocatorTest extends \Test\TestCase { return new CSSResourceLocator( $this->logger, 'theme', - array('core'=>'map'), - array('3rd'=>'party'), + ['core'=>'map'], + ['3rd'=>'party'], $scssCacher ); } private function rrmdir($directory) { - $files = array_diff(scandir($directory), array('.','..')); + $files = array_diff(scandir($directory), ['.','..']); foreach ($files as $file) { if (is_dir($directory . '/' . $file)) { $this->rrmdir($directory . '/' . $file); @@ -111,10 +111,10 @@ class CSSResourceLocatorTest extends \Test\TestCase { $locator = $this->cssResourceLocator(); $this->assertAttributeEquals('theme', 'theme', $locator); $this->assertAttributeEquals('core', 'serverroot', $locator); - $this->assertAttributeEquals(array('core'=>'map','3rd'=>'party'), 'mapping', $locator); + $this->assertAttributeEquals(['core'=>'map','3rd'=>'party'], 'mapping', $locator); $this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator); $this->assertAttributeEquals('map', 'webroot', $locator); - $this->assertAttributeEquals(array(), 'resources', $locator); + $this->assertAttributeEquals([], 'resources', $locator); } public function testFindWithAppPathSymlink() { @@ -130,13 +130,13 @@ class CSSResourceLocatorTest extends \Test\TestCase { // Use the symlink as the app path \OC::$APPSROOTS[] = [ - 'path' => $new_apps_path_symlink, - 'url' => '/css-apps-test', - 'writable' => false, - ]; + 'path' => $new_apps_path_symlink, + 'url' => '/css-apps-test', + 'writable' => false, + ]; $locator = $this->cssResourceLocator(); - $locator->find(array('test-css-app/test-file')); + $locator->find(['test-css-app/test-file']); $resources = $locator->getResources(); $this->assertCount(1, $resources); diff --git a/tests/lib/Template/IconsCacherTest.php b/tests/lib/Template/IconsCacherTest.php index 8e36426393f..4b5c6a73ef8 100644 --- a/tests/lib/Template/IconsCacherTest.php +++ b/tests/lib/Template/IconsCacherTest.php @@ -1,5 +1,6 @@ <?php -declare (strict_types = 1); + +declare(strict_types = 1); /** * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv@protonmail.com) * @@ -27,16 +28,10 @@ namespace Test\Template; use OC\Files\AppData\AppData; use OC\Files\AppData\Factory; use OC\Template\IconsCacher; -use OC_App; -use OCA\Theming\ThemingDefaults; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\IAppData; -use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; -use OCP\ICache; -use OCP\ICacheFactory; -use OCP\IConfig; use OCP\ILogger; use OCP\IURLGenerator; @@ -90,9 +85,9 @@ class IconsCacherTest extends \Test\TestCase { } "; $actual = self::invokePrivate($this->iconsCacher, 'getIconsFromCss', [$css]); - $expected = array( + $expected = [ 'icon-test' => '/svg/core/actions/add/000?v=1' - ); + ]; $this->assertEquals($expected, $actual); } @@ -153,5 +148,4 @@ class IconsCacherTest extends \Test\TestCase { $actual = $this->iconsCacher->setIconsCss($actual); $this->assertEquals($expected, $actual); } - } diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php index b12124ea5a9..0cdea95fd6f 100644 --- a/tests/lib/Template/JSCombinerTest.php +++ b/tests/lib/Template/JSCombinerTest.php @@ -23,7 +23,6 @@ namespace Test\Template; -use function foo\func; use OC\SystemConfig; use OC\Template\JSCombiner; use OCP\Files\IAppData; @@ -71,7 +70,6 @@ class JSCombinerTest extends \Test\TestCase { $this->config, $this->logger ); - } public function testProcessDebugMode() { @@ -121,16 +119,16 @@ class JSCombinerTest extends \Test\TestCase { $fileDeps = $this->createMock(ISimpleFile::class); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file, $gzfile) { + ->willReturnCallback(function ($path) use ($file, $gzfile) { if ($path === 'combine.js') { return $file; - } else if ($path === 'combine.js.deps') { + } elseif ($path === 'combine.js.deps') { throw new NotFoundException(); - } else if ($path === 'combine.js.gzip') { + } elseif ($path === 'combine.js.gzip') { return $gzfile; } $this->fail(); - })); + }); $folder->expects($this->once()) ->method('newFile') ->with('combine.js.deps') @@ -158,16 +156,16 @@ class JSCombinerTest extends \Test\TestCase { $gzfile = $this->createMock(ISimpleFile::class); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file, $gzfile) { + ->willReturnCallback(function ($path) use ($file, $gzfile) { if ($path === 'combine.js') { return $file; - } else if ($path === 'combine.js.deps') { + } elseif ($path === 'combine.js.deps') { throw new NotFoundException(); - } else if ($path === 'combine.js.gzip') { + } elseif ($path === 'combine.js.gzip') { return $gzfile; } $this->fail(); - })); + }); $folder->expects($this->once()) ->method('newFile') ->with('combine.js.deps') @@ -201,7 +199,7 @@ class JSCombinerTest extends \Test\TestCase { ->willReturn(true); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file, $fileDeps) { + ->willReturnCallback(function ($path) use ($file, $fileDeps) { if ($path === 'combine.js') { return $file; } @@ -211,7 +209,7 @@ class JSCombinerTest extends \Test\TestCase { } $this->fail(); - })); + }); $actual = $this->jsCombiner->process(__DIR__, '/data/combine.json', 'awesomeapp'); $this->assertTrue($actual); @@ -246,12 +244,12 @@ class JSCombinerTest extends \Test\TestCase { ->willReturn('{}'); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file) { + ->willReturnCallback(function ($path) use ($file) { if ($path === 'combine.js') { return $file; } $this->fail(); - })); + }); $actual = $this->jsCombiner->process(__DIR__, '/data/combine.json', 'awesomeapp'); $this->assertTrue($actual); @@ -263,7 +261,7 @@ class JSCombinerTest extends \Test\TestCase { $file = $this->createMock(ISimpleFile::class); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file) { + ->willReturnCallback(function ($path) use ($file) { if ($path === 'combine.js') { return $file; } @@ -271,7 +269,7 @@ class JSCombinerTest extends \Test\TestCase { throw new NotFoundException(); } $this->fail(); - })); + }); $actual = self::invokePrivate($this->jsCombiner, 'isCached', [$fileName, $folder]); $this->assertFalse($actual); @@ -345,18 +343,18 @@ class JSCombinerTest extends \Test\TestCase { $folder->method('getFile')->willThrowException(new NotFoundException()); - $folder->method('newFile')->will($this->returnCallback( + $folder->method('newFile')->willReturnCallback( function ($filename) use ($file, $depsFile, $gzFile) { if ($filename === 'combine.js') { return $file; - } else if ($filename === 'combine.js.deps') { + } elseif ($filename === 'combine.js.deps') { return $depsFile; - } else if ($filename === 'combine.js.gzip') { + } elseif ($filename === 'combine.js.gzip') { return $gzFile; } $this->fail(); } - )); + ); $file->expects($this->once())->method('putContent'); $depsFile->expects($this->once())->method('putContent'); @@ -376,18 +374,18 @@ class JSCombinerTest extends \Test\TestCase { $path = __DIR__ . '/data/'; - $folder->method('getFile')->will($this->returnCallback( + $folder->method('getFile')->willReturnCallback( function ($filename) use ($file, $depsFile, $gzFile) { if ($filename === 'combine.js') { return $file; - } else if ($filename === 'combine.js.deps') { + } elseif ($filename === 'combine.js.deps') { return $depsFile; - } else if ($filename === 'combine.js.gzip') { + } elseif ($filename === 'combine.js.gzip') { return $gzFile; } $this->fail(); } - )); + ); $file->expects($this->once())->method('putContent'); $depsFile->expects($this->once())->method('putContent'); @@ -444,18 +442,18 @@ var b = \'world\'; $path = __DIR__ . '/data/'; - $folder->method('getFile')->will($this->returnCallback( + $folder->method('getFile')->willReturnCallback( function ($filename) use ($file, $depsFile, $gzFile) { if ($filename === 'combine.js') { return $file; - } else if ($filename === 'combine.js.deps') { + } elseif ($filename === 'combine.js.deps') { return $depsFile; - } else if ($filename === 'combine.js.gzip') { + } elseif ($filename === 'combine.js.gzip') { return $gzFile; } $this->fail(); } - )); + ); $file->expects($this->at(0)) ->method('putContent') @@ -561,5 +559,4 @@ var b = \'world\'; $this->jsCombiner->resetCache(); } - } diff --git a/tests/lib/Template/JSResourceLocatorTest.php b/tests/lib/Template/JSResourceLocatorTest.php index 38c5fc0eadd..0e6b217ec52 100644 --- a/tests/lib/Template/JSResourceLocatorTest.php +++ b/tests/lib/Template/JSResourceLocatorTest.php @@ -64,14 +64,14 @@ class JSResourceLocatorTest extends \Test\TestCase { return new JSResourceLocator( $this->logger, 'theme', - array('core'=>'map'), - array('3rd'=>'party'), + ['core'=>'map'], + ['3rd'=>'party'], $jsCombiner ); } private function rrmdir($directory) { - $files = array_diff(scandir($directory), array('.','..')); + $files = array_diff(scandir($directory), ['.','..']); foreach ($files as $file) { if (is_dir($directory . '/' . $file)) { $this->rrmdir($directory . '/' . $file); @@ -91,10 +91,10 @@ class JSResourceLocatorTest extends \Test\TestCase { $locator = $this->jsResourceLocator(); $this->assertAttributeEquals('theme', 'theme', $locator); $this->assertAttributeEquals('core', 'serverroot', $locator); - $this->assertAttributeEquals(array('core'=>'map','3rd'=>'party'), 'mapping', $locator); + $this->assertAttributeEquals(['core'=>'map','3rd'=>'party'], 'mapping', $locator); $this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator); $this->assertAttributeEquals('map', 'webroot', $locator); - $this->assertAttributeEquals(array(), 'resources', $locator); + $this->assertAttributeEquals([], 'resources', $locator); } public function testFindWithAppPathSymlink() { @@ -110,13 +110,13 @@ class JSResourceLocatorTest extends \Test\TestCase { // Use the symlink as the app path \OC::$APPSROOTS[] = [ - 'path' => $new_apps_path_symlink, - 'url' => '/js-apps-test', - 'writable' => false, - ]; + 'path' => $new_apps_path_symlink, + 'url' => '/js-apps-test', + 'writable' => false, + ]; $locator = $this->jsResourceLocator(); - $locator->find(array('test-js-app/test-file')); + $locator->find(['test-js-app/test-file']); $resources = $locator->getResources(); $this->assertCount(1, $resources); diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php index 90488071b4f..f0fa8186686 100644 --- a/tests/lib/Template/ResourceLocatorTest.php +++ b/tests/lib/Template/ResourceLocatorTest.php @@ -29,24 +29,24 @@ class ResourceLocatorTest extends \Test\TestCase { */ public function getResourceLocator($theme, $core_map, $party_map, $appsRoots) { return $this->getMockForAbstractClass('OC\Template\ResourceLocator', - array($this->logger, $theme, $core_map, $party_map, $appsRoots ), - '', true, true, true, array()); + [$this->logger, $theme, $core_map, $party_map, $appsRoots ], + '', true, true, true, []); } public function testConstructor() { $locator = $this->getResourceLocator('theme', - array('core'=>'map'), array('3rd'=>'party'), array('foo'=>'bar')); + ['core'=>'map'], ['3rd'=>'party'], ['foo'=>'bar']); $this->assertAttributeEquals('theme', 'theme', $locator); $this->assertAttributeEquals('core', 'serverroot', $locator); - $this->assertAttributeEquals(array('core'=>'map','3rd'=>'party'), 'mapping', $locator); + $this->assertAttributeEquals(['core'=>'map','3rd'=>'party'], 'mapping', $locator); $this->assertAttributeEquals('3rd', 'thirdpartyroot', $locator); $this->assertAttributeEquals('map', 'webroot', $locator); - $this->assertAttributeEquals(array(), 'resources', $locator); + $this->assertAttributeEquals([], 'resources', $locator); } public function testFind() { $locator = $this->getResourceLocator('theme', - array('core' => 'map'), array('3rd' => 'party'), array('foo' => 'bar')); + ['core' => 'map'], ['3rd' => 'party'], ['foo' => 'bar']); $locator->expects($this->once()) ->method('doFind') ->with('foo'); @@ -54,12 +54,12 @@ class ResourceLocatorTest extends \Test\TestCase { ->method('doFindTheme') ->with('foo'); /** @var \OC\Template\ResourceLocator $locator */ - $locator->find(array('foo')); + $locator->find(['foo']); } public function testFindNotFound() { $locator = $this->getResourceLocator('theme', - array('core'=>'map'), array('3rd'=>'party'), array('foo'=>'bar')); + ['core'=>'map'], ['3rd'=>'party'], ['foo'=>'bar']); $locator->expects($this->once()) ->method('doFind') ->with('foo') @@ -72,25 +72,25 @@ class ResourceLocatorTest extends \Test\TestCase { ->method('debug') ->with($this->stringContains('map/foo')); /** @var \OC\Template\ResourceLocator $locator */ - $locator->find(array('foo')); + $locator->find(['foo']); } public function testAppendIfExist() { $locator = $this->getResourceLocator('theme', - array(__DIR__=>'map'), array('3rd'=>'party'), array('foo'=>'bar')); + [__DIR__=>'map'], ['3rd'=>'party'], ['foo'=>'bar']); /** @var \OC\Template\ResourceLocator $locator */ $method = new \ReflectionMethod($locator, 'appendIfExist'); $method->setAccessible(true); $method->invoke($locator, __DIR__, basename(__FILE__), 'webroot'); - $resource1 = array(__DIR__, 'webroot', basename(__FILE__)); - $this->assertEquals(array($resource1), $locator->getResources()); + $resource1 = [__DIR__, 'webroot', basename(__FILE__)]; + $this->assertEquals([$resource1], $locator->getResources()); $method->invoke($locator, __DIR__, basename(__FILE__)); - $resource2 = array(__DIR__, 'map', basename(__FILE__)); - $this->assertEquals(array($resource1, $resource2), $locator->getResources()); + $resource2 = [__DIR__, 'map', basename(__FILE__)]; + $this->assertEquals([$resource1, $resource2], $locator->getResources()); $method->invoke($locator, __DIR__, 'does-not-exist'); - $this->assertEquals(array($resource1, $resource2), $locator->getResources()); + $this->assertEquals([$resource1, $resource2], $locator->getResources()); } } diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 6f9fdf1e7fb..9dfd8d20fea 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -27,7 +27,6 @@ use OC\Files\AppData\AppData; use OC\Files\AppData\Factory; use OC\Template\IconsCacher; use OC\Template\SCSSCacher; -use OC_App; use OCA\Theming\ThemingDefaults; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\IAppData; @@ -121,17 +120,17 @@ class SCSSCacherTest extends \Test\TestCase { substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-'; $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file, $gzfile, $filePrefix) { + ->willReturnCallback(function ($path) use ($file, $gzfile, $filePrefix) { if ($path === $filePrefix.'styles.css') { return $file; - } else if ($path === $filePrefix.'styles.css.deps') { + } elseif ($path === $filePrefix.'styles.css.deps') { throw new NotFoundException(); - } else if ($path === $filePrefix.'styles.css.gzip') { + } elseif ($path === $filePrefix.'styles.css.gzip') { return $gzfile; } else { $this->fail(); } - })); + }); $folder->expects($this->once()) ->method('newFile') ->with($filePrefix.'styles.css.deps') @@ -161,17 +160,17 @@ class SCSSCacherTest extends \Test\TestCase { substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-'; $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file, $gzfile, $filePrefix) { + ->willReturnCallback(function ($path) use ($file, $gzfile, $filePrefix) { if ($path === $filePrefix.'styles.css') { return $file; - } else if ($path === $filePrefix.'styles.css.deps') { + } elseif ($path === $filePrefix.'styles.css.deps') { throw new NotFoundException(); - } else if ($path === $filePrefix.'styles.css.gzip') { + } elseif ($path === $filePrefix.'styles.css.gzip') { return $gzfile; - }else { + } else { $this->fail(); } - })); + }); $folder->expects($this->once()) ->method('newFile') ->with($filePrefix.'styles.css.deps') @@ -197,16 +196,16 @@ class SCSSCacherTest extends \Test\TestCase { substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-'; $folder->method('getFile') - ->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile, $filePrefix) { + ->willReturnCallback(function ($name) use ($file, $fileDeps, $gzFile, $filePrefix) { if ($name === $filePrefix.'styles.css') { return $file; - } else if ($name === $filePrefix.'styles.css.deps') { + } elseif ($name === $filePrefix.'styles.css.deps') { return $fileDeps; - } else if ($name === $filePrefix.'styles.css.gzip') { + } elseif ($name === $filePrefix.'styles.css.gzip') { return $gzFile; } $this->fail(); - })); + }); $this->iconsCacher->expects($this->any()) ->method('setIconsCss') @@ -235,16 +234,16 @@ class SCSSCacherTest extends \Test\TestCase { $filePrefix = substr(md5(\OC_Util::getVersionString('core')), 0, 4) . '-' . substr(md5('http://localhost/nextcloud/index.php'), 0, 4) . '-'; $folder->method('getFile') - ->will($this->returnCallback(function($name) use ($file, $fileDeps, $gzFile, $filePrefix) { + ->willReturnCallback(function ($name) use ($file, $fileDeps, $gzFile, $filePrefix) { if ($name === $filePrefix.'styles.css') { return $file; - } else if ($name === $filePrefix.'styles.css.deps') { + } elseif ($name === $filePrefix.'styles.css.deps') { return $fileDeps; - } else if ($name === $filePrefix.'styles.css.gzip') { + } elseif ($name === $filePrefix.'styles.css.gzip') { return $gzFile; } $this->fail(); - })); + }); $this->iconsCacher->expects($this->any()) ->method('setIconsCss') @@ -273,15 +272,15 @@ class SCSSCacherTest extends \Test\TestCase { $file->expects($this->once())->method('getSize')->willReturn(1); $folder->method('getFile') - ->will($this->returnCallback(function($path) use ($file) { + ->willReturnCallback(function ($path) use ($file) { if ($path === 'styles.css') { return $file; - } else if ($path === 'styles.css.deps') { + } elseif ($path === 'styles.css.deps') { throw new NotFoundException(); } else { $this->fail(); } - })); + }); $this->appData->expects($this->any()) ->method('getFolder') @@ -301,16 +300,16 @@ class SCSSCacherTest extends \Test\TestCase { $path = \OC::$SERVERROOT . '/core/css/'; $folder->method('getFile')->willThrowException(new NotFoundException()); - $folder->method('newFile')->will($this->returnCallback(function($fileName) use ($file, $depsFile, $gzipFile) { + $folder->method('newFile')->willReturnCallback(function ($fileName) use ($file, $depsFile, $gzipFile) { if ($fileName === 'styles.css') { return $file; - } else if ($fileName === 'styles.css.deps') { + } elseif ($fileName === 'styles.css.deps') { return $depsFile; - } else if ($fileName === 'styles.css.gzip') { + } elseif ($fileName === 'styles.css.gzip') { return $gzipFile; } throw new \Exception(); - })); + }); $this->iconsCacher->expects($this->any()) ->method('setIconsCss') @@ -335,16 +334,16 @@ class SCSSCacherTest extends \Test\TestCase { $webDir = "core/css"; $path = \OC::$SERVERROOT; - $folder->method('getFile')->will($this->returnCallback(function($fileName) use ($file, $depsFile, $gzipFile) { + $folder->method('getFile')->willReturnCallback(function ($fileName) use ($file, $depsFile, $gzipFile) { if ($fileName === 'styles.css') { return $file; - } else if ($fileName === 'styles.css.deps') { + } elseif ($fileName === 'styles.css.deps') { return $depsFile; - } else if ($fileName === 'styles.css.gzip') { + } elseif ($fileName === 'styles.css.gzip') { return $gzipFile; } throw new \Exception(); - })); + }); $file->expects($this->once())->method('putContent'); $depsFile->expects($this->once())->method('putContent'); @@ -369,23 +368,23 @@ class SCSSCacherTest extends \Test\TestCase { $webDir = "tests/data/scss"; $path = \OC::$SERVERROOT . $webDir; - $folder->method('getFile')->will($this->returnCallback(function($fileName) use ($file, $depsFile, $gzipFile) { + $folder->method('getFile')->willReturnCallback(function ($fileName) use ($file, $depsFile, $gzipFile) { if ($fileName === 'styles-success.css') { return $file; - } else if ($fileName === 'styles-success.css.deps') { + } elseif ($fileName === 'styles-success.css.deps') { return $depsFile; - } else if ($fileName === 'styles-success.css.gzip') { + } elseif ($fileName === 'styles-success.css.gzip') { return $gzipFile; } throw new \Exception(); - })); + }); $this->iconsCacher->expects($this->at(0)) ->method('setIconsCss') ->willReturn('body{background-color:#0082c9}'); $file->expects($this->at(0))->method('putContent')->with($this->callback( - function ($content){ + function ($content) { return 'body{background-color:#0082c9}' === $content; })); $depsFile->expects($this->at(0))->method('putContent')->with($this->callback( @@ -471,7 +470,7 @@ class SCSSCacherTest extends \Test\TestCase { } private function rrmdir($directory) { - $files = array_diff(scandir($directory), array('.','..')); + $files = array_diff(scandir($directory), ['.','..']); foreach ($files as $file) { if (is_dir($directory . '/' . $file)) { $this->rrmdir($directory . '/' . $file); @@ -540,6 +539,4 @@ class SCSSCacherTest extends \Test\TestCase { $this->scssCacher->resetCache(); } - - } diff --git a/tests/lib/TemplateFunctionsTest.php b/tests/lib/TemplateFunctionsTest.php index ac73873ce37..caecdfc76ac 100644 --- a/tests/lib/TemplateFunctionsTest.php +++ b/tests/lib/TemplateFunctionsTest.php @@ -23,12 +23,10 @@ namespace Test; class TemplateFunctionsTest extends \Test\TestCase { - protected function setUp(): void { parent::setUp(); - $loader = new \OC\Autoloader([\OC::$SERVERROOT . '/lib']); - $loader->load('OC_Template'); + require_once \OC::$SERVERROOT . '/lib/private/legacy/OC_Template.php'; } public function testPJavaScript() { diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index b80e720efd3..b28be47875a 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -38,10 +38,10 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { private $commandBus; /** @var IDBConnection */ - static protected $realDatabase = null; + protected static $realDatabase = null; /** @var bool */ - static private $wasDatabaseAllowed = false; + private static $wasDatabaseAllowed = false; /** @var array */ protected $services = []; @@ -194,7 +194,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * @param array $parameters * @return mixed */ - protected static function invokePrivate($object, $methodName, array $parameters = array()) { + protected static function invokePrivate($object, $methodName, array $parameters = []) { if (is_string($object)) { $className = $object; } else { @@ -266,7 +266,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * * @param IQueryBuilder $queryBuilder */ - static protected function tearDownAfterClassCleanShares(IQueryBuilder $queryBuilder) { + protected static function tearDownAfterClassCleanShares(IQueryBuilder $queryBuilder) { $queryBuilder->delete('share') ->execute(); } @@ -276,7 +276,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * * @param IQueryBuilder $queryBuilder */ - static protected function tearDownAfterClassCleanStorages(IQueryBuilder $queryBuilder) { + protected static function tearDownAfterClassCleanStorages(IQueryBuilder $queryBuilder) { $queryBuilder->delete('storages') ->execute(); } @@ -286,7 +286,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * * @param IQueryBuilder $queryBuilder */ - static protected function tearDownAfterClassCleanFileCache(IQueryBuilder $queryBuilder) { + protected static function tearDownAfterClassCleanFileCache(IQueryBuilder $queryBuilder) { $queryBuilder->delete('filecache') ->execute(); } @@ -296,15 +296,15 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * * @param string $dataDir */ - static protected function tearDownAfterClassCleanStrayDataFiles($dataDir) { - $knownEntries = array( + protected static function tearDownAfterClassCleanStrayDataFiles($dataDir) { + $knownEntries = [ 'nextcloud.log' => true, 'audit.log' => true, 'owncloud.db' => true, '.ocdata' => true, '..' => true, '.' => true, - ); + ]; if ($dh = opendir($dataDir)) { while (($file = readdir($dh)) !== false) { @@ -321,7 +321,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * * @param string $dir */ - static protected function tearDownAfterClassCleanStrayDataUnlinkDir($dir) { + protected static function tearDownAfterClassCleanStrayDataUnlinkDir($dir) { if ($dh = @opendir($dir)) { while (($file = readdir($dh)) !== false) { if (\OC\Files\Filesystem::isIgnoredDir($file)) { @@ -342,14 +342,14 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { /** * Clean up the list of hooks */ - static protected function tearDownAfterClassCleanStrayHooks() { + protected static function tearDownAfterClassCleanStrayHooks() { \OC_Hook::clear(); } /** * Clean up the list of locks */ - static protected function tearDownAfterClassCleanStrayLocks() { + protected static function tearDownAfterClassCleanStrayLocks() { \OC::$server->getLockingProvider()->releaseAll(); } @@ -359,7 +359,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * * @param string $user user id or empty for a generic FS */ - static protected function loginAsUser($user = '') { + protected static function loginAsUser($user = '') { self::logout(); \OC\Files\Filesystem::tearDown(); \OC_User::setUserId($user); @@ -376,7 +376,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { /** * Logout the current user and tear down the filesystem. */ - static protected function logout() { + protected static function logout() { \OC_Util::tearDownFS(); \OC_User::setUserId(''); // needed for fully logout @@ -449,7 +449,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { } $annotations = $this->getAnnotations(); if (isset($annotations['class']['group'])) { - if(in_array('DB', $annotations['class']['group']) || in_array('SLOWDB', $annotations['class']['group']) ) { + if (in_array('DB', $annotations['class']['group']) || in_array('SLOWDB', $annotations['class']['group'])) { return true; } } @@ -463,7 +463,6 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { * @param array $vars */ protected function assertTemplate($expectedHtml, $template, $vars = []) { - require_once __DIR__.'/../../lib/private/legacy/template/functions.php'; $requestToken = 12345; @@ -479,9 +478,9 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { $l10n ->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters = array()) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); - })); + }); $t = new Base($template, $requestToken, $l10n, $theme); $buf = $t->fetchPage($vars); @@ -513,10 +512,10 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { private function removeWhitespaces(DOMNode $domNode) { foreach ($domNode->childNodes as $node) { - if($node->hasChildNodes()) { + if ($node->hasChildNodes()) { $this->removeWhitespaces($node); } else { - if ($node instanceof \DOMText && $node->isWhitespaceInElementContent() ) { + if ($node instanceof \DOMText && $node->isWhitespaceInElementContent()) { $domNode->removeChild($node); } } diff --git a/tests/lib/Traits/ClientServiceTrait.php b/tests/lib/Traits/ClientServiceTrait.php index d4f540e6c36..cab28e76dba 100644 --- a/tests/lib/Traits/ClientServiceTrait.php +++ b/tests/lib/Traits/ClientServiceTrait.php @@ -21,7 +21,6 @@ namespace Test\Traits; - use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php index ad98ba91212..8799ce72fd0 100644 --- a/tests/lib/Traits/EncryptionTrait.php +++ b/tests/lib/Traits/EncryptionTrait.php @@ -75,7 +75,7 @@ trait EncryptionTrait { \OC::$server->getLogger() ); - $this->registerStorageWrapper('oc_encryption', array($encryptionWrapper, 'wrapStorage')); + $this->registerStorageWrapper('oc_encryption', [$encryptionWrapper, 'wrapStorage']); } protected function setUpEncryptionTrait() { diff --git a/tests/lib/Updater/ChangesCheckTest.php b/tests/lib/Updater/ChangesCheckTest.php index 1bc8b47e58f..4d7dce43ee1 100644 --- a/tests/lib/Updater/ChangesCheckTest.php +++ b/tests/lib/Updater/ChangesCheckTest.php @@ -77,7 +77,7 @@ class ChangesCheckTest extends TestCase { ->method('getStatusCode') ->willReturn($statusCode); - if(!in_array($statusCode, [200, 304, 404])) { + if (!in_array($statusCode, [200, 304, 404])) { $this->logger->expects($this->once()) ->method('debug'); } @@ -348,8 +348,12 @@ class ChangesCheckTest extends TestCase { public function changeDataProvider():array { $testDataFound = $testDataNotFound = $this->versionProvider(); - array_walk($testDataFound, function(&$params) { $params[] = true; }); - array_walk($testDataNotFound, function(&$params) { $params[] = false; }); + array_walk($testDataFound, function (&$params) { + $params[] = true; + }); + array_walk($testDataNotFound, function (&$params) { + $params[] = false; + }); return array_merge($testDataFound, $testDataNotFound); } @@ -362,7 +366,7 @@ class ChangesCheckTest extends TestCase { ->method('getChanges') ->with($normalizedVersion); - if(!$isFound) { + if (!$isFound) { $this->expectException(DoesNotExistException::class); $mocker->willThrowException(new DoesNotExistException('Changes info is not present')); } else { diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index b25557d5569..2f139319bbf 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -74,12 +74,12 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue(time())); + ->willReturn(time()); $this->config ->expects($this->at(2)) ->method('getAppValue') ->with('core', 'lastupdateResult') - ->will($this->returnValue(json_encode($expectedResult))); + ->willReturn(json_encode($expectedResult)); $this->assertSame($expectedResult, $this->updater->check()); } @@ -104,7 +104,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue(0)); + ->willReturn(0); $this->config ->expects($this->at(2)) ->method('getSystemValue') @@ -118,12 +118,12 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(5)) ->method('getAppValue') ->with('core', 'installedat') - ->will($this->returnValue('installedat')); + ->willReturn('installedat'); $this->config ->expects($this->at(6)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue('lastupdatedat')); + ->willReturn('lastupdatedat'); $this->config ->expects($this->at(7)) ->method('setAppValue') @@ -142,7 +142,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->once()) ->method('getUrlContent') ->with($this->buildUpdateUrl('https://updates.nextcloud.com/updater_server/')) - ->will($this->returnValue($updateXml)); + ->willReturn($updateXml); $this->assertSame($expectedResult, $this->updater->check()); } @@ -157,7 +157,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue(0)); + ->willReturn(0); $this->config ->expects($this->at(2)) ->method('getSystemValue') @@ -171,12 +171,12 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(5)) ->method('getAppValue') ->with('core', 'installedat') - ->will($this->returnValue('installedat')); + ->willReturn('installedat'); $this->config ->expects($this->at(6)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue('lastupdatedat')); + ->willReturn('lastupdatedat'); $this->config ->expects($this->at(7)) ->method('setAppValue') @@ -187,7 +187,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->once()) ->method('getUrlContent') ->with($this->buildUpdateUrl('https://updates.nextcloud.com/updater_server/')) - ->will($this->returnValue($updateXml)); + ->willReturn($updateXml); $this->assertSame([], $this->updater->check()); } @@ -212,7 +212,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue(0)); + ->willReturn(0); $this->config ->expects($this->at(2)) ->method('getSystemValue') @@ -226,12 +226,12 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(5)) ->method('getAppValue') ->with('core', 'installedat') - ->will($this->returnValue('installedat')); + ->willReturn('installedat'); $this->config ->expects($this->at(6)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue('lastupdatedat')); + ->willReturn('lastupdatedat'); $updateXml = '<?xml version="1.0"?> <owncloud> @@ -245,7 +245,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->once()) ->method('getUrlContent') ->with($this->buildUpdateUrl('https://updates.nextcloud.com/updater_server/')) - ->will($this->returnValue($updateXml)); + ->willReturn($updateXml); $this->assertSame($expectedResult, $this->updater->check()); } @@ -262,7 +262,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue(0)); + ->willReturn(0); $this->config ->expects($this->at(2)) ->method('getSystemValue') @@ -276,12 +276,12 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(5)) ->method('getAppValue') ->with('core', 'installedat') - ->will($this->returnValue('installedat')); + ->willReturn('installedat'); $this->config ->expects($this->at(6)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue('lastupdatedat')); + ->willReturn('lastupdatedat'); $this->config ->expects($this->at(7)) ->method('setAppValue') @@ -292,7 +292,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->once()) ->method('getUrlContent') ->with($this->buildUpdateUrl('https://updates.nextcloud.com/updater_server/')) - ->will($this->returnValue($updateXml)); + ->willReturn($updateXml); $this->assertSame($expectedResult, $this->updater->check()); } @@ -317,7 +317,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue(0)); + ->willReturn(0); $this->config ->expects($this->at(2)) ->method('getSystemValue') @@ -331,12 +331,12 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->at(5)) ->method('getAppValue') ->with('core', 'installedat') - ->will($this->returnValue('installedat')); + ->willReturn('installedat'); $this->config ->expects($this->at(6)) ->method('getAppValue') ->with('core', 'lastupdatedat') - ->will($this->returnValue('lastupdatedat')); + ->willReturn('lastupdatedat'); // missing autoupdater element should still not fail $updateXml = '<?xml version="1.0"?> @@ -350,7 +350,7 @@ class VersionCheckTest extends \Test\TestCase { ->expects($this->once()) ->method('getUrlContent') ->with($this->buildUpdateUrl('https://updates.nextcloud.com/updater_server/')) - ->will($this->returnValue($updateXml)); + ->willReturn($updateXml); $this->assertSame($expectedResult, $this->updater->check()); } diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php index 1732cf4c1cf..3ccf4c8b8c7 100644 --- a/tests/lib/UpdaterTest.php +++ b/tests/lib/UpdaterTest.php @@ -114,5 +114,4 @@ class UpdaterTest extends TestCase { $this->assertSame($result, $this->updater->isUpgradePossible($oldVersion, $newVersion, $allowedVersions)); } - } diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php index afde88e3995..03f55ff2244 100644 --- a/tests/lib/UrlGeneratorTest.php +++ b/tests/lib/UrlGeneratorTest.php @@ -7,6 +7,7 @@ */ namespace Test; + use OCP\ICacheFactory; use OCP\IConfig; use OCP\IRequest; @@ -115,7 +116,7 @@ class UrlGeneratorTest extends \Test\TestCase { * test absolute URL construction * @dataProvider provideDocRootURLs */ - function testGetAbsoluteURLDocRoot($url, $expectedResult) { + public function testGetAbsoluteURLDocRoot($url, $expectedResult) { $this->mockBaseUrl(); \OC::$WEBROOT = ''; $result = $this->urlGenerator->getAbsoluteURL($url); @@ -127,7 +128,7 @@ class UrlGeneratorTest extends \Test\TestCase { * test absolute URL construction * @dataProvider provideSubDirURLs */ - function testGetAbsoluteURLSubDir($url, $expectedResult) { + public function testGetAbsoluteURLSubDir($url, $expectedResult) { $this->mockBaseUrl(); \OC::$WEBROOT = '/nextcloud'; $result = $this->urlGenerator->getAbsoluteURL($url); @@ -178,6 +179,4 @@ class UrlGeneratorTest extends \Test\TestCase { ['core.WhatsNew.dismiss', 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'], ]; } - - } diff --git a/tests/lib/User/AvatarUserDummy.php b/tests/lib/User/AvatarUserDummy.php index 123825de50f..87e1cfc5f83 100644 --- a/tests/lib/User/AvatarUserDummy.php +++ b/tests/lib/User/AvatarUserDummy.php @@ -1,24 +1,24 @@ <?php /** -* ownCloud -* -* @author Arthur Schiwon -* @copyright 2013 Arthur Schiwon blizzz@owncloud.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * ownCloud + * + * @author Arthur Schiwon + * @copyright 2013 Arthur Schiwon blizzz@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ namespace Test\User; diff --git a/tests/lib/User/Backend.php b/tests/lib/User/Backend.php index 1c7d482c480..3fb08777abb 100644 --- a/tests/lib/User/Backend.php +++ b/tests/lib/User/Backend.php @@ -1,24 +1,24 @@ <?php /** -* ownCloud -* -* @author Robin Appelman -* @copyright 2012 Robin Appelman icewind@owncloud.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * ownCloud + * + * @author Robin Appelman + * @copyright 2012 Robin Appelman icewind@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ namespace Test\User; diff --git a/tests/lib/User/DatabaseTest.php b/tests/lib/User/DatabaseTest.php index 65d483734d9..1c63190890b 100644 --- a/tests/lib/User/DatabaseTest.php +++ b/tests/lib/User/DatabaseTest.php @@ -1,24 +1,24 @@ <?php /** -* ownCloud -* -* @author Robin Appelman -* @copyright 2012 Robin Appelman icewind@owncloud.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * ownCloud + * + * @author Robin Appelman + * @copyright 2012 Robin Appelman icewind@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ namespace Test\User; @@ -56,10 +56,10 @@ class DatabaseTest extends Backend { } protected function tearDown(): void { - if(!isset($this->users)) { + if (!isset($this->users)) { return; } - foreach($this->users as $user) { + foreach ($this->users as $user) { $this->backend->deleteUser($user); } parent::tearDown(); diff --git a/tests/lib/User/Dummy.php b/tests/lib/User/Dummy.php index 7eb5cc41ba8..a543e7e58b6 100644 --- a/tests/lib/User/Dummy.php +++ b/tests/lib/User/Dummy.php @@ -1,24 +1,24 @@ <?php /** -* ownCloud -* -* @author Robin Appelman -* @copyright 2012 Robin Appelman icewind@owncloud.com -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE -* License as published by the Free Software Foundation; either -* version 3 of the License, or any later version. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* -* You should have received a copy of the GNU Affero General Public -* License along with this library. If not, see <http://www.gnu.org/licenses/>. -* -*/ + * ownCloud + * + * @author Robin Appelman + * @copyright 2012 Robin Appelman icewind@owncloud.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ namespace Test\User; diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php index 40197101fd6..7cc42e81ba2 100644 --- a/tests/lib/User/ManagerTest.php +++ b/tests/lib/User/ManagerTest.php @@ -8,6 +8,7 @@ */ namespace Test\User; + use OC\AllConfig; use OC\User\Database; use OC\User\Manager; @@ -60,7 +61,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); @@ -76,7 +77,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)); + ->willReturn(false); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); @@ -98,7 +99,7 @@ class ManagerTest extends TestCase { $backend1->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)); + ->willReturn(false); /** * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 @@ -107,7 +108,7 @@ class ManagerTest extends TestCase { $backend2->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend1); @@ -124,7 +125,7 @@ class ManagerTest extends TestCase { $backend1->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)); + ->willReturn(true); /** * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 @@ -148,17 +149,17 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('checkPassword') ->with($this->equalTo('foo'), $this->equalTo('bar')) - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\USER\BACKEND::CHECK_PASSWORD) { return true; } else { return false; } - })); + }); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); @@ -177,7 +178,7 @@ class ManagerTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(false)); + ->willReturn(false); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); @@ -193,7 +194,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->never()) ->method('loginName2UserName'); @@ -211,7 +212,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)); + ->willReturn(false); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); @@ -227,7 +228,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('bLeNdEr')) - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->never()) ->method('loginName2UserName'); @@ -245,7 +246,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('getUsers') ->with($this->equalTo('fo')) - ->will($this->returnValue(array('foo', 'afoo', 'Afoo1', 'Bfoo'))); + ->willReturn(['foo', 'afoo', 'Afoo1', 'Bfoo']); $backend->expects($this->never()) ->method('loginName2UserName'); @@ -268,7 +269,7 @@ class ManagerTest extends TestCase { $backend1->expects($this->once()) ->method('getUsers') ->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1)) - ->will($this->returnValue(array('foo1', 'foo2'))); + ->willReturn(['foo1', 'foo2']); $backend1->expects($this->never()) ->method('loginName2UserName'); @@ -279,7 +280,7 @@ class ManagerTest extends TestCase { $backend2->expects($this->once()) ->method('getUsers') ->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1)) - ->will($this->returnValue(array('foo3'))); + ->willReturn(['foo3']); $backend2->expects($this->never()) ->method('loginName2UserName'); @@ -351,7 +352,7 @@ class ManagerTest extends TestCase { $backend = $this->createMock(\Test\Util\User\Dummy::class); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('createUser') @@ -360,7 +361,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)); + ->willReturn(false); $backend->expects($this->never()) ->method('loginName2UserName'); @@ -381,7 +382,7 @@ class ManagerTest extends TestCase { $backend = $this->createMock(\Test\Util\User\Dummy::class); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->never()) ->method('createUser'); @@ -389,7 +390,7 @@ class ManagerTest extends TestCase { $backend->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); @@ -404,7 +405,7 @@ class ManagerTest extends TestCase { $backend = $this->createMock(\Test\Util\User\Dummy::class); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(false)); + ->willReturn(false); $backend->expects($this->never()) ->method('createUser'); @@ -453,7 +454,7 @@ class ManagerTest extends TestCase { $backend1 = $this->createMock(\Test\Util\User\Dummy::class); $backend1->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend1->expects($this->never()) ->method('createUser'); @@ -461,7 +462,7 @@ class ManagerTest extends TestCase { $backend1->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)); + ->willReturn(false); /** * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 @@ -469,7 +470,7 @@ class ManagerTest extends TestCase { $backend2 = $this->createMock(\Test\Util\User\Dummy::class); $backend2->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(true)); + ->willReturn(true); $backend2->expects($this->never()) ->method('createUser'); @@ -477,7 +478,7 @@ class ManagerTest extends TestCase { $backend2->expects($this->once()) ->method('userExists') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend1); @@ -501,16 +502,16 @@ class ManagerTest extends TestCase { $backend = $this->createMock(\Test\Util\User\Dummy::class); $backend->expects($this->once()) ->method('countUsers') - ->will($this->returnValue(7)); + ->willReturn(7); $backend->expects($this->once()) ->method('implementsActions') ->with(\OC\USER\BACKEND::COUNT_USERS) - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->once()) ->method('getBackendName') - ->will($this->returnValue('Mock_Test_Util_User_Dummy')); + ->willReturn('Mock_Test_Util_User_Dummy'); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); @@ -530,28 +531,28 @@ class ManagerTest extends TestCase { $backend1 = $this->createMock(\Test\Util\User\Dummy::class); $backend1->expects($this->once()) ->method('countUsers') - ->will($this->returnValue(7)); + ->willReturn(7); $backend1->expects($this->once()) ->method('implementsActions') ->with(\OC\USER\BACKEND::COUNT_USERS) - ->will($this->returnValue(true)); + ->willReturn(true); $backend1->expects($this->once()) ->method('getBackendName') - ->will($this->returnValue('Mock_Test_Util_User_Dummy')); + ->willReturn('Mock_Test_Util_User_Dummy'); $backend2 = $this->createMock(\Test\Util\User\Dummy::class); $backend2->expects($this->once()) ->method('countUsers') - ->will($this->returnValue(16)); + ->willReturn(16); $backend2->expects($this->once()) ->method('implementsActions') ->with(\OC\USER\BACKEND::COUNT_USERS) - ->will($this->returnValue(true)); + ->willReturn(true); $backend2->expects($this->once()) ->method('getBackendName') - ->will($this->returnValue('Mock_Test_Util_User_Dummy')); + ->willReturn('Mock_Test_Util_User_Dummy'); $manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend1); @@ -672,21 +673,21 @@ class ManagerTest extends TestCase { ->expects($this->at(0)) ->method('getUsersForUserValueCaseInsensitive') ->with('settings', 'email', 'test@example.com') - ->will($this->returnValue(['uid1', 'uid99', 'uid2'])); + ->willReturn(['uid1', 'uid99', 'uid2']); $backend = $this->createMock(\Test\Util\User\Dummy::class); $backend->expects($this->at(0)) ->method('userExists') ->with($this->equalTo('uid1')) - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->at(1)) ->method('userExists') ->with($this->equalTo('uid99')) - ->will($this->returnValue(false)); + ->willReturn(false); $backend->expects($this->at(2)) ->method('userExists') ->with($this->equalTo('uid2')) - ->will($this->returnValue(true)); + ->willReturn(true); $manager = new \OC\User\Manager($config, $this->oldDispatcher, $this->eventDispatcher); $manager->registerBackend($backend); diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index e7df7578c7d..48c4785bf71 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -67,7 +67,7 @@ class SessionTest extends \Test\TestCase { $this->timeFactory = $this->createMock(ITimeFactory::class); $this->timeFactory->expects($this->any()) ->method('getTime') - ->will($this->returnValue(10000)); + ->willReturn(10000); $this->tokenProvider = $this->createMock(IProvider::class); $this->config = $this->createMock(IConfig::class); $this->throttler = $this->createMock(Throttler::class); @@ -105,12 +105,12 @@ class SessionTest extends \Test\TestCase { $expectedUser = $this->createMock(IUser::class); $expectedUser->expects($this->any()) ->method('getUID') - ->will($this->returnValue('user123')); + ->willReturn('user123'); $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock(); $session->expects($this->at(0)) ->method('get') ->with('user_id') - ->will($this->returnValue($expectedUser->getUID())); + ->willReturn($expectedUser->getUID()); $sessionId = 'abcdef12345'; $manager = $this->getMockBuilder('\OC\User\Manager') @@ -119,25 +119,25 @@ class SessionTest extends \Test\TestCase { $session->expects($this->at(1)) ->method('get') ->with('app_password') - ->will($this->returnValue(null)); // No password set -> browser session + ->willReturn(null); // No password set -> browser session $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($sessionId) - ->will($this->returnValue($token)); + ->willReturn($token); $this->tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, $sessionId) - ->will($this->returnValue('passme')); + ->willReturn('passme'); $manager->expects($this->once()) ->method('checkPassword') ->with('User123', 'passme') - ->will($this->returnValue(true)); + ->willReturn(true); $expectedUser->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(true)); + ->willReturn(true); $this->tokenProvider->expects($this->once()) ->method('updateTokenActivity') @@ -146,7 +146,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($expectedUser->getUID()) - ->will($this->returnValue($expectedUser)); + ->willReturn($expectedUser); $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher); $user = $userSession->getUser(); @@ -178,7 +178,7 @@ class SessionTest extends \Test\TestCase { $user = new User('sepp', null, $this->createMock(EventDispatcherInterface::class)); $userSession->expects($this->once()) ->method('getUser') - ->will($this->returnValue($isLoggedIn ? $user : null)); + ->willReturn($isLoggedIn ? $user : null); $this->assertEquals($isLoggedIn, $userSession->isLoggedIn()); } @@ -195,7 +195,7 @@ class SessionTest extends \Test\TestCase { $user = $this->createMock(IUser::class); $user->expects($this->once()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher); $userSession->setUser($user); @@ -240,17 +240,17 @@ class SessionTest extends \Test\TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('isEnabled') - ->will($this->returnValue(true)); + ->willReturn(true); $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $user->expects($this->once()) ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue($user)); + ->willReturn($user); $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) @@ -264,7 +264,7 @@ class SessionTest extends \Test\TestCase { $this->dispatcher->expects($this->once()) ->method('dispatchTyped') ->with( - $this->callback(function(PostLoginEvent $e) { + $this->callback(function (PostLoginEvent $e) { return $e->getUser()->getUID() === 'foo' && $e->getPassword() === 'bar' && $e->isTokenLogin() === false; @@ -304,14 +304,14 @@ class SessionTest extends \Test\TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any()) ->method('isEnabled') - ->will($this->returnValue(false)); + ->willReturn(false); $user->expects($this->never()) ->method('updateLastLoginTimestamp'); $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue($user)); + ->willReturn($user); $this->dispatcher->expects($this->never()) ->method('dispatch'); @@ -355,7 +355,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue(false)); + ->willReturn(false); $this->dispatcher->expects($this->never()) ->method('dispatch'); @@ -380,7 +380,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->login('foo', 'bar'); } @@ -404,12 +404,12 @@ class SessionTest extends \Test\TestCase { $this->tokenProvider->expects($this->once()) ->method('getToken') ->with('bar') - ->will($this->returnValue($token)); + ->willReturn($token); $manager->expects($this->once()) ->method('checkPasswordNoLogging') ->with('foo', 'bar') - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->login('foo', 'bar'); } @@ -435,7 +435,7 @@ class SessionTest extends \Test\TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('token_auth_enforced', false) - ->will($this->returnValue(true)); + ->willReturn(true); $request ->expects($this->any()) ->method('getRemoteAddress') @@ -471,7 +471,7 @@ class SessionTest extends \Test\TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('token_auth_enforced', false) - ->will($this->returnValue(false)); + ->willReturn(false); $manager->method('getByEmail') ->with('unexist') ->willReturn([]); @@ -492,11 +492,11 @@ class SessionTest extends \Test\TestCase { $userSession->expects($this->once()) ->method('isTokenPassword') - ->will($this->returnValue(true)); + ->willReturn(true); $userSession->expects($this->once()) ->method('login') ->with('john', 'I-AM-AN-APP-PASSWORD') - ->will($this->returnValue(true)); + ->willReturn(true); $session->expects($this->once()) ->method('set') @@ -539,12 +539,12 @@ class SessionTest extends \Test\TestCase { $this->config->expects($this->once()) ->method('getSystemValue') ->with('token_auth_enforced', false) - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->expects($this->once()) ->method('isTwoFactorEnforced') ->with('john') - ->will($this->returnValue(true)); + ->willReturn(true); $request ->expects($this->any()) @@ -592,18 +592,18 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($user)); + ->willReturn($user); $this->config->expects($this->once()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue([$token])); + ->willReturn([$token]); $this->config->expects($this->once()) ->method('deleteUserValue') ->with('foo', 'login_token', $token); $this->random->expects($this->once()) ->method('generate') ->with(32) - ->will($this->returnValue('abcdefg123456')); + ->willReturn('abcdefg123456'); $this->config->expects($this->once()) ->method('setUserValue') ->with('foo', 'login_token', 'abcdefg123456', 10000); @@ -617,7 +617,7 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('renewSessionToken') ->with($oldSessionId, $sessionId) @@ -628,7 +628,7 @@ class SessionTest extends \Test\TestCase { $user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $userSession->expects($this->once()) ->method('setMagicInCookie'); $user->expects($this->once()) @@ -636,11 +636,11 @@ class SessionTest extends \Test\TestCase { $setUID = false; $session ->method('set') - ->will($this->returnCallback(function ($k, $v) use (&$setUID) { + ->willReturnCallback(function ($k, $v) use (&$setUID) { if ($k === 'user_id' && $v === 'foo') { $setUID = true; } - })); + }); $userSession->expects($this->once()) ->method('setLoginName') ->willReturn('foobar'); @@ -681,11 +681,11 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($user)); + ->willReturn($user); $this->config->expects($this->once()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue([$token])); + ->willReturn([$token]); $this->config->expects($this->once()) ->method('deleteUserValue') ->with('foo', 'login_token', $token); @@ -694,7 +694,7 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('renewSessionToken') ->with($oldSessionId, $sessionId) @@ -702,7 +702,7 @@ class SessionTest extends \Test\TestCase { $user->expects($this->never()) ->method('getUID') - ->will($this->returnValue('foo')); + ->willReturn('foo'); $userSession->expects($this->never()) ->method('setMagicInCookie'); $user->expects($this->never()) @@ -744,11 +744,11 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue($user)); + ->willReturn($user); $this->config->expects($this->once()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue(['anothertoken'])); + ->willReturn(['anothertoken']); $this->config->expects($this->never()) ->method('deleteUserValue') ->with('foo', 'login_token', $token); @@ -794,11 +794,11 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with('foo') - ->will($this->returnValue(null)); + ->willReturn(null); $this->config->expects($this->never()) ->method('getUserKeys') ->with('foo', 'login_token') - ->will($this->returnValue(['anothertoken'])); + ->willReturn(['anothertoken']); $this->tokenProvider->expects($this->never()) ->method('renewSessionToken'); @@ -814,10 +814,10 @@ class SessionTest extends \Test\TestCase { } public function testActiveUserAfterSetSession() { - $users = array( + $users = [ 'foo' => new User('foo', null, $this->createMock(EventDispatcherInterface::class)), 'bar' => new User('bar', null, $this->createMock(EventDispatcherInterface::class)) - ); + ]; $manager = $this->getMockBuilder('\OC\User\Manager') ->disableOriginalConstructor() @@ -825,9 +825,9 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->any()) ->method('get') - ->will($this->returnCallback(function ($uid) use ($users) { + ->willReturnCallback(function ($uid) use ($users) { return $users[$uid]; - })); + }); $session = new Memory(''); $session->set('user_id', 'foo'); @@ -873,10 +873,10 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue($user)); + ->willReturn($user); $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($password) @@ -914,10 +914,10 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue($user)); + ->willReturn($user); $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($password) @@ -959,18 +959,18 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue($user)); + ->willReturn($user); $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with($password) - ->will($this->returnValue($token)); + ->willReturn($token); $this->tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, $password) - ->will($this->returnValue($realPassword)); + ->willReturn($realPassword); $this->tokenProvider->expects($this->once()) ->method('generateToken') @@ -994,7 +994,7 @@ class SessionTest extends \Test\TestCase { $manager->expects($this->once()) ->method('get') ->with($uid) - ->will($this->returnValue(null)); + ->willReturn(null); $this->assertFalse($userSession->createSessionToken($request, $uid, $loginName, $password)); } @@ -1021,18 +1021,18 @@ class SessionTest extends \Test\TestCase { $request->expects($this->once()) ->method('getHeader') ->with('Authorization') - ->will($this->returnValue('Bearer xxxxx')); + ->willReturn('Bearer xxxxx'); $this->tokenProvider->expects($this->once()) ->method('getToken') ->with('xxxxx') - ->will($this->returnValue($token)); + ->willReturn($token); $manager->expects($this->once()) ->method('get') ->with('fritz0') - ->will($this->returnValue($user)); + ->willReturn($user); $user->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(false)); + ->willReturn(false); $userSession->tryTokenLogin($request); } @@ -1055,23 +1055,23 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('get') ->with('app_password') - ->will($this->returnValue('APP-PASSWORD')); + ->willReturn('APP-PASSWORD'); $tokenProvider->expects($this->once()) ->method('getToken') ->with('APP-PASSWORD') - ->will($this->returnValue($token)); + ->willReturn($token); $timeFactory->expects($this->once()) ->method('getTime') - ->will($this->returnValue(1000)); // more than 5min since last check + ->willReturn(1000); // more than 5min since last check $tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, 'APP-PASSWORD') - ->will($this->returnValue('123456')); + ->willReturn('123456'); $userManager->expects($this->never()) ->method('checkPassword'); $user->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(false)); + ->willReturn(false); $tokenProvider->expects($this->once()) ->method('invalidateToken') ->with('APP-PASSWORD'); @@ -1099,14 +1099,14 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('get') ->with('app_password') - ->will($this->returnValue('APP-PASSWORD')); + ->willReturn('APP-PASSWORD'); $tokenProvider->expects($this->once()) ->method('getToken') ->with('APP-PASSWORD') - ->will($this->returnValue($token)); + ->willReturn($token); $timeFactory->expects($this->once()) ->method('getTime') - ->will($this->returnValue(1000)); // more than 5min since last check + ->willReturn(1000); // more than 5min since last check $tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, 'APP-PASSWORD') @@ -1135,25 +1135,25 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('get') ->with('app_password') - ->will($this->returnValue('APP-PASSWORD')); + ->willReturn('APP-PASSWORD'); $tokenProvider->expects($this->once()) ->method('getToken') ->with('APP-PASSWORD') - ->will($this->returnValue($token)); + ->willReturn($token); $timeFactory->expects($this->once()) ->method('getTime') - ->will($this->returnValue(1000)); // more than 5min since last check + ->willReturn(1000); // more than 5min since last check $tokenProvider->expects($this->once()) ->method('getPassword') ->with($token, 'APP-PASSWORD') - ->will($this->returnValue('123456')); + ->willReturn('123456'); $userManager->expects($this->once()) ->method('checkPassword') ->with('susan', '123456') ->willReturn(false); $user->expects($this->once()) ->method('isEnabled') - ->will($this->returnValue(true)); + ->willReturn(true); $tokenProvider->expects($this->never()) ->method('invalidateToken'); $tokenProvider->expects($this->once()) @@ -1179,11 +1179,11 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $tokenProvider->expects($this->once()) ->method('getToken') ->with($sessionId) - ->will($this->returnValue($token)); + ->willReturn($token); $tokenProvider->expects($this->once()) ->method('setPassword') ->with($token, $sessionId, $password); @@ -1218,11 +1218,11 @@ class SessionTest extends \Test\TestCase { $session->expects($this->once()) ->method('getId') - ->will($this->returnValue($sessionId)); + ->willReturn($sessionId); $tokenProvider->expects($this->once()) ->method('getToken') ->with($sessionId) - ->will($this->returnValue($token)); + ->willReturn($token); $tokenProvider->expects($this->once()) ->method('setPassword') ->with($token, $sessionId, $password) @@ -1254,7 +1254,7 @@ class SessionTest extends \Test\TestCase { $mapper->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $mapper->expects($this->once()) ->method('update'); $request @@ -1273,7 +1273,7 @@ class SessionTest extends \Test\TestCase { $this->timeFactory ->expects($this->any()) ->method('getTime') - ->will($this->returnValue(100)); + ->willReturn(100); $manager->method('getByEmail') ->with('john') @@ -1308,7 +1308,7 @@ class SessionTest extends \Test\TestCase { $mapper->expects($this->any()) ->method('getToken') - ->will($this->returnValue($token)); + ->willReturn($token); $mapper->expects($this->never()) ->method('update'); $request @@ -1327,7 +1327,7 @@ class SessionTest extends \Test\TestCase { $this->timeFactory ->expects($this->any()) ->method('getTime') - ->will($this->returnValue(100)); + ->willReturn(100); $manager->method('getByEmail') ->with('john') @@ -1375,7 +1375,7 @@ class SessionTest extends \Test\TestCase { $this->session ->method('set') - ->will($this->returnCallback(function($k, $v) use (&$davAuthenticatedSet, &$lastPasswordConfirmSet) { + ->willReturnCallback(function ($k, $v) use (&$davAuthenticatedSet, &$lastPasswordConfirmSet) { switch ($k) { case Auth::DAV_AUTHENTICATED: $davAuthenticatedSet = $v; @@ -1386,7 +1386,7 @@ class SessionTest extends \Test\TestCase { default: throw new \Exception(); } - })); + }); $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([ diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 8431f14f8a2..4e527addc6e 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -47,12 +47,12 @@ class UserTest extends TestCase { $backend->expects($this->once()) ->method('getDisplayName') ->with($this->equalTo('foo')) - ->will($this->returnValue('Foo')); + ->willReturn('Foo'); $backend->expects($this->any()) ->method('implementsActions') ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME)) - ->will($this->returnValue(true)); + ->willReturn(true); $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('Foo', $user->getDisplayName()); @@ -69,12 +69,12 @@ class UserTest extends TestCase { $backend->expects($this->once()) ->method('getDisplayName') ->with($this->equalTo('foo')) - ->will($this->returnValue(' ')); + ->willReturn(' '); $backend->expects($this->any()) ->method('implementsActions') ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME)) - ->will($this->returnValue(true)); + ->willReturn(true); $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('foo', $user->getDisplayName()); @@ -91,7 +91,7 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') ->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME)) - ->will($this->returnValue(false)); + ->willReturn(false); $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('foo', $user->getDisplayName()); @@ -108,13 +108,13 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::SET_PASSWORD) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->setPassword('bar','')); @@ -130,7 +130,7 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(false)); + ->willReturn(false); $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->setPassword('bar','')); @@ -144,17 +144,17 @@ class UserTest extends TestCase { $backend->expects($this->once()) ->method('canChangeAvatar') ->with($this->equalTo('foo')) - ->will($this->returnValue(true)); + ->willReturn(true); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::PROVIDE_AVATAR) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->canChangeAvatar()); @@ -168,17 +168,17 @@ class UserTest extends TestCase { $backend->expects($this->once()) ->method('canChangeAvatar') ->with($this->equalTo('foo')) - ->will($this->returnValue(false)); + ->willReturn(false); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::PROVIDE_AVATAR) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->canChangeAvatar()); @@ -221,13 +221,13 @@ class UserTest extends TestCase { $backend->expects($this->at(0)) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::GET_HOME) { return true; } else { return false; } - })); + }); // important: getHome MUST be called before deleteUser because // once the user is deleted, getHome implementations might not @@ -235,7 +235,7 @@ class UserTest extends TestCase { $backend->expects($this->at(1)) ->method('getHome') ->with($this->equalTo('foo')) - ->will($this->returnValue('/home/foo')); + ->willReturn('/home/foo'); $backend->expects($this->at(2)) ->method('deleteUser') @@ -253,17 +253,17 @@ class UserTest extends TestCase { $backend->expects($this->once()) ->method('getHome') ->with($this->equalTo('foo')) - ->will($this->returnValue('/home/foo')); + ->willReturn('/home/foo'); $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::GET_HOME) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher); $this->assertEquals('/home/foo', $user->getHome()); @@ -286,18 +286,18 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(false)); + ->willReturn(false); $allConfig = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $allConfig->expects($this->any()) ->method('getUserValue') - ->will($this->returnValue(true)); + ->willReturn(true); $allConfig->expects($this->any()) ->method('getSystemValue') ->with($this->equalTo('datadirectory')) - ->will($this->returnValue('arbitrary/path')); + ->willReturn('arbitrary/path'); $user = new User('foo', $backend, $this->dispatcher, null, $allConfig); $this->assertEquals('arbitrary/path/foo', $user->getHome()); @@ -311,13 +311,13 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::SET_PASSWORD) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->canChangePassword()); @@ -331,7 +331,7 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(false)); + ->willReturn(false); $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->canChangePassword()); @@ -345,13 +345,13 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::SET_DISPLAYNAME) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher); $this->assertTrue($user->canChangeDisplayName()); @@ -365,7 +365,7 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnValue(false)); + ->willReturn(false); $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->canChangeDisplayName()); @@ -379,13 +379,13 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::SET_DISPLAYNAME) { return true; } else { return false; } - })); + }); $backend->expects($this->once()) ->method('setDisplayName') @@ -408,13 +408,13 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::SET_DISPLAYNAME) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher); $this->assertFalse($user->setDisplayName(' ')); @@ -466,13 +466,13 @@ class UserTest extends TestCase { $backend->expects($this->any()) ->method('implementsActions') - ->will($this->returnCallback(function ($actions) { + ->willReturnCallback(function ($actions) { if ($actions === \OC\User\Backend::SET_PASSWORD) { return true; } else { return false; } - })); + }); $user = new User('foo', $backend, $this->dispatcher, $emitter); @@ -751,13 +751,13 @@ class UserTest extends TestCase { $config = $this->createMock(IConfig::class); $config->method('getUserValue') - ->will($this->returnCallback(function ($uid, $app, $key, $default) { + ->willReturnCallback(function ($uid, $app, $key, $default) { if ($uid === 'foo' && $app === 'login' && $key === 'lastLogin') { return 42; } else { return $default; } - })); + }); $user = new User('foo', $backend, $this->dispatcher, null, $config); $this->assertSame(42, $user->getLastLogin()); @@ -861,13 +861,13 @@ class UserTest extends TestCase { $config = $this->createMock(IConfig::class); $config->method('getUserValue') - ->will($this->returnCallback(function ($uid, $app, $key, $default) { + ->willReturnCallback(function ($uid, $app, $key, $default) { if ($uid === 'foo' && $app === 'settings' && $key === 'email') { return 'foo@bar.com'; } else { return $default; } - })); + }); $user = new User('foo', $backend, $this->dispatcher, null, $config); $this->assertSame('foo@bar.com', $user->getEMailAddress()); diff --git a/tests/lib/Util/Group/Dummy.php b/tests/lib/Util/Group/Dummy.php index 0681a317c28..293c8f48945 100644 --- a/tests/lib/Util/Group/Dummy.php +++ b/tests/lib/Util/Group/Dummy.php @@ -35,7 +35,7 @@ use OC\Group\Backend; * dummy group backend, does not keep state, only for testing use */ class Dummy extends Backend { - private $groups=array(); + private $groups=[]; /** * Try to create a new group * @param string $gid The name of the group to create @@ -45,10 +45,10 @@ class Dummy extends Backend { * be returned. */ public function createGroup($gid) { - if(!isset($this->groups[$gid])) { - $this->groups[$gid]=array(); + if (!isset($this->groups[$gid])) { + $this->groups[$gid]=[]; return true; - }else{ + } else { return false; } } @@ -61,10 +61,10 @@ class Dummy extends Backend { * Deletes a group and removes it from the group_user-table */ public function deleteGroup($gid) { - if(isset($this->groups[$gid])) { + if (isset($this->groups[$gid])) { unset($this->groups[$gid]); return true; - }else{ + } else { return false; } } @@ -78,9 +78,9 @@ class Dummy extends Backend { * Checks whether the user is member of a group or not. */ public function inGroup($uid, $gid) { - if(isset($this->groups[$gid])) { + if (isset($this->groups[$gid])) { return (array_search($uid, $this->groups[$gid])!==false); - }else{ + } else { return false; } } @@ -94,14 +94,14 @@ class Dummy extends Backend { * Adds a user to a group. */ public function addToGroup($uid, $gid) { - if(isset($this->groups[$gid])) { - if(array_search($uid, $this->groups[$gid])===false) { + if (isset($this->groups[$gid])) { + if (array_search($uid, $this->groups[$gid])===false) { $this->groups[$gid][]=$uid; return true; - }else{ + } else { return false; } - }else{ + } else { return false; } } @@ -115,14 +115,14 @@ class Dummy extends Backend { * removes the user from a group. */ public function removeFromGroup($uid, $gid) { - if(isset($this->groups[$gid])) { - if(($index=array_search($uid, $this->groups[$gid]))!==false) { + if (isset($this->groups[$gid])) { + if (($index=array_search($uid, $this->groups[$gid]))!==false) { unset($this->groups[$gid][$index]); return true; - }else{ + } else { return false; } - }else{ + } else { return false; } } @@ -136,10 +136,10 @@ class Dummy extends Backend { * if the user exists at all. */ public function getUserGroups($uid) { - $groups=array(); + $groups=[]; $allGroups=array_keys($this->groups); - foreach($allGroups as $group) { - if($this->inGroup($uid, $group)) { + foreach ($allGroups as $group) { + if ($this->inGroup($uid, $group)) { $groups[]=$group; } } @@ -154,12 +154,12 @@ class Dummy extends Backend { * @return array an array of group names */ public function getGroups($search = '', $limit = -1, $offset = 0) { - if(empty($search)) { + if (empty($search)) { return array_keys($this->groups); } - $result = array(); - foreach(array_keys($this->groups) as $group) { - if(stripos($group, $search) !== false) { + $result = []; + foreach (array_keys($this->groups) as $group) { + if (stripos($group, $search) !== false) { $result[] = $group; } } @@ -175,20 +175,20 @@ class Dummy extends Backend { * @return array an array of user IDs */ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { - if(isset($this->groups[$gid])) { - if(empty($search)) { + if (isset($this->groups[$gid])) { + if (empty($search)) { $length = $limit < 0 ? null : $limit; return array_slice($this->groups[$gid], $offset, $length); } - $result = array(); - foreach($this->groups[$gid] as $user) { - if(stripos($user, $search) !== false) { + $result = []; + foreach ($this->groups[$gid] as $user) { + if (stripos($user, $search) !== false) { $result[] = $user; } } return $result; - }else{ - return array(); + } else { + return []; } } @@ -201,18 +201,17 @@ class Dummy extends Backend { * @return int */ public function countUsersInGroup($gid, $search = '', $limit = -1, $offset = 0) { - if(isset($this->groups[$gid])) { - if(empty($search)) { + if (isset($this->groups[$gid])) { + if (empty($search)) { return count($this->groups[$gid]); } $count = 0; - foreach($this->groups[$gid] as $user) { - if(stripos($user, $search) !== false) { + foreach ($this->groups[$gid] as $user) { + if (stripos($user, $search) !== false) { $count++; } } return $count; } } - } diff --git a/tests/lib/Util/User/Dummy.php b/tests/lib/Util/User/Dummy.php index 4771983e9bc..478b7599701 100644 --- a/tests/lib/Util/User/Dummy.php +++ b/tests/lib/Util/User/Dummy.php @@ -33,8 +33,8 @@ use OC\User\Backend; * dummy user backend, does not keep state, only for testing use */ class Dummy extends Backend implements \OCP\IUserBackend { - private $users = array(); - private $displayNames = array(); + private $users = []; + private $displayNames = []; /** * Create a new user @@ -109,7 +109,7 @@ class Dummy extends Backend implements \OCP\IUserBackend { } public function loginName2UserName($loginName) { - if(isset($this->users[strtolower($loginName)])) { + if (isset($this->users[strtolower($loginName)])) { return strtolower($loginName); } return false; @@ -127,7 +127,7 @@ class Dummy extends Backend implements \OCP\IUserBackend { if (empty($search)) { return array_keys($this->users); } - $result = array(); + $result = []; foreach (array_keys($this->users) as $user) { if (stripos($user, $search) !== false) { $result[] = $user; @@ -175,7 +175,7 @@ class Dummy extends Backend implements \OCP\IUserBackend { * Backend name to be shown in user management * @return string the name of the backend to be shown */ - public function getBackendName(){ + public function getBackendName() { return 'Dummy'; } } diff --git a/tests/lib/UtilCheckServerTest.php b/tests/lib/UtilCheckServerTest.php index 3f956601ce4..b5a05535009 100644 --- a/tests/lib/UtilCheckServerTest.php +++ b/tests/lib/UtilCheckServerTest.php @@ -14,7 +14,6 @@ namespace Test; * @group DB */ class UtilCheckServerTest extends \Test\TestCase { - private $datadir; /** @@ -30,9 +29,9 @@ class UtilCheckServerTest extends \Test\TestCase { $config->expects($this->any()) ->method('getValue') - ->will($this->returnCallback(function ($key, $default) use ($systemOptions) { + ->willReturnCallback(function ($key, $default) use ($systemOptions) { return isset($systemOptions[$key]) ? $systemOptions[$key] : $default; - })); + }); return $config; } @@ -55,9 +54,9 @@ class UtilCheckServerTest extends \Test\TestCase { * Test that checkServer() returns no errors in the regular case. */ public function testCheckServer() { - $result = \OC_Util::checkServer($this->getConfig(array( + $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true - ))); + ])); $this->assertEmpty($result); } @@ -72,9 +71,9 @@ class UtilCheckServerTest extends \Test\TestCase { // even though ".ocdata" is missing, the error isn't // triggered to allow setup to run - $result = \OC_Util::checkServer($this->getConfig(array( + $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false - ))); + ])); $this->assertEmpty($result); } @@ -91,14 +90,14 @@ class UtilCheckServerTest extends \Test\TestCase { $oldCurrentVersion = $session->get('OC_Version'); // upgrade condition to simulate needUpgrade() === true - $session->set('OC_Version', array(6, 0, 0, 2)); + $session->set('OC_Version', [6, 0, 0, 2]); // even though ".ocdata" is missing, the error isn't // triggered to allow for upgrade - $result = \OC_Util::checkServer($this->getConfig(array( + $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => '6.0.0.1' - ))); + ])); $this->assertEmpty($result); // restore versions @@ -123,10 +122,10 @@ class UtilCheckServerTest extends \Test\TestCase { $result = \OC_Util::checkDataDirectoryValidity($this->datadir); $this->assertEquals(1, count($result)); - $result = \OC_Util::checkServer($this->getConfig(array( + $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) - ))); + ])); $this->assertCount(1, $result); } @@ -134,10 +133,10 @@ class UtilCheckServerTest extends \Test\TestCase { * Tests that no error is given when the datadir is writable */ public function testDataDirWritable() { - $result = \OC_Util::checkServer($this->getConfig(array( + $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) - ))); + ])); $this->assertEmpty($result); } @@ -148,10 +147,10 @@ class UtilCheckServerTest extends \Test\TestCase { $this->markTestSkipped('TODO: Disable because fails on drone'); chmod($this->datadir, 0300); - $result = \OC_Util::checkServer($this->getConfig(array( + $result = \OC_Util::checkServer($this->getConfig([ 'installed' => true, 'version' => implode('.', \OCP\Util::getVersion()) - ))); + ])); $this->assertCount(1, $result); } @@ -160,10 +159,10 @@ class UtilCheckServerTest extends \Test\TestCase { */ public function testDataDirNotWritableSetup() { chmod($this->datadir, 0300); - $result = \OC_Util::checkServer($this->getConfig(array( + $result = \OC_Util::checkServer($this->getConfig([ 'installed' => false, 'version' => implode('.', \OCP\Util::getVersion()) - ))); + ])); chmod($this->datadir, 0700); //needed for cleanup $this->assertEmpty($result); } diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index a5ddd50ab27..6e25ce16e75 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -38,7 +38,7 @@ class UtilTest extends \Test\TestCase { $this->assertTrue(is_string($edition)); } - function testSanitizeHTML() { + public function testSanitizeHTML() { $badArray = [ 'While it is unusual to pass an array', 'this function actually <blink>supports</blink> it.', @@ -71,7 +71,7 @@ class UtilTest extends \Test\TestCase { $this->assertEquals('This is a good string without HTML.', $result); } - function testEncodePath() { + public function testEncodePath() { $component = '/§#@test%&^ä/-child'; $result = OC_Util::encodePath($component); $this->assertEquals("/%C2%A7%23%40test%25%26%5E%C3%A4/-child", $result); @@ -82,12 +82,12 @@ class UtilTest extends \Test\TestCase { $this->assertEquals($expected, \OC_Util::fileInfoLoaded()); } - function testGetDefaultEmailAddress() { + public function testGetDefaultEmailAddress() { $email = \OCP\Util::getDefaultEmailAddress("no-reply"); $this->assertEquals('no-reply@localhost', $email); } - function testGetDefaultEmailAddressFromConfig() { + public function testGetDefaultEmailAddressFromConfig() { $config = \OC::$server->getConfig(); $config->setSystemValue('mail_domain', 'example.com'); $email = \OCP\Util::getDefaultEmailAddress("no-reply"); @@ -95,7 +95,7 @@ class UtilTest extends \Test\TestCase { $config->deleteSystemValue('mail_domain'); } - function testGetConfiguredEmailAddressFromConfig() { + public function testGetConfiguredEmailAddressFromConfig() { $config = \OC::$server->getConfig(); $config->setSystemValue('mail_domain', 'example.com'); $config->setSystemValue('mail_from_address', 'owncloud'); @@ -105,7 +105,7 @@ class UtilTest extends \Test\TestCase { $config->deleteSystemValue('mail_from_address'); } - function testGetInstanceIdGeneratesValidId() { + public function testGetInstanceIdGeneratesValidId() { \OC::$server->getConfig()->deleteSystemValue('instanceid'); $instanceId = OC_Util::getInstanceId(); $this->assertStringStartsWith('oc', $instanceId); @@ -178,7 +178,7 @@ class UtilTest extends \Test\TestCase { * @param array $excludedGroups groups which should be excluded from sharing * @param bool $expected expected result */ - function testIsSharingDisabledForUser($groups, $membership, $excludedGroups, $expected) { + public function testIsSharingDisabledForUser($groups, $membership, $excludedGroups, $expected) { $config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock(); $groupManager = $this->getMockBuilder('OCP\IGroupManager')->disableOriginalConstructor()->getMock(); $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); @@ -187,18 +187,18 @@ class UtilTest extends \Test\TestCase { ->expects($this->at(0)) ->method('getAppValue') ->with('core', 'shareapi_exclude_groups', 'no') - ->will($this->returnValue('yes')); + ->willReturn('yes'); $config ->expects($this->at(1)) ->method('getAppValue') ->with('core', 'shareapi_exclude_groups_list') - ->will($this->returnValue(json_encode($excludedGroups))); + ->willReturn(json_encode($excludedGroups)); $groupManager ->expects($this->at(0)) ->method('getUserGroupIds') ->with($user) - ->will($this->returnValue($membership)); + ->willReturn($membership); $result = \OC_Util::isSharingDisabledForUser($config, $groupManager, $user); @@ -206,16 +206,16 @@ class UtilTest extends \Test\TestCase { } public function dataProviderForTestIsSharingDisabledForUser() { - return array( + return [ // existing groups, groups the user belong to, groups excluded from sharing, expected result - array(array('g1', 'g2', 'g3'), array(), array('g1'), false), - array(array('g1', 'g2', 'g3'), array(), array(), false), - array(array('g1', 'g2', 'g3'), array('g2'), array('g1'), false), - array(array('g1', 'g2', 'g3'), array('g2'), array(), false), - array(array('g1', 'g2', 'g3'), array('g1', 'g2'), array('g1'), false), - array(array('g1', 'g2', 'g3'), array('g1', 'g2'), array('g1', 'g2'), true), - array(array('g1', 'g2', 'g3'), array('g1', 'g2'), array('g1', 'g2', 'g3'), true), - ); + [['g1', 'g2', 'g3'], [], ['g1'], false], + [['g1', 'g2', 'g3'], [], [], false], + [['g1', 'g2', 'g3'], ['g2'], ['g1'], false], + [['g1', 'g2', 'g3'], ['g2'], [], false], + [['g1', 'g2', 'g3'], ['g1', 'g2'], ['g1'], false], + [['g1', 'g2', 'g3'], ['g1', 'g2'], ['g1', 'g2'], true], + [['g1', 'g2', 'g3'], ['g1', 'g2'], ['g1', 'g2', 'g3'], true], + ]; } /** @@ -224,7 +224,7 @@ class UtilTest extends \Test\TestCase { * @dataProvider defaultAppsProvider * @group DB */ - function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps) { + public function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps) { $oldDefaultApps = \OC::$server->getConfig()->getSystemValue('defaultapp', ''); // CLI is doing messy stuff with the webroot, so need to work it around $oldWebRoot = \OC::$WEBROOT; @@ -233,9 +233,9 @@ class UtilTest extends \Test\TestCase { $appManager = $this->createMock(IAppManager::class); $appManager->expects($this->any()) ->method('isEnabledForUser') - ->will($this->returnCallback(function($appId) use ($enabledApps){ + ->willReturnCallback(function ($appId) use ($enabledApps) { return in_array($appId, $enabledApps); - })); + }); Dummy_OC_Util::$appManager = $appManager; // need to set a user id to make sure enabled apps are read from cache @@ -249,33 +249,33 @@ class UtilTest extends \Test\TestCase { \OC_User::setUserId(null); } - function defaultAppsProvider() { - return array( + public function defaultAppsProvider() { + return [ // none specified, default to files - array( + [ '', 'index.php/apps/files/', - array('files'), - ), + ['files'], + ], // unexisting or inaccessible app specified, default to files - array( + [ 'unexist', 'index.php/apps/files/', - array('files'), - ), + ['files'], + ], // non-standard app - array( + [ 'calendar', 'index.php/apps/calendar/', - array('files', 'calendar'), - ), + ['files', 'calendar'], + ], // non-standard app with fallback - array( + [ 'contacts,calendar', 'index.php/apps/calendar/', - array('files', 'calendar'), - ), - ); + ['files', 'calendar'], + ], + ]; } public function testGetDefaultPageUrlWithRedirectUrlWithoutFrontController() { @@ -319,14 +319,14 @@ class UtilTest extends \Test\TestCase { $this->assertFalse(\OCP\Util::needUpgrade()); $config->setSystemValue('version', '7.0.0.0'); - \OC::$server->getSession()->set('OC_Version', array(7, 0, 0, 1)); - self::invokePrivate(new \OCP\Util, 'needUpgradeCache', array(null)); + \OC::$server->getSession()->set('OC_Version', [7, 0, 0, 1]); + self::invokePrivate(new \OCP\Util, 'needUpgradeCache', [null]); $this->assertTrue(\OCP\Util::needUpgrade()); $config->setSystemValue('version', $oldConfigVersion); \OC::$server->getSession()->set('OC_Version', $oldSessionVersion); - self::invokePrivate(new \OCP\Util, 'needUpgradeCache', array(null)); + self::invokePrivate(new \OCP\Util, 'needUpgradeCache', [null]); $this->assertFalse(\OCP\Util::needUpgrade()); } |