mirror of
https://github.com/silverstripe/silverstripe-textextraction
synced 2024-10-22 11:06:00 +02:00
Add tests for isAvailable()
This commit is contained in:
parent
21ed6e0f86
commit
86eba78064
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace SilverStripe\TextExtraction\Tests;
|
namespace SilverStripe\TextExtraction\Tests;
|
||||||
|
|
||||||
|
use PHPUnit_Framework_MockObject_MockObject;
|
||||||
use SilverStripe\Assets\File;
|
use SilverStripe\Assets\File;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\TextExtraction\Extractor\TikaServerTextExtractor;
|
use SilverStripe\TextExtraction\Extractor\TikaServerTextExtractor;
|
||||||
|
use SilverStripe\TextExtraction\Rest\TikaRestClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group tika-tests
|
* @group tika-tests
|
||||||
@ -33,4 +35,44 @@ class TikaServerTextExtractorTest extends SapphireTest
|
|||||||
$this->assertTrue($extractor->supportsMime('text/html'));
|
$this->assertTrue($extractor->supportsMime('text/html'));
|
||||||
$this->assertFalse($extractor->supportsMime('application/not-supported'));
|
$this->assertFalse($extractor->supportsMime('application/not-supported'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $version
|
||||||
|
* @param bool $expected
|
||||||
|
* @dataProvider isAvailableProvider
|
||||||
|
*/
|
||||||
|
public function testIsAvailable($version, $expected)
|
||||||
|
{
|
||||||
|
/** @var PHPUnit_Framework_MockObject_MockObject|TikaServerTextExtractor $extractor */
|
||||||
|
$extractor = $this->getMockBuilder(TikaServerTextExtractor::class)
|
||||||
|
->setMethods(['getClient', 'getServerEndpoint'])
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$client = $this->createMock(TikaRestClient::class);
|
||||||
|
$client->method('isAvailable')->willReturn(true);
|
||||||
|
$client->method('getVersion')->willReturn($version);
|
||||||
|
|
||||||
|
$extractor->method('getClient')->willReturn($client);
|
||||||
|
$extractor->method('getServerEndpoint')->willReturn('tikaserver.example');
|
||||||
|
|
||||||
|
$result = $extractor->isAvailable();
|
||||||
|
$this->assertSame($expected, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
|
public function isAvailableProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['1.5.2', false],
|
||||||
|
['1.5', false],
|
||||||
|
['1.7.0', true],
|
||||||
|
['1.7.5', true],
|
||||||
|
['1.8.0', true],
|
||||||
|
['1.7', true],
|
||||||
|
['1.8', true],
|
||||||
|
['2.0.0', true],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user