Completed
Pull Request — master (#213)
by Thomas
07:42
created

ConfigReaderTest::testGetByPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
namespace Owncloud\Updater\Tests\Utils;
4
5
use Owncloud\Updater\Utils\ConfigReader;
6
7
class ConfigReaderTest extends \PHPUnit_Framework_TestCase {
8
9
	protected $config = [
10
		"system" => [
11
			"instanceid" => "oc8v9kkjo6bh",
12
			"ldapIgnoreNamingRules" => false,
13
		],
14
		"apps" => [
15
			"backgroundjob" => [
16
				"lastjob" => "3"
17
			],
18
			"core" => [
19
				"installedat" => "1423763974.698",
20
				"lastupdatedat" => "1450277990",
21
				"lastcron" => "1444753126",
22
				"OC_Channel" => "beta",
23
			],
24
			"dav" => [
25
				"installed_version" => "0.1.3",
26
				"types" => "filesystem",
27
				"enabled" => "yes"
28
			]
29
		]
30
	];
31
32
	public function testGetByPathProvider(){
33
		return [
34
				[ 'apps.core.OC_Channel', 'beta']
35
		];
36
	}
37
38
	/**
39
	 * @dataProvider testGetByPathProvider
40
	 */
41
	public function testGetByPath($key, $expected){
42
		$occRunnerMock = $this->getOccRunnerMock(json_encode($this->config));
43
		$configReader = new ConfigReader($occRunnerMock);
44
		$configReader->init();
45
		$value = $configReader->getByPath($key);
46
		$this->assertEquals($expected, $value);
47
	}
48
49 View Code Duplication
	protected function getOccRunnerMock($result){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
		$runnerMock = $this->getMockBuilder('Owncloud\Updater\Utils\OccRunner')
51
				->setMethods(['run'])
52
				->disableOriginalConstructor()
53
				->getMock()
54
		;
55
		$runnerMock
56
				->expects($this->any())
57
				->method('run')
58
				->willReturn($result)
59
		;
60
		return $runnerMock;
61
	}
62
63
}
64