Skip to content

Commit

Permalink
Merge remote-tracking branch 'trigger/AC-106' into AC-1434
Browse files Browse the repository at this point in the history
  • Loading branch information
kieuphan2406 committed Oct 25, 2021
2 parents f150199 + 31c6a5c commit 27a37e0
Show file tree
Hide file tree
Showing 162 changed files with 1,281 additions and 2,052 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function testRecreateWithExpression(
->willReturn($this->selectMock);
$withArgs = [];

foreach (array_keys($selectParts) as $key => $partName) {
foreach (array_keys($selectParts) as $partName) {
$withArgs[] = [$partName, $expectedParts[$partName]];
}
$this->selectMock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ protected function setUp(): void
$args = ['context' => $contextMock];

$testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->controller = $testHelper->getObject(
Save::class,
$args
);
$this->controller = $testHelper->getObject(Save::class, $args);
}

/**
Expand Down
11 changes: 3 additions & 8 deletions app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,7 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
'getBundleOption',
'getBundleOptionsData'
]
)
->disableOriginalConstructor()
)->disableOriginalConstructor()
->getMock();
/* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Catalog\Model\Product\Option $option */
$option = $this->getMockBuilder(Option::class)
Expand All @@ -1405,8 +1404,7 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
'hasData',
'getData'
]
)
->addMethods(['getHasOptions', 'setCartQty', 'getSkipCheckRequiredOption'])
)->addMethods(['getHasOptions', 'setCartQty', 'getSkipCheckRequiredOption'])
->disableOriginalConstructor()
->getMock();
/** @var MockObject|Type $productType */
Expand All @@ -1419,7 +1417,6 @@ public function testPrepareForCartAdvancedAllRequiredOption(): void
->onlyMethods(['getItems'])
->disableOriginalConstructor()
->getMock();

$this->parentClass($group, $option, $buyRequest, $product);

$product->expects($this->any())
Expand All @@ -1444,7 +1441,6 @@ function ($key) use ($optionCollection) {
$resultValue = [0 => 5];
break;
}

return $resultValue;
}
);
Expand All @@ -1456,8 +1452,7 @@ function ($key) use ($optionCollection) {
$buyRequest->expects($this->once())
->method('getBundleOption')
->willReturn([3 => 5]);
$option
->method('getId')
$option->method('getId')
->willReturnOnConsecutiveCalls(3);
$option->expects($this->once())
->method('getRequired')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,20 @@ public function testModifyMeta(string $shipmentTypePath, string $dataScope): voi
->willReturn([]);
$this->arrayManagerMock->method('set')
->willReturn([]);

$metaArgument = [
$shipmentTypePath . BundlePanel::META_CONFIG_PATH,
[],
[
'dataScope' => $dataScope,
'validation' => [
'required-entry' => false
]
]
];
$this->arrayManagerMock
->method('merge')
->withConsecutive(
[], [], [], [], [], [], [], [], [], [], [], [],
[
$shipmentTypePath . BundlePanel::META_CONFIG_PATH,
[],
[
'dataScope' => $dataScope,
'validation' => [
'required-entry' => false
]
]
]

);
->withConsecutive([], [], [], [], [], [], [], [], [], [], [], [], $metaArgument);
$this->bundlePanelModel->modifyMeta($sourceMeta);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ protected function setUp(): void
'delete',
'quoteInto',
'fetchAssoc'
])
]
)
->disableOriginalConstructor()
->getMock();
$this->select = $this->createMock(Select::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public function testSendPurgeRequest(array $hosts): void
$connectWithArgs = $writeWithArgs = [];

foreach ($uris as $uri) {
$withArgs[] = [$uri->getHost(), $uri->getPort()];
$writeWithArgs[] = ['PURGE', $uri, '1.1', ['X-Magento-Tags-Pattern' => 'tags', 'Host' => $uri->getHost()]];
}
$this->socketAdapterMock
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Captcha/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"magento/module-sales": "*",
"magento/module-store": "*",
"magento/module-authorization": "*",
"laminas/laminas-captcha": "^2.10",
"laminas/laminas-db": "^2.8.2",
"laminas/laminas-session": "^2.10"
"laminas/laminas-captcha": "^2.11.0",
"laminas/laminas-db": "^2.13.4",
"laminas/laminas-session": "^2.12.0"
},
"type": "magento2-module",
"license": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function execute()
if (isset($categoryPostData['use_config']) && !empty($categoryPostData['use_config'])) {
foreach ($categoryPostData['use_config'] as $attributeCode => $attributeValue) {
if ($attributeValue) {
$useConfig[] = $attributeValue;
$useConfig[] = $attributeCode;
$category->setData($attributeCode, null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class SaveHandlerTest extends TestCase
{
/**
* Magento\Framework\TestFramework\Unit\Helper\ObjectManager
* @var ObjectManager
*/
private $objectManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class CategoryTest extends TestCase

/**
* @inheritDoc
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function setUp(): void
{
Expand Down Expand Up @@ -105,8 +106,7 @@ protected function setUp(): void
'getChildrenCategories',
'getIsActive'
]
)
->getMock();
)->getMock();

$this->dataProvider
->method('getCategory')
Expand Down Expand Up @@ -153,8 +153,7 @@ protected function setUp(): void
'setValue',
'setCount'
]
)
->getMock();
)->getMock();
$filterItem->expects($this->any())
->method($this->anything())->willReturnSelf();
$this->filterItemFactory->expects($this->any())
Expand Down Expand Up @@ -192,12 +191,23 @@ protected function setUp(): void
public function testApplyWithEmptyRequest($requestValue, $idValue): void
{
$requestField = 'test_request_var';
$idField = 'id';

$this->target->setRequestVar($requestField);

$this->request
->method('getParam')
->with($requestField);
->with($requestField)
->willReturnCallback(
function ($field) use ($requestField, $idField, $requestValue, $idValue) {
switch ($field) {
case $requestField:
return $requestValue;
case $idField:
return $idValue;
}
}
);

$result = $this->target->apply($this->request);
$this->assertSame($this->target, $result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,17 @@ public function testApplyWithEmptyRequest($requestValue, $idValue): void

$this->request
->method('getParam')
->with($requestField);
->with($requestField)
->willReturnCallback(
function ($field) use ($requestField, $idField, $requestValue, $idValue) {
switch ($field) {
case $requestField:
return $requestValue;
case $idField:
return $idValue;
}
}
);

$result = $this->target->apply($this->request);
$this->assertSame($this->target, $result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ protected function setUp(): void
}

/**
* @return void
*/
* @return void
*/
public function testGetList(): void
{
$productSku = 'simple_product';
Expand All @@ -106,17 +106,17 @@ public function testGetList(): void
}

/**
* @return void
*/
* @return void
*/
public function testDelete(): void
{
$this->optionResourceMock->expects($this->once())->method('delete')->with($this->optionMock);
$this->assertTrue($this->optionRepository->delete($this->optionMock));
}

/**
* @return void
*/
* @return void
*/
public function testGetNonExistingOption(): void
{
$this->expectException('Magento\Framework\Exception\NoSuchEntityException');
Expand All @@ -136,8 +136,8 @@ public function testGetNonExistingOption(): void
}

/**
* @return void
*/
* @return void
*/
public function testGet(): void
{
$optionId = 1;
Expand All @@ -155,8 +155,8 @@ public function testGet(): void
}

/**
* @return void
*/
* @return void
*/
public function testDeleteByIdentifierNonExistingOption(): void
{
$this->expectException('Magento\Framework\Exception\NoSuchEntityException');
Expand All @@ -177,8 +177,8 @@ public function testDeleteByIdentifierNonExistingOption(): void
}

/**
* @return void
*/
* @return void
*/
public function testDeleteByIdentifier(): void
{
$optionId = 1;
Expand All @@ -200,8 +200,8 @@ public function testDeleteByIdentifier(): void
}

/**
* @return void
*/
* @return void
*/
public function testDeleteByIdentifierWhenCannotRemoveOption(): void
{
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
Expand All @@ -228,8 +228,8 @@ public function testDeleteByIdentifierWhenCannotRemoveOption(): void
}

/**
* @return void
*/
* @return void
*/
public function testSaveCouldNotSaveException(): void
{
$this->expectException('Magento\Framework\Exception\CouldNotSaveException');
Expand All @@ -239,8 +239,8 @@ public function testSaveCouldNotSaveException(): void
}

/**
* @return void
*/
* @return void
*/
public function testSaveNoSuchEntityException(): void
{
$this->expectException('Magento\Framework\Exception\NoSuchEntityException');
Expand All @@ -261,8 +261,8 @@ public function testSaveNoSuchEntityException(): void
}

/**
* @return void
*/
* @return void
*/
public function testSave(): void
{
$productSku = 'simple_product';
Expand Down Expand Up @@ -307,8 +307,8 @@ public function testSave(): void
}

/**
* @return void
*/
* @return void
*/
public function testSaveWhenOptionTypeWasChanged(): void
{
$productSku = 'simple_product';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class PriceTest extends TestCase
*/
protected $websiteMock;

/**
* @var ProductTierPriceExtensionFactory|MockObject
*/
private $tierPriceExtensionFactoryMock;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public function testGetCompositeTypes(): void
public function testGetTypesByPriority(): void
{
$expected = [];
$options = [];
foreach ($this->_productTypes as $typeId => $type) {
$type['label'] = __($type['label']);
$options[$typeId] = $type;
Expand Down
Loading

0 comments on commit 27a37e0

Please sign in to comment.