|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace N98\Magento\Command\Database\Maintain; |
|
4
|
|
|
|
|
5
|
|
|
use N98\Magento\Command\PHPUnit\TestCase; |
|
6
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @see \N98\Magento\Command\Database\Maintain\CheckTablesCommand |
|
10
|
|
|
*/ |
|
11
|
|
|
class CheckTablesCommandTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
public function testExecuteMyIsam() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->markTestSkipped('Currently we have no myisam tables in a magento2 installation'); |
|
16
|
|
|
|
|
17
|
|
|
$command = $this->getCommand(); |
|
18
|
|
|
|
|
19
|
|
|
$commandTester = new CommandTester($command); |
|
20
|
|
|
$commandTester->execute( |
|
21
|
|
|
array( |
|
22
|
|
|
'command' => $command->getName(), |
|
23
|
|
|
'--format' => 'csv', |
|
24
|
|
|
'--type' => 'quick', |
|
25
|
|
|
'--table' => 'oauth_nonce', |
|
26
|
|
|
) |
|
27
|
|
|
); |
|
28
|
|
|
$this->assertContains('oauth_nonce,check,quick,OK', $commandTester->getDisplay()); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testExecuteInnoDb() |
|
32
|
|
|
{ |
|
33
|
|
|
$command = $this->getCommand(); |
|
34
|
|
|
|
|
35
|
|
|
$commandTester = new CommandTester($command); |
|
36
|
|
|
$commandTester->execute( |
|
37
|
|
|
array( |
|
38
|
|
|
'command' => $command->getName(), |
|
39
|
|
|
'--format' => 'csv', |
|
40
|
|
|
'--type' => 'quick', |
|
41
|
|
|
'--table' => 'catalog_product_entity_media_gallery*', |
|
42
|
|
|
) |
|
43
|
|
|
); |
|
44
|
|
|
$timeRegex = '"\s+[0-9]+\srows","[0-9\.]+\ssecs"'; |
|
45
|
|
|
$this->assertRegExp( |
|
46
|
|
|
'~catalog_product_entity_media_gallery,"ENGINE InnoDB",' . $timeRegex . '~', |
|
47
|
|
|
$commandTester->getDisplay() |
|
48
|
|
|
); |
|
49
|
|
|
$this->assertRegExp( |
|
50
|
|
|
'~catalog_product_entity_media_gallery_value,"ENGINE InnoDB",' . $timeRegex . '~', |
|
51
|
|
|
$commandTester->getDisplay() |
|
52
|
|
|
); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return \Symfony\Component\Console\Command\Command |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function getCommand() |
|
59
|
|
|
{ |
|
60
|
|
|
$application = $this->getApplication(); |
|
61
|
|
|
$application->add(new CheckTablesCommand()); |
|
|
|
|
|
|
62
|
|
|
$command = $this->getApplication()->find('db:maintain:check-tables'); |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
return $command; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: