mirror of
https://github.com/silverstripe/silverstripe-textextraction
synced 2024-10-22 11:06:00 +02:00
30 lines
898 B
PHP
30 lines
898 B
PHP
<?php
|
|
|
|
namespace SilverStripe\TextExtraction\Tests;
|
|
|
|
use SilverStripe\Assets\File;
|
|
use SilverStripe\Dev\SapphireTest;
|
|
use SilverStripe\TextExtraction\Extractor\FileTextExtractor\Exception;
|
|
use SilverStripe\TextExtraction\Extractor\PDFTextExtractor;
|
|
|
|
class PDFTextExtractorTest extends SapphireTest
|
|
{
|
|
protected $usesDatabase = true;
|
|
|
|
public function testExtraction()
|
|
{
|
|
$extractor = new PDFTextExtractor();
|
|
if (!$extractor->isAvailable()) {
|
|
$this->expectException(Exception::class);
|
|
$this->expectExceptionMessage('getRawOutput called on unavailable extractor');
|
|
}
|
|
|
|
$file = new File();
|
|
$file->setFromLocalFile(dirname(__FILE__) . '/fixtures/test1.pdf');
|
|
$file->write();
|
|
|
|
$content = $extractor->getContent($file);
|
|
$this->assertStringContainsString('This is a test file with a link', $content);
|
|
}
|
|
}
|