diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-08-16 10:45:51 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-08-17 20:51:35 +0200 |
commit | 5b103744c8b480a47a8973079280b3cc078714f2 (patch) | |
tree | eacc31ace30bfd355b0795cb9d2218c53a2572a0 /tests | |
parent | bcc1a53f05a8442ff1a8a5f06c585470aa44f521 (diff) | |
download | nextcloud-server-5b103744c8b480a47a8973079280b3cc078714f2.tar.gz nextcloud-server-5b103744c8b480a47a8973079280b3cc078714f2.zip |
Check if a preview provider is available before using it
Else if a preview provider is registerd but not available (for example
missing support in some external lib). It will do :boom:. This way the
providers can at least do the sanity checks required.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Preview/GeneratorTest.php | 14 |
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'); })); |