Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.3-devel…
Browse files Browse the repository at this point in the history
…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
magento-engcom-team authored Sep 28, 2019
2 parents 41b9991 + 7254da3 commit f35c6eb
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
</strong>
<?= $block->getReviewsSummaryHtml($_product, $templateType) ?>
<?= /* @noEscape */ $block->getProductPrice($_product) ?>
<?= $block->getProductDetailsHtml($_product) ?>
<?php if ($_product->isAvailable()) :?>
<?= $block->getProductDetailsHtml($_product) ?>
<?php endif; ?>

<div class="product-item-inner">
<div class="product actions product-item-actions"<?= strpos($pos, $viewMode . '-actions') ? $block->escapeHtmlAttr($position) : '' ?>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,18 @@ public function __construct(
protected function _prepareShipment($invoice)
{
$invoiceData = $this->getRequest()->getParam('invoice');

$itemArr = [];
if (!isset($invoiceData['items']) || empty($invoiceData['items'])) {
$orderItems = $invoice->getOrder()->getItems();
foreach ($orderItems as $item) {
$itemArr[$item->getId()] = (int)$item->getQtyOrdered();
}
}
$shipment = $this->shipmentFactory->create(
$invoice->getOrder(),
isset($invoiceData['items']) ? $invoiceData['items'] : [],
isset($invoiceData['items']) ? $invoiceData['items'] : $itemArr,
$this->getRequest()->getPost('tracking')
);

if (!$shipment->getTotalQty()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,7 @@
<argument name="sortable" xsi:type="string">1</argument>
<argument name="index" xsi:type="string">display_in_terms</argument>
<argument name="type" xsi:type="string">options</argument>
<argument name="options" xsi:type="array">
<item name="yes" xsi:type="array">
<item name="value" xsi:type="string">1</item>
<item name="label" xsi:type="string" translate="true">yes</item>
</item>
<item name="no" xsi:type="array">
<item name="value" xsi:type="string">0</item>
<item name="label" xsi:type="string" translate="true">no</item>
</item>
</argument>
<argument name="options" xsi:type="options" model="Magento\Config\Model\Config\Source\Yesno"/>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.search.grid.columnSet.action" as="action">
Expand Down
11 changes: 10 additions & 1 deletion lib/internal/Magento/Framework/Console/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Magento\Setup\Application;
use Magento\Setup\Console\CompilerPreparation;
use Magento\Setup\Model\ObjectManagerProvider;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console;
use Magento\Framework\Config\ConfigOptionsListConstants;

Expand Down Expand Up @@ -61,6 +62,11 @@ class Cli extends Console\Application
*/
private $objectManager;

/**
* @var LoggerInterface
*/
private $logger;

/**
* @param string $name the application name
* @param string $version the application version
Expand Down Expand Up @@ -94,6 +100,7 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')

parent::__construct($name, $version);
$this->serviceManager->setService(\Symfony\Component\Console\Application::class, $this);
$this->logger = $this->objectManager->get(LoggerInterface::class);
}

/**
Expand All @@ -107,7 +114,9 @@ public function doRun(Console\Input\InputInterface $input, Console\Output\Output
try {
$exitCode = parent::doRun($input, $output);
} catch (\Exception $e) {
$output->writeln($e->getTraceAsString());
$errorMessage = $e->getMessage() . PHP_EOL . $e->getTraceAsString();
$this->logger->error($errorMessage);
$this->initException = $e;
}

if ($this->initException) {
Expand Down
81 changes: 81 additions & 0 deletions lib/internal/Magento/Framework/Console/Test/Unit/CliTest.php
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);
}
}

0 comments on commit f35c6eb

Please sign in to comment.