-
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 #1833 from magento-engcom/2.2-develop-prs
EngCom] Public Pull Requests - 2.2-develop - MAGETWO-85520: Remove @escapenotverified from documentation #12639 - MAGETWO-85317: 12526: Currency change, Bank Transfer but checkout page shows "Your credit card will be charged for" #993 - MAGETWO-85298: 8011: Strip Tags from attribute. #968 - MAGETWO-85294: 12535: Product change sku via repository. #984 - MAGETWO-85274: Update CrontabManager.php #12610 - MAGETWO-84994: 8862: Can't emptying values by magento 2 api #916
- Loading branch information
Showing
14 changed files
with
333 additions
and
23 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
52 changes: 52 additions & 0 deletions
52
dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.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,52 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Model; | ||
|
||
use Magento\Catalog\Api\ProductRepositoryInterface; | ||
use Magento\Catalog\Model\ResourceModel\Product as ProductResource; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
/** | ||
* Provide tests for ProductRepository model. | ||
*/ | ||
class ProductRepositoryTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* Test subject. | ||
* | ||
* @var ProductRepositoryInterface | ||
*/ | ||
private $productRepository; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); | ||
} | ||
|
||
/** | ||
* Test Product Repository can change(update) "sku" for given product. | ||
* | ||
* @magentoDataFixture Magento/Catalog/_files/product_simple.php | ||
* @magentoAppArea adminhtml | ||
*/ | ||
public function testUpdateProductSku() | ||
{ | ||
$newSku = 'simple-edited'; | ||
$productId = Bootstrap::getObjectManager()->get(ProductResource::class)->getIdBySku('simple'); | ||
$initialProduct = Bootstrap::getObjectManager()->create(Product::class)->load($productId); | ||
|
||
$initialProduct->setSku($newSku); | ||
$this->productRepository->save($initialProduct); | ||
|
||
$updatedProduct = Bootstrap::getObjectManager()->create(Product::class); | ||
$updatedProduct->load($productId); | ||
self::assertSame($newSku, $updatedProduct->getSku()); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Product/AbstractProductTest.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,83 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Rule\Model\Condition\Product; | ||
|
||
use Magento\Backend\Helper\Data; | ||
use Magento\Catalog\Api\ProductRepositoryInterface; | ||
use Magento\Catalog\Model\ProductCategoryList; | ||
use Magento\Catalog\Model\ProductFactory; | ||
use Magento\Catalog\Model\ResourceModel\Product; | ||
use Magento\Eav\Model\Config; | ||
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection; | ||
use Magento\Framework\Locale\FormatInterface; | ||
use Magento\Rule\Model\Condition\Context; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
/** | ||
* Provide tests for Abstract Rule product condition data model. | ||
* @magentoAppArea adminhtml | ||
*/ | ||
class AbstractProductTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* Test subject. | ||
* | ||
* @var AbstractProduct|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$objectManager = Bootstrap::getObjectManager(); | ||
$context = $objectManager->get(Context::class); | ||
$helperData = $objectManager->get(Data::class); | ||
$config = $objectManager->get(Config::class); | ||
$productFactory = $objectManager->get(ProductFactory::class); | ||
$productRepository = $objectManager->get(ProductRepositoryInterface::class); | ||
$productResource = $objectManager->get(Product::class); | ||
$attributeSetCollection = $objectManager->get(Collection::class); | ||
$localeFormat = $objectManager->get(FormatInterface::class); | ||
$data = []; | ||
$productCategoryList = $objectManager->get(ProductCategoryList::class); | ||
$this->model = $this->getMockBuilder(AbstractProduct::class) | ||
->setMethods(['getOperator', 'getFormName', 'setFormName']) | ||
->setConstructorArgs([ | ||
$context, | ||
$helperData, | ||
$config, | ||
$productFactory, | ||
$productRepository, | ||
$productResource, | ||
$attributeSetCollection, | ||
$localeFormat, | ||
$data, | ||
$productCategoryList | ||
]) | ||
->getMockForAbstractClass(); | ||
} | ||
|
||
/** | ||
* Test Abstract Rule product condition data model shows attribute labels in more readable view | ||
* (without html tags, if one presented). | ||
* | ||
* @magentoDataFixture Magento/Rule/_files/dropdown_attribute_with_html.php | ||
*/ | ||
public function testGetValueSelectOptions() | ||
{ | ||
$expectedLabels = [' ', 'Option 1', 'Option 2', 'Option 3']; | ||
$this->model->setAttribute('dropdown_attribute_with_html'); | ||
$options = $this->model->getValueSelectOptions(); | ||
$labels = []; | ||
foreach ($options as $option) { | ||
$labels[] = $option['label']; | ||
} | ||
self::assertSame($expectedLabels, $labels); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
dev/tests/integration/testsuite/Magento/Rule/_files/dropdown_attribute_with_html.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,59 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/* Create attribute */ | ||
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ | ||
$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( | ||
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class | ||
); | ||
|
||
if (!$attribute->loadByCode(4, 'dropdown_attribute_with_html')->getId()) { | ||
/** @var $installer \Magento\Catalog\Setup\CategorySetup */ | ||
$installer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( | ||
\Magento\Catalog\Setup\CategorySetup::class | ||
); | ||
|
||
$attribute->setData( | ||
[ | ||
'attribute_code' => 'dropdown_attribute_with_html', | ||
'entity_type_id' => $installer->getEntityTypeId('catalog_product'), | ||
'is_global' => 0, | ||
'is_user_defined' => 1, | ||
'frontend_input' => 'select', | ||
'is_unique' => 0, | ||
'is_required' => 0, | ||
'is_searchable' => 0, | ||
'is_visible_in_advanced_search' => 0, | ||
'is_comparable' => 0, | ||
'is_filterable' => 0, | ||
'is_filterable_in_search' => 0, | ||
'is_used_for_promo_rules' => 0, | ||
'is_html_allowed_on_front' => 1, | ||
'is_visible_on_front' => 0, | ||
'used_in_product_listing' => 0, | ||
'used_for_sort_by' => 0, | ||
'frontend_label' => ['Drop-Down Attribute'], | ||
'backend_type' => 'varchar', | ||
'backend_model' => \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend::class, | ||
'option' => [ | ||
'value' => [ | ||
'option_1' => ['<a href="#">Option 1</a>'], | ||
'option_2' => ['<a href="#">Option 2</a>'], | ||
'option_3' => ['<a href="#">Option 3</a>'], | ||
], | ||
'order' => [ | ||
'option_1' => 1, | ||
'option_2' => 2, | ||
'option_3' => 3, | ||
], | ||
], | ||
] | ||
); | ||
$attribute->save(); | ||
|
||
/* Assign attribute to attribute set */ | ||
$installer->addAttributeToGroup('catalog_product', 'Default', 'Attributes', $attribute->getId()); | ||
} |
22 changes: 22 additions & 0 deletions
22
...tests/integration/testsuite/Magento/Rule/_files/dropdown_attribute_with_html_rollback.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,22 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
/* Delete attribute with dropdown_attribute_with_html code */ | ||
|
||
use Magento\Catalog\Model\ResourceModel\Eav\Attribute; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
|
||
$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); | ||
$registry->unregister('isSecureArea'); | ||
$registry->register('isSecureArea', true); | ||
/** @var $attribute Attribute */ | ||
$attribute = Bootstrap::getObjectManager()->create( | ||
Attribute::class | ||
); | ||
$attribute->load('dropdown_attribute_with_html', 'attribute_code'); | ||
$attribute->delete(); | ||
|
||
$registry->unregister('isSecureArea'); | ||
$registry->register('isSecureArea', false); |
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
Oops, something went wrong.