-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
ConfigTest.php
86 lines (67 loc) · 1.99 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare(strict_types=1);
namespace Roots\WPConfig;
use PHPUnit\Framework\TestCase;
use Roots\WPConfig\Exceptions\ConstantAlreadyDefinedException;
use Roots\WPConfig\Exceptions\UndefinedConfigKeyException;
/**
* @runTestsInSeparateProcesses
*/
class ConfigTest extends TestCase
{
public function testDefineHappy() {
Config::define('WP_SCRIPT_DEBUG', true);
$this->assertEquals(true, Config::get('WP_SCRIPT_DEBUG'));
}
public function testDefineSad() {
$this->expectException(ConstantAlreadyDefinedException::class);
define('WP_SCRIPT_DEBUG', false);
Config::define('WP_SCRIPT_DEBUG', true);
}
public function testApplyHappy()
{
Config::define('WP_SCRIPT_DEBUG', true);
Config::apply();
$this->assertTrue(WP_SCRIPT_DEBUG);
}
public function testApplyRedefine()
{
$this->expectException(ConstantAlreadyDefinedException::class);
Config::define('WP_SCRIPT_DEBUG', true);
define('WP_SCRIPT_DEBUG', false);
Config::apply();
}
public function testReapply()
{
Config::define('WP_SCRIPT_DEBUG', true);
Config::apply();
Config::define('AUSTIN', 'PRO');
Config::apply();
$this->assertTrue(WP_SCRIPT_DEBUG);
}
/* Below are not used in Bedrock */
public function testGetHappy()
{
Config::define('WP_SCRIPT_DEBUG', true);
Config::define('AUSTIN', 'PRO');
Config::define('CRAIG', -1);
Config::define('KALEN', 1);
$this->assertEquals(true, Config::get('WP_SCRIPT_DEBUG'));
$this->assertEquals('PRO', Config::get('AUSTIN'));
$this->assertEquals(-1, Config::get('CRAIG'));
$this->assertEquals(1, Config::get('KALEN'));
}
public function testGetSad()
{
$this->expectException(UndefinedConfigKeyException::class);
Config::get('WORDPRESS_SANITY');
}
public function testRemove()
{
$this->expectException(UndefinedConfigKeyException::class);
Config::remove('NEVER_EXISTED');
Config::define('EXISTS', 'yep');
Config::remove('EXISTS');
Config::get('EXISTS');
}
}