mirror of
https://github.com/silverstripe/silverstripe-textextraction
synced 2024-10-22 11:06:00 +02:00
MINOR: module support for Silverstripe 3.7
This commit is contained in:
parent
944cabb805
commit
6fe7172663
10
.travis.yml
10
.travis.yml
@ -10,16 +10,14 @@ addons:
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.4
|
|
||||||
env: DB=PGSQL CORE_RELEASE=3.2
|
|
||||||
- php: 5.5
|
- php: 5.5
|
||||||
env: DB=PGSQL CORE_RELEASE=3.3
|
env: DB=PGSQL CORE_RELEASE=3.7
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=PGSQL CORE_RELEASE=3.4
|
env: DB=PGSQL CORE_RELEASE=3.7
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL CORE_RELEASE=3.5
|
env: DB=MYSQL CORE_RELEASE=3.7
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: DB=MYSQL CORE_RELEASE=3.6
|
env: DB=MYSQL CORE_RELEASE=3.7
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
env: DB=MYSQL CORE_RELEASE=3
|
env: DB=MYSQL CORE_RELEASE=3
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* @author mstephens
|
* @author mstephens
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract class FileTextExtractor extends Object
|
abstract class FileTextExtractor extends SS_Object
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Set priority from 0-100.
|
* Set priority from 0-100.
|
||||||
@ -34,7 +34,7 @@ abstract class FileTextExtractor extends Object
|
|||||||
if (self::$sorted_extractor_classes) {
|
if (self::$sorted_extractor_classes) {
|
||||||
return self::$sorted_extractor_classes;
|
return self::$sorted_extractor_classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the sorted list of extractors on demand.
|
// Generate the sorted list of extractors on demand.
|
||||||
$classes = ClassInfo::subclassesFor("FileTextExtractor");
|
$classes = ClassInfo::subclassesFor("FileTextExtractor");
|
||||||
array_shift($classes);
|
array_shift($classes);
|
||||||
@ -108,7 +108,7 @@ abstract class FileTextExtractor extends Object
|
|||||||
/**
|
/**
|
||||||
* Checks if the extractor is supported on the current environment,
|
* Checks if the extractor is supported on the current environment,
|
||||||
* for example if the correct binaries or libraries are available.
|
* for example if the correct binaries or libraries are available.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
abstract public function isAvailable();
|
abstract public function isAvailable();
|
||||||
@ -125,7 +125,7 @@ abstract class FileTextExtractor extends Object
|
|||||||
/**
|
/**
|
||||||
* Determine if this extractor suports the given mime type.
|
* Determine if this extractor suports the given mime type.
|
||||||
* Will only be called if supportsExtension returns false.
|
* Will only be called if supportsExtension returns false.
|
||||||
*
|
*
|
||||||
* @param string $mime
|
* @param string $mime
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@ -133,7 +133,7 @@ abstract class FileTextExtractor extends Object
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a file path, extract the contents as text.
|
* Given a file path, extract the contents as text.
|
||||||
*
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.2",
|
"php": ">=5.3.2",
|
||||||
"composer/installers": "*",
|
"composer/installers": "*",
|
||||||
"silverstripe/framework": "^3.1",
|
"silverstripe/framework": "^3.7",
|
||||||
"guzzle/guzzle": "^3.9",
|
"guzzle/guzzle": "^3.9",
|
||||||
"symfony/event-dispatcher": "^2.6.0@stable",
|
"symfony/event-dispatcher": "^2.6.0@stable",
|
||||||
"symfony/http-foundation": "^2.6.0"
|
"symfony/http-foundation": "^2.6.0"
|
||||||
|
@ -26,15 +26,16 @@ class FileTextExtractableTest extends SapphireTest
|
|||||||
// Create a copy of the file, as it may be clobbered by the test
|
// Create a copy of the file, as it may be clobbered by the test
|
||||||
// ($file->extractFileAsText() calls $file->write)
|
// ($file->extractFileAsText() calls $file->write)
|
||||||
copy(BASE_PATH.'/textextraction/tests/fixtures/test1.html', BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html');
|
copy(BASE_PATH.'/textextraction/tests/fixtures/test1.html', BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html');
|
||||||
|
|
||||||
// Use HTML, since the extractor is always available
|
// Use HTML, since the extractor is always available
|
||||||
|
/** @var File&FileTextExtractable $file */
|
||||||
$file = new File(array(
|
$file = new File(array(
|
||||||
'Name' => 'test1-copy.html',
|
'Name' => 'test1-copy.html',
|
||||||
'Filename' => 'textextraction/tests/fixtures/test1-copy.html'
|
'Filename' => 'textextraction/tests/fixtures/test1-copy.html'
|
||||||
));
|
));
|
||||||
$file->write();
|
$file->write();
|
||||||
|
|
||||||
$content = $file->extractFileAsText();
|
$content = (string) $file->extractFileAsText();
|
||||||
$this->assertContains('Test Headline', $content);
|
$this->assertContains('Test Headline', $content);
|
||||||
$this->assertContains('Test Text', $content);
|
$this->assertContains('Test Text', $content);
|
||||||
$this->assertEquals($content, $file->FileContentCache);
|
$this->assertEquals($content, $file->FileContentCache);
|
||||||
|
Loading…
Reference in New Issue
Block a user