1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverLeague\Console\Tests\Command\Object; |
4
|
|
|
|
5
|
|
|
use SilverLeague\Console\Tests\Command\AbstractCommandTest; |
6
|
|
|
use SilverStripe\Assets\AssetControlExtension; |
7
|
|
|
use SilverStripe\Security\Member; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @coversDefaultClass \SilverLeague\Console\Command\Object\ExtensionsCommand |
11
|
|
|
* @package silverstripe-console |
12
|
|
|
* @author Robbie Averill <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class ExtensionsCommandTest extends AbstractCommandTest |
15
|
|
|
{ |
16
|
|
|
protected function getTestCommand() |
17
|
|
|
{ |
18
|
|
|
return 'object:extensions'; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Ensure that the Injector's class resolution is returned for a given Object |
23
|
|
|
* |
24
|
|
|
* @covers ::execute |
25
|
|
|
*/ |
26
|
|
View Code Duplication |
public function testExecute() |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
$tester = $this->executeTest(['object' => Member::class]); |
29
|
|
|
$output = $tester->getDisplay(); |
30
|
|
|
$this->assertContains(AssetControlExtension::class, $output); |
31
|
|
|
$this->assertContains('silverstripe/assets', $output); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Ensure that the InputArgument for the object is added |
36
|
|
|
* |
37
|
|
|
* @covers ::configure |
38
|
|
|
*/ |
39
|
|
|
public function testConfigure() |
40
|
|
|
{ |
41
|
|
|
$this->assertTrue($this->command->getDefinition()->hasArgument('object')); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Ensure that extra headers are added for CMS pages |
46
|
|
|
* |
47
|
|
|
* @covers ::getRows |
48
|
|
|
* @dataProvider rowsProvider |
49
|
|
|
* |
50
|
|
|
* @param array $extensions |
51
|
|
|
* @param string[] $expected |
52
|
|
|
*/ |
53
|
|
|
public function testGetRows($extensions, $expected) |
54
|
|
|
{ |
55
|
|
|
$this->assertSame($expected, $this->command->getRows($extensions)); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return array[] |
60
|
|
|
*/ |
61
|
|
|
public function rowsProvider() |
62
|
|
|
{ |
63
|
|
|
$extensions = [ |
64
|
|
|
AssetControlExtension::class, |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
return [ |
68
|
|
|
[ |
69
|
|
|
$extensions, |
70
|
|
|
[array_merge($extensions, ['silverstripe/assets', 0])], |
71
|
|
|
], |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
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.