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

TikaServerTextExtractorTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testServerExtraction() 0 19 2
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