Completed
Push — master ( a7939e...84054a )
by Alessandro
03:27
created

PHPUnitConfigFileTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 64
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A tearDown() 0 7 1
A testRelativeDirectoryDoesUseDefaultFileName() 0 12 1
A testRelativeFilenameDoesNotUseDefaultFileName() 0 10 1
A testRelativeDirectoryAndDefaultFileDoesNotExistThrowException() 0 8 1
A testInvalidDirectoryProvidedThrowException() 0 8 1
1
<?php
2
3
namespace Paraunit\Tests\Unit\Configuration;
4
5
use Paraunit\Configuration\PHPUnitConfigFile;
6
7
class PHPUnitConfigFileTest extends \PHPUnit_Framework_TestCase
8
{
9
    private $previousCWD;
10
11
    protected function setUp()
12
    {
13
        parent::setUp();
14
15
        $this->previousCWD = getcwd();
16
17
        $stubPath = realpath(__DIR__ . '/../../Stub');
18
        chdir($stubPath);
19
    }
20
21
    protected function tearDown()
22
    {
23
        chdir($this->previousCWD);
24
        $this->previousCWD = null;
25
26
        parent::tearDown();
27
    }
28
29
    public function testRelativeDirectoryDoesUseDefaultFileName()
30
    {
31
        $dir = 'StubbedXMLConfigs';
32
33
        $config = new PHPUnitConfigFile($dir);
34
35
        $filePath = $config->getFileFullPath();
36
        $this->assertStringEndsWith(PHPUnitConfigFile::DEFAULT_FILE_NAME, $filePath);
37
38
        $directoryPath = $config->getDirectory();
39
        $this->assertStringEndsWith($dir, $directoryPath);
40
    }
41
42
    public function testRelativeFilenameDoesNotUseDefaultFileName()
43
    {
44
        $file = 'StubbedXMLConfigs/stubbed_for_filter_test.xml';
45
46
        $config = new PHPUnitConfigFile($file);
47
48
        $filePath = $config->getFileFullPath();
49
50
        $this->assertStringEndsNotWith(PHPUnitConfigFile::DEFAULT_FILE_NAME, $filePath);
51
    }
52
53
    public function testRelativeDirectoryAndDefaultFileDoesNotExistThrowException()
54
    {
55
        $dir = 'PHPUnitOutput';
56
57
        $this->setExpectedException('InvalidArgumentException', PHPUnitConfigFile::DEFAULT_FILE_NAME . ' does not exist');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
58
59
        new PHPUnitConfigFile($dir);
60
    }
61
62
    public function testInvalidDirectoryProvidedThrowException()
63
    {
64
        $dir = 'foobar';
65
66
        $this->setExpectedException('InvalidArgumentException', 'Config path/file provided is not valid');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
67
68
        new PHPUnitConfigFile($dir);
69
    }
70
}
71