![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/setup/src/Magento/Setup/Test/Unit/Console/Command/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Setup\Test\Unit\Console\Command; use Magento\Framework\App\DeploymentConfig; use Magento\Setup\Console\Command\DbSchemaUpgradeCommand; use Magento\Setup\Model\Installer; use Magento\Setup\Model\InstallerFactory; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; class DbSchemaUpgradeCommandTest extends TestCase { /** * @var InstallerFactory|MockObject */ private $installerFactory; /** * @var DeploymentConfig|MockObject */ private $deploymentConfig; protected function setUp(): void { $this->installerFactory = $this->createMock(InstallerFactory::class); $this->deploymentConfig = $this->createMock(DeploymentConfig::class); } /** * @dataProvider executeDataProvider * @param $options * @param $expectedOptions */ public function testExecute($options, $expectedOptions) { $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true); $installer = $this->createMock(Installer::class); $this->installerFactory->expects($this->once())->method('create')->willReturn($installer); $installer ->expects($this->once()) ->method('installSchema') ->with($expectedOptions); $commandTester = new CommandTester( new DbSchemaUpgradeCommand($this->installerFactory, $this->deploymentConfig) ); $commandTester->execute($options); } /** * @return array */ public function executeDataProvider() { return [ [ 'options' => [ '--magento-init-params' => '', '--convert-old-scripts' => false ], 'expectedOptions' => [ 'convert-old-scripts' => false, 'magento-init-params' => '', ] ], ]; } public function testExecuteNoConfig() { $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false); $this->installerFactory->expects($this->never())->method('create'); $commandTester = new CommandTester( new DbSchemaUpgradeCommand($this->installerFactory, $this->deploymentConfig) ); $commandTester->execute([]); $this->assertStringMatchesFormat( 'No information is available: the Magento application is not installed.%w', $commandTester->getDisplay() ); } }