From 458c2fa2971e6595a18a289b0afeb4a79ea0e0d3 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 12 May 2022 17:08:54 +0200 Subject: Remove OCP\App and OCP\BackgroundJob Both deprecated since NC 23 IAppManager is the replacement for OCP\App unfortunately it can't be dependency injected in classes used by the installed otherwise the database connection is initialised too early Signed-off-by: Carl Schwan --- tests/lib/Encryption/UtilTest.php | 29 ++++++++++------------------- tests/lib/UrlGeneratorTest.php | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php index 02155be11dd..248377fc698 100644 --- a/tests/lib/Encryption/UtilTest.php +++ b/tests/lib/Encryption/UtilTest.php @@ -8,6 +8,8 @@ use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\Service\GlobalStoragesService; use OCP\Encryption\IEncryptionModule; use OCP\IConfig; +use OCP\IGroupManager; +use OCP\IUserManager; use Test\TestCase; class UtilTest extends TestCase { @@ -15,24 +17,21 @@ class UtilTest extends TestCase { /** * block size will always be 8192 for a PHP stream * @see https://bugs.php.net/bug.php?id=21641 - * @var integer */ - protected $headerSize = 8192; + protected int $headerSize = 8192; /** @var \PHPUnit\Framework\MockObject\MockObject */ protected $view; - /** @var \PHPUnit\Framework\MockObject\MockObject */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IUserManager */ protected $userManager; - /** @var \PHPUnit\Framework\MockObject\MockObject */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IGroupManager */ protected $groupManager; - /** @var \PHPUnit\Framework\MockObject\MockObject */ + /** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */ private $config; - - /** @var \OC\Encryption\Util */ - private $util; + private Util $util; protected function setUp(): void { parent::setUp(); @@ -40,17 +39,9 @@ class UtilTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('OC\User\Manager') - ->disableOriginalConstructor() - ->getMock(); - - $this->groupManager = $this->getMockBuilder('OC\Group\Manager') - ->disableOriginalConstructor() - ->getMock(); - - $this->config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); + $this->userManager = $this->createMock(IUserManager::class); + $this->groupManager = $this->createMock(IGroupManager::class); + $this->config = $this->createMock(IConfig::class); $this->util = new Util( $this->view, diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php index 9e5795fc41e..7fdbb7fb37e 100644 --- a/tests/lib/UrlGeneratorTest.php +++ b/tests/lib/UrlGeneratorTest.php @@ -297,7 +297,7 @@ class UrlGeneratorTest extends \Test\TestCase { $this->assertEquals('http://localhost' . \OC::$WEBROOT . $expectedPath, $this->urlGenerator->linkToDefaultPageUrl()); } - public function provideDefaultApps() { + public function provideDefaultApps(): array { return [ // none specified, default to files [ @@ -321,4 +321,18 @@ class UrlGeneratorTest extends \Test\TestCase { ], ]; } + + public function imagePathProvider(): array { + return [ + ['core', 'favicon-mask.svg', \OC::$WEBROOT . '/core/img/favicon-mask.svg'], + ['files', 'external.svg', \OC::$WEBROOT . '/apps/files/img/external.svg'], + ]; + } + + /** + * @dataProvider imagePathProvider + */ + public function testImagePath(string $appName, string $file, string $result): void { + $this->assertSame($result, $this->urlGenerator->imagePath($appName, $file)); + } } -- cgit v1.2.3