|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace N98\Magento\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
|
6
|
|
|
use N98\Magento\Command\PHPUnit\TestCase; |
|
7
|
|
|
|
|
8
|
|
|
class ScriptCommandTest extends TestCase |
|
9
|
|
|
{ |
|
|
|
|
|
|
10
|
|
|
/** @var null|\Magento\Framework\App\ProductMetadata */ |
|
11
|
|
|
protected $productMetadata = null; |
|
12
|
|
|
|
|
13
|
|
|
public function testExecute() |
|
14
|
|
|
{ |
|
15
|
|
|
$application = $this->getApplication(); |
|
16
|
|
|
$application->add(new ScriptCommand()); |
|
|
|
|
|
|
17
|
|
|
$application->setAutoExit(false); |
|
|
|
|
|
|
18
|
|
|
$command = $this->getApplication()->find('script'); |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
$commandTester = new CommandTester($command); |
|
21
|
|
|
$commandTester->execute( |
|
22
|
|
|
array( |
|
23
|
|
|
'command' => $command->getName(), |
|
24
|
|
|
'filename' => __DIR__ . '/_files/test.mr', |
|
25
|
|
|
) |
|
26
|
|
|
); |
|
27
|
|
|
|
|
28
|
|
|
// Check pre defined vars |
|
29
|
|
|
$this->assertContains('magento.root: ' . $this->getApplication()->getMagentoRootFolder(), $commandTester->getDisplay()); |
|
|
|
|
|
|
30
|
|
|
$this->assertContains('magento.version: ' . $this->getMagentoVersion(), $commandTester->getDisplay()); |
|
31
|
|
|
$this->assertContains('magento.edition: ' . $this->getMagentoEdition(), $commandTester->getDisplay()); |
|
32
|
|
|
|
|
33
|
|
|
$this->assertContains('magerun.version: ' . $this->getApplication()->getVersion(), $commandTester->getDisplay()); |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
$this->assertContains('code', $commandTester->getDisplay()); |
|
36
|
|
|
$this->assertContains('foo.sql', $commandTester->getDisplay()); |
|
37
|
|
|
$this->assertContains('BAR: foo.sql.gz', $commandTester->getDisplay()); |
|
38
|
|
|
$this->assertContains('Magento Websites', $commandTester->getDisplay()); |
|
39
|
|
|
$this->assertContains('web/secure/base_url', $commandTester->getDisplay()); |
|
40
|
|
|
$this->assertContains('web/seo/use_rewrites => 1', $commandTester->getDisplay()); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return string |
|
45
|
|
|
*/ |
|
46
|
|
|
protected function getMagentoVersion() |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->getProductMetadata()->getVersion(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* |
|
53
|
|
|
* @return mixed |
|
54
|
|
|
*/ |
|
55
|
|
|
protected function getMagentoEdition() |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->getProductMetadata()->getEdition(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return \Magento\Framework\App\ProductMetadata |
|
62
|
|
|
*/ |
|
63
|
|
View Code Duplication |
protected function getProductMetadata() |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
if(is_null($this->productMetadata)) { |
|
66
|
|
|
$objectManager = $this->getApplication()->getObjectManager(); |
|
|
|
|
|
|
67
|
|
|
$this->productMetadata = $objectManager->get('\Magento\Framework\App\ProductMetadata'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return $this->productMetadata; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|