Completed
Pull Request — master (#28)
by
unknown
08:00
created

TikaTextExtractorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 89.47 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExtraction() 17 17 2
A testServerExtraction() 17 17 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
/**
4
 * Tests the {@see TikaTextExtractor} class
5
 */
6
class TikaTextExtractorTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8 View Code Duplication
    public function testExtraction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
    {
10
        $extractor = new TikaTextExtractor();
11
        if (!$extractor->isAvailable()) {
12
            $this->markTestSkipped('tika cli not available');
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
13
        }
14
15
        // Check file
16
        $file = Director::baseFolder() . '/textextraction/tests/fixtures/test1.pdf';
17
        $content = $extractor->getContent($file);
18
        $this->assertContains('This is a test file with a link', $content);
19
20
        // Check mime validation
21
        $this->assertTrue($extractor->supportsMime('application/pdf'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
22
        $this->assertTrue($extractor->supportsMime('text/html'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
        $this->assertFalse($extractor->supportsMime('application/not-supported'));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
24
    }
25
26 View Code Duplication
    public function testServerExtraction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $extractor = new TikaServerTextExtractor();
29
        if (!$extractor->isAvailable()) {
30
            $this->markTestSkipped('tika server not available');
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
        }
32
33
        // Check file
34
        $file = Director::baseFolder() . '/textextraction/tests/fixtures/test1.pdf';
35
        $content = $extractor->getContent($file);
36
        $this->assertContains('This is a test file with a link', $content);
37
38
        // Check mime validation
39
        $this->assertTrue($extractor->supportsMime('application/pdf'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
        $this->assertTrue($extractor->supportsMime('text/html'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
        $this->assertFalse($extractor->supportsMime('application/not-supported'));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<TikaTextExtractorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
    }
43
}
44