diff options
author | Daniel <mail@danielkesselberg.de> | 2023-08-15 15:08:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 15:08:28 +0200 |
commit | 89f66a5a4b7e384de3610afba8beea05a16e4f8f (patch) | |
tree | 6218ebfa733be39026dd45c333ebbe0647e85078 | |
parent | 240e8ab0997d93c63dcbe792bc06fdf29bc60b57 (diff) | |
parent | f57c12b14e360f1694a699fce5a7e8ae4c50b91c (diff) | |
download | nextcloud-server-89f66a5a4b7e384de3610afba8beea05a16e4f8f.tar.gz nextcloud-server-89f66a5a4b7e384de3610afba8beea05a16e4f8f.zip |
Merge pull request #39866 from nextcloud/enh/fix-php-8.3-support-in-tests
-rw-r--r-- | apps/dav/tests/unit/CalDAV/CalDavBackendTest.php | 2 | ||||
-rw-r--r-- | apps/files/tests/Controller/ViewControllerTest.php | 1 | ||||
-rw-r--r-- | tests/lib/App/AppManagerTest.php | 5 | ||||
-rw-r--r-- | tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php | 3 | ||||
-rw-r--r-- | tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php | 2 | ||||
-rw-r--r-- | tests/lib/Files/ViewTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Http/Client/ClientTest.php | 1 | ||||
-rw-r--r-- | tests/lib/TestCase.php | 6 | ||||
-rw-r--r-- | tests/lib/TextProcessing/TextProcessingTest.php | 9 |
9 files changed, 29 insertions, 4 deletions
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index acf5504eb66..3da6ca61b7e 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -656,7 +656,7 @@ EOS; try { $actual = $this->backend->getDenormalizedData($calData); $this->assertEquals($expected, $actual[$key]); - } catch (\ValueError $e) { + } catch (\Throwable $e) { if (($e->getMessage() === 'Epoch doesn\'t fit in a PHP integer') && (PHP_INT_SIZE < 8)) { $this->markTestSkipped('This fail on 32bits because of PHP limitations in DateTime'); } diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 783c9c8bbbb..d9ccaf47eed 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -158,6 +158,7 @@ class ViewControllerTest extends TestCase { ->willReturnMap([ [$this->user->getUID(), 'files', 'file_sorting', 'name', 'name'], [$this->user->getUID(), 'files', 'file_sorting_direction', 'asc', 'asc'], + [$this->user->getUID(), 'files', 'files_sorting_configs', '{}', '{}'], [$this->user->getUID(), 'files', 'show_hidden', false, false], [$this->user->getUID(), 'files', 'crop_image_previews', true, true], [$this->user->getUID(), 'files', 'show_grid', true], diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index 4717da008a4..3bf2195499f 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -642,6 +642,11 @@ class AppManagerTest extends TestCase { ->with('defaultapp', $this->anything()) ->willReturn($defaultApps); + $this->config->expects($this->once()) + ->method('getUserValue') + ->with('user1', 'core', 'defaultapp') + ->willReturn(''); + $this->assertEquals($expectedApp, $this->manager->getDefaultAppForUser()); } } diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index a614780a908..e37ef68852d 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -38,6 +38,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\Security\ICrypto; +use OCP\Security\IHasher; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Test\TestCase; @@ -47,6 +48,8 @@ class PublicKeyTokenProviderTest extends TestCase { private $tokenProvider; /** @var PublicKeyTokenMapper|\PHPUnit\Framework\MockObject\MockObject */ private $mapper; + /** @var IHasher|\PHPUnit\Framework\MockObject\MockObject */ + private $hasher; /** @var ICrypto */ private $crypto; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ diff --git a/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php index 96fb7909d6b..5b4589de317 100644 --- a/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php +++ b/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php @@ -46,6 +46,8 @@ class LocalTimeProviderTest extends TestCase { private $actionFactory; /** @var IL10N|MockObject */ private $l; + /** @var IL10NFactory|MockObject */ + private $l10nFactory; /** @var IURLGenerator|MockObject */ private $urlGenerator; /** @var IUserManager|MockObject */ diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 18a6fca05b0..200b54d5829 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1568,10 +1568,10 @@ class ViewTest extends \Test\TestCase { $defaultRootValue->setAccessible(true); $oldRoot = $defaultRootValue->getValue(); $defaultView = new View('/foo/files'); - $defaultRootValue->setValue($defaultView); + $defaultRootValue->setValue(null, $defaultView); $view = new View($root); $result = self::invokePrivate($view, 'shouldEmitHooks', [$path]); - $defaultRootValue->setValue($oldRoot); + $defaultRootValue->setValue(null, $oldRoot); $this->assertEquals($shouldEmit, $result); } diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index e48e237e0cc..3cef9d75986 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -36,6 +36,7 @@ class ClientTest extends \Test\TestCase { private $config; /** @var IRemoteHostValidator|MockObject */ private IRemoteHostValidator $remoteHostValidator; + private LoggerInterface $logger; /** @var array */ private $defaultRequestOptions; diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index a242a51a887..f5fc9a6e8f2 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -230,7 +230,11 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { $property->setAccessible(true); if (!empty($parameters)) { - $property->setValue($object, array_pop($parameters)); + if ($property->isStatic()) { + $property->setValue(null, array_pop($parameters)); + } else { + $property->setValue($object, array_pop($parameters)); + } } if (is_object($object)) { diff --git a/tests/lib/TextProcessing/TextProcessingTest.php b/tests/lib/TextProcessing/TextProcessingTest.php index 3bda73e995b..15f36cb2452 100644 --- a/tests/lib/TextProcessing/TextProcessingTest.php +++ b/tests/lib/TextProcessing/TextProcessingTest.php @@ -19,6 +19,7 @@ use OC\TextProcessing\RemoveOldTasksBackgroundJob; use OC\TextProcessing\TaskBackgroundJob; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\IJobList; use OCP\Common\Exception\NotFoundException; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; @@ -90,6 +91,14 @@ class FreePromptProvider implements IProvider { class TextProcessingTest extends \Test\TestCase { private IManager $manager; private Coordinator $coordinator; + private array $providers; + private IServerContainer $serverContainer; + private IEventDispatcher $eventDispatcher; + private RegistrationContext $registrationContext; + private \DateTimeImmutable $currentTime; + private TaskMapper $taskMapper; + private array $tasksDb; + private IJobList $jobList; protected function setUp(): void { parent::setUp(); |