Test Failed
Pull Request — master (#132)
by Alessandro
03:15
created

PHPUnitConfigTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 40 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 16
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetBaseDirectoryIsNotLazy() 0 9 1
A testGetFileFullPathWithDirAndUseDefaultFileName() 0 9 1
A testGetFileFullPathWithFileDoesNotExistWillThrowException() 8 8 1
A testGetFileFullPathWithPathDoesNotExistWillThrowException() 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
declare(strict_types=1);
4
5
namespace Tests\Unit\Configuration;
6
7
use Paraunit\Configuration\PHPUnitConfig;
8
use Tests\BaseUnitTestCase;
9
10
/**
11
 * Class PHPUnitConfigTest
12
 * @package Tests\Unit\Configuration
13
 */
14
class PHPUnitConfigTest extends BaseUnitTestCase
15
{
16
    public function testGetBaseDirectoryIsNotLazy()
17
    {
18
        $config = new PHPUnitConfig('');
19
20
        $directoryPath = $config->getBaseDirectory();
21
        $this->assertNotEquals('', $directoryPath);
22
        $this->assertNotEquals('/', $directoryPath);
23
        $this->assertNotEquals('C:\\', $directoryPath);
24
    }
25
26
    public function testGetFileFullPathWithDirAndUseDefaultFileName()
27
    {
28
        $dir = $this->getStubPath() . 'StubbedXMLConfigs';
29
        $configurationFile = $dir . DIRECTORY_SEPARATOR . 'phpunit.xml.dist';
30
31
        $config = new PHPUnitConfig($dir);
32
33
        $this->assertEquals($configurationFile, $config->getFileFullPath());
34
    }
35
36 View Code Duplication
    public function testGetFileFullPathWithFileDoesNotExistWillThrowException()
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...
37
    {
38
        $dir = $this->getStubPath() . 'PHPUnitJSONLogOutput';
39
        $this->expectException(\InvalidArgumentException::class);
40
        $this->expectExceptionMessage(PHPUnitConfig::DEFAULT_FILE_NAME . ' does not exist');
41
42
        new PHPUnitConfig($dir);
43
    }
44
45 View Code Duplication
    public function testGetFileFullPathWithPathDoesNotExistWillThrowException()
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...
46
    {
47
        $dir = $this->getStubPath() . 'foobar';
48
        $this->expectException(\InvalidArgumentException::class);
49
        $this->expectExceptionMessage('Config path/file provided is not valid');
50
51
        new PHPUnitConfig($dir);
52
    }
53
}
54