-
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.
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Accepted Community Pull Requests: - #25940: Asynchronous operation validate (by @sedonik) - #25523: Contact form > Adding ViewModel (by @rafaelstz) - #25697: [New Relic] Making system configs dependent by Enabled field (by @eduard13) - #26067: [Msrp] Cover MsrpPriceCalculator by Unit Test (by @edenduong) - #24360: #24357 Eav sort order by attribute option_id (by @tnsezer) - #26069: [CMS] Improving the test coverage for UrlBuilder ViewModel (by @eduard13) - #26063: [Theme] Reverting removed container class (by @eduard13) - #26057: [Contact] covered Model Config by Unit Test (by @srsathish92) - #26050: [Catalog] covered product ViewModel AddToCompareAvailability by Unit Test (by @srsathish92) - #26037: Fixes phpcs errors and warnings for Magento\Framework\View\Element (by @krisdante) - #26045: [Downloadable] Cover Helper Data by Unit Test (by @edenduong) - #26043: [Persistent] Cover CustomerData by Unit Test (by @edenduong) - #26042: [Catalog] Cover Component/FilterFactory by Unit Test (by @edenduong) - #26044: Set empty value to color picker when input is reset to update preview (by @gperis) - #26034: MAGETWO-95866 Add horizontal scroll if elements extend menu's width (by @ptylek) - #26001: Fix caching Magento Metadata getVersion (by @luklewluk) - #26003: [Directory] Cover action directory/json/countryRegion by Integration Test (by @edenduong) Fixed GitHub Issues: - #100: Oracle and Other RDBMS Status? (reported by @dicgf8) has been fixed in #25940 by @sedonik in 2.4-develop branch Related commits: 1. dc8821d 2. f305a84 3. 345ece3 4. b1e518c - #24357: Eav sort order by attribute option_id (reported by @tnsezer) has been fixed in #24360 by @tnsezer in 2.4-develop branch Related commits: 1. 459c596 2. a047aca 3. 952d12e 4. 4000459 5. 49738bd 6. d0006b9 - #20379: calendar icon not aligned inside the textbox in Add Design Change page (reported by @irajneeshgupta) has been fixed in #26063 by @eduard13 in 2.4-develop branch Related commits: 1. 218c3ff - #18687: Left Side Back End Menu Design fix (reported by @jigar48) has been fixed in #26034 by @ptylek in 2.4-develop branch Related commits: 1. f59c1ca 2. 7a2bc8f 3. 6bf903f - #24025: Slow Performance of ProductMetadata::getVersion (reported by @beberlei) has been fixed in #26001 by @luklewluk in 2.4-develop branch Related commits: 1. 16ab63b 2. ab6cabd 3. 0b7c34e
- Loading branch information
Showing
46 changed files
with
1,651 additions
and
21 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
37 changes: 37 additions & 0 deletions
37
app/code/Magento/AsynchronousOperations/Model/OperationStatusPool.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,37 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AsynchronousOperations\Model; | ||
|
||
/** | ||
* Class OperationStatusPool | ||
* | ||
* Pool of statuses that require validate | ||
*/ | ||
class OperationStatusPool | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $statuses; | ||
|
||
/** | ||
* @param array $statuses | ||
*/ | ||
public function __construct(array $statuses = []) | ||
{ | ||
$this->statuses = $statuses; | ||
} | ||
|
||
/** | ||
* Retrieve statuses that require validate | ||
* | ||
* @return array | ||
*/ | ||
public function getStatuses() | ||
{ | ||
return $this->statuses; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
app/code/Magento/AsynchronousOperations/Model/OperationStatusValidator.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,47 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AsynchronousOperations\Model; | ||
|
||
use Magento\AsynchronousOperations\Model\OperationStatusPool; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Doctrine\Instantiator\Exception\InvalidArgumentException; | ||
|
||
/** | ||
* Class OperationStatusValidator to validate operation status | ||
*/ | ||
class OperationStatusValidator | ||
{ | ||
/** | ||
* @var OperationStatusPool | ||
*/ | ||
private $operationStatusPool; | ||
|
||
/** | ||
* OperationStatusValidator constructor. | ||
* | ||
* @param OperationStatusPool $operationStatusPool | ||
*/ | ||
public function __construct(OperationStatusPool $operationStatusPool) | ||
{ | ||
$this->operationStatusPool = $operationStatusPool; | ||
} | ||
|
||
/** | ||
* Validate method | ||
* | ||
* @param int $status | ||
* @throws \InvalidArgumentException | ||
* @return void | ||
*/ | ||
public function validate($status) | ||
{ | ||
$statuses = $this->operationStatusPool->getStatuses(); | ||
|
||
if (!in_array($status, $statuses)) { | ||
throw new \InvalidArgumentException('Invalid Operation Status.'); | ||
} | ||
} | ||
} |
155 changes: 155 additions & 0 deletions
155
app/code/Magento/AsynchronousOperations/Test/Unit/Model/OperationStatusValidatorTest.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,155 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\AsynchronousOperations\Test\Unit\Model; | ||
|
||
use Magento\AsynchronousOperations\Model\OperationStatusValidator; | ||
use Magento\AsynchronousOperations\Model\Operation; | ||
use Magento\AsynchronousOperations\Model\OperationStatusPool; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class OperationStatusValidatorTest implements logic for testing Operation::setStatus() method | ||
*/ | ||
class OperationStatusValidatorTest extends TestCase | ||
{ | ||
/** | ||
* @var OperationStatusPool | ||
*/ | ||
private $operationStatusPool; | ||
|
||
/** | ||
* @var OperationStatusValidator | ||
*/ | ||
private $operationStatusValidator; | ||
|
||
/** | ||
* @var Operation | ||
*/ | ||
private $operation; | ||
|
||
protected function setUp() | ||
{ | ||
$this->operationStatusPool = $this->getMockBuilder(OperationStatusPool::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$objectManager = new ObjectManager($this); | ||
|
||
$this->operationStatusValidator = $objectManager->getObject( | ||
OperationStatusValidator::class, | ||
[ | ||
'operationStatusPool' => $this->operationStatusPool | ||
] | ||
); | ||
|
||
$this->operation = $objectManager->getObject( | ||
Operation::class, | ||
[ | ||
'operationStatusValidator' => $this->operationStatusValidator | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param string $status | ||
* @param array $statusPool | ||
* @param string $expectedResult | ||
* @dataProvider dataProviderForTestSetStatus | ||
*/ | ||
public function testSetStatus( | ||
string $status, | ||
array $statusPool, | ||
string $expectedResult | ||
) { | ||
$this->operationStatusPool | ||
->expects($this->any()) | ||
->method('getStatuses') | ||
->willReturn($statusPool); | ||
|
||
try { | ||
$this->operation->setStatus($status); | ||
$this->assertEquals($expectedResult, $this->operation->getStatus()); | ||
} catch (\Exception $exception) { | ||
$this->assertEquals($expectedResult, $exception->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function dataProviderForTestSetStatus() | ||
{ | ||
return [ | ||
[ | ||
'status' => 0, | ||
'statusPool' => [ | ||
'complete' => 1, | ||
'retriablyFailed' => 2, | ||
'notRetriablyFailed' => 3, | ||
'open' => 4, | ||
'rejected' => 5 | ||
], | ||
'expectedResult' => 'Invalid Operation Status.' | ||
], | ||
[ | ||
'status' => 1, | ||
'statusPool' => [ | ||
'complete' => 1, | ||
'retriablyFailed' => 2, | ||
'notRetriablyFailed' => 3, | ||
'open' => 4, | ||
'rejected' => 5 | ||
], | ||
'expectedResult' => 1 | ||
], | ||
[ | ||
'status' => 2, | ||
'statusPool' => [ | ||
'complete' => 1, | ||
'retriablyFailed' => 2, | ||
'notRetriablyFailed' => 3, | ||
'open' => 4, | ||
'rejected' => 5 | ||
], | ||
'expectedResult' => 2 | ||
], | ||
[ | ||
'status' => 3, | ||
'statusPool' => [ | ||
'complete' => 1, | ||
'retriablyFailed' => 2, | ||
'notRetriablyFailed' => 3, | ||
'open' => 4, | ||
'rejected' => 5 | ||
], | ||
'expectedResult' => 3 | ||
], | ||
[ | ||
'status' => 4, | ||
'statusPool' => [ | ||
'complete' => 1, | ||
'retriablyFailed' => 2, | ||
'notRetriablyFailed' => 3, | ||
'open' => 4, | ||
'rejected' => 5 | ||
], | ||
'expectedResult' => 4 | ||
], | ||
[ | ||
'status' => 5, | ||
'statusPool' => [ | ||
'complete' => 1, | ||
'retriablyFailed' => 2, | ||
'notRetriablyFailed' => 3, | ||
'open' => 4, | ||
'rejected' => 5 | ||
], | ||
'expectedResult' => 5 | ||
] | ||
]; | ||
} | ||
} |
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
Oops, something went wrong.