Completed
Push — master ( dd292b...979586 )
by
unknown
11s
created

TikaTextExtractorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 89.47 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 34
loc 38
c 0
b 0
f 0
wmc 4
lcom 0
cbo 4
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExtraction() 0 19 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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