forked from ankitpokhrel/tus-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigTest.php
More file actions
101 lines (87 loc) 路 2.04 KB
/
Copy pathConfigTest.php
File metadata and controls
101 lines (87 loc) 路 2.04 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace TusPhp\Test;
use TusPhp\Config;
use PHPUnit\Framework\TestCase;
/**
* @coversDefaultClass \TusPhp\Config
*/
class ConfigTest extends TestCase
{
/** @var array */
protected $config;
/**
* Prepare vars.
*
* @return void
*/
public function setUp() : void
{
parent::setUp();
$this->config = require __DIR__ . '/Fixtures/config.php';
}
/**
* @test
*
* @covers ::set
* @covers ::get
*/
public function it_loads_config_from_array() : void
{
$config = [
'redis' => [
'host' => '129.0.0.1',
'port' => '6381',
'database' => 15,
],
'file' => [
'dir' => '/var/www/.cache/',
'name' => 'tus_php.cache',
],
];
Config::set($config, true);
$this->assertEquals($config, Config::get());
}
/**
* @test
*
* @covers ::set
* @covers ::get
*/
public function it_loads_config_from_file() : void
{
Config::set(__DIR__ . '/Fixtures/config.php', true);
$this->assertEquals($this->config, Config::get());
}
/**
* @test
*
* @covers ::set
* @covers ::get
*/
public function it_should_not_load_config_if_config_is_set() : void
{
Config::set([]);
$this->assertNotEmpty(Config::get());
$this->assertEquals($this->config, Config::get());
}
/**
* @test
*
* @covers ::get
*/
public function it_gets_value_for_a_key() : void
{
$this->assertEquals($this->config['redis'], Config::get('redis'));
$this->assertEquals($this->config['redis']['host'], Config::get('redis.host'));
$this->assertEquals($this->config['file']['meta']['name'], Config::get('file.meta.name'));
}
/**
* @test
*
* @covers ::get
*/
public function it_returns_null_for_invalid_key() : void
{
$this->assertNull(Config::get('redis.invalid'));
}
}