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