TikaTextExtractorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExtraction() 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\TikaTextExtractor;
8
9
/**
10
 * Tests the {@see TikaTextExtractor} class
11
 *
12
 * @group tika-tests
13
 */
14
class TikaTextExtractorTest extends SapphireTest
15
{
16
    protected $usesDatabase = true;
17
18
    public function testExtraction()
19
    {
20
        $extractor = TikaTextExtractor::create();
21
        if (!$extractor->isAvailable()) {
22
            $this->markTestSkipped('tika cli not available');
23
        }
24
25
        // Check file
26
        $file = new File();
27
        $file->setFromLocalFile(dirname(__FILE__) . '/fixtures/test1.pdf');
28
        $file->write();
29
30
        $content = $extractor->getContent($file);
31
        $this->assertContains('This is a test file with a link', $content);
32
33
        // Check mime validation
34
        $this->assertTrue($extractor->supportsMime('application/pdf'));
35
        $this->assertTrue($extractor->supportsMime('text/html'));
36
        $this->assertFalse($extractor->supportsMime('application/not-supported'));
37
    }
38
}
39