From 3a7cf40aaa678bea1df143d2982d603b7a334eec Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 27 Nov 2019 15:27:18 +0100 Subject: Mode to modern phpunit Signed-off-by: Roeland Jago Douma --- tests/lib/App/AppManagerTest.php | 5 +++-- tests/lib/App/AppStore/Bundles/BundleBase.php | 2 +- tests/lib/App/AppStore/Bundles/BundleFetcherTest.php | 10 +++++----- tests/lib/App/AppStore/Bundles/CoreBundleTest.php | 2 +- tests/lib/App/AppStore/Bundles/EducationBundleTest.php | 2 +- .../lib/App/AppStore/Bundles/EnterpriseBundleTest.php | 2 +- tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php | 2 +- .../App/AppStore/Bundles/SocialSharingBundleTest.php | 2 +- tests/lib/App/AppStore/Fetcher/AppFetcherTest.php | 2 +- tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php | 2 +- tests/lib/App/AppStore/Fetcher/FetcherBase.php | 2 +- tests/lib/App/AppStore/Version/VersionParserTest.php | 18 +++++++++--------- tests/lib/App/DependencyAnalyzerTest.php | 2 +- 13 files changed, 27 insertions(+), 26 deletions(-) (limited to 'tests/lib/App') diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index 0dc93174a67..b3437ad290c 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -248,10 +248,11 @@ class AppManagerTest extends TestCase { * * @param string $type * - * @expectedException \Exception - * @expectedExceptionMessage test can't be enabled for groups. */ public function testEnableAppForGroupsForbiddenTypes($type) { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('test can\'t be enabled for groups.'); + $group1 = $this->createMock(IGroup::class); $group1->method('getGID') ->willReturn('group1'); diff --git a/tests/lib/App/AppStore/Bundles/BundleBase.php b/tests/lib/App/AppStore/Bundles/BundleBase.php index 6b03940c9a9..2c566b0ea0a 100644 --- a/tests/lib/App/AppStore/Bundles/BundleBase.php +++ b/tests/lib/App/AppStore/Bundles/BundleBase.php @@ -37,7 +37,7 @@ abstract class BundleBase extends TestCase { /** @var array */ protected $bundleAppIds; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->l10n = $this->createMock(IL10N::class); $this->l10n->method('t') diff --git a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php index 27384953d3f..f453fbcb59a 100644 --- a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php +++ b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php @@ -36,7 +36,7 @@ class BundleFetcherTest extends TestCase { /** @var BundleFetcher */ private $bundleFetcher; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->l10n = $this->createMock(IL10N::class); @@ -69,11 +69,11 @@ class BundleFetcherTest extends TestCase { $this->assertEquals(new GroupwareBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('GroupwareBundle')); } - /** - * @expectedException \BadMethodCallException - * @expectedExceptionMessage Bundle with specified identifier does not exist - */ + public function testGetBundleByIdentifierWithException() { + $this->expectException(\BadMethodCallException::class); + $this->expectExceptionMessage('Bundle with specified identifier does not exist'); + $this->bundleFetcher->getBundleByIdentifier('NotExistingBundle'); } diff --git a/tests/lib/App/AppStore/Bundles/CoreBundleTest.php b/tests/lib/App/AppStore/Bundles/CoreBundleTest.php index 01a449c8093..2ace537b938 100644 --- a/tests/lib/App/AppStore/Bundles/CoreBundleTest.php +++ b/tests/lib/App/AppStore/Bundles/CoreBundleTest.php @@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles; use OC\App\AppStore\Bundles\CoreBundle; class CoreBundleTest extends BundleBase { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->bundle = new CoreBundle($this->l10n); $this->bundleIdentifier = 'CoreBundle'; diff --git a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php index e3da7f1f660..1c5d2a480e9 100644 --- a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php +++ b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php @@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles; use OC\App\AppStore\Bundles\EducationBundle; class EducationBundleTest extends BundleBase { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->bundle = new EducationBundle($this->l10n); $this->bundleIdentifier = 'EducationBundle'; diff --git a/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php index 717c6151ed4..d24e8846f56 100644 --- a/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php +++ b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php @@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles; use OC\App\AppStore\Bundles\EnterpriseBundle; class EnterpriseBundleTest extends BundleBase { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->bundle = new EnterpriseBundle($this->l10n); $this->bundleIdentifier = 'EnterpriseBundle'; diff --git a/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php index 547e6e84ec8..88391a6382f 100644 --- a/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php +++ b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php @@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles; use OC\App\AppStore\Bundles\GroupwareBundle; class GroupwareBundleTest extends BundleBase { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->bundle = new GroupwareBundle($this->l10n); $this->bundleIdentifier = 'GroupwareBundle'; diff --git a/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php index 7f0e0f49302..17b2974b7c7 100644 --- a/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php +++ b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php @@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles; use OC\App\AppStore\Bundles\SocialSharingBundle; class SocialSharingBundleTest extends BundleBase { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->bundle = new SocialSharingBundle($this->l10n); $this->bundleIdentifier = 'SocialSharingBundle'; diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php index cf19b5aa355..9a118234049 100644 --- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php @@ -59,7 +59,7 @@ class AppFetcherTest extends TestCase { EOD; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); /** @var Factory|PHPUnit_Framework_MockObject_MockObject $factory */ diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php index 753a1bf88d3..8a82322b61c 100644 --- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php @@ -24,7 +24,7 @@ namespace Test\App\AppStore\Fetcher; use OC\App\AppStore\Fetcher\CategoryFetcher; class CategoryFetcherTest extends FetcherBase { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->fileName = 'categories.json'; $this->endpoint = 'https://apps.nextcloud.com/api/v1/categories.json'; diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index 4f614d33101..84584e5432f 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -56,7 +56,7 @@ abstract class FetcherBase extends TestCase { /** @var string */ protected $endpoint; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->appDataFactory = $this->createMock(Factory::class); $this->appData = $this->createMock(AppData::class); diff --git a/tests/lib/App/AppStore/Version/VersionParserTest.php b/tests/lib/App/AppStore/Version/VersionParserTest.php index ea30f40d821..327c8cac779 100644 --- a/tests/lib/App/AppStore/Version/VersionParserTest.php +++ b/tests/lib/App/AppStore/Version/VersionParserTest.php @@ -29,7 +29,7 @@ class VersionParserTest extends TestCase { /** @var VersionParser */ private $versionParser; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->versionParser = new VersionParser(); } @@ -81,19 +81,19 @@ class VersionParserTest extends TestCase { $this->assertEquals($expected, $this->versionParser->getVersion($input)); } - /** - * @expectedException \Exception - * @expectedExceptionMessage Version cannot be parsed: BogusVersion - */ + public function testGetVersionException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Version cannot be parsed: BogusVersion'); + $this->versionParser->getVersion('BogusVersion'); } - /** - * @expectedException \Exception - * @expectedExceptionMessage Version cannot be parsed: >=8.2 <=9.1a - */ + public function testGetVersionExceptionWithMultiple() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Version cannot be parsed: >=8.2 <=9.1a'); + $this->versionParser->getVersion('>=8.2 <=9.1a'); } } diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php index d6848971a84..943b53eee64 100644 --- a/tests/lib/App/DependencyAnalyzerTest.php +++ b/tests/lib/App/DependencyAnalyzerTest.php @@ -26,7 +26,7 @@ class DependencyAnalyzerTest extends TestCase { /** @var DependencyAnalyzer */ private $analyser; - public function setUp(): void { + protected function setUp(): void { $this->platformMock = $this->getMockBuilder(Platform::class) ->disableOriginalConstructor() ->getMock(); -- cgit v1.2.3