-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigTest.php
60 lines (54 loc) · 1.62 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
<?php
namespace F3\PimpleConfig;
use PHPUnit\Framework\TestCase;
use Pimple\Container;
class ConfigTest extends TestCase
{
public function testExampleProd()
{
$container = new Container();
$container->register(new Config(__DIR__ . '/example', 'prod'));
$this->assertEquals(
'prod',
$container['env'],
'Environment name is set correctly'
);
$this->assertFalse(
$container['debug'],
'Debug is disabled in prod'
);
$this->assertEquals(
'foo is common_foo, bar is prod_bar, password is s3(r37p455w0rd',
$container['hello'],
'Hello service returns the correct string'
);
}
public function testExampleDev()
{
$container = new Container();
$container->register(new Config(__DIR__ . '/example', 'dev'));
$this->assertEquals(
'dev',
$container['env'],
'Environment name is set correctly'
);
$this->assertTrue(
$container['debug'],
'Debug is enabled in dev'
);
$this->assertEquals(
'foo is dev_foo, bar is common_bar, password is dev_password',
$container['hello'],
'Hello service returns the correct string'
);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Configuration not found for stage
*/
public function testInvalidEnvName()
{
$container = new Container();
$container->register(new Config(__DIR__ . '/example', 'stage'));
}
}