diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-04-16 16:50:44 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-04-16 16:50:44 +0200 |
commit | 7c264cb7faaec5f6d851a254250ff041b5bbd32b (patch) | |
tree | b65c528d22f69bc199e7d252a0fe1bb0d4ee28e5 /apps/files_sharing | |
parent | 29d78eaf803957ab8df232e435d9d0ad1fc2741a (diff) | |
download | nextcloud-server-7c264cb7faaec5f6d851a254250ff041b5bbd32b.tar.gz nextcloud-server-7c264cb7faaec5f6d851a254250ff041b5bbd32b.zip |
Harden public preview tests
This way there are less timing issues.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php index 3cb38a5e388..54d57dd2d46 100644 --- a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php +++ b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php @@ -26,6 +26,7 @@ use OCA\Files_Sharing\Controller\PublicPreviewController; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\FileDisplayResponse; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\Constants; use OCP\Files\File; use OCP\Files\Folder; @@ -37,6 +38,7 @@ use OCP\ISession; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IShare; +use PHPUnit\Framework\MockObject\MockObject; use Punic\Data; use Test\TestCase; @@ -44,9 +46,10 @@ class PublicPreviewControllerTest extends TestCase { /** @var IPreview|\PHPUnit_Framework_MockObject_MockObject */ private $previewManager; - /** @var IManager|\PHPUnit_Framework_MockObject_MockObject */ private $shareManager; + /** @var ITimeFactory|MockObject */ + private $timeFactory; /** @var PublicPreviewController */ private $controller; @@ -56,6 +59,12 @@ class PublicPreviewControllerTest extends TestCase { $this->previewManager = $this->createMock(IPreview::class); $this->shareManager = $this->createMock(IManager::class); + $this->timeFactory = $this->createMock(ITimeFactory::class); + + $this->timeFactory->method('getTime') + ->willReturn(1337); + + $this->overwriteService(ITimeFactory::class, $this->timeFactory); $this->controller = new PublicPreviewController( 'files_sharing', |