Completed
Push — master ( e5e771...ea902a )
by Thomas
02:47
created

AppManagerTest::testGetAppPath()   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 0
1
<?php
2
3
namespace Owncloud\Updater\Tests\Utils;
4
5
use Owncloud\Updater\Utils\AppManager;
6
7
class AppManagerTest extends \PHPUnit_Framework_TestCase {
8
9 View Code Duplication
	public function testDisableApp(){
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...
10
		$appId = 'anyapp';
11
		$appManager = new AppManager($this->getOccRunnerMock(''));
12
		$result = $appManager->disableApp($appId);
13
		$this->assertTrue($result);
14
	}
15
16 View Code Duplication
	public function testEnableApp(){
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...
17
		$appId = 'anyapp';
18
		$appManager = new AppManager($this->getOccRunnerMock(''));
19
		$result = $appManager->enableApp($appId);
20
		$this->assertTrue($result);
21
	}
22
23
	public function appListProvider(){
24
		return [
25
26
					[
27
						[
28
							'enabled' => [ 'app1' => '1.0.1', 'app2' => '2.4.1' ],
29
							'disabled' => [	'dapp1' => '0.0.1',	'dapp2' => '5.1.1' ]
30
						],
31
						[ 'app1', 'app2', 'dapp1', 'dapp2'	]
32
					]
33
		];
34
	}
35
36
	/**
37
	 * @dataProvider appListProvider
38
	 */
39 View Code Duplication
	public function testGetAllApps($apps, $expected){
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...
40
		$encoded = json_encode($apps);
41
		$appManager = new AppManager($this->getOccRunnerMock($encoded));
42
		$actual = $appManager->getShippedApps();
43
		$this->assertEquals($expected, $actual);
44
	}
45
46
	/**
47
	 * @dataProvider appListProvider
48
	*/
49 View Code Duplication
	public function testGetShippedApps($apps, $expected){
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
		$encoded = json_encode($apps);
51
		$appManager = new AppManager($this->getOccRunnerMock($encoded));
52
		$actual = $appManager->getShippedApps();
53
		$this->assertEquals($expected, $actual);
54
	}
55
56
	public function testGetAppPath(){
57
		$expected = '/dev/null';
58
		$appId = 'anyapp';
59
		$appManager =  new AppManager($this->getOccRunnerMock($expected));
60
		$actual = $appManager->getAppPath($appId);
61
		$this->assertEquals($expected, $actual);
62
	}
63
64 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...
65
		$runnerMock = $this->getMockBuilder('Owncloud\Updater\Utils\OccRunner')
66
				->setMethods(['run'])
67
				->disableOriginalConstructor()
68
				->getMock()
69
		;
70
		$runnerMock
71
				->expects($this->any())
72
				->method('run')
73
				->willReturn($result)
74
		;
75
		return $runnerMock;
76
	}
77
78
}
79