Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DbSchemaUpgradeCommandTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 use Symfony\Component\Console\Tester\CommandTester;
12 
13 class DbSchemaUpgradeCommandTest extends \PHPUnit\Framework\TestCase
14 {
18  private $installerFactory;
19 
23  private $deploymentConfig;
24 
25  protected function setUp()
26  {
27  $this->installerFactory = $this->createMock(\Magento\Setup\Model\InstallerFactory::class);
28  $this->deploymentConfig = $this->createMock(\Magento\Framework\App\DeploymentConfig::class);
29  }
30 
36  public function testExecute($options, $expectedOptions)
37  {
38  $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
39  $installer = $this->createMock(\Magento\Setup\Model\Installer::class);
40  $this->installerFactory->expects($this->once())->method('create')->will($this->returnValue($installer));
42  ->expects($this->once())
43  ->method('installSchema')
44  ->with($expectedOptions);
45 
46  $commandTester = new CommandTester(
47  new DbSchemaUpgradeCommand($this->installerFactory, $this->deploymentConfig)
48  );
49  $commandTester->execute($options);
50  }
51 
55  public function executeDataProvider()
56  {
57  return [
58  [
59  'options' => [
60  '--magento-init-params' => '',
61  '--convert-old-scripts' => false
62  ],
63  'expectedOptions' => [
64  'convert-old-scripts' => false,
65  'magento-init-params' => '',
66  ]
67  ],
68  ];
69  }
70 
71  public function testExecuteNoConfig()
72  {
73  $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
74  $this->installerFactory->expects($this->never())->method('create');
75 
76  $commandTester = new CommandTester(
77  new DbSchemaUpgradeCommand($this->installerFactory, $this->deploymentConfig)
78  );
79  $commandTester->execute([]);
80  $this->assertStringMatchesFormat(
81  'No information is available: the Magento application is not installed.%w',
82  $commandTester->getDisplay()
83  );
84  }
85 }
return false
Definition: gallery.phtml:36