2012-08-22 18:23:06 +02:00
|
|
|
<?php
|
2018-07-03 01:35:24 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\TextExtraction\Tests;
|
|
|
|
|
2018-07-03 05:55:02 +02:00
|
|
|
use SilverStripe\Assets\File;
|
2018-07-03 01:35:24 +02:00
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\TextExtraction\Extractor\FileTextExtractor\Exception;
|
|
|
|
use SilverStripe\TextExtraction\Extractor\PDFTextExtractor;
|
|
|
|
|
2015-11-18 05:07:31 +01:00
|
|
|
class PDFTextExtractorTest extends SapphireTest
|
|
|
|
{
|
2018-07-03 05:55:02 +02:00
|
|
|
protected $usesDatabase = true;
|
|
|
|
|
2015-11-18 05:07:31 +01:00
|
|
|
public function testExtraction()
|
|
|
|
{
|
|
|
|
$extractor = new PDFTextExtractor();
|
|
|
|
if (!$extractor->isAvailable()) {
|
2018-07-03 01:35:24 +02:00
|
|
|
$this->expectException(Exception::class);
|
|
|
|
$this->expectExceptionMessage('getRawOutput called on unavailable extractor');
|
2015-11-18 05:07:31 +01:00
|
|
|
}
|
2012-08-22 18:23:06 +02:00
|
|
|
|
2018-07-03 05:55:02 +02:00
|
|
|
$file = new File();
|
|
|
|
$file->setFromLocalFile(dirname(__FILE__) . '/fixtures/test1.pdf');
|
|
|
|
$file->write();
|
|
|
|
|
|
|
|
$content = $extractor->getContent($file);
|
2021-10-27 07:16:05 +02:00
|
|
|
$this->assertStringContainsString('This is a test file with a link', $content);
|
2015-11-18 05:07:31 +01:00
|
|
|
}
|
2015-02-18 03:31:38 +01:00
|
|
|
}
|