silverstripe-textextraction/tests/PDFTextExtractorTest.php

30 lines
898 B
PHP
Raw Normal View History

2012-08-22 18:23:06 +02:00
<?php
namespace SilverStripe\TextExtraction\Tests;
use SilverStripe\Assets\File;
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
{
protected $usesDatabase = true;
2015-11-18 05:07:31 +01:00
public function testExtraction()
{
$extractor = new PDFTextExtractor();
if (!$extractor->isAvailable()) {
$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
$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
}
}