diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/AppPasswordControllerTest.php | 4 | ||||
-rw-r--r-- | tests/Core/Controller/ClientFlowLoginControllerTest.php | 14 | ||||
-rw-r--r-- | tests/Core/Controller/PreviewControllerTest.php | 2 | ||||
-rw-r--r-- | tests/data/broken-video.webm | bin | 0 -> 1714189 bytes | |||
-rw-r--r-- | tests/lib/AppFramework/Http/ResponseTest.php | 6 | ||||
-rw-r--r-- | tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php | 6 | ||||
-rw-r--r-- | tests/lib/AppFramework/Utility/SimpleContainerTest.php | 10 | ||||
-rw-r--r-- | tests/lib/Group/HideFromCollaborationTest.php | 53 | ||||
-rw-r--r-- | tests/lib/Preview/MovieBrokenStuckFfmpegTest.php | 20 | ||||
-rw-r--r-- | tests/lib/Preview/MovieTest.php | 9 |
10 files changed, 103 insertions, 21 deletions
diff --git a/tests/Core/Controller/AppPasswordControllerTest.php b/tests/Core/Controller/AppPasswordControllerTest.php index b33033edac3..eb1566eca8b 100644 --- a/tests/Core/Controller/AppPasswordControllerTest.php +++ b/tests/Core/Controller/AppPasswordControllerTest.php @@ -123,7 +123,7 @@ class AppPasswordControllerTest extends TestCase { $credentials->method('getLoginName') ->willReturn('myLoginName'); $this->request->method('getHeader') - ->with('USER_AGENT') + ->with('user-agent') ->willReturn('myUA'); $this->random->method('generate') ->with( @@ -164,7 +164,7 @@ class AppPasswordControllerTest extends TestCase { $credentials->method('getLoginName') ->willReturn('myLoginName'); $this->request->method('getHeader') - ->with('USER_AGENT') + ->with('user-agent') ->willReturn('myUA'); $this->random->method('generate') ->with( diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php index b10055ef542..c9ccf9ac674 100644 --- a/tests/Core/Controller/ClientFlowLoginControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php @@ -119,7 +119,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->request ->method('getHeader') ->willReturnMap([ - ['USER_AGENT', 'Mac OS X Sync Client'], + ['user-agent', 'Mac OS X Sync Client'], ['OCS-APIREQUEST', 'true'], ]); $this->random @@ -178,7 +178,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->request ->method('getHeader') ->willReturnMap([ - ['USER_AGENT', 'Mac OS X Sync Client'], + ['user-agent', 'Mac OS X Sync Client'], ['OCS-APIREQUEST', 'false'], ]); $client = new Client(); @@ -555,7 +555,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'http'], ['X-Forwarded-Ssl', 'off'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'http', @@ -564,7 +564,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'http'], ['X-Forwarded-Ssl', 'off'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'https', 'https', @@ -573,7 +573,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'https'], ['X-Forwarded-Ssl', 'off'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'https', @@ -582,7 +582,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'https'], ['X-Forwarded-Ssl', 'on'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'https', @@ -591,7 +591,7 @@ class ClientFlowLoginControllerTest extends TestCase { [ ['X-Forwarded-Proto', 'http'], ['X-Forwarded-Ssl', 'on'], - ['USER_AGENT', ''], + ['user-agent', ''], ], 'http', 'https', diff --git a/tests/Core/Controller/PreviewControllerTest.php b/tests/Core/Controller/PreviewControllerTest.php index e7ecba27064..2c2411e666f 100644 --- a/tests/Core/Controller/PreviewControllerTest.php +++ b/tests/Core/Controller/PreviewControllerTest.php @@ -265,7 +265,7 @@ class PreviewControllerTest extends \Test\TestCase { $this->request ->method('getHeader') - ->with('X-NC-Preview') + ->with('x-nc-preview') ->willReturn('true'); $preview = $this->createMock(ISimpleFile::class); diff --git a/tests/data/broken-video.webm b/tests/data/broken-video.webm Binary files differnew file mode 100644 index 00000000000..0cafb9314f8 --- /dev/null +++ b/tests/data/broken-video.webm diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php index 28614b14b40..c129b5637c5 100644 --- a/tests/lib/AppFramework/Http/ResponseTest.php +++ b/tests/lib/AppFramework/Http/ResponseTest.php @@ -229,7 +229,7 @@ class ResponseTest extends \Test\TestCase { $headers = $this->childResponse->getHeaders(); $this->assertEquals('private, max-age=33, must-revalidate', $headers['Cache-Control']); - $this->assertEquals('Thu, 15 Jan 1970 06:56:40 +0000', $headers['Expires']); + $this->assertEquals('Thu, 15 Jan 1970 06:56:40 GMT', $headers['Expires']); } @@ -239,7 +239,7 @@ class ResponseTest extends \Test\TestCase { $lastModified->setTimestamp(1); $this->childResponse->setLastModified($lastModified); $headers = $this->childResponse->getHeaders(); - $this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']); + $this->assertEquals('Thu, 01 Jan 1970 00:00:01 GMT', $headers['Last-Modified']); } public function testChainability(): void { @@ -257,7 +257,7 @@ class ResponseTest extends \Test\TestCase { $this->assertEquals('world', $headers['hello']); $this->assertEquals(Http::STATUS_NOT_FOUND, $this->childResponse->getStatus()); $this->assertEquals('hi', $this->childResponse->getEtag()); - $this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']); + $this->assertEquals('Thu, 01 Jan 1970 00:00:01 GMT', $headers['Last-Modified']); $this->assertEquals('private, max-age=33, must-revalidate', $headers['Cache-Control']); } diff --git a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php index 204cc647cad..d80df1841c8 100644 --- a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php @@ -43,13 +43,13 @@ class NotModifiedMiddlewareTest extends \Test\TestCase { [null, '"etag"', null, '', false], ['etag', '"etag"', null, '', true], - [null, '', $now, $now->format(\DateTimeInterface::RFC2822), true], + [null, '', $now, $now->format(\DateTimeInterface::RFC7231), true], [null, '', $now, $now->format(\DateTimeInterface::ATOM), false], - [null, '', null, $now->format(\DateTimeInterface::RFC2822), false], + [null, '', null, $now->format(\DateTimeInterface::RFC7231), false], [null, '', $now, '', false], ['etag', '"etag"', $now, $now->format(\DateTimeInterface::ATOM), true], - ['etag', '"etag"', $now, $now->format(\DateTimeInterface::RFC2822), true], + ['etag', '"etag"', $now, $now->format(\DateTimeInterface::RFC7231), true], ]; } diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php index 754da8e5fb3..a1cc1e76aeb 100644 --- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php +++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php @@ -36,7 +36,9 @@ class ClassComplexConstructor { } class ClassNullableUntypedConstructorArg { + public $class; public function __construct($class) { + $this->class = $class; } } class ClassNullableTypedConstructorArg { @@ -217,6 +219,8 @@ class SimpleContainerTest extends \Test\TestCase { $object = $this->container->query( 'Test\AppFramework\Utility\ClassComplexConstructor' ); + /* Use the object to trigger DI on PHP >= 8.4 */ + get_object_vars($object); } public function testRegisterFactory(): void { @@ -243,7 +247,11 @@ class SimpleContainerTest extends \Test\TestCase { public function testQueryUntypedNullable(): void { $this->expectException(\OCP\AppFramework\QueryException::class); - $this->container->query(ClassNullableUntypedConstructorArg::class); + $object = $this->container->query( + ClassNullableUntypedConstructorArg::class + ); + /* Use the object to trigger DI on PHP >= 8.4 */ + get_object_vars($object); } public function testQueryTypedNullable(): void { diff --git a/tests/lib/Group/HideFromCollaborationTest.php b/tests/lib/Group/HideFromCollaborationTest.php new file mode 100644 index 00000000000..5ff7c797508 --- /dev/null +++ b/tests/lib/Group/HideFromCollaborationTest.php @@ -0,0 +1,53 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace Test\Group; + +use OC\Group\Group; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\Group\Backend\ABackend; +use OCP\Group\Backend\IHideFromCollaborationBackend; +use OCP\IUserManager; +use PHPUnit\Framework\MockObject\MockObject; +use Test\TestCase; + +abstract class HideFromCollaborationBackendTest extends ABackend implements IHideFromCollaborationBackend { + +} + +class HideFromCollaborationTest extends TestCase { + + private IUserManager&MockObject $userManager; + private IEventDispatcher&MockObject $dispatcher; + + protected function setUp(): void { + parent::setUp(); + + $this->userManager = $this->createMock(IUserManager::class); + $this->dispatcher = $this->createMock(IEventDispatcher::class); + } + + + public function testHideFromCollaboration(): void { + // Arrange + $backend1 = $this->createMock(HideFromCollaborationBackendTest::class); + $backend1->method('hideGroup') + ->willReturn(false); + $backend2 = $this->createMock(HideFromCollaborationBackendTest::class); + $backend2->method('hideGroup') + ->willReturn(true); + $group = new Group('group1', [$backend1, $backend2], $this->dispatcher, $this->userManager); + + // Act + $result = $group->hideFromCollaboration(); + + // Assert + $this->assertTrue($result); + } +} diff --git a/tests/lib/Preview/MovieBrokenStuckFfmpegTest.php b/tests/lib/Preview/MovieBrokenStuckFfmpegTest.php new file mode 100644 index 00000000000..e66d5e64649 --- /dev/null +++ b/tests/lib/Preview/MovieBrokenStuckFfmpegTest.php @@ -0,0 +1,20 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace Test\Preview; + +/** + * Class MovieTest + * + * @group DB + * + * @package Test\Preview + */ +class MovieBrokenStuckFfmpegTest extends MovieTest { + protected string $fileName = 'broken-video.webm'; +} diff --git a/tests/lib/Preview/MovieTest.php b/tests/lib/Preview/MovieTest.php index b8946ad4c5e..6009943b89d 100644 --- a/tests/lib/Preview/MovieTest.php +++ b/tests/lib/Preview/MovieTest.php @@ -18,6 +18,10 @@ use OCP\Server; * @package Test\Preview */ class MovieTest extends Provider { + protected string $fileName = 'testimage.mp4'; + protected int $width = 560; + protected int $height = 320; + protected function setUp(): void { $binaryFinder = Server::get(IBinaryFinder::class); $movieBinary = $binaryFinder->findBinaryPath('avconv'); @@ -28,10 +32,7 @@ class MovieTest extends Provider { if (is_string($movieBinary)) { parent::setUp(); - $fileName = 'testimage.mp4'; - $this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName); - $this->width = 560; - $this->height = 320; + $this->imgPath = $this->prepareTestFile($this->fileName, \OC::$SERVERROOT . '/tests/data/' . $this->fileName); $this->provider = new \OC\Preview\Movie(['movieBinary' => $movieBinary]); } else { $this->markTestSkipped('No Movie provider present'); |