-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔃 [Magento Community Engineering] Community Contributions - 2.3-devel…
…op expedited Accepted Community Pull Requests: - #24741: Resolve Suggested Terms Yes/No not in camel case #24739 (by @edenduong) - #24734: #24043: Better exception handling during cli commands. (by @p-bystritsky) - #24728: Fixed LayeredNavigation color filter show only loader for out of stock product (by @ravi-chandra3197) - #24494: #14012 fixed (by @vishalverma279) Fixed GitHub Issues: - #24739: Suggested Terms Yes/No not in camel case (reported by @bhavik43) has been fixed in #24741 by @edenduong in 2.3-develop branch Related commits: 1. 1ed98c6 - #24043: Better exception handling during cli commands (reported by @PascalBrouwers) has been fixed in #24734 by @p-bystritsky in 2.3-develop branch Related commits: 1. dfd481d - #24678: Static Content Deploy in developer mode without force flag is broken in 2.3-develop (reported by @hostep) has been fixed in #24734 by @p-bystritsky in 2.3-develop branch Related commits: 1. dfd481d - #14012: 2.2 - Admin will not create shipment from the invoice create screen if credit card was used (reported by @mzenner1) has been fixed in #24494 by @vishalverma279 in 2.3-develop branch Related commits: 1. 529e19d
- Loading branch information
Showing
5 changed files
with
103 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
lib/internal/Magento/Framework/Console/Test/Unit/CliTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Framework\Console\Test\Unit; | ||
|
||
use Magento\Framework\Console\Cli; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Test for Magento\Framework\Console\Cli class. | ||
*/ | ||
class CliTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var Cli | ||
*/ | ||
private $cli; | ||
|
||
/** | ||
* @var InputInterface|MockObject | ||
*/ | ||
private $inputMock; | ||
|
||
/** | ||
* @var OutputInterface|MockObject | ||
*/ | ||
private $outputMock; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->inputMock = $this->getMockBuilder(InputInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->outputMock = $this->getMockBuilder(OutputInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->cli = new Cli(); | ||
} | ||
|
||
/** | ||
* Make sure exception message is displayed and trace is logged. | ||
* | ||
* @expectedException \Exception | ||
* @expectedExceptionMessage Test message | ||
*/ | ||
public function testDoRunExceptionLogging() | ||
{ | ||
$e = new \Exception('Test message'); | ||
$this->inputMock->expects($this->once())->method('getFirstArgument')->willThrowException($e); | ||
$loggerMock = $this->createMock(LoggerInterface::class); | ||
$loggerMock->expects($this->once()) | ||
->method('error') | ||
->with($e->getMessage() . PHP_EOL . $e->getTraceAsString()); | ||
$this->injectMock($loggerMock, 'logger'); | ||
|
||
$this->cli->doRun($this->inputMock, $this->outputMock); | ||
} | ||
|
||
/** | ||
* Inject mock to Cli property. | ||
* | ||
* @param MockObject $mockObject | ||
* @param string $propertyName | ||
* @throws \ReflectionException | ||
*/ | ||
private function injectMock(MockObject $mockObject, string $propertyName): void | ||
{ | ||
$reflection = new \ReflectionClass(Cli::class); | ||
$reflectionProperty = $reflection->getProperty($propertyName); | ||
$reflectionProperty->setAccessible(true); | ||
$reflectionProperty->setValue($this->cli, $mockObject); | ||
} | ||
} |