diff --git a/tests/Api/Controller/FileControllerTest.php b/tests/Api/Controller/FileControllerTest.php index e4986e991d..f33dd7e4f7 100644 --- a/tests/Api/Controller/FileControllerTest.php +++ b/tests/Api/Controller/FileControllerTest.php @@ -16,7 +16,7 @@ final class FileControllerTest extends ApiTestCase { * @runInSeparateProcess */ public function testValidateUsignUuidWithInvalidData() { - $this->mockAppConfig([]); + $this->getMockAppConfig([]); $this->request ->withPath('/api/v1/file/validate/uuid/invalid') diff --git a/tests/Unit/Handler/FooterHandlerTest.php b/tests/Unit/Handler/FooterHandlerTest.php index e02d988e1c..cd73261e82 100644 --- a/tests/Unit/Handler/FooterHandlerTest.php +++ b/tests/Unit/Handler/FooterHandlerTest.php @@ -12,7 +12,7 @@ use PHPUnit\Framework\MockObject\MockObject; final class FooterHandlerTest extends \OCA\Libresign\Tests\Unit\TestCase { - private IAppConfig|MockObject $appConfig; + private IAppConfig $appConfig; private PdfParserService|MockObject $pdfParserService; private IURLGenerator|MockObject $urlGenerator; private IL10N|MockObject $l10n; diff --git a/tests/Unit/Service/Install/SignSetupServiceTest.php b/tests/Unit/Service/Install/SignSetupServiceTest.php index 64e53218d6..796d64b45b 100644 --- a/tests/Unit/Service/Install/SignSetupServiceTest.php +++ b/tests/Unit/Service/Install/SignSetupServiceTest.php @@ -26,8 +26,9 @@ final class SignSetupServiceTest extends \OCA\Libresign\Tests\Unit\TestCase { private EnvironmentHelper|MockObject $environmentHelper; private FileAccessHelper $fileAccessHelper; private IConfig|MockObject $config; - private IAppConfig|MockObject $appConfig; + private IAppConfig $appConfig; private IAppManager|MockObject $appManager; + private IAppDataFactory $appDataFactory; public function setUp(): void { $this->environmentHelper = $this->createMock(EnvironmentHelper::class); @@ -200,9 +201,7 @@ public function testVerify(): void { $this->assertJsonStringEqualsJsonString($expected, $actual); } - /** - * @dataProvider dataGetInstallPath - */ + #[DataProvider('dataGetInstallPath')] public function testGetInstallPath(string $architecture, string $resource, string $distro, string $expected): void { $this->appConfig->setValueString(Application::APP_ID, 'java_path', 'vfs://home/data/appdata_1/libresign/x86_64/linux/java/jdk-21.0.2+13-jre/bin/java'); $this->appConfig->setValueString(Application::APP_ID, 'jsignpdf_jar_path', 'vfs://home/data/appdata_1/libresign/x86_64/jsignpdf/jsignpdf-2.2.2/JSignPdf.jar'); diff --git a/tests/Unit/TestCase.php b/tests/Unit/TestCase.php index e88c856ae9..336b4c07cf 100644 --- a/tests/Unit/TestCase.php +++ b/tests/Unit/TestCase.php @@ -23,11 +23,11 @@ class TestCase extends \Test\TestCase { private signRequestMapper $signRequestMapper; private array $users = []; - public function mockAppConfig($config) { + public function getMockAppConfig(): IAppConfig { \OC::$server->registerParameter('appName', 'libresign'); $service = \OCP\Server::get(\OCP\IAppConfig::class); if (!$service instanceof AppConfigOverwrite) { - \OC::$server->registerService(\OCP\IAppConfig::class, function () { + \OC::$server->registerService(\OCP\IAppConfig::class, function ():AppConfigOverwrite { return new AppConfigOverwrite( \OCP\Server::get(\OCP\IDBConnection::class), \OCP\Server::get(\Psr\Log\LoggerInterface::class), @@ -39,10 +39,10 @@ public function mockAppConfig($config) { return $service; } - public function mockConfig($config) { - $service = \OC::$server->get(\OCP\IConfig::class); + public function mockConfig($config):void { + $service = \OCP\Server::get(\OCP\IConfig::class); if (!$service instanceof AllConfigOverwrite) { - \OC::$server->registerService(\OCP\IConfig::class, function () { + \OC::$server->registerService(\OCP\IConfig::class, function ():AllConfigOverwrite { $configOverwrite = new ConfigOverwrite(\OC::$configDir); $systemConfig = new SystemConfig($configOverwrite); return new AllConfigOverwrite($systemConfig); @@ -71,7 +71,7 @@ public function haveDependents(): bool { if (!$docblock) { return false; } - if (preg_match('#@depends ' . $this->getName(false) . '\n#s', $docblock)) { + if (preg_match('#@depends ' . $this->name() . '\n#s', $docblock)) { return true; } } @@ -80,7 +80,7 @@ public function haveDependents(): bool { public function iDependOnOthers(): bool { $reflector = new \ReflectionClass(\get_class($this)); - $docblock = $reflector->getMethod($this->getName(false))->getDocComment(); + $docblock = $reflector->getMethod($this->name())->getDocComment(); if (!$docblock) { return false; } @@ -137,12 +137,8 @@ private function cleanDatabase(): void { /** * Create user - * - * @param string $username - * @param string $password - * @return \OC\User\User */ - public function createAccount($username, $password, $groupName = 'testGroup') { + public function createAccount(string $username, string $password, string $groupName = 'testGroup'):\OC\User\User { $this->users[] = $username; $this->mockConfig([ 'core' => [ @@ -172,7 +168,7 @@ public function markUserExists($username): void { $this->users[] = $username; } - public function deleteUsers() { + public function deleteUsers():void { foreach ($this->users as $username) { $this->deleteUserIfExists($username); }