From 9a4253ef7c34f9dc71a6a9f7828a10df769f0c32 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 19 May 2016 09:38:52 +0200 Subject: [PATCH] Fix lib/ --- .../{httphelper.php => HTTPHelperTest.php} | 4 ++- ...elperstorage.php => HelperStorageTest.php} | 4 ++- tests/lib/{image.php => ImageTest.php} | 6 +++- .../lib/{helper.php => LegacyHelperTest.php} | 6 +++- .../{naturalsort.php => NaturalSortTest.php} | 4 ++- .../{RepairTest.php => RepairStepTest.php} | 2 +- tests/lib/{setup.php => SetupTest.php} | 18 +++++----- ...eamwrappers.php => StreamWrappersTest.php} | 6 ++-- tests/lib/{tags.php => TagsTest.php} | 36 ++++++++++--------- ...template.php => TemplateFunctionsTest.php} | 8 +++-- tests/lib/{updater.php => UpdaterTest.php} | 3 +- ...{urlGenerator.php => UrlGeneratorTest.php} | 6 ++-- ...heckserver.php => UtilCheckServerTest.php} | 6 ++-- tests/lib/{util.php => UtilTest.php} | 12 ++++--- .../{group.php => group/LegacyGroupTest.php} | 7 +++- tests/lib/ocsclienttest.php | 2 ++ 16 files changed, 84 insertions(+), 46 deletions(-) rename tests/lib/{httphelper.php => HTTPHelperTest.php} (97%) rename tests/lib/{helperstorage.php => HelperStorageTest.php} (99%) rename tests/lib/{image.php => ImageTest.php} (99%) rename tests/lib/{helper.php => LegacyHelperTest.php} (99%) rename tests/lib/{naturalsort.php => NaturalSortTest.php} (98%) rename tests/lib/{RepairTest.php => RepairStepTest.php} (98%) rename tests/lib/{setup.php => SetupTest.php} (86%) rename tests/lib/{streamwrappers.php => StreamWrappersTest.php} (97%) rename tests/lib/{tags.php => TagsTest.php} (90%) rename tests/lib/{template.php => TemplateFunctionsTest.php} (98%) rename tests/lib/{updater.php => UpdaterTest.php} (99%) rename tests/lib/{urlGenerator.php => UrlGeneratorTest.php} (97%) rename tests/lib/{utilcheckserver.php => UtilCheckServerTest.php} (97%) rename tests/lib/{util.php => UtilTest.php} (98%) rename tests/lib/{group.php => group/LegacyGroupTest.php} (98%) diff --git a/tests/lib/httphelper.php b/tests/lib/HTTPHelperTest.php similarity index 97% rename from tests/lib/httphelper.php rename to tests/lib/HTTPHelperTest.php index 1d0981ba51b..6d9c4788735 100644 --- a/tests/lib/httphelper.php +++ b/tests/lib/HTTPHelperTest.php @@ -6,7 +6,9 @@ * See the COPYING-README file. */ -class TestHTTPHelper extends \Test\TestCase { +namespace Test; + +class HTTPHelperTest extends \Test\TestCase { /** @var \OCP\IConfig*/ private $config; diff --git a/tests/lib/helperstorage.php b/tests/lib/HelperStorageTest.php similarity index 99% rename from tests/lib/helperstorage.php rename to tests/lib/HelperStorageTest.php index 3109b509549..e841dbfce18 100644 --- a/tests/lib/helperstorage.php +++ b/tests/lib/HelperStorageTest.php @@ -6,12 +6,14 @@ * See the COPYING-README file. */ +namespace Test; + /** * Test the storage functions of OC_Helper * * @group DB */ -class Test_Helper_Storage extends \Test\TestCase { +class HelperStorageTest extends \Test\TestCase { /** @var string */ private $user; /** @var \OC\Files\Storage\Storage */ diff --git a/tests/lib/image.php b/tests/lib/ImageTest.php similarity index 99% rename from tests/lib/image.php rename to tests/lib/ImageTest.php index e74c75b48cf..9dba7e3739b 100644 --- a/tests/lib/image.php +++ b/tests/lib/ImageTest.php @@ -6,7 +6,11 @@ * See the COPYING-README file. */ -class Test_Image extends \Test\TestCase { +namespace Test; + +use OC; + +class ImageTest extends \Test\TestCase { public static function tearDownAfterClass() { @unlink(OC::$SERVERROOT.'/tests/data/testimage2.png'); @unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg'); diff --git a/tests/lib/helper.php b/tests/lib/LegacyHelperTest.php similarity index 99% rename from tests/lib/helper.php rename to tests/lib/LegacyHelperTest.php index 89a981e6e23..d8b1a82c271 100644 --- a/tests/lib/helper.php +++ b/tests/lib/LegacyHelperTest.php @@ -6,7 +6,11 @@ * See the COPYING-README file. */ -class Test_Helper extends \Test\TestCase { +namespace Test; + +use OC_Helper; + +class LegacyHelperTest extends \Test\TestCase { /** * @dataProvider humanFileSizeProvider diff --git a/tests/lib/naturalsort.php b/tests/lib/NaturalSortTest.php similarity index 98% rename from tests/lib/naturalsort.php rename to tests/lib/NaturalSortTest.php index 8fcbc6f5fd3..50c2d0be9f0 100644 --- a/tests/lib/naturalsort.php +++ b/tests/lib/NaturalSortTest.php @@ -6,7 +6,9 @@ * See the COPYING-README file. */ -class Test_NaturalSort extends \Test\TestCase { +namespace Test; + +class NaturalSortTest extends \Test\TestCase { /** * @dataProvider naturalSortDataProvider diff --git a/tests/lib/RepairTest.php b/tests/lib/RepairStepTest.php similarity index 98% rename from tests/lib/RepairTest.php rename to tests/lib/RepairStepTest.php index 9ae1318eb32..3f7a0ce064b 100644 --- a/tests/lib/RepairTest.php +++ b/tests/lib/RepairStepTest.php @@ -11,7 +11,7 @@ namespace Test; use OCP\Migration\IRepairStep; use Symfony\Component\EventDispatcher\EventDispatcher; -class TestRepairStep implements IRepairStep { +class RepairStepTest implements IRepairStep { private $warning; public function __construct($warning = false) { diff --git a/tests/lib/setup.php b/tests/lib/SetupTest.php similarity index 86% rename from tests/lib/setup.php rename to tests/lib/SetupTest.php index bc78c14008f..e2723efd76a 100644 --- a/tests/lib/setup.php +++ b/tests/lib/SetupTest.php @@ -6,23 +6,25 @@ * See the COPYING-README file. */ +namespace Test; + use OCP\IConfig; -class Test_OC_Setup extends \Test\TestCase { +class SetupTest extends \Test\TestCase { - /** @var IConfig | PHPUnit_Framework_MockObject_MockObject */ + /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */ protected $config; - /** @var \bantu\IniGetWrapper\IniGetWrapper | PHPUnit_Framework_MockObject_MockObject */ + /** @var \bantu\IniGetWrapper\IniGetWrapper | \PHPUnit_Framework_MockObject_MockObject */ private $iniWrapper; - /** @var \OCP\IL10N | PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject */ private $l10n; - /** @var \OC_Defaults | PHPUnit_Framework_MockObject_MockObject */ + /** @var \OC_Defaults | \PHPUnit_Framework_MockObject_MockObject */ private $defaults; - /** @var \OC\Setup | PHPUnit_Framework_MockObject_MockObject */ + /** @var \OC\Setup | \PHPUnit_Framework_MockObject_MockObject */ protected $setupClass; - /** @var \OCP\ILogger | PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\ILogger | \PHPUnit_Framework_MockObject_MockObject */ protected $logger; - /** @var \OCP\Security\ISecureRandom | PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\Security\ISecureRandom | \PHPUnit_Framework_MockObject_MockObject */ protected $random; protected function setUp() { diff --git a/tests/lib/streamwrappers.php b/tests/lib/StreamWrappersTest.php similarity index 97% rename from tests/lib/streamwrappers.php rename to tests/lib/StreamWrappersTest.php index 7175683a60b..14bcbb847d9 100644 --- a/tests/lib/streamwrappers.php +++ b/tests/lib/StreamWrappersTest.php @@ -20,12 +20,14 @@ * */ +namespace Test; + /** - * Class Test_StreamWrappers + * Class StreamWrappersTest * * @group DB */ -class Test_StreamWrappers extends \Test\TestCase { +class StreamWrappersTest extends \Test\TestCase { private static $trashBinStatus; diff --git a/tests/lib/tags.php b/tests/lib/TagsTest.php similarity index 90% rename from tests/lib/tags.php rename to tests/lib/TagsTest.php index 91472d5ceb8..88e0f87ad8f 100644 --- a/tests/lib/tags.php +++ b/tests/lib/TagsTest.php @@ -20,12 +20,14 @@ * */ +namespace Test; + /** - * Class Test_Tags + * Class TagsTest * * @group DB */ -class Test_Tags extends \Test\TestCase { +class TagsTest extends \Test\TestCase { protected $objectType; /** @var \OCP\IUser */ @@ -41,12 +43,12 @@ class Test_Tags extends \Test\TestCase { protected function setUp() { parent::setUp(); - OC_User::clearBackends(); - OC_User::useBackend('dummy'); + \OC_User::clearBackends(); + \OC_User::useBackend('dummy'); $userId = $this->getUniqueID('user_'); \OC::$server->getUserManager()->createUser($userId, 'pass'); - OC_User::setUserId($userId); - $this->user = new OC\User\User($userId, null); + \OC_User::setUserId($userId); + $this->user = new \OC\User\User($userId, null); $this->userSession = $this->getMock('\OCP\IUserSession'); $this->userSession ->expects($this->any()) @@ -54,8 +56,8 @@ class Test_Tags extends \Test\TestCase { ->will($this->returnValue($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); + $this->tagMapper = new \OC\Tagging\TagMapper(\OC::$server->getDatabaseConnection()); + $this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession); } @@ -73,7 +75,7 @@ class Test_Tags extends \Test\TestCase { ->expects($this->any()) ->method('getUser') ->will($this->returnValue(null)); - $this->tagMgr = new OC\TagManager($this->tagMapper, $this->userSession); + $this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession); $this->assertNull($this->tagMgr->load($this->objectType)); } @@ -236,7 +238,7 @@ class Test_Tags extends \Test\TestCase { $this->assertTrue($tagger->rename('Wrok', 'Work')); $this->assertTrue($tagger->hasTag('Work')); - $this->assertFalse($tagger->hastag('Wrok')); + $this->assertFalse($tagger->hasTag('Wrok')); $this->assertFalse($tagger->rename('Wrok', 'Work')); // Rename non-existant tag. $this->assertFalse($tagger->rename('Work', 'Family')); // Collide with existing tag. } @@ -284,28 +286,28 @@ class Test_Tags extends \Test\TestCase { public function testShareTags() { $testTag = 'TestTag'; - OCP\Share::registerBackend('test', 'Test_Share_Backend'); + \OCP\Share::registerBackend('test', 'Test_Share_Backend'); $tagger = $this->tagMgr->load('test'); $tagger->tagAs(1, $testTag); $otherUserId = $this->getUniqueID('user2_'); \OC::$server->getUserManager()->createUser($otherUserId, 'pass'); - OC_User::setUserId($otherUserId); + \OC_User::setUserId($otherUserId); $otherUserSession = $this->getMock('\OCP\IUserSession'); $otherUserSession ->expects($this->any()) ->method('getUser') - ->will($this->returnValue(new OC\User\User($otherUserId, null))); + ->will($this->returnValue(new \OC\User\User($otherUserId, null))); - $otherTagMgr = new OC\TagManager($this->tagMapper, $otherUserSession); + $otherTagMgr = new \OC\TagManager($this->tagMapper, $otherUserSession); $otherTagger = $otherTagMgr->load('test'); $this->assertFalse($otherTagger->hasTag($testTag)); - OC_User::setUserId($this->user->getUID()); - OCP\Share::shareItem('test', 1, OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); + \OC_User::setUserId($this->user->getUID()); + \OCP\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ); - OC_User::setUserId($otherUserId); + \OC_User::setUserId($otherUserId); $otherTagger = $otherTagMgr->load('test', array(), true); // Update tags, load shared ones. $this->assertTrue($otherTagger->hasTag($testTag)); $this->assertContains(1, $otherTagger->getIdsForTag($testTag)); diff --git a/tests/lib/template.php b/tests/lib/TemplateFunctionsTest.php similarity index 98% rename from tests/lib/template.php rename to tests/lib/TemplateFunctionsTest.php index 6e62d3955f1..aa3c73d4743 100644 --- a/tests/lib/template.php +++ b/tests/lib/TemplateFunctionsTest.php @@ -1,5 +1,4 @@ . * */ -class Test_TemplateFunctions extends \Test\TestCase { + +namespace Test; + +class TemplateFunctionsTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $loader = new \OC\Autoloader([OC::$SERVERROOT . '/lib']); + $loader = new \OC\Autoloader([\OC::$SERVERROOT . '/lib']); $loader->load('OC_Template'); } diff --git a/tests/lib/updater.php b/tests/lib/UpdaterTest.php similarity index 99% rename from tests/lib/updater.php rename to tests/lib/UpdaterTest.php index f97eb3ac139..643a18cc714 100644 --- a/tests/lib/updater.php +++ b/tests/lib/UpdaterTest.php @@ -20,8 +20,9 @@ * */ -namespace OC; +namespace Test; +use OC\Updater; use OCP\IConfig; use OCP\ILogger; use OC\IntegrityCheck\Checker; diff --git a/tests/lib/urlGenerator.php b/tests/lib/UrlGeneratorTest.php similarity index 97% rename from tests/lib/urlGenerator.php rename to tests/lib/UrlGeneratorTest.php index 07103225baa..7186c8fad80 100644 --- a/tests/lib/urlGenerator.php +++ b/tests/lib/UrlGeneratorTest.php @@ -6,12 +6,14 @@ * See the COPYING-README file. */ +namespace Test; + /** - * Class Test_UrlGenerator + * Class UrlGeneratorTest * * @group DB */ -class Test_UrlGenerator extends \Test\TestCase { +class UrlGeneratorTest extends \Test\TestCase { /** * @small diff --git a/tests/lib/utilcheckserver.php b/tests/lib/UtilCheckServerTest.php similarity index 97% rename from tests/lib/utilcheckserver.php rename to tests/lib/UtilCheckServerTest.php index 94e7fd2f779..b864af6888a 100644 --- a/tests/lib/utilcheckserver.php +++ b/tests/lib/UtilCheckServerTest.php @@ -6,18 +6,20 @@ * See the COPYING-README file. */ +namespace Test; + /** * Tests for server check functions * * @group DB */ -class Test_Util_CheckServer extends \Test\TestCase { +class UtilCheckServerTest extends \Test\TestCase { private $datadir; /** * @param array $systemOptions - * @return \OCP\IConfig | PHPUnit_Framework_MockObject_MockObject + * @return \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject */ protected function getConfig($systemOptions) { $systemOptions['datadirectory'] = $this->datadir; diff --git a/tests/lib/util.php b/tests/lib/UtilTest.php similarity index 98% rename from tests/lib/util.php rename to tests/lib/UtilTest.php index 4d788353881..7da7db0291c 100644 --- a/tests/lib/util.php +++ b/tests/lib/UtilTest.php @@ -1,12 +1,16 @@ * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ -class Test_Util extends \Test\TestCase { + +namespace Test; + +use OC_Util; + +class UtilTest extends \Test\TestCase { public function testGetVersion() { $version = \OCP\Util::getVersion(); $this->assertTrue(is_array($version)); @@ -46,7 +50,7 @@ class Test_Util extends \Test\TestCase { } /** - * @expectedException Exception + * @expectedException \Exception */ function testFormatDateWithInvalidTZ() { OC_Util::formatDate(1350129205, false, 'Mordor/Barad-dûr'); @@ -283,7 +287,7 @@ class Test_Util extends \Test\TestCase { * @dataProvider defaultAppsProvider */ function testDefaultApps($defaultAppConfig, $expectedPath, $enabledApps) { - $oldDefaultApps = \OCP\Config::getSystemValue('core', 'defaultapp', ''); + $oldDefaultApps = \OCP\Config::getSystemValue('defaultapp', ''); // CLI is doing messy stuff with the webroot, so need to work it around $oldWebRoot = \OC::$WEBROOT; \OC::$WEBROOT = ''; diff --git a/tests/lib/group.php b/tests/lib/group/LegacyGroupTest.php similarity index 98% rename from tests/lib/group.php rename to tests/lib/group/LegacyGroupTest.php index d3ac6d8d69e..12bcfdddf15 100644 --- a/tests/lib/group.php +++ b/tests/lib/group/LegacyGroupTest.php @@ -22,7 +22,12 @@ * */ -class Test_Group extends \Test\TestCase { +namespace Test\Group; + +use OC_Group; +use OC_User; + +class LegacyGroupTest extends \Test\TestCase { protected function setUp() { parent::setUp(); OC_Group::clearBackends(); diff --git a/tests/lib/ocsclienttest.php b/tests/lib/ocsclienttest.php index 7555562d124..4ae6fb62e0e 100644 --- a/tests/lib/ocsclienttest.php +++ b/tests/lib/ocsclienttest.php @@ -19,6 +19,8 @@ * */ +namespace Test; + use OC\OCSClient; use OCP\Http\Client\IClientService; use OCP\IConfig;