Completed
Branch master (9dcfc4)
by Daniel
24:32
created

FileWritableCheckTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCheckReportsWritablePaths() 11 11 1
A testCheckReportsNonWritablePaths() 8 8 1

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\EnvironmentCheck\Tests\Checks;
4
5
use SilverStripe\EnvironmentCheck\Checks\FileWriteableCheck;
6
use SilverStripe\EnvironmentCheck\EnvironmentCheck;
7
use SilverStripe\Dev\SapphireTest;
8
9
/**
10
 * Class FileWritableCheckTest
11
 *
12
 * @mixin PHPUnit_Framework_TestCase
13
 *
14
 * @package environmentcheck
15
 */
16 View Code Duplication
class FileWritableCheckTest extends SapphireTest
0 ignored issues
show
Duplication introduced by
This class 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...
17
{
18
    public function testCheckReportsWritablePaths()
19
    {
20
        $check = new FileWriteableCheck(TEMP_FOLDER);
21
22
        $expected = [
23
            EnvironmentCheck::OK,
24
            ''
25
        ];
26
27
        $this->assertEquals($expected, $check->check());
28
    }
29
30
    public function testCheckReportsNonWritablePaths()
31
    {
32
        $check = new FileWriteableCheck('/var');
33
34
        $result = $check->check();
35
36
        $this->assertEquals(EnvironmentCheck::ERROR, $result[0]);
37
    }
38
}
39