Completed
Push — master ( bb7259...dc298a )
by Sam
03:00
created

ParserTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 1
cbo 5
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testParser() 0 28 1
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 &copy; 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