Completed
Pull Request — master (#45)
by Robbie
24:33 queued 17:24
created

testServerExtraction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\TextExtraction\Tests;
4
5
use SilverStripe\Assets\File;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\TextExtraction\Extractor\TikaServerTextExtractor;
8
9
/**
10
 * @group tika-tests
11
 */
12
class TikaServerTextExtractorTest extends SapphireTest
13
{
14
    protected $usesDatabase = true;
15
16
    public function testServerExtraction()
17
    {
18
        $extractor = TikaServerTextExtractor::create();
19
        if (!$extractor->isAvailable()) {
20
            $this->markTestSkipped('tika server not available');
21
        }
22
23
        // Check file
24
        $file = new File();
25
        $file->setFromLocalFile(dirname(__FILE__) . '/fixtures/test1.pdf');
26
        $file->write();
27
28
        $content = $extractor->getContent($file);
29
        $this->assertContains('This is a test file with a link', $content);
30
31
        // Check mime validation
32
        $this->assertTrue($extractor->supportsMime('application/pdf'));
33
        $this->assertTrue($extractor->supportsMime('text/html'));
34
        $this->assertFalse($extractor->supportsMime('application/not-supported'));
35
    }
36
}
37