mirror of
https://github.com/silverstripe/silverstripe-textextraction
synced 2024-10-22 09:06:00 +00:00
Merge branch '3.0'
This commit is contained in:
commit
801cd9cacb
@ -19,6 +19,8 @@ matrix:
|
||||
- php: 7.1
|
||||
env: DB=PGSQL RECIPE_VERSION=4.2.x-dev PHPUNIT_COVERAGE_TEST=1
|
||||
- php: 7.2
|
||||
env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1
|
||||
- php: 7.3
|
||||
env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_TEST=1
|
||||
|
||||
before_script:
|
||||
@ -34,7 +36,7 @@ before_script:
|
||||
|
||||
# Install composer dependencies
|
||||
- composer validate
|
||||
- composer require --no-update silverstripe/recipe-core "$RECIPE_VERSION"
|
||||
- composer require --no-update silverstripe/recipe-cms:"$RECIPE_VERSION"
|
||||
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql 2.1.x-dev; fi
|
||||
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||
|
||||
|
@ -29,6 +29,12 @@
|
||||
"squizlabs/php_codesniffer": "^3",
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SilverStripe\\TextExtraction\\": "src/",
|
||||
"SilverStripe\\TextExtraction\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"ext-fileinfo": "Improved support for file mime detection"
|
||||
},
|
||||
|
@ -86,7 +86,7 @@ class TikaServerTextExtractor extends FileTextExtractor
|
||||
{
|
||||
return $this->getServerEndpoint()
|
||||
&& $this->getClient()->isAvailable()
|
||||
&& version_compare($this->getVersion(), '1.7.0') >= 0;
|
||||
&& version_compare($this->getVersion(), '1.7') >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ class TikaRestClient extends Client
|
||||
Injector::inst()->get(LoggerInterface::class)->info($msg);
|
||||
}
|
||||
|
||||
return $text;
|
||||
return (string) $text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
namespace SilverStripe\TextExtraction\Tests;
|
||||
|
||||
use PHPUnit_Framework_MockObject_MockObject;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\TextExtraction\Extractor\TikaServerTextExtractor;
|
||||
use SilverStripe\TextExtraction\Rest\TikaRestClient;
|
||||
|
||||
/**
|
||||
* @group tika-tests
|
||||
@ -33,4 +35,44 @@ class TikaServerTextExtractorTest extends SapphireTest
|
||||
$this->assertTrue($extractor->supportsMime('text/html'));
|
||||
$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…
x
Reference in New Issue
Block a user