1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jalle19\StatusManager\Test\Configuration; |
4
|
|
|
|
5
|
|
|
use Jalle19\StatusManager\Configuration\Parser; |
6
|
|
|
use Jalle19\StatusManager\Configuration\Reader\ArrayReader; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class ParserTest |
10
|
|
|
* @package Jalle19\StatusManager\Test\Configuration |
11
|
|
|
* @copyright Copyright © Sam Stenvall 2016- |
12
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0 |
13
|
|
|
*/ |
14
|
|
|
class ParserTest extends \PHPUnit_Framework_TestCase |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
use BasicConfigurationTrait; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
public function testParser() |
21
|
|
|
{ |
22
|
|
|
$rawConfiguration = $this->getBaseConfiguration(); |
23
|
|
|
|
24
|
|
|
// Configure two instances |
25
|
|
|
$rawConfiguration['instances'] = [ |
26
|
|
|
'example.com' => [ |
27
|
|
|
'address' => 'example.com', |
28
|
|
|
'port' => 9981, |
29
|
|
|
], |
30
|
|
|
'foo.example.com' => [ |
31
|
|
|
'address' => 'foo.example.com', |
32
|
|
|
'port' => 9981, |
33
|
|
|
], |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
$configuration = Parser::parseConfiguration(new ArrayReader($rawConfiguration)); |
37
|
|
|
|
38
|
|
|
$this->assertEquals($rawConfiguration['database_path'], $configuration->getDatabasePath()); |
39
|
|
|
$this->assertEquals($rawConfiguration['log_path'], $configuration->getLogPath()); |
40
|
|
|
$this->assertEquals($rawConfiguration['access_token'], $configuration->getAccessToken()); |
41
|
|
|
$this->assertCount(2, $configuration->getInstances()); |
42
|
|
|
$this->assertEquals('example.com', $configuration->getInstanceByName('example.com')->getName()); |
43
|
|
|
$this->assertEquals('foo.example.com', $configuration->getInstanceByName('foo.example.com')->getName()); |
44
|
|
|
$this->assertEquals($rawConfiguration['update_interval'], $configuration->getUpdateInterval()); |
45
|
|
|
$this->assertEquals($rawConfiguration['listen_address'], $configuration->getListenAddress()); |
46
|
|
|
$this->assertEquals($rawConfiguration['listen_port'], $configuration->getListenPort()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
} |
50
|
|
|
|