-
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.
Merge pull request #4936 from magento-tsg/2.3-develop-com-pr2
[TSG-Commerce] Tests for 2.3 (pr2) (2.3-develop)
- Loading branch information
Showing
26 changed files
with
2,576 additions
and
115 deletions.
There are no files selected for viewing
172 changes: 172 additions & 0 deletions
172
...ork/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractBase.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,172 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type; | ||
|
||
/** | ||
* Base custom options data provider. | ||
*/ | ||
abstract class AbstractBase | ||
{ | ||
/** | ||
* Return data for create options for all cases. | ||
* | ||
* @return array | ||
*/ | ||
public function getDataForCreateOptions(): array | ||
{ | ||
return [ | ||
"type_{$this->getType()}_title" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'sku' => 'test-option-title-1', | ||
'max_characters' => 50, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
], | ||
], | ||
"type_{$this->getType()}_required_options" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'sku' => 'test-option-title-1', | ||
'max_characters' => 50, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
], | ||
], | ||
"type_{$this->getType()}_not_required_options" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 0, | ||
'sku' => 'test-option-title-1', | ||
'max_characters' => 50, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
], | ||
], | ||
"type_{$this->getType()}_options_with_fixed_price" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'sku' => 'test-option-title-1', | ||
'max_characters' => 50, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
], | ||
], | ||
"type_{$this->getType()}_options_with_percent_price" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'sku' => 'test-option-title-1', | ||
'max_characters' => 50, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
'price' => 10, | ||
'price_type' => 'percent', | ||
], | ||
], | ||
"type_{$this->getType()}_price" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'sku' => 'test-option-title-1', | ||
'max_characters' => 50, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
'price' => 22, | ||
'price_type' => 'percent', | ||
], | ||
], | ||
"type_{$this->getType()}_sku" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'sku' => 'test-option-title-1', | ||
'max_characters' => 50, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
'price' => 22, | ||
'price_type' => 'percent', | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Return data for create options for all cases. | ||
* | ||
* @return array | ||
*/ | ||
public function getDataForUpdateOptions(): array | ||
{ | ||
return array_merge_recursive( | ||
$this->getDataForCreateOptions(), | ||
[ | ||
"type_{$this->getType()}_title" => [ | ||
[ | ||
'title' => 'Test updated option title', | ||
] | ||
], | ||
"type_{$this->getType()}_required_options" => [ | ||
[ | ||
'is_require' => 0, | ||
], | ||
], | ||
"type_{$this->getType()}_not_required_options" => [ | ||
[ | ||
'is_require' => 1, | ||
], | ||
], | ||
"type_{$this->getType()}_options_with_fixed_price" => [ | ||
[ | ||
'price_type' => 'percent', | ||
], | ||
], | ||
"type_{$this->getType()}_options_with_percent_price" => [ | ||
[ | ||
'price_type' => 'fixed', | ||
], | ||
], | ||
"type_{$this->getType()}_price" => [ | ||
[ | ||
'price' => 60, | ||
], | ||
], | ||
"type_{$this->getType()}_sku" => [ | ||
[ | ||
'sku' => 'Updated option sku', | ||
], | ||
], | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Return option type. | ||
* | ||
* @return string | ||
*/ | ||
abstract protected function getType(): string; | ||
} |
199 changes: 199 additions & 0 deletions
199
...k/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractSelect.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,199 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type; | ||
|
||
use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase; | ||
|
||
/** | ||
* Abstract data provider for options from select group. | ||
*/ | ||
abstract class AbstractSelect extends AbstractBase | ||
{ | ||
/** | ||
* @inheritdoc | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function getDataForCreateOptions(): array | ||
{ | ||
return [ | ||
"type_{$this->getType()}_title" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
], | ||
[ | ||
'record_id' => 0, | ||
'title' => 'Test option 1 value 1', | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
'sku' => 'test-option-1-value-1', | ||
'sort_order' => 1, | ||
], | ||
], | ||
"type_{$this->getType()}_required_options" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
], | ||
[ | ||
'record_id' => 0, | ||
'title' => 'Test option 1 value 1', | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
'sku' => 'test-option-1-value-1', | ||
'sort_order' => 1, | ||
], | ||
], | ||
"type_{$this->getType()}_not_required_options" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 0, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
], | ||
[ | ||
'record_id' => 0, | ||
'title' => 'Test option 1 value 1', | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
'sku' => 'test-option-1-value-1', | ||
'sort_order' => 1, | ||
], | ||
], | ||
"type_{$this->getType()}_options_with_fixed_price" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
], | ||
[ | ||
'record_id' => 0, | ||
'title' => 'Test option 1 value 1', | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
'sku' => 'test-option-1-value-1', | ||
'sort_order' => 1, | ||
], | ||
], | ||
"type_{$this->getType()}_options_with_percent_price" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
], | ||
[ | ||
'record_id' => 0, | ||
'title' => 'Test option 1 value 1', | ||
'price' => 10, | ||
'price_type' => 'percent', | ||
'sku' => 'test-option-1-value-1', | ||
'sort_order' => 1, | ||
], | ||
], | ||
"type_{$this->getType()}_price" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
], | ||
[ | ||
'record_id' => 0, | ||
'title' => 'Test option 1 value 1', | ||
'price' => 22, | ||
'price_type' => 'fixed', | ||
'sku' => 'test-option-1-value-1', | ||
'sort_order' => 1, | ||
], | ||
], | ||
"type_{$this->getType()}_sku" => [ | ||
[ | ||
'record_id' => 0, | ||
'sort_order' => 1, | ||
'is_require' => 1, | ||
'title' => 'Test option title 1', | ||
'type' => $this->getType(), | ||
], | ||
[ | ||
'record_id' => 0, | ||
'title' => 'Test option 1 value 1', | ||
'price' => 10, | ||
'price_type' => 'fixed', | ||
'sku' => 'test-option-1-value-1', | ||
'sort_order' => 1, | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getDataForUpdateOptions(): array | ||
{ | ||
return array_merge_recursive( | ||
$this->getDataForCreateOptions(), | ||
[ | ||
"type_{$this->getType()}_title" => [ | ||
[ | ||
'title' => 'Updated test option title 1', | ||
], | ||
[], | ||
], | ||
"type_{$this->getType()}_required_options" => [ | ||
[ | ||
'is_require' => 0, | ||
], | ||
[], | ||
], | ||
"type_{$this->getType()}_not_required_options" => [ | ||
[ | ||
'is_require' => 1, | ||
], | ||
[], | ||
], | ||
"type_{$this->getType()}_options_with_fixed_price" => [ | ||
[], | ||
[ | ||
'price_type' => 'percent', | ||
], | ||
], | ||
"type_{$this->getType()}_options_with_percent_price" => [ | ||
[], | ||
[ | ||
'price_type' => 'fixed', | ||
], | ||
], | ||
"type_{$this->getType()}_price" => [ | ||
[], | ||
[ | ||
'price' => 666, | ||
], | ||
], | ||
"type_{$this->getType()}_sku" => [ | ||
[], | ||
[ | ||
'sku' => 'updated-test-option-1-value-1', | ||
], | ||
], | ||
] | ||
); | ||
} | ||
} |
Oops, something went wrong.