-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔃 [EngCom] Public Pull Requests - 2.3-develop
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
Showing
20 changed files
with
583 additions
and
52 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
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
136 changes: 136 additions & 0 deletions
136
app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.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,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); | ||
} | ||
} |
Oops, something went wrong.