-
Notifications
You must be signed in to change notification settings - Fork 58
/
ConfigTest.php
53 lines (46 loc) · 1.66 KB
/
ConfigTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Edge\QA;
class ConfigTest extends \PHPUnit_Framework_TestCase
{
public function testLoadDefaultConfig()
{
$config = new Config();
assertThat($config->value('phpcpd.minLines'), is(greaterThan(0)));
assertThat($config->value('phpcpd.minTokens'), is(greaterThan(0)));
assertThat($config->value('phpcs.standard'), is(nonEmptyString()));
assertThat($config->path('phpmd.standard'), is(nonEmptyString()));
assertThat($config->value('phpstan.level'), identicalTo(0));
}
public function testBuildAbsolutePath()
{
$config = new Config();
assertThat($config->path('phpmd.standard'), not(startsWith('app/')));
}
public function testOverrideDefaultConfig()
{
$config = new Config();
$config->loadCustomConfig(__DIR__);
assertThat($config->value('phpcpd.minLines'), is(5));
assertThat($config->value('phpcpd.minTokens'), is(70));
assertThat($config->value('phpcs.standard'), is('Zend'));
assertThat($config->path('phpmd.standard'), is(__DIR__ . "/my-standard.xml"));
}
public function testIgnoreNonExistentUserConfig()
{
$directoryWithoutConfig = __DIR__ . '/../';
$config = new Config();
$this->shouldStopPhpqa();
$config->loadCustomConfig($directoryWithoutConfig, true);
}
public function testThrowExceptionWhenFileDoesNotExist()
{
$config = new Config();
$config->loadCustomConfig(__DIR__);
$this->shouldStopPhpqa();
$config->path('phpcs.standard');
}
private function shouldStopPhpqa()
{
$this->setExpectedException('Exception');
}
}