summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2018-08-20 13:21:16 +0200
committerGitHub <noreply@github.com>2018-08-20 13:21:16 +0200
commit4b92a0986cb7c30265a39bf5baf0d6deebec8d8b (patch)
tree534fd83f115260fb6353ebea6815c46c1b773f4e /tests
parentc260e4403d2b54c56c50043d67490e2c1041f3b2 (diff)
parent5b103744c8b480a47a8973079280b3cc078714f2 (diff)
downloadnextcloud-server-4b92a0986cb7c30265a39bf5baf0d6deebec8d8b.tar.gz
nextcloud-server-4b92a0986cb7c30265a39bf5baf0d6deebec8d8b.zip
Merge pull request #10712 from nextcloud/fix/noid/check_if_provider_is_available_before_use
Check if a preview provider is available before using it
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Preview/GeneratorTest.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php
index b6200b1829b..64786fa9fe8 100644
--- a/tests/lib/Preview/GeneratorTest.php
+++ b/tests/lib/Preview/GeneratorTest.php
@@ -150,16 +150,24 @@ class GeneratorTest extends \Test\TestCase {
}));
$invalidProvider = $this->createMock(IProvider::class);
+ $invalidProvider->method('isAvailable')
+ ->willReturn(true);
+ $unavailableProvider = $this->createMock(IProvider::class);
+ $unavailableProvider->method('isAvailable')
+ ->willReturn(false);
$validProvider = $this->createMock(IProvider::class);
+ $validProvider->method('isAvailable')
+ ->with($file)
+ ->willReturn(true);
$this->previewManager->method('getProviders')
->willReturn([
'/image\/png/' => ['wrongProvider'],
- '/myMimeType/' => ['brokenProvider', 'invalidProvider', 'validProvider'],
+ '/myMimeType/' => ['brokenProvider', 'invalidProvider', 'unavailableProvider', 'validProvider'],
]);
$this->helper->method('getProvider')
- ->will($this->returnCallback(function($provider) use ($invalidProvider, $validProvider) {
+ ->will($this->returnCallback(function($provider) use ($invalidProvider, $validProvider, $unavailableProvider) {
if ($provider === 'wrongProvider') {
$this->fail('Wrongprovider should not be constructed!');
} else if ($provider === 'brokenProvider') {
@@ -168,6 +176,8 @@ class GeneratorTest extends \Test\TestCase {
return $invalidProvider;
} else if ($provider === 'validProvider') {
return $validProvider;
+ } else if ($provider === 'unavailableProvider') {
+ return $unavailableProvider;
}
$this->fail('Unexpected provider requested');
}));