1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\System\Setup; |
4
|
|
|
|
5
|
|
|
use N98\Magento\Command\PHPUnit\TestCase; |
6
|
|
|
|
7
|
|
|
class AbstractSetupCommandTest extends TestCase |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Mocked command |
11
|
|
|
* @var Mock_AbstractSetupCommand |
12
|
|
|
*/ |
13
|
|
|
protected $command; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Set up the mocked command for testing |
17
|
|
|
*/ |
18
|
|
|
public function setUp() |
19
|
|
|
{ |
20
|
|
|
$moduleListMock = $this->getMockBuilder('Magento\Framework\Module\ModuleList') |
21
|
|
|
->setMethods(array('getAll')) |
22
|
|
|
->getMock(); |
23
|
|
|
|
24
|
|
|
$moduleListMock |
25
|
|
|
->expects($this->once()) |
26
|
|
|
->method('getAll') |
27
|
|
|
->will($this->returnValue(array('Magento_Catalog' => 'info', 'Magento_Customer' => 'info'))); |
28
|
|
|
|
29
|
|
|
// Test one its children since the framework expects to be testing commands |
30
|
|
|
$this->command = $this->getMockBuilder('N98\Magento\Command\System\Setup\AbstractSetupCommand') |
31
|
|
|
->disableOriginalConstructor() |
32
|
|
|
->setMethods(array('getMagentoModuleList')) |
33
|
|
|
->getMockForAbstractClass(); |
34
|
|
|
|
35
|
|
|
$this->command |
36
|
|
|
->expects($this->once()) |
37
|
|
|
->method('getMagentoModuleList') |
38
|
|
|
->will($this->returnValue($moduleListMock)); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Test the getMagentoModuleName() method returns the actual module name when it exists |
43
|
|
|
* @param string $moduleName |
44
|
|
|
* |
45
|
|
|
* @dataProvider validModuleNameProvider |
46
|
|
|
*/ |
47
|
|
|
public function testShouldReturnModuleNameForExistingModule($moduleName) |
48
|
|
|
{ |
49
|
|
|
$result = $this->command->getMagentoModuleName($moduleName); |
50
|
|
|
$this->assertStringStartsWith('Magento', $result); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Provide some inconsistently cased module names |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
public function validModuleNameProvider() |
58
|
|
|
{ |
59
|
|
|
return array( |
60
|
|
|
array('magento_catalog'), |
61
|
|
|
array('magento_customer'), |
62
|
|
|
array('Magento_Catalog'), |
63
|
|
|
array('MaGeNtO_cUstOmeR') |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Ensure that an exception is thrown when a module doesn't exist |
69
|
|
|
* @expectedException InvalidArgumentException |
70
|
|
|
*/ |
71
|
|
|
public function testShouldThrowExceptionWhenModuleDoesntExist() |
72
|
|
|
{ |
73
|
|
|
$this->command->getMagentoModuleName('Some_Module_That_Will_Never_Exist'); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|