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

testRelativeDirectoryDoesUseDefaultFileName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
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