Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #18708: Cover \Magento\GiftMessage\Observer\SalesEventQuoteMerge with Unit test (by @vasilii-b)
 - #18733: Correct a typo in the reference to ISO language codes (by @mage2pratik)
 - #18723: Updated links in README (by @StrikerRUS)
 - #18694: Added Unit Test for WindowsSmtpConfig Plugin (by @vasilii-b)
 - #18707: Cover \Magento\Email\Model\Template\SenderResolver class with Unit test (by @vasilii-b)
 - #18710: [Elasticsearch] Covering the CategoryProductIndexer by Unit Test (by @eduard13)
 - #18284: save the custom option price when it is 0 (by @amatanovic)
 - #18702: [Forwardport][2.3] of MAGETWO-93818: Magnifier function does not disappear after mouse-off the image from the bottom (by @gwharton)
 - #17300: Add ReadFactory and WriteFactory to Magento's public API (by @navarr)
 - #17296: Add Value to Magento Framework's public API (by @navarr)
 - #18671: Remove unnecessary class import, see #18117 (by @sreichel)
 - #18667: Fixed class name issue in comment (by @gelanivishal)
 - #18627: Fixed incorrect datepicker icon position in admin panel (by @rogyar)
 - #18614: Braintree Paypal Review: check if variable is array when validating request data (by @deninchoo)
 - #18488: Fix issue with unexpected changing of subscription status after customer saving (by @alexeya-ven)
 - #18333: Support of error pages behind a load balancer that serves HTTPS  (by @stkams)
 - #18080: Add checkout_cart_product_add_before event #17830 (by @leandro-rosa)


Fixed GitHub Issues:
 - #2686: 500 Internal Server Error upon clicking SAVE button of product record adding/editing (reported by @protodevsystems) has been fixed in #18733 by @mage2pratik in 2.3-develop branch
   Related commits:
     1. a4b5cc1

 - #17616: Importer fails when updating an existing product with custom options (reported by @simonworkhouse) has been fixed in #18284 by @amatanovic in 2.3-develop branch
   Related commits:
     1. 4c76f9a
     2. 74ca77c

 - #15035: [2.2.4] Gallery Magnifier hover event does not always cancel magnifier when mouse leaves gallery (reported by @gwharton) has been fixed in #18702 by @gwharton in 2.3-develop branch
   Related commits:
     1. 031d8ec
     2. 4b76ffd

 - #18605: Calendar Icon is displaced at the Backend (reported by @larsroettig) has been fixed in #18627 by @rogyar in 2.3-develop branch
   Related commits:
     1. 3f0e9a4

 - #17830: Add checkout_cart_product_add_before event (reported by @peterjaap) has been fixed in #18080 by @leandro-rosa in 2.3-develop branch
   Related commits:
     1. 7b728b1
     2. f9389ad
     3. fef2205
     4. 0de795a
  • Loading branch information
Stanislav Idolov authored Oct 25, 2018
2 parents 2e036c4 + b7190c7 commit 5916c5a
Show file tree
Hide file tree
Showing 20 changed files with 583 additions and 52 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.

## Magento system requirements
[Magento system requirements](http://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html).
[Magento system requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html).

## Install Magento

* [Installation guide](http://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html).
* [Installation guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html).

<h2>Contributing to the Magento 2 code base</h2>
Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions.
Expand All @@ -21,10 +21,10 @@ To learn about issues, click [here][2]. To open an issue, click [here][3].

To suggest documentation improvements, click [here][4].

[1]: <http://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html>
[2]: <http://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#report>
[1]: <https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html>
[2]: <https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#report>
[3]: <https://github.com/magento/magento2/issues>
[4]: <http://devdocs.magento.com>
[4]: <https://devdocs.magento.com>

<h3>Community Maintainers</h3>
The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions.
Expand Down Expand Up @@ -53,9 +53,9 @@ Stay up-to-date on the latest security news and patches for Magento by signing u

Each Magento source file included in this distribution is licensed under OSL 3.0 or the Magento Enterprise Edition (MEE) license.

http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Please see LICENSE.txt for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.
[Open Software License (OSL 3.0)](https://opensource.org/licenses/osl-3.0.php).
Please see [LICENSE.txt](https://github.com/magento/magento2/blob/2.3-develop/LICENSE.txt) for the full text of the OSL 3.0 license or contact license@magentocommerce.com for a copy.

Subject to Licensee's payment of fees and compliance with the terms and conditions of the MEE License, the MEE License supersedes the OSL 3.0 license for each source file.
Please see LICENSE_EE.txt for the full text of the MEE License or visit http://magento.com/legal/terms/enterprise.
Please see LICENSE_EE.txt for the full text of the MEE License or visit https://magento.com/legal/terms/enterprise.

6 changes: 4 additions & 2 deletions app/code/Magento/AdminNotification/Block/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace Magento\AdminNotification\Block;

/**
* Admin notification window block
*
* @api
* @since 100.0.2
*/
Expand Down Expand Up @@ -40,7 +42,7 @@ class Window extends \Magento\Backend\Block\Template
protected $_criticalCollection;

/**
* @var \Magento\Adminnotification\Model\Inbox
* @var \Magento\AdminNotification\Model\Inbox
*/
protected $_latestItem;

Expand Down Expand Up @@ -92,7 +94,7 @@ protected function _toHtml()
/**
* Retrieve latest critical item
*
* @return bool|\Magento\Adminnotification\Model\Inbox
* @return bool|\Magento\AdminNotification\Model\Inbox
*/
protected function _getLatestItem()
{
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/Braintree/Controller/Paypal/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
use Magento\Braintree\Gateway\Config\PayPal\Config;
use Magento\Braintree\Model\Paypal\Helper\QuoteUpdater;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\App\Action\HttpPostActionInterface;

/**
* Class Review
*/
class Review extends AbstractAction
class Review extends AbstractAction implements HttpPostActionInterface
{
/**
* @var QuoteUpdater
Expand Down Expand Up @@ -60,7 +61,7 @@ public function execute()
try {
$this->validateQuote($quote);

if ($this->validateRequestData($requestData)) {
if ($requestData && $this->validateRequestData($requestData)) {
$this->quoteUpdater->execute(
$requestData['nonce'],
$requestData['details'],
Expand Down Expand Up @@ -91,6 +92,8 @@ public function execute()
}

/**
* Validate request data
*
* @param array $requestData
* @return boolean
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,8 @@ protected function _getSpecificTypeData(array $rowData, $optionTypeId, $defaultS
];

$priceData = false;
if (!empty($rowData[self::COLUMN_ROW_PRICE])) {
$customOptionRowPrice = $rowData[self::COLUMN_ROW_PRICE];
if (!empty($customOptionRowPrice) || $customOptionRowPrice === '0') {
$priceData = [
'price' => (double)rtrim($rowData[self::COLUMN_ROW_PRICE], '%'),
'price_type' => 'fixed',
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Checkout/Model/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ public function addProduct($productInfo, $requestInfo = null)
}

try {
$this->_eventManager->dispatch(
'checkout_cart_product_add_before',
['info' => $requestInfo, 'product' => $product]
);
$result = $this->getQuote()->addProduct($product, $request);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->_checkoutSession->setUseNotice(false);
Expand Down Expand Up @@ -615,6 +619,8 @@ public function truncate()
}

/**
* Get product ids.
*
* @return int[]
*/
public function getProductIds()
Expand Down
23 changes: 18 additions & 5 deletions app/code/Magento/Checkout/Test/Unit/Model/CartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,20 @@ public function testAddProduct($productInfo, $requestInfo)
$this->productRepository->expects($this->any())
->method('getById')
->will($this->returnValue($product));

$this->eventManagerMock->expects($this->at(0))->method('dispatch')->with(
'checkout_cart_product_add_before',
['info' => $requestInfo, 'product' => $product]
);

$this->quoteMock->expects($this->once())
->method('addProduct')
->will($this->returnValue(1));
$this->checkoutSessionMock->expects($this->once())
->method('getQuote')
->will($this->returnValue($this->quoteMock));

$this->eventManagerMock->expects($this->at(0))->method('dispatch')->with(
$this->eventManagerMock->expects($this->at(1))->method('dispatch')->with(
'checkout_cart_product_add_after',
['quote_item' => 1, 'product' => $product]
);
Expand Down Expand Up @@ -363,17 +369,19 @@ public function testAddProductException()
$this->productRepository->expects($this->any())
->method('getById')
->will($this->returnValue($product));

$this->eventManagerMock->expects($this->once())->method('dispatch')->with(
'checkout_cart_product_add_before',
['info' => 4, 'product' => $product]
);

$this->quoteMock->expects($this->once())
->method('addProduct')
->will($this->returnValue('error'));
$this->checkoutSessionMock->expects($this->once())
->method('getQuote')
->will($this->returnValue($this->quoteMock));

$this->eventManagerMock->expects($this->never())->method('dispatch')->with(
'checkout_cart_product_add_after',
['quote_item' => 1, 'product' => $product]
);
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
$this->cart->addProduct(4, 4);
}
Expand All @@ -399,6 +407,11 @@ public function testAddProductExceptionBadParams()
->method('getById')
->will($this->returnValue($product));

$this->eventManagerMock->expects($this->never())->method('dispatch')->with(
'checkout_cart_product_add_before',
['info' => 'bad', 'product' => $product]
);

$this->eventManagerMock->expects($this->never())->method('dispatch')->with(
'checkout_cart_product_add_after',
['quote_item' => 1, 'product' => $product]
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Customer/Model/GroupManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Magento\Framework\Api\SortOrderBuilder;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Data\Collection;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\StoreManagerInterface;

Expand Down Expand Up @@ -170,7 +169,7 @@ public function getLoggedInGroups()
->create();
$groupNameSortOrder = $this->sortOrderBuilder
->setField('customer_group_code')
->setDirection(Collection::SORT_ORDER_ASC)
->setAscendingDirection()
->create();
$searchCriteria = $this->searchCriteriaBuilder
->addFilters($notLoggedInFilter)
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Deploy/Console/DeployStaticOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private function getBasicOptions()
new InputArgument(
self::LANGUAGES_ARGUMENT,
InputArgument::IS_ARRAY,
'Space-separated list of ISO-636 language codes for which to output static view files.'
'Space-separated list of ISO-639 language codes for which to output static view files.'
),
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Elasticsearch\Test\Unit\Observer;

use Magento\CatalogSearch\Model\Indexer\Fulltext\Processor;
use Magento\Elasticsearch\Model\Config;
use Magento\Elasticsearch\Observer\CategoryProductIndexer;
use Magento\Framework\Event;
use Magento\Framework\Event\Observer;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

/**
* Class CategoryProductIndexerTest
*/
class CategoryProductIndexerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CategoryProductIndexer
*/
private $observer;

/**
* @var Config|\PHPUnit_Framework_MockObject_MockObject
*/
private $configMock;

/**
* @var Processor|\PHPUnit_Framework_MockObject_MockObject
*/
private $processorMock;

/**
* @var Observer|\PHPUnit_Framework_MockObject_MockObject
*/
private $observerMock;

/**
* Set Up method
*
* @return void
*/
protected function setUp(): void
{
$this->configMock = $this->createMock(Config::class);
$this->processorMock = $this->createMock(Processor::class);
$this->observerMock = $this->createMock(Observer::class);

$objectManager = new ObjectManagerHelper($this);
$this->observer = $objectManager->getObject(
CategoryProductIndexer::class,
[
'config' => $this->configMock,
'processor' => $this->processorMock,
]
);
}

/**
* Test if a category has changed products
*
* @return void
*/
public function testExecuteIfCategoryHasChangedProducts()
{
$this->getProductIdsWithEnabledElasticSearch();
$this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(true);
$this->processorMock->expects($this->once())->method('markIndexerAsInvalid');
$this->observer->execute($this->observerMock);
}

/**
* Test if a category has changed products and not scheduled indexer
*
* @return void
*/
public function testExecuteIfCategoryHasChangedProductsAndNotScheduledIndexer(): void
{
$this->getProductIdsWithEnabledElasticSearch();
$this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(false);
$this->processorMock->expects($this->never())->method('markIndexerAsInvalid');
$this->observer->execute($this->observerMock);
}

/**
* Test if a category has none changed products
*
* @return void
*/
public function testExecuteIfCategoryHasNoneChangedProducts(): void
{
/** @var Event|\PHPUnit_Framework_MockObject_MockObject $eventMock */
$eventMock = $this->createPartialMock(Event::class, ['getProductIds']);
$this->configMock->expects($this->once())->method('isElasticsearchEnabled')->willReturn(true);

$eventMock->expects($this->once())->method('getProductIds')->willReturn([]);
$this->observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock);

$this->processorMock->expects($this->never())->method('isIndexerScheduled');
$this->processorMock->expects($this->never())->method('markIndexerAsInvalid');

$this->observer->execute($this->observerMock);
}

/**
* Test if ElasticSearch is disabled
*
* @return void
*/
public function testExecuteIfElasticSearchIsDisabled(): void
{
/** @var Event|\PHPUnit_Framework_MockObject_MockObject $eventMock */
$eventMock = $this->createPartialMock(Event::class, ['getProductIds']);
$this->configMock->expects($this->once())->method('isElasticsearchEnabled')->willReturn(false);
$eventMock->expects($this->never())->method('getProductIds')->willReturn([]);
$this->observer->execute($this->observerMock);
}

/**
* Get product ids with enabled ElasticSearch
*
* @return void
*/
private function getProductIdsWithEnabledElasticSearch(): void
{
/** @var Event|\PHPUnit_Framework_MockObject_MockObject $eventMock */
$eventMock = $this->createPartialMock(Event::class, ['getProductIds']);
$this->configMock->expects($this->once())->method('isElasticsearchEnabled')->willReturn(true);
$eventMock->expects($this->once())->method('getProductIds')->willReturn([1]);
$this->observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
}
}
Loading

0 comments on commit 5916c5a

Please sign in to comment.