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

FileTextExtractableTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
class FileTextExtractableTest 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...
3
{
4
    protected $requiredExtensions = array(
5
        'File' => array('FileTextExtractable')
6
    );
7
8
    public function setUp()
9
    {
10
        parent::setUp();
11
12
        // Ensure that html is a valid extension
13
        Config::inst()
14
            ->nest()
15
            ->update('File', 'allowed_extensions', array('html'));
16
    }
17
18
    public function tearDown()
19
    {
20
        Config::unnest();
21
        parent::tearDown();
22
    }
23
24
    public function testExtractFileAsText()
25
    {
26
        // Create a copy of the file, as it may be clobbered by the test
27
        // ($file->extractFileAsText() calls $file->write)
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
        copy(BASE_PATH.'/textextraction/tests/fixtures/test1.html', BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html');
29
        
30
        // Use HTML, since the extractor is always available
31
        $file = new File(array(
32
            'Name' => 'test1-copy.html',
33
            'Filename' => 'textextraction/tests/fixtures/test1-copy.html'
34
        ));
35
        $file->write();
36
    
37
        $content = $file->extractFileAsText();
38
        $this->assertContains('Test Headline', $content);
39
        $this->assertContains('Test Text', $content);
40
        $this->assertEquals($content, $file->FileContentCache);
0 ignored issues
show
Bug introduced by
The property FileContentCache does not seem to exist. Did you mean Content?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<FileTextExtractableTest>.

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
42
        if (file_exists(BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html')) {
43
            unlink(BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html');
44
        }
45
    }
46
}
47