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\ListInterface') |
21
|
|
|
->disableOriginalConstructor() |
22
|
|
|
->setMethods(array('getAll')) |
23
|
|
|
->getMock(); |
24
|
|
|
|
25
|
|
|
$moduleListMock |
26
|
|
|
->expects($this->once()) |
27
|
|
|
->method('getAll') |
28
|
|
|
->will($this->returnValue(array('Magento_Catalog' => 'info', 'Magento_Customer' => 'info'))); |
29
|
|
|
|
30
|
|
|
// Test one its children since the framework expects to be testing commands |
31
|
|
|
$this->command = $this->getMockBuilder('N98\Magento\Command\System\Setup\AbstractSetupCommand') |
32
|
|
|
->disableOriginalConstructor() |
33
|
|
|
->setMethods(array('getMagentoModuleList')) |
34
|
|
|
->getMockForAbstractClass(); |
35
|
|
|
|
36
|
|
|
$this->command |
37
|
|
|
->expects($this->once()) |
38
|
|
|
->method('getMagentoModuleList') |
39
|
|
|
->will($this->returnValue($moduleListMock)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Test the getMagentoModuleName() method returns the actual module name when it exists |
44
|
|
|
* @param string $moduleName |
45
|
|
|
* |
46
|
|
|
* @dataProvider validModuleNameProvider |
47
|
|
|
*/ |
48
|
|
|
public function testShouldReturnModuleNameForExistingModule($moduleName) |
49
|
|
|
{ |
50
|
|
|
$result = $this->command->getMagentoModuleName($moduleName); |
51
|
|
|
$this->assertStringStartsWith('Magento', $result); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Provide some inconsistently cased module names |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function validModuleNameProvider() |
59
|
|
|
{ |
60
|
|
|
return array( |
61
|
|
|
array('magento_catalog'), |
62
|
|
|
array('magento_customer'), |
63
|
|
|
array('Magento_Catalog'), |
64
|
|
|
array('MaGeNtO_cUstOmeR') |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Ensure that an exception is thrown when a module doesn't exist |
70
|
|
|
* @expectedException InvalidArgumentException |
71
|
|
|
*/ |
72
|
|
|
public function testShouldThrowExceptionWhenModuleDoesntExist() |
73
|
|
|
{ |
74
|
|
|
$this->command->getMagentoModuleName('Some_Module_That_Will_Never_Exist'); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|