This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,24 @@
<?php
/***
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
/**
* Testing markAsRead controller.
*
* @magentoAppArea adminhtml
*/
class MarkAsReadTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->resource = 'Magento_AdminNotification::mark_as_read';
$this->uri = 'backend/admin/notification/markasread';
parent::setUp();
}
}
@@ -0,0 +1,19 @@
<?php
/***
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
use Magento\Framework\App\Request\Http as HttpRequest;
class MassMarkAsReadTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
protected function setUp(): void
{
$this->resource = 'Magento_AdminNotification::mark_as_read';
$this->uri = 'backend/admin/notification/massmarkasread';
$this->httpMethod = HttpRequest::METHOD_POST;
parent::setUp();
}
}
@@ -0,0 +1,19 @@
<?php
/***
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
use Magento\Framework\App\Request\Http as HttpRequest;
class MassRemoveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
protected function setUp(): void
{
$this->resource = 'Magento_AdminNotification::adminnotification_remove';
$this->uri = 'backend/admin/notification/massremove';
$this->httpMethod = HttpRequest::METHOD_POST;
parent::setUp();
}
}
@@ -0,0 +1,16 @@
<?php
/***
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
class RemoveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
protected function setUp(): void
{
$this->resource = 'Magento_AdminNotification::adminnotification_remove';
$this->uri = 'backend/admin/notification/remove';
parent::setUp();
}
}
@@ -0,0 +1,30 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdminNotification\Model\ResourceModel\Inbox\Collection;
class CriticalTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Critical
*/
protected $_model;
protected function setUp(): void
{
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\AdminNotification\Model\ResourceModel\Inbox\Collection\Critical::class
);
}
/**
* @magentoDataFixture Magento/AdminNotification/_files/notifications.php
*/
public function testCollectionContainsLastUnreadCriticalItem()
{
$items = array_values($this->_model->getItems());
$this->assertEquals('Unread Critical 3', $items[0]->getTitle());
}
}
@@ -0,0 +1,50 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\AdminNotification\Model\Inbox;
use Magento\AdminNotification\Model\ResourceModel\Inbox as InboxResource;
use Magento\Framework\Notification\MessageInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
/** @var ObjectManagerInterface $objectManager */
$objectManager = Bootstrap::getObjectManager();
/**
* @var Inbox $message
* @var InboxResource $messageResource
*/
$message = $objectManager->create(Inbox::class);
$messageResource = $objectManager->create(InboxResource::class);
$message->setSeverity(MessageInterface::SEVERITY_CRITICAL)->setTitle('Unread Critical 1');
$messageResource->save($message);
$message = $objectManager->create(Inbox::class);
$message->setSeverity(MessageInterface::SEVERITY_MAJOR)->setTitle('Unread Major 1');
$messageResource->save($message);
$message = $objectManager->create(Inbox::class);
$message->setSeverity(MessageInterface::SEVERITY_CRITICAL)->setTitle('Unread Critical 2');
$messageResource->save($message);
$message = $objectManager->create(Inbox::class);
$message->setSeverity(MessageInterface::SEVERITY_CRITICAL)->setTitle('Unread Critical 3');
$messageResource->save($message);
$message = $objectManager->create(Inbox::class);
$message->setSeverity(MessageInterface::SEVERITY_CRITICAL)->setTitle('Read Critical 1')->setIsRead(1);
$messageResource->save($message);
$message = $objectManager->create(Inbox::class);
$message->setSeverity(MessageInterface::SEVERITY_MAJOR)->setTitle('Unread Major 2');
$messageResource->save($message);
$message = $objectManager->create(Inbox::class);
$message->setSeverity(MessageInterface::SEVERITY_CRITICAL)->setTitle('Removed Critical 1')->setIsRemove(1);
$messageResource->save($message);
@@ -0,0 +1,390 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdvancedPricingImportExport\Model\Export;
use Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing as ExportAdvancedPricing;
use Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing as ImportAdvancedPricing;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\Write;
use Magento\ImportExport\Model\Export\Adapter\Csv as ExportAdapterCsv;
use Magento\ImportExport\Model\Import;
use Magento\ImportExport\Model\Import\Source\Csv as ImportSourceCsv;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Indexer\TestCase;
/**
* Test for \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AdvancedPricingTest extends TestCase
{
/**
* @var ExportAdvancedPricing
*/
protected $model;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
/**
* @var Filesystem
*/
protected $fileSystem;
/**
* @var Write
*/
private $directory;
// @codingStandardsIgnoreStart
public static function setUpBeforeClass(): void
{
$db = Bootstrap::getInstance()
->getBootstrap()
->getApplication()
->getDbInstance();
if (!$db->isDbDumpExists()) {
throw new \LogicException('DB dump does not exist.');
}
$db->restoreFromDbDump();
parent::setUpBeforeClass();
}
// @codingStandardsIgnoreEnd
protected function setUp(): void
{
parent::setUp();
$this->objectManager = Bootstrap::getObjectManager();
$this->fileSystem = $this->objectManager->get(Filesystem::class);
$this->directory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
$this->model = $this->objectManager->create(ExportAdvancedPricing::class);
}
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation disabled
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testExport()
{
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$index = 0;
$ids = [];
$origPricingData = [];
$skus = ['simple'];
while (isset($skus[$index])) {
$ids[$index] = $productRepository->get($skus[$index])
->getId();
$origPricingData[$index] = $this->objectManager->create(Product::class)
->load($ids[$index])
->getTierPrices();
$index++;
}
$csvfile = uniqid('importexport_') . '.csv';
$exportContent = $this->exportData($csvfile);
$this->assertDiscountTypes($exportContent);
$this->importData($csvfile);
while ($index > 0) {
$index--;
$newPricingData = $this->objectManager->create(Product::class)
->load($ids[$index])
->getTierPrices();
$this->assertEquals(count($origPricingData[$index]), count($newPricingData));
$this->assertEqualsOtherThanSkippedAttributes($origPricingData[$index], $newPricingData, []);
}
$this->removeImportedProducts($skus);
}
/**
* Assert for correct tier prices discount types.
*
* @param string $exportContent
* @return void
*/
private function assertDiscountTypes($exportContent)
{
$this->assertStringContainsString(
'2.0000,8.000000,Fixed',
$exportContent
);
$this->assertStringContainsString(
'10.0000,50.00,Discount',
$exportContent
);
}
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation disabled
* @magentoAppIsolation enabled
* @magentoConfigFixture current_store catalog/price/scope 1
* @magentoDataFixture Magento/AdvancedPricingImportExport/_files/product_with_second_website.php
*/
public function testExportMultipleWebsites()
{
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$index = 0;
$ids = [];
$origPricingData = [];
$skus = ['AdvancedPricingSimple 1', 'AdvancedPricingSimple 2'];
while (isset($skus[$index])) {
$ids[$index] = $productRepository->get($skus[$index])
->getId();
$origPricingData[$index] = $this->objectManager->create(Product::class)
->load($ids[$index])
->getTierPrices();
$index++;
}
$csvfile = uniqid('importexport_') . '.csv';
$exportContent = $this->exportData($csvfile);
$this->assertStringContainsString(
'"AdvancedPricingSimple 2",test,"ALL GROUPS",3.0000,5.0000',
$exportContent
);
$this->importData($csvfile);
while ($index > 0) {
$index--;
$newPricingData = $this->objectManager->create(Product::class)
->load($ids[$index])
->getTierPrices();
$this->assertEquals(count($origPricingData[$index]), count($newPricingData));
$this->assertEqualsOtherThanSkippedAttributes($origPricingData[$index], $newPricingData, []);
}
$this->removeImportedProducts($skus);
}
/**
* Export and Import of Advanced Pricing with different Price Types.
*
* @magentoDataFixture Magento/Catalog/_files/two_simple_products_with_tier_price.php
* @return void
*/
public function testExportImportOfAdvancedPricing(): void
{
$simpleSku = 'simple';
$secondSimpleSku = 'second_simple';
$csvfile = $this->directory->getAbsolutePath(uniqid('importexport_') . '.csv');
$exportContent = $this->exportData($csvfile);
$this->assertStringContainsString(
\sprintf('%s,"All Websites [USD]","ALL GROUPS",10.0000,3.00,Discount', $secondSimpleSku),
$exportContent
);
$this->assertStringContainsString(
\sprintf('%s,"All Websites [USD]",General,5.0000,95.000000,Fixed', $simpleSku),
$exportContent
);
$this->updateTierPriceDataInCsv($csvfile);
$this->importData($csvfile);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$firstProductTierPrices = $productRepository->get('simple')->getTierPrices();
$secondProductTierPrices = $productRepository->get('second_simple')->getTierPrices();
$this->assertSame(
['0', '1'],
[
$firstProductTierPrices[0]->getExtensionAttributes()->getWebsiteId(),
$firstProductTierPrices[0]->getCustomerGroupId(),
]
);
$this->assertEqualsWithDelta(
['5.0000', '90.000000'],
[
$firstProductTierPrices[0]->getQty(),
$firstProductTierPrices[0]->getValue(),
],
0.1
);
$this->assertSame(
['0', \Magento\Customer\Model\Group::CUST_GROUP_ALL],
[
$secondProductTierPrices[0]->getExtensionAttributes()->getWebsiteId(),
$secondProductTierPrices[0]->getCustomerGroupId(),
]
);
$this->assertEqualsWithDelta(
['5.00', '10.0000'],
[
$secondProductTierPrices[0]->getExtensionAttributes()->getPercentageValue(),
$secondProductTierPrices[0]->getQty(),
],
0.1
);
$this->removeImportedProducts([$simpleSku, $secondSimpleSku]);
}
/**
* Update tier price data in CSV.
*
* @param string $csvfile
* @return void
*/
private function updateTierPriceDataInCsv(string $csvfile): void
{
$csvNewData = [
0 => [
0 => 'sku',
1 => 'tier_price_website',
2 => 'tier_price_customer_group',
3 => 'tier_price_qty',
4 => 'tier_price',
5 => 'tier_price_value_type',
],
1 => [
0 => 'simple',
1 => 'All Websites [USD]',
2 => 'General',
3 => '5',
4 => '90',
5 => 'Fixed',
],
2 => [
0 => 'second_simple',
1 => 'All Websites [USD]',
2 => 'ALL GROUPS',
3 => '10',
4 => '5',
5 => 'Discount',
],
];
$this->updateCsvFile($csvfile, $csvNewData);
}
/**
* @param string $csvFile
* @return string
*/
private function exportData($csvFile)
{
$writer = Bootstrap::getObjectManager()->create(ExportAdapterCsv::class, ['fileSystem' => $this->fileSystem]);
$this->model->setWriter($writer);
$exportContent = $this->model->export();
$this->assertNotEmpty($exportContent);
$driver = $this->directory->getDriver();
$driver->filePutContents($this->directory->getAbsolutePath($csvFile), $exportContent);
return $exportContent;
}
/**
* @param string $csvFile
*/
private function importData($csvFile)
{
/** @var ImportAdvancedPricing $importModel */
$importModel = $this->objectManager->create(ImportAdvancedPricing::class);
$source = $this->objectManager->create(
ImportSourceCsv::class,
[
'file' => $csvFile,
'directory' => $this->directory
]
);
$errors = $importModel->setParameters(
[
'behavior' => Import::BEHAVIOR_APPEND,
'entity' => 'advanced_pricing'
]
)->setSource(
$source
)->validateData();
$this->assertTrue(
$errors->getErrorsCount() == 0,
'Advanced Pricing import error, imported from file:' . $csvFile
);
$importModel->importData();
}
private function assertEqualsOtherThanSkippedAttributes($expected, $actual, $skippedAttributes)
{
foreach ($expected as $key => $value) {
if (in_array($key, $skippedAttributes)) {
continue;
} else {
$this->assertEquals(
$value,
$actual[$key],
'Assert value at key - ' . $key . ' failed'
);
}
}
}
/**
* Cleanup test by removing imported product.
*
* @param string[] $skus
* @return void
*/
private function removeImportedProducts(array $skus): void
{
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$registry = $this->objectManager->get(\Magento\Framework\Registry::class);
/** @var ProductRepositoryInterface $productRepository */
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', true);
foreach ($skus as $sku) {
try {
$productRepository->deleteById($sku);
} catch (NoSuchEntityException $e) {
// product already deleted
}
}
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
}
/**
* Appends csv data to the file
*
* @param string $filePath
* @param array $csv
* @return void
*/
private function updateCsvFile(string $filePath, array $csv): void
{
$driver = $this->directory->getDriver();
$driver->deleteFile($filePath);
$fileResource = $driver->fileOpen($filePath, 'w');
foreach ($csv as $dataRow) {
$driver->filePutCsv($fileResource, $dataRow);
}
$driver->fileClose($fileResource);
}
}
@@ -0,0 +1,501 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdvancedPricingImportExport\Model\Import;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Test\Fixture\SelectAttribute;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\ImportExport\Model\Import;
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
use Magento\ImportExport\Model\Import\Source\Csv;
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\AppArea;
/**
* @magentoAppArea adminhtml
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AdvancedPricingTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\CatalogImportExport\Model\Import\Product
*/
protected $model;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
/**
* @var \Magento\Framework\Filesystem
*/
protected $fileSystem;
/**
* Expected Product Tier Price mapping with data
*
* @var array
*/
protected $expectedTierPrice;
protected function setUp(): void
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->fileSystem = $this->objectManager->get(\Magento\Framework\Filesystem::class);
$this->model = $this->objectManager->create(
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class
);
$this->expectedTierPrice = [
'AdvancedPricingSimple 1' => [
[
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'value' => '300.000000',
'qty' => '10.0000',
'percentage_value' => null
],
[
'customer_group_id' => '1',
'value' => '11.000000',
'qty' => '11.0000',
'percentage_value' => null
],
[
'customer_group_id' => '3',
'value' => '14.000000',
'qty' => '14.0000',
'percentage_value' => null
],
[
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'value' => 160.5,
'qty' => '20.0000',
'percentage_value' => '50.00'
]
],
'AdvancedPricingSimple 2' => [
[
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'value' => '1000000.000000',
'qty' => '100.0000',
'percentage_value' => null
],
[
'customer_group_id' => '0',
'value' => '12.000000',
'qty' => '12.0000',
'percentage_value' => null
],
[
'customer_group_id' => '2',
'value' => '13.000000',
'qty' => '13.0000',
'percentage_value' => null
],
[
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'value' => 327.0,
'qty' => '200.0000',
'percentage_value' => '50.00'
]
]
];
}
/**
* @magentoDataFixture Magento/AdvancedPricingImportExport/_files/create_products.php
* @magentoAppArea adminhtml
*/
public function testImportAddUpdate()
{
// import data from CSV file
$pathToFile = __DIR__ . '/_files/import_advanced_pricing.csv';
$errors = $this->doImport($pathToFile, DirectoryList::ROOT, Import::BEHAVIOR_APPEND, true);
$this->assertEquals(0, $errors->getErrorsCount(), 'Advanced pricing import validation error');
$this->model->importData();
/** @var \Magento\Catalog\Model\ResourceModel\Product $resource */
$resource = $this->objectManager->get(\Magento\Catalog\Model\ResourceModel\Product::class);
$productIdList = $resource->getProductsIdsBySkus(array_keys($this->expectedTierPrice));
/** @var \Magento\Catalog\Model\Product $product */
$product = $this->objectManager->create(\Magento\Catalog\Model\Product::class);
foreach ($productIdList as $sku => $productId) {
$product->load($productId);
$tierPriceCollection = $product->getTierPrices();
$this->assertCount(4, $tierPriceCollection);
$index = 0;
/** @var \Magento\Catalog\Model\Product\TierPrice $tierPrice */
foreach ($tierPriceCollection as $tierPrice) {
$this->checkPercentageDiscount($tierPrice, $sku, $index);
$this->assertEquals(0, $tierPrice->getExtensionAttributes()->getWebsiteId());
$tierPriceData = $tierPrice->getData();
unset($tierPriceData['extension_attributes']);
$this->assertContains($tierPriceData, $this->expectedTierPrice[$sku]);
$index ++;
}
}
}
/**
* Check percentage discount type.
*
* @param \Magento\Catalog\Model\Product\TierPrice $tierPrice
* @param string $sku
* @param int $index
* @return void
*/
private function checkPercentageDiscount(
\Magento\Catalog\Model\Product\TierPrice $tierPrice,
$sku,
$index
) {
$this->assertEquals(
(int)$this->expectedTierPrice[$sku][$index]['percentage_value'],
(int)$tierPrice->getExtensionAttributes()->getPercentageValue()
);
$tierPrice->setData('percentage_value', $tierPrice->getExtensionAttributes()->getPercentageValue());
}
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testImportDelete()
{
$productRepository = $this->objectManager->create(
\Magento\Catalog\Api\ProductRepositoryInterface::class
);
$index = 0;
$ids = [];
$origPricingData = [];
$skus = ['simple'];
while (isset($skus[$index])) {
$ids[$index] = $productRepository->get($skus[$index])->getId();
$origPricingData[$index] = $this->objectManager->create(\Magento\Catalog\Model\Product::class)
->load($ids[$index])
->getTierPrices();
$index++;
}
$csvfile = uniqid('importexport_') . '.csv';
/** @var \Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing $exportModel */
$exportModel = $this->objectManager->create(
\Magento\AdvancedPricingImportExport\Model\Export\AdvancedPricing::class
);
$exportModel->setWriter(
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\ImportExport\Model\Export\Adapter\Csv::class,
['fileSystem' => $this->fileSystem]
)
);
$exportContent = $exportModel->export();
$this->assertNotEmpty($exportContent);
$directory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT);
$directory->getDriver()->filePutContents($directory->getAbsolutePath($csvfile), $exportContent);
$errors = $this->doImport($csvfile, DirectoryList::VAR_IMPORT_EXPORT, Import::BEHAVIOR_DELETE, true);
$this->assertTrue(
$errors->getErrorsCount() == 0,
'Advanced Pricing import error, imported from file:' . $csvfile
);
$this->model->importData();
while ($index > 0) {
$index--;
$newPricingData = $this->objectManager->create(\Magento\Catalog\Model\Product::class)
->load($ids[$index])
->getTierPrices();
$this->assertCount(0, $newPricingData);
}
}
/**
* @magentoDataFixture Magento/AdvancedPricingImportExport/_files/create_products.php
* @magentoAppArea adminhtml
*/
public function testImportReplace()
{
// import data from CSV file
$pathToFile = __DIR__ . '/_files/import_advanced_pricing.csv';
$errors = $this->doImport($pathToFile, DirectoryList::ROOT, Import::BEHAVIOR_REPLACE, true);
$this->assertEquals(0, $errors->getErrorsCount(), 'Advanced pricing import validation error');
$this->model->importData();
/** @var \Magento\Catalog\Model\ResourceModel\Product $resource */
$resource = $this->objectManager->get(\Magento\Catalog\Model\ResourceModel\Product::class);
$productIdList = $resource->getProductsIdsBySkus(array_keys($this->expectedTierPrice));
/** @var \Magento\Catalog\Model\Product $product */
$product = $this->objectManager->create(\Magento\Catalog\Model\Product::class);
foreach ($productIdList as $sku => $productId) {
$product->load($productId);
$tierPriceCollection = $product->getTierPrices();
$this->assertCount(4, $tierPriceCollection);
$index = 0;
/** @var \Magento\Catalog\Model\Product\TierPrice $tierPrice */
foreach ($tierPriceCollection as $tierPrice) {
$this->checkPercentageDiscount($tierPrice, $sku, $index);
$this->assertEquals(0, $tierPrice->getExtensionAttributes()->getWebsiteId());
$tierPriceData = $tierPrice->getData();
unset($tierPriceData['extension_attributes']);
$this->assertContains($tierPriceData, $this->expectedTierPrice[$sku]);
$index ++;
}
}
}
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture current_store catalog/price/scope 1
* @magentoDataFixture Magento/AdvancedPricingImportExport/_files/create_products.php
* @param array $dbData
* @param array $importData
* @param string $importBehavior
* @param array $invalidRows
* @dataProvider importValidationDuplicateWithSameBaseCurrencyDataProvider
*/
public function testImportValidationDuplicateWithSameBaseCurrency(
array $dbData,
array $importData,
string $importBehavior,
array $invalidRows
) {
$this->createTierPrices($dbData);
$pathToFile = $this->generateImportFile($importData);
$errors = $this->doImport($pathToFile, DirectoryList::VAR_DIR, $importBehavior);
$rows = $errors->getRowsGroupedByErrorCode(['duplicateTierPrice'], [], false);
$this->assertEquals($invalidRows, $rows['duplicateTierPrice'] ?? []);
}
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture current_store catalog/price/scope 1
* @magentoConfigFixture base_website catalog/price/scope 1
* @magentoConfigFixture base_website currency/options/base EUR
* @magentoDataFixture Magento/AdvancedPricingImportExport/_files/create_products.php
* @param array $dbData
* @param array $importData
* @param string $importBehavior
* @param array $invalidRows
* @dataProvider importValidationDuplicateWithDifferentBaseCurrencyDataProvider
*/
public function testImportValidationDuplicateWithDifferentBaseCurrency(
array $dbData,
array $importData,
string $importBehavior,
array $invalidRows
) {
$this->createTierPrices($dbData);
$pathToFile = $this->generateImportFile($importData);
$errors = $this->doImport($pathToFile, DirectoryList::VAR_DIR, $importBehavior);
$rows = $errors->getRowsGroupedByErrorCode(['duplicateTierPrice'], [], false);
$this->assertEquals($invalidRows, $rows['duplicateTierPrice'] ?? []);
}
/**
* @return array[]
*/
public function importValidationDuplicateWithSameBaseCurrencyDataProvider(): array
{
return require __DIR__ . '/_files/import_validation_duplicate_same_currency_data_provider.php';
}
/**
* @return array[]
*/
public function importValidationDuplicateWithDifferentBaseCurrencyDataProvider(): array
{
return require __DIR__ . '/_files/import_validation_duplicate_diff_currency_data_provider.php';
}
/**
* @param string $directoryCode
* @param string $file
* @param string $behavior
* @param bool $validateOnly
* @return ProcessingErrorAggregatorInterface
* @throws \Magento\Framework\Exception\FileSystemException
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function doImport(
string $file,
string $directoryCode = DirectoryList::ROOT,
string $behavior = Import::BEHAVIOR_APPEND,
bool $validateOnly = false,
string $entity = 'advanced_pricing'
): ProcessingErrorAggregatorInterface {
/** @var Filesystem $filesystem */
$filesystem = $this->objectManager->create(Filesystem::class);
$directory = $filesystem->getDirectoryWrite($directoryCode);
$source = $this->objectManager->create(
Csv::class,
[
'file' => $file,
'directory' => $directory
]
);
$errors = $this->model->setSource($source)
->setParameters(
[
'behavior' => $behavior,
'entity' => $entity
]
)
->validateData();
if (!$validateOnly && !$errors->getAllErrors()) {
$this->model->importData();
}
return $errors;
}
/**
* @param array $tierPrices
*/
private function createTierPrices(array $tierPrices)
{
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$tierPriceFactory = $this->objectManager->get(ProductTierPriceInterfaceFactory::class);
$tpExtensionAttributesFactory = $this->objectManager->get(ProductTierPriceExtensionFactory::class);
$storeManager = $this->objectManager->get(StoreManagerInterface::class);
$productTierPrices = [];
foreach ($tierPrices as $price) {
$sku = $price['sku'];
$websiteId = 0;
$websiteCode = $price['website_id'];
$percentageValue = $price['percentage_value'] ?? null;
unset($price['sku'], $price['website_id'], $price['percentage_value']);
if ($websiteCode !== 0) {
$websiteId = $storeManager->getWebsite($websiteCode)->getId();
}
$tierPriceExtensionAttributes = $tpExtensionAttributesFactory->create();
$tierPriceExtensionAttributes->setWebsiteId($websiteId);
$tierPriceExtensionAttributes->setPercentageValue($percentageValue);
$productTierPrices[$sku][] = $tierPriceFactory->create(['data' => $price])
->setExtensionAttributes($tierPriceExtensionAttributes);
}
foreach ($productTierPrices as $sku => $prices) {
$product = $productRepository->get($sku, true, null, true);
$product->setTierPrices($prices);
$productRepository->save($product);
}
}
/**
* @param array $data
* @return string
*/
private function generateImportFile(array $data): string
{
$fields = [
'sku',
'tier_price_website',
'tier_price_customer_group',
'tier_price_qty',
'tier_price',
'tier_price_value_type',
];
$objectManager = Bootstrap::getObjectManager();
/** @var Filesystem $filesystem */
$filesystem = $objectManager->get(Filesystem::class);
$varDir = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$tmpFilename = uniqid('test_import_advanced_pricing_') . '.csv';
$stream = $varDir->openFile($tmpFilename, 'w+');
$stream->lock();
$stream->writeCsv($fields);
$emptyRow = array_fill_keys($fields, '');
foreach ($data as $row) {
$row = array_replace($emptyRow, $row);
$stream->writeCsv($row);
}
$stream->unlock();
$stream->close();
return $varDir->getAbsolutePath($tmpFilename);
}
/**
* For checking if correct add and update count are being displayed after importing file having 100+ records
*/
#[
DataFixture(
SelectAttribute::class,
[
'attribute_code' => 'size',
'default_frontend_label' => 'Size',
'scope' => 'global',
'options' => [28,29,30,31,32,33,34,36,38]
],
'attr1'
),
DataFixture(
SelectAttribute::class,
[
'attribute_code' => 'colors',
'default_frontend_label' => 'Colors',
'scope' => 'global',
'options' => ["Red","Green","Yellow","Blue","Orange"]
]
),
AppArea('adminhtml')
]
public function testImportAddUpdateCounts()
{
$this->model = $this->objectManager->create(\Magento\CatalogImportExport\Model\Import\Product::class);
// Import product data from CSV file
$productFilePath = __DIR__ . '/_files/import_catalog_product.csv';
$errors = $this->doImport(
$productFilePath,
DirectoryList::ROOT,
Import::BEHAVIOR_ADD_UPDATE,
true,
'catalog_product'
);
print_r($errors->getAllErrors());
$this->assertEquals(0, $errors->getErrorsCount(), 'Product import validation error');
$this->model->importData();
$this->assertEquals(64, $this->model->getCreatedItemsCount(), 'Products create item count');
$this->assertEquals(0, $this->model->getUpdatedItemsCount(), 'Products update item count');
// Import advance pricing data from CSV file
$this->model = $this->objectManager->create(
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class
);
$pathToFile = __DIR__ . '/_files/import_advanced_pricing_for_additional_attributes_products.csv';
$errors = $this->doImport($pathToFile, DirectoryList::ROOT, Import::BEHAVIOR_APPEND, true);
print_r($errors->getAllErrors());
$this->assertEquals(0, $errors->getErrorsCount(), 'Advanced pricing import validation error');
$this->model->importData();
$this->assertEquals(127, $this->model->getCreatedItemsCount(), 'Advance pricing create count1');
$this->assertEquals(0, $this->model->getUpdatedItemsCount(), 'Advance pricing update count1');
// Initializing again, since old model object holds old count
// Import advance pricing data from CSV file
$this->model = $this->objectManager->create(
\Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing::class
);
$this->doImport($pathToFile, DirectoryList::ROOT, Import::BEHAVIOR_APPEND);
$this->assertEquals(0, $this->model->getCreatedItemsCount(), 'Advance pricing create count2');
$this->assertEquals(127, $this->model->getUpdatedItemsCount(), 'Advance pricing update count2');
}
}
@@ -0,0 +1,9 @@
sku,tier_price_website,tier_price_customer_group,tier_price_qty,tier_price,tier_price_value_type
"AdvancedPricingSimple 1","All Websites [USD]","ALL GROUPS",10.0000,300.0000,Fixed
"AdvancedPricingSimple 2","All Websites [USD]","ALL GROUPS",100.0000,1000000.0000,Fixed
"AdvancedPricingSimple 1","All Websites [USD]",General,11.0000,11.0000,Fixed
"AdvancedPricingSimple 2","All Websites [USD]","NOT LOGGED IN",12.0000,12.0000,Fixed
"AdvancedPricingSimple 1","All Websites [USD]",Retailer,14.0000,14.0000,Fixed
"AdvancedPricingSimple 2","All Websites [USD]",Wholesale,13.0000,13.0000,Fixed
"AdvancedPricingSimple 1","All Websites [USD]","ALL GROUPS",20.0000,50,Discount
"AdvancedPricingSimple 2","All Websites [USD]","ALL GROUPS",200.0000,50,Discount
1 sku tier_price_website tier_price_customer_group tier_price_qty tier_price tier_price_value_type
2 AdvancedPricingSimple 1 All Websites [USD] ALL GROUPS 10.0000 300.0000 Fixed
3 AdvancedPricingSimple 2 All Websites [USD] ALL GROUPS 100.0000 1000000.0000 Fixed
4 AdvancedPricingSimple 1 All Websites [USD] General 11.0000 11.0000 Fixed
5 AdvancedPricingSimple 2 All Websites [USD] NOT LOGGED IN 12.0000 12.0000 Fixed
6 AdvancedPricingSimple 1 All Websites [USD] Retailer 14.0000 14.0000 Fixed
7 AdvancedPricingSimple 2 All Websites [USD] Wholesale 13.0000 13.0000 Fixed
8 AdvancedPricingSimple 1 All Websites [USD] ALL GROUPS 20.0000 50 Discount
9 AdvancedPricingSimple 2 All Websites [USD] ALL GROUPS 200.0000 50 Discount
@@ -0,0 +1,128 @@
sku,tier_price_website,tier_price_customer_group,tier_price_qty,tier_price,tier_price_value_type
test-sample,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-1,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-1,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-1,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-1,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Blue-34,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Blue-34,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Blue-34,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Blue-34,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Blue-36,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Blue-36,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Blue-36,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Blue-36,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Blue-38,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Blue-38,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Blue-38,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Blue-38,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Blue-39,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Blue-39,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Blue-39,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Blue-39,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Blue-42,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Blue-42,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Blue-42,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Blue-42,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Blue-44,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Blue-44,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Blue-44,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Blue-44,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Green-34,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Green-34,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Green-34,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Green-34,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Green-36,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Green-36,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Green-36,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Green-36,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Green-38,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Green-38,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Green-38,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Green-38,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Green-39,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Green-39,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Green-39,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Green-39,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Green-42,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Green-42,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Green-42,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Green-42,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Green-44,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Green-44,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Green-44,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Green-44,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Orange-34,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Orange-34,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Orange-34,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Orange-34,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Orange-36,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Orange-36,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Orange-36,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Orange-36,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Orange-38,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Orange-38,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Orange-38,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Orange-38,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Orange-39,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Orange-39,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Orange-39,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Orange-39,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Orange-42,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Orange-42,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Orange-42,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Orange-42,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Orange-44,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Orange-44,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Orange-44,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Orange-44,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Red-34,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Red-34,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Red-34,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Red-36,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Red-36,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Red-36,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Red-36,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Red-38,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Red-38,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Red-38,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Red-38,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Red-39,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Red-39,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Red-39,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Red-39,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Red-42,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Red-42,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Red-42,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Red-42,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Red-44,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Red-44,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Red-44,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Red-44,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Yellow-34,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Yellow-34,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Yellow-34,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Yellow-34,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Yellow-36,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Yellow-36,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Yellow-36,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Yellow-36,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Yellow-38,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Yellow-38,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Yellow-38,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Yellow-38,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Yellow-39,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Yellow-39,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Yellow-39,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Yellow-39,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Yellow-42,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Yellow-42,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Yellow-42,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Yellow-42,"All Websites [USD]",General,3.0000,15.00,Discount
test-sample-Yellow-44,"All Websites [USD]","ALL GROUPS",2.0000,10.000000,Fixed
test-sample-Yellow-44,"All Websites [USD]","ALL GROUPS",3.0000,15.00,Discount
test-sample-Yellow-44,"All Websites [USD]",General,2.0000,10.000000,Fixed
test-sample-Yellow-44,"All Websites [USD]",General,3.0000,15.00,Discount
1 sku tier_price_website tier_price_customer_group tier_price_qty tier_price tier_price_value_type
2 test-sample All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
3 test-sample All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
4 test-sample All Websites [USD] General 2.0000 10.000000 Fixed
5 test-sample All Websites [USD] General 3.0000 15.00 Discount
6 test-sample-1 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
7 test-sample-1 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
8 test-sample-1 All Websites [USD] General 2.0000 10.000000 Fixed
9 test-sample-1 All Websites [USD] General 3.0000 15.00 Discount
10 test-sample-Blue-34 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
11 test-sample-Blue-34 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
12 test-sample-Blue-34 All Websites [USD] General 2.0000 10.000000 Fixed
13 test-sample-Blue-34 All Websites [USD] General 3.0000 15.00 Discount
14 test-sample-Blue-36 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
15 test-sample-Blue-36 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
16 test-sample-Blue-36 All Websites [USD] General 2.0000 10.000000 Fixed
17 test-sample-Blue-36 All Websites [USD] General 3.0000 15.00 Discount
18 test-sample-Blue-38 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
19 test-sample-Blue-38 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
20 test-sample-Blue-38 All Websites [USD] General 2.0000 10.000000 Fixed
21 test-sample-Blue-38 All Websites [USD] General 3.0000 15.00 Discount
22 test-sample-Blue-39 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
23 test-sample-Blue-39 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
24 test-sample-Blue-39 All Websites [USD] General 2.0000 10.000000 Fixed
25 test-sample-Blue-39 All Websites [USD] General 3.0000 15.00 Discount
26 test-sample-Blue-42 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
27 test-sample-Blue-42 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
28 test-sample-Blue-42 All Websites [USD] General 2.0000 10.000000 Fixed
29 test-sample-Blue-42 All Websites [USD] General 3.0000 15.00 Discount
30 test-sample-Blue-44 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
31 test-sample-Blue-44 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
32 test-sample-Blue-44 All Websites [USD] General 2.0000 10.000000 Fixed
33 test-sample-Blue-44 All Websites [USD] General 3.0000 15.00 Discount
34 test-sample-Green-34 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
35 test-sample-Green-34 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
36 test-sample-Green-34 All Websites [USD] General 2.0000 10.000000 Fixed
37 test-sample-Green-34 All Websites [USD] General 3.0000 15.00 Discount
38 test-sample-Green-36 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
39 test-sample-Green-36 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
40 test-sample-Green-36 All Websites [USD] General 2.0000 10.000000 Fixed
41 test-sample-Green-36 All Websites [USD] General 3.0000 15.00 Discount
42 test-sample-Green-38 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
43 test-sample-Green-38 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
44 test-sample-Green-38 All Websites [USD] General 2.0000 10.000000 Fixed
45 test-sample-Green-38 All Websites [USD] General 3.0000 15.00 Discount
46 test-sample-Green-39 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
47 test-sample-Green-39 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
48 test-sample-Green-39 All Websites [USD] General 2.0000 10.000000 Fixed
49 test-sample-Green-39 All Websites [USD] General 3.0000 15.00 Discount
50 test-sample-Green-42 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
51 test-sample-Green-42 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
52 test-sample-Green-42 All Websites [USD] General 2.0000 10.000000 Fixed
53 test-sample-Green-42 All Websites [USD] General 3.0000 15.00 Discount
54 test-sample-Green-44 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
55 test-sample-Green-44 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
56 test-sample-Green-44 All Websites [USD] General 2.0000 10.000000 Fixed
57 test-sample-Green-44 All Websites [USD] General 3.0000 15.00 Discount
58 test-sample-Orange-34 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
59 test-sample-Orange-34 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
60 test-sample-Orange-34 All Websites [USD] General 2.0000 10.000000 Fixed
61 test-sample-Orange-34 All Websites [USD] General 3.0000 15.00 Discount
62 test-sample-Orange-36 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
63 test-sample-Orange-36 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
64 test-sample-Orange-36 All Websites [USD] General 2.0000 10.000000 Fixed
65 test-sample-Orange-36 All Websites [USD] General 3.0000 15.00 Discount
66 test-sample-Orange-38 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
67 test-sample-Orange-38 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
68 test-sample-Orange-38 All Websites [USD] General 2.0000 10.000000 Fixed
69 test-sample-Orange-38 All Websites [USD] General 3.0000 15.00 Discount
70 test-sample-Orange-39 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
71 test-sample-Orange-39 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
72 test-sample-Orange-39 All Websites [USD] General 2.0000 10.000000 Fixed
73 test-sample-Orange-39 All Websites [USD] General 3.0000 15.00 Discount
74 test-sample-Orange-42 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
75 test-sample-Orange-42 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
76 test-sample-Orange-42 All Websites [USD] General 2.0000 10.000000 Fixed
77 test-sample-Orange-42 All Websites [USD] General 3.0000 15.00 Discount
78 test-sample-Orange-44 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
79 test-sample-Orange-44 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
80 test-sample-Orange-44 All Websites [USD] General 2.0000 10.000000 Fixed
81 test-sample-Orange-44 All Websites [USD] General 3.0000 15.00 Discount
82 test-sample-Red-34 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
83 test-sample-Red-34 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
84 test-sample-Red-34 All Websites [USD] General 2.0000 10.000000 Fixed
85 test-sample-Red-36 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
86 test-sample-Red-36 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
87 test-sample-Red-36 All Websites [USD] General 2.0000 10.000000 Fixed
88 test-sample-Red-36 All Websites [USD] General 3.0000 15.00 Discount
89 test-sample-Red-38 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
90 test-sample-Red-38 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
91 test-sample-Red-38 All Websites [USD] General 2.0000 10.000000 Fixed
92 test-sample-Red-38 All Websites [USD] General 3.0000 15.00 Discount
93 test-sample-Red-39 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
94 test-sample-Red-39 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
95 test-sample-Red-39 All Websites [USD] General 2.0000 10.000000 Fixed
96 test-sample-Red-39 All Websites [USD] General 3.0000 15.00 Discount
97 test-sample-Red-42 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
98 test-sample-Red-42 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
99 test-sample-Red-42 All Websites [USD] General 2.0000 10.000000 Fixed
100 test-sample-Red-42 All Websites [USD] General 3.0000 15.00 Discount
101 test-sample-Red-44 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
102 test-sample-Red-44 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
103 test-sample-Red-44 All Websites [USD] General 2.0000 10.000000 Fixed
104 test-sample-Red-44 All Websites [USD] General 3.0000 15.00 Discount
105 test-sample-Yellow-34 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
106 test-sample-Yellow-34 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
107 test-sample-Yellow-34 All Websites [USD] General 2.0000 10.000000 Fixed
108 test-sample-Yellow-34 All Websites [USD] General 3.0000 15.00 Discount
109 test-sample-Yellow-36 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
110 test-sample-Yellow-36 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
111 test-sample-Yellow-36 All Websites [USD] General 2.0000 10.000000 Fixed
112 test-sample-Yellow-36 All Websites [USD] General 3.0000 15.00 Discount
113 test-sample-Yellow-38 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
114 test-sample-Yellow-38 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
115 test-sample-Yellow-38 All Websites [USD] General 2.0000 10.000000 Fixed
116 test-sample-Yellow-38 All Websites [USD] General 3.0000 15.00 Discount
117 test-sample-Yellow-39 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
118 test-sample-Yellow-39 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
119 test-sample-Yellow-39 All Websites [USD] General 2.0000 10.000000 Fixed
120 test-sample-Yellow-39 All Websites [USD] General 3.0000 15.00 Discount
121 test-sample-Yellow-42 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
122 test-sample-Yellow-42 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
123 test-sample-Yellow-42 All Websites [USD] General 2.0000 10.000000 Fixed
124 test-sample-Yellow-42 All Websites [USD] General 3.0000 15.00 Discount
125 test-sample-Yellow-44 All Websites [USD] ALL GROUPS 2.0000 10.000000 Fixed
126 test-sample-Yellow-44 All Websites [USD] ALL GROUPS 3.0000 15.00 Discount
127 test-sample-Yellow-44 All Websites [USD] General 2.0000 10.000000 Fixed
128 test-sample-Yellow-44 All Websites [USD] General 3.0000 15.00 Discount
@@ -0,0 +1,65 @@
sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,related_position,crosssell_skus,crosssell_position,upsell_skus,upsell_position,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,bundle_shipment_type,associated_skus,downloadable_links,downloadable_samples,configurable_variations,configurable_variation_labels
test-sample-Red-34,,Default,simple,,base,test-sample-Red-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-red-34,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Red,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Red-36,,Default,simple,,base,test-sample-Red-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-red-36,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Red,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Red-38,,Default,simple,,base,test-sample-Red-38,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-red-38,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Red,size=33",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Red-39,,Default,simple,,base,test-sample-Red-39,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-red-39,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Red,size=34",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Red-42,,Default,simple,,base,test-sample-Red-42,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-red-42,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Red,size=36",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Red-44,,Default,simple,,base,test-sample-Red-44,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-red-44,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Red,size=28",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Green-34,,Default,simple,,base,test-sample-Green-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-green-34,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Green,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Green-36,,Default,simple,,base,test-sample-Green-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-green-36,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Green,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Green-38,,Default,simple,,base,test-sample-Green-38,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-green-38,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Green,size=33",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Green-39,,Default,simple,,base,test-sample-Green-39,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-green-39,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Green,size=34",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Green-42,,Default,simple,,base,test-sample-Green-42,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-green-42,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Green,size=36",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Green-44,,Default,simple,,base,test-sample-Green-44,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-green-44,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Green,size=28",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Yellow-34,,Default,simple,,base,test-sample-Yellow-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-yellow-34,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Yellow,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Yellow-36,,Default,simple,,base,test-sample-Yellow-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-yellow-36,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Yellow,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Yellow-38,,Default,simple,,base,test-sample-Yellow-38,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-yellow-38,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Yellow,size=33",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Yellow-39,,Default,simple,,base,test-sample-Yellow-39,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-yellow-39,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Yellow,size=34",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Yellow-42,,Default,simple,,base,test-sample-Yellow-42,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-yellow-42,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Yellow,size=36",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Yellow-44,,Default,simple,,base,test-sample-Yellow-44,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-yellow-44,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Yellow,size=28",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Blue-34,,Default,simple,,base,test-sample-Blue-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-blue-34,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Blue,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Blue-36,,Default,simple,,base,test-sample-Blue-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-blue-36,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Blue,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Blue-38,,Default,virtual,,base,test-sample-Blue-38,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-blue-38,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Blue,size=33",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Blue-39,,Default,virtual,,base,test-sample-Blue-39,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-blue-39,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Blue,size=34",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Blue-42,,Default,virtual,,base,test-sample-Blue-42,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-blue-42,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Blue,size=36",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Blue-44,,Default,virtual,,base,test-sample-Blue-44,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-blue-44,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Blue,size=28",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Orange-34,,Default,virtual,,base,test-sample-Orange-34,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-orange-34,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Orange,size=31",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Orange-36,,Default,virtual,,base,test-sample-Orange-36,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-orange-36,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Orange,size=32",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Orange-38,,Default,virtual,,base,test-sample-Orange-38,,,,1,"Taxable Goods","Not Visible Individually",23.000000,16.500000,5/22/22,,test-sample-orange-38,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Orange,size=33",0.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Orange-39,,Default,virtual,,base,test-sample-Orange-39,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-orange-39,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Orange,size=34",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Orange-42,,Default,virtual,,base,test-sample-Orange-42,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-orange-42,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Orange,size=36",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample-Orange-44,,Default,virtual,,base,test-sample-Orange-44,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,test-sample-orange-44,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,,,"colors=Orange,size=28",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
test-sample,,Default,configurable,,base,test-sample,,,,1,"Taxable Goods","Catalog, Search",,,,,test-sample,test-sample,test-sample,"test-sample ",,,,,,,,,"5/22/22, 11:20 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,"Use config",,,,,,,"Use config",,,0.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,"sku=test-sample-Red-34,colors=Red,size=34|sku=test-sample-Red-44,colors=Red,size=31|sku=test-sample-Red-42,colors=Red,size=32|sku=test-sample-Red-39,colors=Red,size=29|sku=test-sample-Red-38,colors=Red,size=28|sku=test-sample-Red-36,colors=Red,size=36","colors=Colors,size=Size"
test-sample-1,,Default,configurable,,base,test-sample,,,,2,"Taxable Goods","Catalog, Search",,,,,test-sample-1,,,,,,,,,,,,"5/22/22, 11:21 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,"Use config",,,,,,,"Use config",,,0.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,0,,1,0,1,1,0.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,"sku=test-sample-Green-42,colors=Green,size=32|sku=test-sample-Green-39,colors=Green,size=29|sku=test-sample-Green-38,colors=Green,size=28|sku=test-sample-Green-36,colors=Green,size=36|sku=test-sample-Green-34,colors=Green,size=34|sku=test-sample-Green-44,colors=Green,size=31","colors=Colors,size=Size"
new-test-sample-Red-34,,Default,simple,,base,new-test-sample-Red-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-red-34,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Red,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Red-36,,Default,simple,,base,new-test-sample-Red-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-red-36,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Red,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Red-38,,Default,simple,,base,new-test-sample-Red-38,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-red-38,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Red,size=33",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Red-39,,Default,simple,,base,new-test-sample-Red-39,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-red-39,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Red,size=34",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Red-42,,Default,simple,,base,new-test-sample-Red-42,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-red-42,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Red,size=36",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Red-44,,Default,simple,,base,new-test-sample-Red-44,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-red-44,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Red,size=28",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Green-34,,Default,simple,,base,new-test-sample-Green-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-green-34,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Green,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Green-36,,Default,simple,,base,new-test-sample-Green-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-green-36,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Green,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Green-38,,Default,simple,,base,new-test-sample-Green-38,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-green-38,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Green,size=33",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Green-39,,Default,simple,,base,new-test-sample-Green-39,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-green-39,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Green,size=34",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Green-42,,Default,simple,,base,new-test-sample-Green-42,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-green-42,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Green,size=36",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Green-44,,Default,simple,,base,new-test-sample-Green-44,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-green-44,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Green,size=28",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Yellow-34,,Default,simple,,base,new-test-sample-Yellow-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-yellow-34,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Yellow,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Yellow-36,,Default,simple,,base,new-test-sample-Yellow-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-yellow-36,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Yellow,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Yellow-38,,Default,simple,,base,new-test-sample-Yellow-38,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-yellow-38,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Yellow,size=33",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Yellow-39,,Default,simple,,base,new-test-sample-Yellow-39,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-yellow-39,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Yellow,size=34",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Yellow-42,,Default,simple,,base,new-test-sample-Yellow-42,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-yellow-42,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Yellow,size=36",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Yellow-44,,Default,simple,,base,new-test-sample-Yellow-44,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-yellow-44,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Yellow,size=28",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Blue-34,,Default,simple,,base,new-test-sample-Blue-34,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-blue-34,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Blue,size=31",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Blue-36,,Default,simple,,base,new-test-sample-Blue-36,,,1.000000,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-blue-36,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Blue,size=32",55.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Blue-38,,Default,virtual,,base,new-test-sample-Blue-38,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-blue-38,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Blue,size=33",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Blue-39,,Default,virtual,,base,new-test-sample-Blue-39,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-blue-39,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Blue,size=34",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Blue-42,,Default,virtual,,base,new-test-sample-Blue-42,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-blue-42,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Blue,size=36",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Blue-44,,Default,virtual,,base,new-test-sample-Blue-44,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-blue-44,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Blue,size=28",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Orange-34,,Default,virtual,,base,new-test-sample-Orange-34,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-orange-34,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Orange,size=31",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Orange-36,,Default,virtual,,base,new-test-sample-Orange-36,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-orange-36,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Orange,size=32",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Orange-38,,Default,virtual,,base,new-test-sample-Orange-38,,,,1,"Taxable Goods","Not Visible Individually",23.000000,16.500000,5/22/22,,new-test-sample-orange-38,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Orange,size=33",0.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Orange-39,,Default,virtual,,base,new-test-sample-Orange-39,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-orange-39,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Orange,size=34",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Orange-42,,Default,virtual,,base,new-test-sample-Orange-42,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-orange-42,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Orange,size=36",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample-Orange-44,,Default,virtual,,base,new-test-sample-Orange-44,,,,1,"Taxable Goods","Not Visible Individually",23.000000,,,,new-test-sample-orange-44,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,No,,,,,,,"Use config",,"colors=Orange,size=28",,0.0000,1,0,0,1,1.0000,1,10000.0000,1,0,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,,
new-test-sample,,Default,configurable,,base,new-test-sample,,,,1,"Taxable Goods","Catalog, Search",,,,,new-test-sample,new-test-sample,new-test-sample,"new-test-sample ",,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,"Use config",,,,,,,"Use config",,,0.0000,0.0000,1,0,0,1,1.0000,1,10000.0000,1,1,1.0000,1,1,1,1,1.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,"sku=new-test-sample-Yellow-38,colors=Yellow,size=28|sku=new-test-sample-Yellow-39,colors=Yellow,size=29|sku=new-test-sample-Yellow-42,colors=Yellow,size=32|sku=new-test-sample-Yellow-44,colors=Yellow,size=31|sku=new-test-sample-Yellow-34,colors=Yellow,size=34|sku=new-test-sample-Yellow-36,colors=Yellow,size=36","colors=Colors,size=Size"
new-test-sample-1,,Default,configurable,,base,new-test-sample,,,,2,"Taxable Goods","Catalog, Search",,,,,new-test-sample-1,,,,,,,,,,,,"5/23/22, 11:13 PM","5/23/22, 11:13 PM",,,"Block after Info Column",,,,"Use config",,,,,,,"Use config",,,0.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,0,,1,0,1,1,0.0000,1,0,0,0,,,,,,,,,,,,,,,,,,,,"sku=new-test-sample-Blue-39,colors=Blue,size=29|sku=new-test-sample-Blue-42,colors=Blue,size=32|sku=new-test-sample-Blue-44,colors=Blue,size=31|sku=new-test-sample-Blue-34,colors=Blue,size=34|sku=new-test-sample-Blue-36,colors=Blue,size=36|sku=new-test-sample-Blue-38,colors=Blue,size=28","colors=Colors,size=Size"
1 sku store_view_code attribute_set_code product_type categories product_websites name description short_description weight product_online tax_class_name visibility price special_price special_price_from_date special_price_to_date url_key meta_title meta_keywords meta_description base_image base_image_label small_image small_image_label thumbnail_image thumbnail_image_label swatch_image swatch_image_label created_at updated_at new_from_date new_to_date display_product_options_in map_price msrp_price map_enabled gift_message_available custom_design custom_design_from custom_design_to custom_layout_update page_layout product_options_container msrp_display_actual_price_type country_of_manufacture additional_attributes qty out_of_stock_qty use_config_min_qty is_qty_decimal allow_backorders use_config_backorders min_cart_qty use_config_min_sale_qty max_cart_qty use_config_max_sale_qty is_in_stock notify_on_stock_below use_config_notify_stock_qty manage_stock use_config_manage_stock use_config_qty_increments qty_increments use_config_enable_qty_inc enable_qty_increments is_decimal_divided website_id related_skus related_position crosssell_skus crosssell_position upsell_skus upsell_position additional_images additional_image_labels hide_from_product_page custom_options bundle_price_type bundle_sku_type bundle_price_view bundle_weight_type bundle_values bundle_shipment_type associated_skus downloadable_links downloadable_samples configurable_variations configurable_variation_labels
2 test-sample-Red-34 Default simple base test-sample-Red-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-red-34 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Red,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
3 test-sample-Red-36 Default simple base test-sample-Red-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-red-36 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Red,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
4 test-sample-Red-38 Default simple base test-sample-Red-38 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-red-38 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Red,size=33 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
5 test-sample-Red-39 Default simple base test-sample-Red-39 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-red-39 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Red,size=34 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
6 test-sample-Red-42 Default simple base test-sample-Red-42 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-red-42 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Red,size=36 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
7 test-sample-Red-44 Default simple base test-sample-Red-44 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-red-44 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Red,size=28 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
8 test-sample-Green-34 Default simple base test-sample-Green-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-green-34 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Green,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
9 test-sample-Green-36 Default simple base test-sample-Green-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-green-36 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Green,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
10 test-sample-Green-38 Default simple base test-sample-Green-38 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-green-38 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Green,size=33 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
11 test-sample-Green-39 Default simple base test-sample-Green-39 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-green-39 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Green,size=34 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
12 test-sample-Green-42 Default simple base test-sample-Green-42 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-green-42 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Green,size=36 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
13 test-sample-Green-44 Default simple base test-sample-Green-44 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-green-44 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Green,size=28 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
14 test-sample-Yellow-34 Default simple base test-sample-Yellow-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-yellow-34 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Yellow,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
15 test-sample-Yellow-36 Default simple base test-sample-Yellow-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-yellow-36 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Yellow,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
16 test-sample-Yellow-38 Default simple base test-sample-Yellow-38 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-yellow-38 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Yellow,size=33 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
17 test-sample-Yellow-39 Default simple base test-sample-Yellow-39 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-yellow-39 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Yellow,size=34 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
18 test-sample-Yellow-42 Default simple base test-sample-Yellow-42 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-yellow-42 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Yellow,size=36 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
19 test-sample-Yellow-44 Default simple base test-sample-Yellow-44 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-yellow-44 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Yellow,size=28 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
20 test-sample-Blue-34 Default simple base test-sample-Blue-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-blue-34 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Blue,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
21 test-sample-Blue-36 Default simple base test-sample-Blue-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 test-sample-blue-36 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Blue,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
22 test-sample-Blue-38 Default virtual base test-sample-Blue-38 1 Taxable Goods Not Visible Individually 23.000000 test-sample-blue-38 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Blue,size=33 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
23 test-sample-Blue-39 Default virtual base test-sample-Blue-39 1 Taxable Goods Not Visible Individually 23.000000 test-sample-blue-39 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Blue,size=34 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
24 test-sample-Blue-42 Default virtual base test-sample-Blue-42 1 Taxable Goods Not Visible Individually 23.000000 test-sample-blue-42 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Blue,size=36 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
25 test-sample-Blue-44 Default virtual base test-sample-Blue-44 1 Taxable Goods Not Visible Individually 23.000000 test-sample-blue-44 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Blue,size=28 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
26 test-sample-Orange-34 Default virtual base test-sample-Orange-34 1 Taxable Goods Not Visible Individually 23.000000 test-sample-orange-34 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Orange,size=31 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
27 test-sample-Orange-36 Default virtual base test-sample-Orange-36 1 Taxable Goods Not Visible Individually 23.000000 test-sample-orange-36 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Orange,size=32 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
28 test-sample-Orange-38 Default virtual base test-sample-Orange-38 1 Taxable Goods Not Visible Individually 23.000000 16.500000 5/22/22 test-sample-orange-38 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Orange,size=33 0.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
29 test-sample-Orange-39 Default virtual base test-sample-Orange-39 1 Taxable Goods Not Visible Individually 23.000000 test-sample-orange-39 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Orange,size=34 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
30 test-sample-Orange-42 Default virtual base test-sample-Orange-42 1 Taxable Goods Not Visible Individually 23.000000 test-sample-orange-42 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Orange,size=36 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
31 test-sample-Orange-44 Default virtual base test-sample-Orange-44 1 Taxable Goods Not Visible Individually 23.000000 test-sample-orange-44 test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column No colors=Orange,size=28 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
32 test-sample Default configurable base test-sample 1 Taxable Goods Catalog, Search test-sample test-sample test-sample test-sample 5/22/22, 11:20 PM 5/23/22, 11:13 PM Block after Info Column Use config Use config 0.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0 sku=test-sample-Red-34,colors=Red,size=34|sku=test-sample-Red-44,colors=Red,size=31|sku=test-sample-Red-42,colors=Red,size=32|sku=test-sample-Red-39,colors=Red,size=29|sku=test-sample-Red-38,colors=Red,size=28|sku=test-sample-Red-36,colors=Red,size=36 colors=Colors,size=Size
33 test-sample-1 Default configurable base test-sample 2 Taxable Goods Catalog, Search test-sample-1 5/22/22, 11:21 PM 5/23/22, 11:13 PM Block after Info Column Use config Use config 0.0000 0.0000 1 0 0 1 1.0000 1 0.0000 1 0 1 0 1 1 0.0000 1 0 0 0 sku=test-sample-Green-42,colors=Green,size=32|sku=test-sample-Green-39,colors=Green,size=29|sku=test-sample-Green-38,colors=Green,size=28|sku=test-sample-Green-36,colors=Green,size=36|sku=test-sample-Green-34,colors=Green,size=34|sku=test-sample-Green-44,colors=Green,size=31 colors=Colors,size=Size
34 new-test-sample-Red-34 Default simple base new-test-sample-Red-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-red-34 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Red,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
35 new-test-sample-Red-36 Default simple base new-test-sample-Red-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-red-36 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Red,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
36 new-test-sample-Red-38 Default simple base new-test-sample-Red-38 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-red-38 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Red,size=33 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
37 new-test-sample-Red-39 Default simple base new-test-sample-Red-39 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-red-39 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Red,size=34 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
38 new-test-sample-Red-42 Default simple base new-test-sample-Red-42 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-red-42 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Red,size=36 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
39 new-test-sample-Red-44 Default simple base new-test-sample-Red-44 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-red-44 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Red,size=28 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
40 new-test-sample-Green-34 Default simple base new-test-sample-Green-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-green-34 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Green,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
41 new-test-sample-Green-36 Default simple base new-test-sample-Green-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-green-36 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Green,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
42 new-test-sample-Green-38 Default simple base new-test-sample-Green-38 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-green-38 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Green,size=33 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
43 new-test-sample-Green-39 Default simple base new-test-sample-Green-39 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-green-39 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Green,size=34 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
44 new-test-sample-Green-42 Default simple base new-test-sample-Green-42 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-green-42 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Green,size=36 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
45 new-test-sample-Green-44 Default simple base new-test-sample-Green-44 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-green-44 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Green,size=28 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
46 new-test-sample-Yellow-34 Default simple base new-test-sample-Yellow-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-yellow-34 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Yellow,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
47 new-test-sample-Yellow-36 Default simple base new-test-sample-Yellow-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-yellow-36 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Yellow,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
48 new-test-sample-Yellow-38 Default simple base new-test-sample-Yellow-38 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-yellow-38 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Yellow,size=33 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
49 new-test-sample-Yellow-39 Default simple base new-test-sample-Yellow-39 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-yellow-39 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Yellow,size=34 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
50 new-test-sample-Yellow-42 Default simple base new-test-sample-Yellow-42 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-yellow-42 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Yellow,size=36 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
51 new-test-sample-Yellow-44 Default simple base new-test-sample-Yellow-44 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-yellow-44 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Yellow,size=28 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
52 new-test-sample-Blue-34 Default simple base new-test-sample-Blue-34 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-blue-34 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Blue,size=31 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
53 new-test-sample-Blue-36 Default simple base new-test-sample-Blue-36 1.000000 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-blue-36 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Blue,size=32 55.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0
54 new-test-sample-Blue-38 Default virtual base new-test-sample-Blue-38 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-blue-38 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Blue,size=33 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
55 new-test-sample-Blue-39 Default virtual base new-test-sample-Blue-39 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-blue-39 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Blue,size=34 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
56 new-test-sample-Blue-42 Default virtual base new-test-sample-Blue-42 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-blue-42 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Blue,size=36 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
57 new-test-sample-Blue-44 Default virtual base new-test-sample-Blue-44 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-blue-44 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Blue,size=28 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
58 new-test-sample-Orange-34 Default virtual base new-test-sample-Orange-34 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-orange-34 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Orange,size=31 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
59 new-test-sample-Orange-36 Default virtual base new-test-sample-Orange-36 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-orange-36 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Orange,size=32 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
60 new-test-sample-Orange-38 Default virtual base new-test-sample-Orange-38 1 Taxable Goods Not Visible Individually 23.000000 16.500000 5/22/22 new-test-sample-orange-38 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Orange,size=33 0.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
61 new-test-sample-Orange-39 Default virtual base new-test-sample-Orange-39 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-orange-39 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Orange,size=34 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
62 new-test-sample-Orange-42 Default virtual base new-test-sample-Orange-42 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-orange-42 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Orange,size=36 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
63 new-test-sample-Orange-44 Default virtual base new-test-sample-Orange-44 1 Taxable Goods Not Visible Individually 23.000000 new-test-sample-orange-44 new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column No Use config colors=Orange,size=28 0.0000 1 0 0 1 1.0000 1 10000.0000 1 0 1.0000 1 1 1 1 1.0000 1 0 0 0
64 new-test-sample Default configurable base new-test-sample 1 Taxable Goods Catalog, Search new-test-sample new-test-sample new-test-sample new-test-sample 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column Use config Use config 0.0000 0.0000 1 0 0 1 1.0000 1 10000.0000 1 1 1.0000 1 1 1 1 1.0000 1 0 0 0 sku=new-test-sample-Yellow-38,colors=Yellow,size=28|sku=new-test-sample-Yellow-39,colors=Yellow,size=29|sku=new-test-sample-Yellow-42,colors=Yellow,size=32|sku=new-test-sample-Yellow-44,colors=Yellow,size=31|sku=new-test-sample-Yellow-34,colors=Yellow,size=34|sku=new-test-sample-Yellow-36,colors=Yellow,size=36 colors=Colors,size=Size
65 new-test-sample-1 Default configurable base new-test-sample 2 Taxable Goods Catalog, Search new-test-sample-1 5/23/22, 11:13 PM 5/23/22, 11:13 PM Block after Info Column Use config Use config 0.0000 0.0000 1 0 0 1 1.0000 1 0.0000 1 0 1 0 1 1 0.0000 1 0 0 0 sku=new-test-sample-Blue-39,colors=Blue,size=29|sku=new-test-sample-Blue-42,colors=Blue,size=32|sku=new-test-sample-Blue-44,colors=Blue,size=31|sku=new-test-sample-Blue-34,colors=Blue,size=34|sku=new-test-sample-Blue-36,colors=Blue,size=36|sku=new-test-sample-Blue-38,colors=Blue,size=28 colors=Colors,size=Size
@@ -0,0 +1,105 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
return [
[
[
],
[
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '300',
'tier_price_value_type' => 'Fixed',
],
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'base',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '25.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[]
],
[
[
],
[
[
'sku' => 'AdvancedPricingSimple 2',
'tier_price_website' => 'base',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '10.0000',
'tier_price' => '450',
'tier_price_value_type' => 'Fixed',
],
[
'sku' => 'AdvancedPricingSimple 2',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '10.0000',
'tier_price' => '30.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[]
],
[
[
[
'sku' => 'AdvancedPricingSimple 1',
'website_id' => 0,
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'qty' => 5,
'value' => 300,
'percentage_value' => null
]
],
[
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'base',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '25.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[]
],
[
[
[
'sku' => 'AdvancedPricingSimple 2',
'website_id' => 'base',
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'qty' => 10,
'value' => 450,
'percentage_value' => null
]
],
[
[
'sku' => 'AdvancedPricingSimple 2',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '10.0000',
'tier_price' => '30.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[]
]
];
@@ -0,0 +1,153 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
return [
[
[
],
[
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '300',
'tier_price_value_type' => 'Fixed',
],
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'base',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '25.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[2]
],
[
[
],
[
[
'sku' => 'AdvancedPricingSimple 2',
'tier_price_website' => 'base',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '10.0000',
'tier_price' => '450',
'tier_price_value_type' => 'Fixed',
],
[
'sku' => 'AdvancedPricingSimple 2',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '10.0000',
'tier_price' => '30.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[2]
],
[
[
[
'sku' => 'AdvancedPricingSimple 1',
'website_id' => 0,
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'qty' => 5,
'value' => 300,
'percentage_value' => null
]
],
[
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'base',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '25.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[1]
],
[
[
[
'sku' => 'AdvancedPricingSimple 2',
'website_id' => 'base',
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'qty' => 10,
'value' => 450,
'percentage_value' => null
]
],
[
[
'sku' => 'AdvancedPricingSimple 2',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '10.0000',
'tier_price' => '30.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND,
[1]
],
[
[
],
[
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '300',
'tier_price_value_type' => 'Fixed',
],
[
'sku' => 'AdvancedPricingSimple 1',
'tier_price_website' => 'base',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '5.0000',
'tier_price' => '25.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE,
[2]
],
[
[
[
'sku' => 'AdvancedPricingSimple 2',
'website_id' => 'base',
'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL,
'qty' => 10,
'value' => 450,
'percentage_value' => null
]
],
[
[
'sku' => 'AdvancedPricingSimple 2',
'tier_price_website' => 'All Websites [USD]',
'tier_price_customer_group' => 'ALL GROUPS',
'tier_price_qty' => '10.0000',
'tier_price' => '30.0000',
'tier_price_value_type' => 'Discount',
]
],
\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE,
[]
],
];
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Catalog\Model\Product\Type;
use Magento\Catalog\Model\Product\Visibility;
use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
/** @var ObjectManagerInterface $objectManager */
$objectManager = Bootstrap::getObjectManager();
/**
* @var Product $productModel
* @var ProductRepositoryInterface $productRepository
*/
$productModel = $objectManager->create(Product::class);
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
$productModel->setTypeId(Type::TYPE_SIMPLE)
->setAttributeSetId(4)
->setName('AdvancedPricingSimple 1')
->setSku('AdvancedPricingSimple 1')
->setPrice(321)
->setVisibility(Visibility::VISIBILITY_BOTH)
->setStatus(Status::STATUS_ENABLED)
->setWebsiteIds([1])
->setCategoryIds([])
->setStockData(['qty' => 100, 'is_in_stock' => 1, 'manage_stock' => 1])
->setIsObjectNew(true);
$productRepository->save($productModel);
$productModel = $objectManager->create(Product::class);
$productModel->setTypeId(Type::TYPE_SIMPLE)
->setAttributeSetId(4)
->setName('AdvancedPricingSimple 2')
->setSku('AdvancedPricingSimple 2')
->setPrice(654)
->setVisibility(Visibility::VISIBILITY_BOTH)
->setStatus(Status::STATUS_ENABLED)
->setWebsiteIds([1])
->setCategoryIds([])
->setStockData(['qty' => 100, 'is_in_stock' => 1, 'manage_stock' => 1])
->setIsObjectNew(true);
$productRepository->save($productModel);
@@ -0,0 +1,28 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
/** @var ObjectManagerInterface $objectManager */
$objectManager = Bootstrap::getObjectManager();
/**
* @var ProductRepositoryInterface $productRepository
*/
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
$skus = ['AdvancedPricingSimple 1', 'AdvancedPricingSimple 2'];
foreach ($skus as $sku) {
try {
$product = $productRepository->deleteById($sku);
} catch (NoSuchEntityException $exception) {
// product already removed
}
}
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Customer\Model\Group;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
use Magento\Store\Api\WebsiteRepositoryInterface;
Resolver::getInstance()->requireDataFixture('Magento/Store/_files/website.php');
Resolver::getInstance()->requireDataFixture('Magento/AdvancedPricingImportExport/_files/create_products.php');
$objectManager = Bootstrap::getObjectManager();
/** @var ProductAttributeRepositoryInterface $attributeRepository */
$attributeRepository = $objectManager->get(ProductAttributeRepositoryInterface::class);
$groupPriceAttribute = $attributeRepository->get('tier_price')->setScope(ScopedAttributeInterface::SCOPE_WEBSITE);
$attributeRepository->save($groupPriceAttribute);
/** @var WebsiteRepositoryInterface $websiteRepository */
$websiteRepository = $objectManager->get(WebsiteRepositoryInterface::class);
$website = $websiteRepository->get('test');
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
$productModel = $productRepository->get('AdvancedPricingSimple 2');
$productModel->setWebsiteIds(array_merge($productModel->getWebsiteIds(), [(int)$website->getId()]));
$productModel->setTierPrice(
[
[
'website_id' => $website->getId(),
'cust_group' => Group::CUST_GROUP_ALL,
'price_qty' => 3,
'price' => 5
]
]
);
$productRepository->save($productModel);
@@ -0,0 +1,12 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
Resolver::getInstance()->requireDataFixture('Magento/Store/_files/website_rollback.php');
Resolver::getInstance()->requireDataFixture('Magento/AdvancedPricingImportExport/_files/create_products_rollback.php');
@@ -0,0 +1,46 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdvancedSearch\Block;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Search\Model\QueryResult;
use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;
use Magento\Framework\View\LayoutInterface;
/**
* @magentoAppArea frontend
*/
class SuggestionsTest extends \PHPUnit\Framework\TestCase
{
/** @var \Magento\AdvancedSearch\Block\Suggestions */
protected $block;
protected function setUp(): void
{
$suggestedQueries = $this->createMock(SuggestedQueriesInterface::CLASS);
$suggestedQueries->expects($this->any())->method('getItems')->willReturn([
new QueryResult('test item', 1),
new QueryResult("<script>alert('Test');</script>", 1)
]);
$this->block = Bootstrap::getObjectManager()->create(\Magento\AdvancedSearch\Block\Suggestions::class, [
'searchDataProvider' => $suggestedQueries,
'title' => 'title',
]);
}
public function testRenderEscaping()
{
$html = $this->block->toHtml();
$this->assertStringContainsString('test+item', $html);
$this->assertStringContainsString('test item', $html);
$this->assertStringNotContainsString('<script>', $html);
$this->assertStringContainsString('%3Cscript%3Ealert%28%27Test%27%29%3B%3C%2Fscript%3E', $html);
$this->assertStringContainsString("&lt;script&gt;alert(&#039;Test&#039;);&lt;/script&gt;", $html);
}
}
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\AdvancedSearch\Model;
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
use Magento\Search\Model\Query;
use Magento\Store\Model\ScopeInterface;
use Magento\TestFramework\Fixture\Config as FixtureConfig;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DbIsolation;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
class SuggestedQueriesTest extends TestCase
{
/**
* @var SuggestedQueries
*/
private $suggestedQueries;
protected function setUp(): void
{
$this->suggestedQueries = Bootstrap::getObjectManager()
->create(SuggestedQueries::class);
}
#[
DbIsolation(false),
FixtureConfig(
'catalog/search/elasticsearch_index_prefix',
'suggested_queries_test',
ScopeInterface::SCOPE_STORE
),
FixtureConfig(SuggestedQueriesInterface::SEARCH_SUGGESTION_ENABLED, 1, ScopeInterface::SCOPE_STORE),
FixtureConfig(SuggestedQueriesInterface::SEARCH_SUGGESTION_COUNT, 8, ScopeInterface::SCOPE_STORE),
DataFixture(ProductFixture::class, ['name' => 'fresh arugula salad']),
DataFixture('Magento/CatalogSearch/_files/full_reindex.php'),
]
public function testGetItems(): void
{
$query = Bootstrap::getObjectManager()
->create(Query::class, ['data' => ['query_text' => 'frshe arugul salat']]);
$queryResults = $this->suggestedQueries->getItems($query);
$queryTexts = [];
foreach ($queryResults as $queryResult) {
$queryTexts[] = $queryResult->getQueryText();
}
self::assertCount(7, $queryTexts);
self::assertEquals('fresh arugula salad', $queryTexts[0]);
}
}
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Block\Adminhtml\System\Config;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\Data\Form\Element\TimeFactory;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
/**
* Provide tests for CollectionTimeLabel block.
*/
class CollectionTimeLabelTest extends TestCase
{
/**
* Test render will add comment considering config locale(default en_US).
*
* @magentoAppIsolation enabled
*/
public function testRenderWithDefaultLocale()
{
$result = $this->render();
$this->assertMatchesRegularExpression('/<span>Pacific Standard Time/', $result);
}
/**
* Test render will add comment considering config locale(non-default de_DE).
*
* @magentoConfigFixture default_store general/locale/code de_DE
* @magentoAppIsolation enabled
*/
public function testRenderWithNonDefaultLocale()
{
$result = $this->render();
$this->assertMatchesRegularExpression('/<span>Nordamerikanische Westküsten-Normalzeit/', $result);
}
/**
* Render 'time' element.
*
* @return string
*/
private function render()
{
$collectionTimeLabel = Bootstrap::getObjectManager()->get(CollectionTimeLabelFactory::class)->create();
$form = Bootstrap::getObjectManager()->get(FormFactory::class)->create();
$element = Bootstrap::getObjectManager()->get(TimeFactory::class)->create();
$element->setForm($form);
return $collectionTimeLabel->render($element);
}
}
@@ -0,0 +1,35 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Analytics\Controller\Adminhtml\Reports;
use Magento\TestFramework\TestCase\AbstractBackendController;
/**
* @magentoAppArea adminhtml
*/
class ShowTest extends AbstractBackendController
{
private const REPORT_HOST = 'experienceleague.adobe.com';
/**
* @var string
*/
protected $resource = 'Magento_Analytics::advanced_reporting';
/**
* @var string
*/
protected $uri = 'backend/analytics/reports/show';
/**
* @inheritDoc
*/
public function testAclHasAccess()
{
parent::testAclHasAccess();
$this->assertSame(302, $this->getResponse()->getHttpResponseCode());
$this->assertSame(self::REPORT_HOST, $this->getResponse()->getHeader('location')->uri()->getHost());
}
}
@@ -0,0 +1,91 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Analytics\Cron;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
/**
* Checks data collection process behaviour
*
* @see \Magento\Analytics\Cron\CollectData
*
* @magentoAppArea adminhtml
*/
class CollectDataTest extends TestCase
{
/** @var ObjectManagerInterface */
private $objectManager;
/** @var CollectData */
private $collectDataService;
/** @var WriteInterface */
private $mediaDirectory;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->objectManager = Bootstrap::getObjectManager();
$this->collectDataService = $this->objectManager->get(CollectData::class);
$this->mediaDirectory = $this->objectManager->get(Filesystem::class)->getDirectoryWrite(DirectoryList::MEDIA);
$this->removeAnalyticsDirectory();
}
/**
* @inheritdoc
*/
protected function tearDown(): void
{
$this->removeAnalyticsDirectory();
parent::tearDown();
}
/**
* @magentoConfigFixture current_store analytics/subscription/enabled 1
* @magentoConfigFixture default/analytics/general/token 123
*
* @return void
*/
public function testExecute(): void
{
$this->collectDataService->execute();
$this->assertTrue(
$this->mediaDirectory->isDirectory('analytics'),
'Analytics was not created'
);
$files = $this->mediaDirectory->getDriver()
->readDirectoryRecursively($this->mediaDirectory->getAbsolutePath('analytics'));
$file = array_filter($files, function ($element) {
return substr($element, -8) === 'data.tgz';
});
$this->assertNotEmpty($file, 'File was not created');
}
/**
* Remove Analytics directory
*
* @return void
*/
private function removeAnalyticsDirectory(): void
{
$directoryToRemove = $this->mediaDirectory->getAbsolutePath('analytics');
if ($this->mediaDirectory->isDirectory($directoryToRemove)) {
$this->mediaDirectory->delete($directoryToRemove);
}
}
}
@@ -0,0 +1,235 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Analytics\Cron;
use Laminas\Http\Response;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector\Http\Client\Curl as CurlClient;
use Magento\Analytics\Model\Connector\Http\ClientInterface;
use Magento\Config\Model\PreparedValueFactory;
use Magento\Config\Model\ResourceModel\Config\Data as ConfigDataResource;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\Store\Model\Store;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
/**
* @magentoAppArea adminhtml
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class UpdateTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
*/
private $objectManager;
/**
* @var PreparedValueFactory
*/
private $preparedValueFactory;
/**
* @var ConfigDataResource
*/
private $configValueResourceModel;
/**
* @var Update
*/
private $updateCron;
/**
* @var ClientInterface|\PHPUnit\Framework\MockObject\MockObject
*/
private $httpClient;
/**
* @var FlagManager
*/
private $flagManager;
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;
/**
* @return void
*/
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->httpClient = $this->getMockBuilder(ClientInterface::class)
->getMockForAbstractClass();
$this->objectManager->addSharedInstance($this->httpClient, CurlClient::class);
$this->preparedValueFactory = $this->objectManager->get(PreparedValueFactory::class);
$this->configValueResourceModel = $this->objectManager->get(ConfigDataResource::class);
$this->updateCron = $this->objectManager->get(Update::class);
$this->scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
$this->flagManager = $this->objectManager->get(FlagManager::class);
}
/**
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
*
*/
public function testSuccessfulAttemptExecute()
{
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'http://store.com/'
);
$this->mockRequestCall(201, 'URL has been changed');
$this->updateCron->execute();
$this->assertEmpty($this->getUpdateCounterFlag());
$this->assertEmpty($this->getPreviousBaseUrlFlag());
$this->assertEmpty($this->getConfigValue(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH));
}
/**
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
*
*/
public function testUnsuccessfulAttemptExecute()
{
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'http://store.com/'
);
$reverseCounter = $this->getUpdateCounterFlag();
$this->mockRequestCall(500, 'Unauthorized access');
$this->updateCron->execute();
$this->assertEquals($reverseCounter - 1, $this->getUpdateCounterFlag());
}
/**
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
*
*/
public function testLastUnsuccessfulAttemptExecute()
{
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'http://store.com/'
);
$this->setUpdateCounterValue(1);
$this->mockRequestCall(500, 'Unauthorized access');
$this->updateCron->execute();
$this->assertEmpty($this->getUpdateCounterFlag());
$this->assertEmpty($this->getPreviousBaseUrlFlag());
$this->assertEmpty($this->getConfigValue(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH));
}
/**
* Save configuration value
*
* @param string $path The configuration path in format section/group/field_name
* @param string $value The configuration value
* @param string $scope The configuration scope (default, website, or store)
* @return void
* @throws \Magento\Framework\Exception\RuntimeException
* @throws \Magento\Framework\Exception\AlreadyExistsException
*/
private function saveConfigValue(
string $path,
string $value,
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
) {
$configValue = $this->preparedValueFactory->create(
$path,
$value,
$scope
);
$this->configValueResourceModel->save($configValue);
}
/**
* Get configuration value
*
* @param string $path
* @param string $scopeType
* @return mixed
*/
private function getConfigValue(
string $path,
string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
) {
return $this->scopeConfig->getValue(
$path,
$scopeType
);
}
/**
* Get update counter flag value
*
* @return int|null
*/
private function getUpdateCounterFlag(): ?int
{
return $this->flagManager
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
}
/**
* Get previous URL flag value
*
* @return string|null
*/
private function getPreviousBaseUrlFlag(): ?string
{
return $this->flagManager
->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
}
/**
* Set response mock for the HTTP client
*
* @param int $responseCode
* @param string $responseMessage
*/
private function mockRequestCall(int $responseCode, string $responseMessage): void
{
/** @var Response $response */
$response = $this->objectManager->create(Response::class);
$response->setStatusCode($responseCode);
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
$response->setContent(json_encode(['message' => $responseMessage]));
$this->httpClient
->expects($this->once())
->method('request')
->willReturn($response);
}
/**
* Set value for update counter flag
*
* @param int $value
*/
private function setUpdateCounterValue(int $value): void
{
$this->flagManager
->saveFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $value);
}
}
@@ -0,0 +1,162 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Analytics\Model\Config\Backend;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Config\Model\Config\Source\Enabledisable;
use Magento\Config\Model\PreparedValueFactory;
use Magento\Config\Model\ResourceModel\Config\Data as ConfigDataResource;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoAppArea adminhtml
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class EnabledTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
private $objectManager;
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;
/**
* @var SubscriptionStatusProvider
*/
private $subscriptionStatusProvider;
/**
* @var PreparedValueFactory
*/
private $preparedValueFactory;
/**
* @var ConfigDataResource
*/
private $configValueResourceModel;
/**
* @var ReinitableConfigInterface
*/
private $reinitableConfig;
/**
* @inheritDoc
*/
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
$this->subscriptionStatusProvider = $this->objectManager->get(SubscriptionStatusProvider::class);
$this->preparedValueFactory = $this->objectManager->get(PreparedValueFactory::class);
$this->configValueResourceModel = $this->objectManager->get(ConfigDataResource::class);
$this->reinitableConfig = $this->objectManager->get(ReinitableConfigInterface::class);
}
/**
* @magentoDbIsolation enabled
*/
public function testDisable()
{
$this->checkInitialStatus();
$this->saveConfigValue(Enabled::XML_ENABLED_CONFIG_STRUCTURE_PATH, (string)Enabledisable::DISABLE_VALUE);
$this->reinitableConfig->reinit();
$this->checkDisabledStatus();
}
/**
* @depends testDisable
* @magentoDbIsolation enabled
*/
public function testReEnable()
{
$this->saveConfigValue(Enabled::XML_ENABLED_CONFIG_STRUCTURE_PATH, (string)Enabledisable::ENABLE_VALUE);
$this->reinitableConfig->reinit();
$this->checkReEnabledStatus();
}
/**
* Get configuration value
*
* @param string $path
* @param string $scopeType
* @return mixed
*/
private function getConfigValue(
string $path,
string $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
) {
return $this->scopeConfig->getValue(
$path,
$scopeType
);
}
/**
* Save configuration value
*
* @param string $path The configuration path in format section/group/field_name
* @param string $value The configuration value
* @param string $scope The configuration scope (default, website, or store)
* @return void
* @throws \Magento\Framework\Exception\RuntimeException
* @throws \Magento\Framework\Exception\AlreadyExistsException
*/
private function saveConfigValue(
string $path,
string $value,
string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT
) {
$configValue = $this->preparedValueFactory->create(
$path,
$value,
$scope
);
$this->configValueResourceModel->save($configValue);
}
/**
* Check the instance status after installation
*/
private function checkInitialStatus()
{
$this->assertNotSame(SubscriptionStatusProvider::DISABLED, $this->subscriptionStatusProvider->getStatus());
$this->assertNotEmpty($this->getConfigValue(CollectionTime::CRON_SCHEDULE_PATH));
}
/**
* Check the instance status after disabling AR synchronisation
*/
private function checkDisabledStatus()
{
$this->assertSame(SubscriptionStatusProvider::DISABLED, $this->subscriptionStatusProvider->getStatus());
$this->assertEmpty($this->getConfigValue(CollectionTime::CRON_SCHEDULE_PATH));
}
/**
* Check the instance status after re-activation AR synchronisation
*/
private function checkReEnabledStatus()
{
$this->assertContains(
$this->subscriptionStatusProvider->getStatus(),
[
SubscriptionStatusProvider::ENABLED,
SubscriptionStatusProvider::PENDING,
]
);
$this->assertNotEmpty($this->getConfigValue(CollectionTime::CRON_SCHEDULE_PATH));
}
}
@@ -0,0 +1,193 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Model\Connector\Http;
use Laminas\Http\Response;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Checks that cron job was set if error handler was set and appropriate http error code was returned.
*/
class ReSignUpResponseResolverTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ResponseResolver
*/
private $otpResponseResolver;
/**
* @var ResponseResolver
*/
private $updateResponseResolver;
/**
* @var ConverterInterface
*/
private $converter;
/**
* @var ResponseResolver
*/
private $notifyDataChangedResponseResolver;
/**
* @var FlagManager
*/
private $flagManager;
/**
* @return void
*/
protected function setUp(): void
{
$objectManager = Bootstrap::getObjectManager();
$this->otpResponseResolver = $objectManager->get(
'OtpResponseResolver'
);
$this->updateResponseResolver = $objectManager->get(
'UpdateResponseResolver'
);
$this->notifyDataChangedResponseResolver = $objectManager->get(
'NotifyDataChangedResponseResolver'
);
$this->converter = $objectManager->get(ConverterInterface::class);
$this->flagManager = $objectManager->get(FlagManager::class);
}
/**
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
* @magentoDbIsolation enabled
*/
public function testReSignUpOnOtp()
{
$body = $this->converter->toBody(['test' => '42']);
$retryResponse = new Response();
$retryResponse->setStatusCode(Response::STATUS_CODE_401);
$retryResponse->getHeaders()->addHeaderLine($this->converter->getContentTypeHeader());
$retryResponse->setContent($body);
$this->otpResponseResolver->getResult($retryResponse);
$this->assertCronWasSet();
}
/**
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
* @magentoDbIsolation enabled
*/
public function testReSignOnOtpWasNotCalled()
{
$body = $this->converter->toBody(['test' => '42']);
$successResponse = new Response();
$successResponse->setStatusCode(Response::STATUS_CODE_201);
$successResponse->getHeaders()->addHeaderLine($this->converter->getContentTypeHeader());
$successResponse->setContent($body);
$this->otpResponseResolver->getResult($successResponse);
$this->assertCronWasNotSet();
}
/**
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
* @magentoDbIsolation enabled
*/
public function testReSignUpOnUpdateWasCalled()
{
$body = $this->converter->toBody(['test' => '42']);
$retryResponse = new Response();
$retryResponse->setStatusCode(Response::STATUS_CODE_401);
$retryResponse->getHeaders()->addHeaderLine($this->converter->getContentTypeHeader());
$retryResponse->setContent($body);
$this->updateResponseResolver->getResult($retryResponse);
$this->assertCronWasSet();
}
/**
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
* @magentoDbIsolation enabled
*/
public function testReSignUpOnUpdateWasNotCalled()
{
$body = $this->converter->toBody(['test' => '42']);
$successResponse = new Response();
$successResponse->setStatusCode(Response::STATUS_CODE_201);
$successResponse->getHeaders()->addHeaderLine($this->converter->getContentTypeHeader());
$successResponse->setContent($body);
$this->updateResponseResolver->getResult($successResponse);
$this->assertCronWasNotSet();
}
/**
* @magentoDataFixture Magento/Analytics/_files/enabled_subscription_with_invalid_token.php
* @magentoDbIsolation enabled
*/
public function testReSignUpOnNotifyDataChangedWasNotCalledWhenSubscriptionUpdateIsRunning()
{
$this->flagManager
->saveFlag(
SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE,
'https://previous.example.com/'
);
$body = $this->converter->toBody(['test' => '42']);
$retryResponse = new Response();
$retryResponse->setStatusCode(Response::STATUS_CODE_401);
$retryResponse->getHeaders()->addHeaderLine($this->converter->getContentTypeHeader());
$retryResponse->setContent($body);
$this->notifyDataChangedResponseResolver->getResult($retryResponse);
$this->assertCronWasNotSet();
}
/**
* @return string|null
*/
private function getSubscribeSchedule()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/**
* @var $scopeConfig ScopeConfigInterface
*/
$scopeConfig = $objectManager->get(ScopeConfigInterface::class);
return $scopeConfig->getValue(
SubscriptionHandler::CRON_STRING_PATH,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
);
}
/**
* @return int|null
*/
private function getAttemptFlag()
{
$objectManager = Bootstrap::getObjectManager();
/**
* @var $flagManager FlagManager
*/
$flagManager = $objectManager->get(FlagManager::class);
return $flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
}
/**
* @return void
*/
private function assertCronWasSet()
{
$this->assertEquals('0 * * * *', $this->getSubscribeSchedule());
$this->assertGreaterThan(1, $this->getAttemptFlag());
}
/**
* @return void
*/
private function assertCronWasNotSet()
{
$this->assertNull($this->getSubscribeSchedule());
$this->assertNull($this->getAttemptFlag());
}
}
@@ -0,0 +1,207 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Model\Plugin;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Config\Model\PreparedValueFactory;
use Magento\Config\Model\ResourceModel\Config\Data as ConfigData;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\ObjectManagerInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\Store;
use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoAppArea adminhtml
*/
class BaseUrlConfigPluginTest extends \PHPUnit\Framework\TestCase
{
/**
* @var PreparedValueFactory
*/
private $preparedValueFactory;
/**
* @var ConfigData
*/
private $configValueResourceModel;
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;
/**
* @var FlagManager
*/
private $flagManager;
/**
* @var ObjectManagerInterface
*/
private $objectManager;
/**
* @return void
*/
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->preparedValueFactory = $this->objectManager->get(PreparedValueFactory::class);
$this->configValueResourceModel = $this->objectManager->get(ConfigData::class);
$this->scopeConfig = $this->objectManager->get(ScopeConfigInterface::class);
$this->flagManager = $this->objectManager->get(FlagManager::class);
}
/**
* @magentoDbIsolation enabled
*/
public function testAfterSaveNotSecureUrl()
{
$this->saveConfigValue(
Store::XML_PATH_UNSECURE_BASE_URL,
'http://store.com/',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$this->assertCronWasNotSet();
}
/**
* @magentoDbIsolation enabled
*/
public function testAfterSaveSecureUrlNotInDefaultScope()
{
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'https://store.com/',
ScopeInterface::SCOPE_STORES
);
$this->assertCronWasNotSet();
}
/**
* @magentoDbIsolation enabled
* @magentoAdminConfigFixture web/secure/base_url https://previous.example.com/
*/
public function testAfterSaveSecureUrlInDefaultScopeOnDoesNotRegisteredInstance()
{
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'https://store.com/',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$this->assertCronWasNotSet();
}
/**
* @magentoDbIsolation enabled
* @magentoAdminConfigFixture web/secure/base_url https://previous.example.com/
* @magentoAdminConfigFixture analytics/general/token MBI_token
*/
public function testAfterSaveSecureUrlInDefaultScopeOnRegisteredInstance()
{
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'https://store.com/',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$this->assertCronWasSet();
}
/**
* @magentoDbIsolation enabled
* @magentoAdminConfigFixture web/secure/base_url https://previous.example.com/
* @magentoAdminConfigFixture analytics/general/token MBI_token
*/
public function testAfterSaveMultipleBaseUrlChanges()
{
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'https://store.com/',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$this->saveConfigValue(
Store::XML_PATH_SECURE_BASE_URL,
'https://store10.com/',
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
$this->assertCronWasSet();
}
/**
* @param string $path The configuration path in format section/group/field_name
* @param string $value The configuration value
* @param string $scope The configuration scope (default, website, or store)
* @return void
*/
private function saveConfigValue(string $path, string $value, string $scope)
{
$value = $this->preparedValueFactory->create(
$path,
$value,
$scope
);
$this->configValueResourceModel->save($value);
}
/**
* @return void
*/
private function assertCronWasNotSet()
{
$this->assertNull($this->getSubscriptionUpdateSchedule());
$this->assertNull($this->getPreviousUpdateUrl());
$this->assertNull($this->getUpdateReverseCounter());
}
/**
* @return void
*/
private function assertCronWasSet()
{
$this->assertSame(
'0 * * * *',
$this->getSubscriptionUpdateSchedule(),
'Subscription update schedule has not been set'
);
$this->assertSame(
'https://previous.example.com/',
$this->getPreviousUpdateUrl(),
'The previous URL stored for update is not correct'
);
$this->assertSame(48, $this->getUpdateReverseCounter());
}
/**
* @return mixed
*/
private function getSubscriptionUpdateSchedule()
{
return $this->scopeConfig->getValue(
SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
}
/**
* @return mixed
*/
private function getPreviousUpdateUrl()
{
return $this->flagManager->getFlagData(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
}
/**
* @return mixed
*/
private function getUpdateReverseCounter()
{
return $this->flagManager
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
}
}
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Analytics\Model;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Framework\FlagManager;
use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoAppArea adminhtml
*/
class ReportUrlProviderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ReportUrlProvider
*/
private $reportUrlProvider;
/**
* @var FlagManager
*/
private $flagManager;
/**
* @return void
*/
protected function setUp(): void
{
$objectManager = Bootstrap::getObjectManager();
$this->reportUrlProvider = $objectManager->get(ReportUrlProvider::class);
$this->flagManager = $objectManager->get(FlagManager::class);
}
/**
* @magentoDbIsolation enabled
*/
public function testGetUrlWhenSubscriptionUpdateIsRunning()
{
$this->flagManager
->saveFlag(
SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE,
'https://previous.example.com/'
);
$this->expectException(SubscriptionUpdateException::class);
$this->reportUrlProvider->getUrl();
}
}
@@ -0,0 +1,21 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/**
* @var $fileInfoManager \Magento\Analytics\Model\FileInfoManager
*/
$fileInfoManager = $objectManager->create(\Magento\Analytics\Model\FileInfoManager::class);
/**
* @var $fileInfo \Magento\Analytics\Model\FileInfo
*/
$fileInfo = $objectManager->create(
\Magento\Analytics\Model\FileInfo::class,
['path' => 'analytics/jsldjsfdkldf/data.tgz', 'initializationVector' => 'binaryDataisdodssds8iui']
);
$fileInfoManager->save($fileInfo);
@@ -0,0 +1,30 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/**
* @var $configWriter WriterInterface
*/
$configWriter = $objectManager->get(WriterInterface::class);
$configWriter->delete(SubscriptionHandler::CRON_STRING_PATH);
/**
* @var $analyticsToken AnalyticsToken
*/
$analyticsToken = $objectManager->get(AnalyticsToken::class);
$analyticsToken->storeToken('42');
/**
* @var $flagManager FlagManager
*/
$flagManager = $objectManager->get(FlagManager::class);
$flagManager->deleteFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
@@ -0,0 +1,30 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/**
* @var $configWriter WriterInterface
*/
$configWriter = $objectManager->get(WriterInterface::class);
$configWriter->save(SubscriptionHandler::CRON_STRING_PATH, join(' ', SubscriptionHandler::CRON_EXPR_ARRAY));
/**
* @var $analyticsToken AnalyticsToken
*/
$analyticsToken = $objectManager->get(AnalyticsToken::class);
$analyticsToken->storeToken(null);
/**
* @var $flagManager FlagManager
*/
$flagManager = $objectManager->get(FlagManager::class);
$flagManager->saveFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, 24);
@@ -0,0 +1,110 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\AsynchronousOperations\Cron;
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;
use Magento\AsynchronousOperations\Api\SaveMultipleOperationsInterface;
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\Collection;
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\CollectionFactory;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Bulk\BulkManagementInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
/**
* Test for MarkIncompleteOperationsAsFailed
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class MarkIncompleteOperationsAsFailedTest extends TestCase
{
/**
* @var MarkIncompleteOperationsAsFailed
*/
private $model;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$objectManager = Bootstrap::getObjectManager();
$this->model = $objectManager->create(MarkIncompleteOperationsAsFailed::class);
}
/**
* @magentoDbIsolation enabled
*/
public function testExecute(): void
{
$objectManager = Bootstrap::getObjectManager();
$jsonSerializer = $objectManager->get(Json::class);
$resource = $objectManager->get(ResourceConnection::class);
$topicName = 'topic_name_1';
$buuid = uniqid('bulk-');
$startedAt = $resource->getConnection()->formatDate(new \DateTime('-14 hours', new \DateTimeZone('UTC')));
$operationsData = [
[
OperationInterface::ID => 0,
OperationInterface::STATUS => OperationInterface::STATUS_TYPE_COMPLETE,
'started_at' => $startedAt,
],
[
OperationInterface::ID => 1,
OperationInterface::STATUS => OperationInterface::STATUS_TYPE_OPEN,
'started_at' => $startedAt,
],
[
OperationInterface::ID => 2,
OperationInterface::STATUS => OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED,
'started_at' => $startedAt,
],
[
OperationInterface::ID => 3,
OperationInterface::STATUS => OperationInterface::STATUS_TYPE_OPEN,
'started_at' => null,
]
];
$operationFactory = $objectManager->get(OperationInterfaceFactory::class);
$operations = [];
foreach ($operationsData as $data) {
$data += [
OperationInterface::BULK_ID => $buuid,
OperationInterface::TOPIC_NAME => $topicName,
OperationInterface::SERIALIZED_DATA => $jsonSerializer->serialize([]),
];
$operations[] = $operationFactory->create(['data' => $data]);
}
$bulkManagement = $objectManager->get(BulkManagementInterface::class);
$saveMultipleOperations = $objectManager->get(SaveMultipleOperationsInterface::class);
$bulkManagement->scheduleBulk($buuid, [], 'test bulk');
$saveMultipleOperations->execute($operations);
$this->model->execute();
$operationCollectionFactory = $objectManager->get(CollectionFactory::class);
/** @var Collection $collection */
$collection = $operationCollectionFactory->create();
$collection->addFieldToFilter(
OperationInterface::BULK_ID,
['eq' => $buuid]
);
$collection->addFieldToFilter(
OperationInterface::STATUS,
['eq' => OperationInterface::STATUS_TYPE_RETRIABLY_FAILED]
);
$this->assertEquals(1, $collection->count());
$operation = $collection->getFirstItem();
$this->assertEquals(1, $operation->getId());
$this->assertEquals(0, $operation->getErrorCode());
$this->assertEquals('Unknown Error', $operation->getResultMessage());
}
}
@@ -0,0 +1,142 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Model;
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\ObjectManagerInterface;
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
use Magento\Framework\MessageQueue\BulkPublisherInterface;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\EntityManager\EntityManager;
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\CollectionFactory;
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterfaceFactory;
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class BulkManagementTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit\Framework\MockObject_MockObject
*/
private $publisherMock;
/**
* @var BulkManagement
*/
private $model;
/**
* @var ObjectManagerInterface
*/
private $objectManager;
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->publisherMock = $this->getMockForAbstractClass(BulkPublisherInterface::class);
$this->model = $this->objectManager->create(
BulkManagement::class,
[
'publisher' => $this->publisherMock
]
);
}
public function testScheduleBulk()
{
// general bulk information
$bulkUuid = '5a12c1bd-a8b5-41d4-8c00-3f5bcaa6d3c7';
$bulkDescription = 'Bulk General Information';
$topicName = 'example.topic.name';
$userId = 1;
// generate bulk operations that must be saved
$operationCount = 100;
$operations = [];
$operationFactory = $this->objectManager->get(OperationInterfaceFactory::class);
for ($index = 0; $index < $operationCount; $index++) {
/** @var OperationInterface $operation */
$operation = $operationFactory->create();
$operation->setBulkUuid($bulkUuid);
$operation->setTopicName($topicName);
$operation->setSerializedData(json_encode(['entity_id' => $index]));
$operations[] = $operation;
}
$this->publisherMock->expects($this->once())
->method('publish')
->with($topicName, $operations);
// schedule bulk
$this->assertTrue($this->model->scheduleBulk($bulkUuid, $operations, $bulkDescription, $userId));
$storedData = $this->getStoredOperationData();
// No operations should be saved to database during bulk creation
$this->assertCount(0, $storedData);
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
*/
public function testRetryBulk()
{
$bulkUuid = 'bulk-uuid-5';
$topicName = 'topic-4';
$errorCodes = [1111, 2222];
$operations = $this->objectManager->get(CollectionFactory::class)
->create()
->addFieldToFilter('bulk_uuid', ['eq' => $bulkUuid])
->getItems();
$this->publisherMock->expects($this->once())
->method('publish')
->with($topicName, array_values($operations));
$this->assertEquals(2, $this->model->retryBulk($bulkUuid, $errorCodes));
$operations = $this->objectManager->get(CollectionFactory::class)
->create()
->addFieldToFilter('bulk_uuid', ['eq' => $bulkUuid])
->getItems();
// Failed operations should be removed from database during bulk retry
$this->assertCount(0, $operations);
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
*/
public function testDeleteBulk()
{
$this->model->deleteBulk('bulk-uuid-1');
/** @var EntityManager $entityManager */
$entityManager = $this->objectManager->get(EntityManager::class);
$bulkSummaryFactory = $this->objectManager->get(BulkSummaryInterfaceFactory::class);
/** @var BulkSummaryInterface $bulkSummary */
$bulkSummary = $entityManager->load($bulkSummaryFactory->create(), 'bulk-uuid-1');
$this->assertNull($bulkSummary->getBulkId());
}
/**
* Retrieve stored operation data
*
* @return array
* @throws \Exception
*/
private function getStoredOperationData()
{
/** @var MetadataPool $metadataPool */
$metadataPool = $this->objectManager->get(MetadataPool::class);
$operationMetadata = $metadataPool->getMetadata(OperationInterface::class);
/** @var ResourceConnection $resourceConnection */
$resourceConnection = $this->objectManager->get(ResourceConnection::class);
$connection = $resourceConnection->getConnectionByName($operationMetadata->getEntityConnectionName());
return $connection->fetchAll($connection->select()->from($operationMetadata->getEntityTable()));
}
}
@@ -0,0 +1,81 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Model;
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\ObjectManagerInterface;
class BulkNotificationManagementTest extends \PHPUnit\Framework\TestCase
{
/**
* @var BulkNotificationManagement
*/
private $model;
/**
* @var ObjectManagerInterface
*/
private $objectManager;
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->model = $this->objectManager->create(
BulkNotificationManagement::class
);
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
*/
public function testAcknowledgeBulks()
{
$this->model->acknowledgeBulks(['bulk-uuid-5']);
$acknowledgedBulks = $this->model->getAcknowledgedBulksByUser(1);
$this->assertCount(1, $acknowledgedBulks);
/** @var BulkSummaryInterface $acknowledgedBulk */
$acknowledgedBulk = array_pop($acknowledgedBulks);
$this->assertEquals('bulk-uuid-5', $acknowledgedBulk->getBulkId());
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/acknowledged_bulk.php
*/
public function testIgnoreBulks()
{
// 'bulk-uuid-5' and 'bulk-uuid-4' are marked as acknowledged in fixture
$this->model->ignoreBulks(['bulk-uuid-5']);
$acknowledgedBulks = $this->model->getAcknowledgedBulksByUser(1);
$this->assertCount(1, $acknowledgedBulks);
/** @var BulkSummaryInterface $acknowledgedBulk */
$acknowledgedBulk = array_pop($acknowledgedBulks);
$this->assertEquals('bulk-uuid-4', $acknowledgedBulk->getBulkId());
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/acknowledged_bulk.php
*/
public function testGetAcknowledgedBulks()
{
// 'bulk-uuid-5' and 'bulk-uuid-4' are marked as acknowledged in fixture
$acknowledgedBulks = $this->model->getAcknowledgedBulksByUser(1);
$this->assertCount(2, $acknowledgedBulks);
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/acknowledged_bulk.php
*/
public function testGetIgnoredBulks()
{
// 'bulk-uuid-5' and 'bulk-uuid-4' are marked as acknowledged in fixture. Fixture creates 5 bulks in total.
$ignoredBulks = $this->model->getIgnoredBulksByUser(1);
$this->assertCount(3, $ignoredBulks);
}
}
@@ -0,0 +1,67 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Model;
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
class BulkStatusTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\AsynchronousOperations\Model\BulkStatus
*/
private $model;
protected function setUp(): void
{
$this->model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\AsynchronousOperations\Model\BulkStatus::class
);
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
*/
public function testGetBulkStatus()
{
$this->assertEquals(BulkSummaryInterface::NOT_STARTED, $this->model->getBulkStatus('bulk-uuid-1'));
$this->assertEquals(BulkSummaryInterface::IN_PROGRESS, $this->model->getBulkStatus('bulk-uuid-2'));
$this->assertEquals(BulkSummaryInterface::FINISHED_SUCCESSFULLY, $this->model->getBulkStatus('bulk-uuid-4'));
$this->assertEquals(BulkSummaryInterface::FINISHED_WITH_FAILURE, $this->model->getBulkStatus('bulk-uuid-5'));
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
*/
public function testGetBulksByUser()
{
/** @var \Magento\AsynchronousOperations\Model\BulkSummary[] $bulks */
$bulksUuidArray = ['bulk-uuid-1', 'bulk-uuid-2', 'bulk-uuid-3', 'bulk-uuid-4', 'bulk-uuid-5'];
$bulks = $this->model->getBulksByUser(1);
$this->assertCount(5, $bulks);
foreach ($bulks as $bulk) {
$this->assertTrue(in_array($bulk->getBulkId(), $bulksUuidArray));
}
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
*/
public function testGetFailedOperationsByBulkId()
{
/** @var \Magento\AsynchronousOperations\Api\Data\OperationInterface[] $operations */
$operations = $this->model->getFailedOperationsByBulkId('bulk-uuid-1');
$this->assertEquals([], $operations);
$operations = $this->model->getFailedOperationsByBulkId('bulk-uuid-5', 3);
foreach ($operations as $operation) {
$this->assertEquals(1111, $operation->getErrorCode());
}
$operations = $this->model->getFailedOperationsByBulkId('bulk-uuid-5', 2);
foreach ($operations as $operation) {
$this->assertEquals(2222, $operation->getErrorCode());
}
}
}
@@ -0,0 +1,154 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\AsynchronousOperations\Model;
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
use Magento\AsynchronousOperations\Api\SaveMultipleOperationsInterface;
use Magento\AsynchronousOperations\Model\ConfigInterface as AsyncConfig;
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\Collection;
use Magento\AsynchronousOperations\Model\ResourceModel\Operation\CollectionFactory;
use Magento\Catalog\Model\Product;
use Magento\Framework\Bulk\BulkManagementInterface;
use Magento\Framework\MessageQueue\ConsumerConfigurationInterface;
use Magento\Framework\MessageQueue\EnvelopeInterface;
use Magento\Framework\MessageQueue\Lock\ReaderInterface;
use Magento\Framework\MessageQueue\LockInterfaceFactory;
use Magento\Framework\MessageQueue\MessageEncoder;
use Magento\Framework\MessageQueue\QueueInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Monolog\Test\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
/**
* Test for MassConsumerEnvelopeCallback
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class MassConsumerEnvelopeCallbackTest extends TestCase
{
/**
* @var MassConsumerEnvelopeCallback
*/
private $model;
/**
* @var QueueInterface|MockObject
*/
private $queue;
/**
* @var ConsumerConfigurationInterface|MockObject
*/
private $configuration;
/**
* @var MessageEncoder
*/
private $messageEncoder;
/**
* @var OperationRepositoryInterface
*/
private $operationRepository;
/**
* @var BulkManagementInterface
*/
private $bulkManagement;
/**
* @var SaveMultipleOperationsInterface
*/
private $saveMultipleOperations;
/**
* @var CollectionFactory
*/
private $operationCollectionFactory;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$objectManager = Bootstrap::getObjectManager();
$this->queue = $this->createMock(QueueInterface::class);
$this->configuration = $this->createMock(ConsumerConfigurationInterface::class);
$this->messageEncoder = $objectManager->get(MessageEncoder::class);
$this->operationRepository = $objectManager->get(OperationRepositoryInterface::class);
$operationProcessor = $this->createMock(OperationProcessor::class);
$this->operationCollectionFactory = $objectManager->get(CollectionFactory::class);
$this->bulkManagement = $objectManager->get(BulkManagementInterface::class);
$this->saveMultipleOperations = $objectManager->get(SaveMultipleOperationsInterface::class);
$operationProcessorFactory = $this->createMock(OperationProcessorFactory::class);
$operationProcessorFactory->method('create')
->willReturn($operationProcessor);
$this->model = Bootstrap::getObjectManager()->create(
MassConsumerEnvelopeCallback::class,
[
'queue' => $this->queue,
'configuration' => $this->configuration,
'operationProcessorFactory' => $operationProcessorFactory
]
);
}
/**
* @magentoDbIsolation enabled
*/
public function testMessageLock(): void
{
$objectManager = Bootstrap::getObjectManager();
$product = $objectManager->create(Product::class);
$product->setSku('simple');
$product->setName('random name update');
$message = [
'product' => $product
];
$topicName = 'async.magento.catalog.api.productrepositoryinterface.save.post';
$buuid = uniqid('bulk-');
$messageProps = [
'message_id' => uniqid('msg-'),
'topic_name' => $topicName
];
$consumerName = 'async.operations.all';
$this->bulkManagement->scheduleBulk($buuid, [], 'test bulk');
$operation = $this->operationRepository->create($topicName, $message, $buuid, 0);
$this->saveMultipleOperations->execute([$operation]);
$envelope = $this->createMock(EnvelopeInterface::class);
$envelope->method('getBody')
->willReturn($this->messageEncoder->encode(AsyncConfig::SYSTEM_TOPIC_NAME, $operation));
$envelope->method('getProperties')
->willReturn($messageProps);
$this->configuration
->method('getConsumerName')
->willReturn($consumerName);
$this->configuration
->method('getTopicNames')
->willReturn([$topicName]);
$this->model->execute($envelope);
/** @var Collection $collection */
$collection = $this->operationCollectionFactory->create();
$collection->addFieldToFilter(OperationInterface::BULK_ID, ['eq' => $buuid]);
$this->assertEquals(1, $collection->count());
$operation = $collection->getFirstItem();
$this->assertNotEmpty($operation->getData('started_at'));
// md5() here is not for cryptographic use.
// phpcs:ignore Magento2.Security.InsecureFunction
$code = md5($consumerName . '-' . $messageProps['message_id']);
$lockFactory = $objectManager->get(LockInterfaceFactory::class);
$lockReader = $objectManager->get(ReaderInterface::class);
$lock = $lockFactory->create();
$lockReader->read($lock, $code);
$this->assertNotEmpty($lock->getId());
}
}
@@ -0,0 +1,358 @@
<?php
/**
* Test services for name collisions.
*
* Let we have two service interfaces called Foo\Bar\Service\SomeBazV1Interface and Foo\Bar\Service\Some\BazV1Interface.
* Given current name generation logic both are going to be translated to BarSomeBazV1. This test checks such things
* are not going to happen.
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Model;
use Magento\AsynchronousOperations\Model\ResourceModel\Bulk\Collection as BulkCollection;
use Magento\Framework\MessageQueue\BulkPublisherInterface;
use Magento\Framework\Exception\BulkException;
use Magento\Framework\Phrase;
use Magento\Framework\Registry;
use Magento\Framework\Webapi\Exception;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\TestFramework\MessageQueue\PublisherConsumerController;
use Magento\TestFramework\MessageQueue\EnvironmentPreconditionException;
use Magento\TestFramework\MessageQueue\PreconditionFailedException;
use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\ObjectManagerInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*
* @magentoDbIsolation disabled
*/
class MassScheduleTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string[]
*/
protected $consumers = ['async.operations.all'];
/**
* @var ObjectManagerInterface
*/
protected $objectManager;
/**
* @var MassSchedule
*/
private $massSchedule;
/**
* @var Collection
*/
private $collection;
/**
* @var ProductRepositoryInterface
*/
private $productRepository;
/**
* @var PublisherConsumerController
*/
private $publisherConsumerController;
/**
* @var array
*/
private $skus = [];
/** @var string */
private $logFilePath;
/**
* @var Registry
*/
private $registry;
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->registry = $this->objectManager->get(Registry::class);
$this->massSchedule = $this->objectManager->create(MassSchedule::class);
$this->logFilePath = TESTS_TEMP_DIR . "/MessageQueueTestLog.txt";
$this->collection = $this->objectManager->create(Collection::class);
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
/** @var PublisherConsumerController publisherConsumerController */
$this->publisherConsumerController = $this->objectManager->create(PublisherConsumerController::class, [
'consumers' => $this->consumers,
'logFilePath' => $this->logFilePath,
'appInitParams' => \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInitParams()
]);
try {
$this->publisherConsumerController->initialize();
} catch (EnvironmentPreconditionException $e) {
$this->markTestSkipped($e->getMessage());
} catch (PreconditionFailedException $e) {
$this->fail($e->getMessage());
}
parent::setUp();
}
/**
* @dataProvider productDataProvider
* @param ProductInterface[] $products
*/
public function testScheduleMass($products)
{
try {
$this->sendBulk($products);
} catch (BulkException $bulkException) {
$this->fail('Bulk was not accepted in full');
}
//assert all products are created
try {
$this->publisherConsumerController->waitForAsynchronousResult(
[$this, 'assertProductExists'],
[$this->skus, count($this->skus)]
);
} catch (PreconditionFailedException $e) {
$this->fail("Not all products were created");
}
}
/**
* @dataProvider publisherExceptionDataProvider
* @param \Exception $exception
*/
public function testScheduleMassWithExceptionDuringPublishing(\Exception $exception)
{
$products = [
['product' => $this->getProduct()],
];
$publisher = $this->createMock(BulkPublisherInterface::class);
$publisher->expects($this->atLeastOnce())
->method('publish')
->willThrowException($exception);
$bulkManagement = $this->objectManager->create(
BulkManagement::class,
['publisher' => $publisher]
);
$this->massSchedule = $this->objectManager->create(
MassSchedule::class,
['bulkManagement' => $bulkManagement]
);
$bulkCollection = $this->objectManager->create(BulkCollection::class);
$bulksCount = $bulkCollection->getSize();
try {
$this->massSchedule->publishMass(
'async.magento.catalog.api.productrepositoryinterface.save.post',
$products
);
$this->fail('Publish is not failed when operations are not published.');
} catch (\Exception $e) {
$bulkCollection = $this->objectManager->create(BulkCollection::class);
$this->assertEquals($bulksCount, $bulkCollection->getSize());
}
}
/**
* @return array
*/
public function publisherExceptionDataProvider(): array
{
return [
[new \InvalidArgumentException('Unknown publisher type async')],
[new \LogicException('Could not find an implementation type for type "async" and connection "amqp".')],
];
}
public function sendBulk($products)
{
$this->skus = [];
foreach ($products as $data) {
if (isset($data['product'])) {
$this->skus[] = $data['product']->getSku();
}
}
$this->clearProducts();
$result = $this->massSchedule->publishMass(
'async.magento.catalog.api.productrepositoryinterface.save.post',
$products
);
//assert bulk accepted with no errors
$this->assertFalse($result->isErrors());
//assert number of products sent to queue
$this->assertCount(count($this->skus), $result->getRequestItems());
}
protected function tearDown(): void
{
$this->publisherConsumerController->stopConsumers();
$this->clearProducts();
parent::tearDown();
}
private function clearProducts()
{
$size = $this->objectManager->create(Collection::class)
->addAttributeToFilter('sku', ['in' => $this->skus])
->load()
->getSize();
if ($size == 0) {
return;
}
$this->registry->unregister('isSecureArea');
$this->registry->register('isSecureArea', true);
try {
foreach ($this->skus as $sku) {
$this->productRepository->deleteById($sku);
}
} catch (\Exception $e) {
//nothing to delete
}
$this->registry->unregister('isSecureArea');
$size = $this->objectManager->create(Collection::class)
->addAttributeToFilter('sku', ['in' => $this->skus])
->load()
->getSize();
if ($size > 0) {
throw new Exception(new Phrase("Collection size after clearing the products: %size", ['size' => $size]));
}
}
public function assertProductExists($productsSkus, $count)
{
$collection = $this->objectManager->create(Collection::class)
->addAttributeToFilter('sku', ['in' => $productsSkus])
->load();
$size = $collection->getSize();
return $size == $count;
}
/**
* @dataProvider productExceptionDataProvider
* @param ProductInterface[] $products
*/
public function testScheduleMassOneEntityFailure($products)
{
try {
$this->sendBulk($products);
} catch (BulkException $e) {
$this->assertCount(1, $e->getErrors());
$errors = $e->getErrors();
$this->assertInstanceOf(\Magento\Framework\Exception\LocalizedException::class, $errors[0]);
$this->assertEquals("Error processing 1 element of input data", $errors[0]->getMessage());
$reasonException = $errors[0]->getPrevious();
$expectedErrorMessage = "Data item corresponding to \"product\" " .
"must be specified in the message with topic " .
"\"async.magento.catalog.api.productrepositoryinterface.save.post\".";
$this->assertEquals(
$expectedErrorMessage,
$reasonException->getMessage()
);
/** @var \Magento\WebapiAsync\Model\AsyncResponse $bulkStatus */
$bulkStatus = $e->getData();
$this->assertTrue($bulkStatus->isErrors());
/** @var ItemStatus[] $items */
$items = $bulkStatus->getRequestItems();
$this->assertCount(2, $items);
$this->assertEquals(ItemStatus::STATUS_ACCEPTED, $items[0]->getStatus());
$this->assertEquals(0, $items[0]->getId());
$this->assertEquals(ItemStatus::STATUS_REJECTED, $items[1]->getStatus());
$this->assertEquals(1, $items[1]->getId());
$this->assertEquals($expectedErrorMessage, $items[1]->getErrorMessage());
}
//assert one products is created
try {
$this->publisherConsumerController->waitForAsynchronousResult(
[$this, 'assertProductExists'],
[$this->skus, count($this->skus)]
);
} catch (PreconditionFailedException $e) {
$this->fail("Not all products were created");
}
}
private function getProduct()
{
/** @var $product \Magento\Catalog\Model\Product */
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create(ProductInterface::class);
$product
->setTypeId('simple')
->setAttributeSetId(4)
->setWebsiteIds([1])
->setName('Simple Product 1')
->setSku('unique-simple-product1')
->setPrice(10)
->setMetaTitle('meta title')
->setMetaKeyword('meta keyword')
->setMetaDescription('meta description')
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
->setStockData(['use_config_manage_stock' => 0]);
return $product;
}
public function productDataProvider()
{
return [
'single_product' => [
[['product' => $this->getProduct()]],
],
'multiple_products' => [
[
['product' => $this->getProduct()
->setName('Simple Product 3')
->setSku('unique-simple-product3')
->setMetaTitle('meta title 3')
],
['product' => $this->getProduct()
->setName('Simple Product 2')
->setSku('unique-simple-product2')
->setMetaTitle('meta title 2')
]
]
],
];
}
public function productExceptionDataProvider()
{
return [
'single_product' => [
[['product' => $this->getProduct()]],
],
'multiple_products' => [
[
['product' => $this->getProduct()],
['customer' => $this->getProduct()]
]
],
];
}
}
@@ -0,0 +1,84 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Model;
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;
use Magento\AsynchronousOperations\Model\BulkStatus;
use Magento\AsynchronousOperations\Model\OperationManagement;
use Magento\Framework\EntityManager\EntityManager;
use Magento\Framework\App\ResourceConnection;
use Magento\TestFramework\Helper\Bootstrap;
class OperationManagementTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\AsynchronousOperations\Model\OperationManagement
*/
private $model;
/**
* @var \Magento\AsynchronousOperations\Model\BulkStatus
*/
private $bulkStatusManagement;
/**
* @var OperationInterfaceFactory
*/
private $operationFactory;
/**
* @var EntityManager
*/
private $entityManager;
/**
* @var ResourceConnection
*/
private $connection;
protected function setUp(): void
{
$this->connection = Bootstrap::getObjectManager()->get(ResourceConnection::class);
$this->model = Bootstrap::getObjectManager()->get(OperationManagement::class);
$this->bulkStatusManagement = Bootstrap::getObjectManager()->get(BulkStatus::class);
$this->operationFactory = Bootstrap::getObjectManager()->get(OperationInterfaceFactory::class);
$this->entityManager = Bootstrap::getObjectManager()->get(EntityManager::class);
}
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
*/
public function testGetBulkStatus()
{
$operations = $this->bulkStatusManagement->getFailedOperationsByBulkId('bulk-uuid-5', 3);
if (empty($operations)) {
$this->fail('Operation doesn\'t exist');
}
/** @var OperationInterface $operation */
$operation = array_shift($operations);
$operationId = $operation->getId();
$this->assertTrue($this->model->changeOperationStatus(
'bulk-uuid-5',
$operationId,
OperationInterface::STATUS_TYPE_OPEN
));
$table = $this->connection->getTableName('magento_operation');
$connection = $this->connection->getConnection();
$select = $connection->select()
->from($table)
->where("bulk_uuid = ?", 'bulk-uuid-5')
->where("operation_key = ?", $operationId);
$updatedOperation = $connection->fetchRow($select);
$this->assertEquals(OperationInterface::STATUS_TYPE_OPEN, $updatedOperation['status']);
$this->assertNull($updatedOperation['result_message']);
$this->assertNull($updatedOperation['serialized_data']);
}
}
@@ -0,0 +1,117 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Model;
use Magento\AsynchronousOperations\Api\Data\OperationInterface;
use Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory;
use Magento\AsynchronousOperations\Api\SaveMultipleOperationsInterface;
use Magento\AsynchronousOperations\Model\BulkStatus;
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterfaceFactory;
use Magento\Framework\EntityManager\EntityManager;
class SaveMultipleOperationsTest extends \PHPUnit\Framework\TestCase
{
private const BULK_UUID = "bulk-uuid-multiple-0";
/**
* @var BulkStatus
*/
private $bulkStatusManagement;
/**
* @var OperationInterfaceFactory
*/
private $operationFactory;
/**
* @var SaveMultipleOperationsInterface
*/
private $saveMultipleOperationsInterface;
/**
* @var EntityManager
*/
private $entityManager;
/**
* @var BulkSummaryInterfaceFactory
*/
private $bulkSummaryFactory;
/**
* Set Up the test
*/
protected function setUp(): void
{
$this->saveMultipleOperationsInterface = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
SaveMultipleOperationsInterface::class
);
$this->operationFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
OperationInterfaceFactory::class
);
$this->bulkStatusManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
BulkStatus::class
);
$this->bulkSummaryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
BulkSummaryInterfaceFactory::class
);
$this->entityManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
EntityManager::class
);
}
/**
* Test execute() of SaveMultipleOperations
*/
public function testExecute()
{
$operation = $this->createOperation();
$operations = [$operation, $operation, $operation];
$bulkSummary = $this->bulkSummaryFactory->create();
$this->entityManager->load($bulkSummary, self::BULK_UUID);
$bulkSummary->setBulkId(self::BULK_UUID);
$bulkSummary->setDescription("Test Bulk");
$bulkSummary->setUserId(1);
$bulkSummary->setUserType(1);
$bulkSummary->setOperationCount(count($operations));
$this->entityManager->save($bulkSummary);
$this->saveMultipleOperationsInterface->execute($operations);
$operationsCount = $this->bulkStatusManagement
->getOperationsCountByBulkIdAndStatus(self::BULK_UUID, OperationInterface::STATUS_TYPE_OPEN);
$this->assertEquals($operationsCount, 3);
}
/**
* Create Operation object and pre-fill with test data
* @return OperationInterface
*/
public function createOperation()
{
$serializedData = [
'entity_id' => null,
'entity_link' => '',
'meta_information' => json_encode([
'entity_id' => 5,
'meta_information' => 'Test'
])
];
$data = [
'data' => [
OperationInterface::BULK_ID => self::BULK_UUID,
OperationInterface::TOPIC_NAME => "topic-4",
OperationInterface::SERIALIZED_DATA => json_encode($serializedData),
OperationInterface::STATUS => OperationInterface::STATUS_TYPE_OPEN,
],
];
return $this->operationFactory->create($data);
}
}
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Ui\Component\DataProvider\Operation\Failed;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Class SearchResultTest
*/
class SearchResultTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
* @magentoDbIsolation enabled
* @magentoAppArea adminhtml
*/
public function testGetItems()
{
$objectManager = Bootstrap::getObjectManager();
$request = $objectManager->get(\Magento\Framework\App\RequestInterface::class);
$requestData = [
'uuid' => 'bulk-uuid-5',
];
$request->setParams($requestData);
/** @var \Magento\AsynchronousOperations\Ui\Component\DataProvider\SearchResult $searchResult */
$searchResult = $objectManager->create(
\Magento\AsynchronousOperations\Ui\Component\DataProvider\Operation\Failed\SearchResult::class
);
$this->assertEquals(1, $searchResult->getTotalCount());
$expected = $searchResult->getItems();
$expectedItem = array_shift($expected);
$this->assertEquals('Test', $expectedItem->getMetaInformation());
$this->assertEquals('5', $expectedItem->getEntityId());
}
}
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Ui\Component\DataProvider\Operation\Retriable;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Class SearchResultTest
*/
class SearchResultTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
* @magentoDbIsolation enabled
* @magentoAppArea adminhtml
*/
public function testGetTotalCount()
{
$objectManager = Bootstrap::getObjectManager();
$requestData = [
'uuid' => 'bulk-uuid-5',
];
$request = $objectManager->get(\Magento\Framework\App\RequestInterface::class);
$request->setParams($requestData);
/**
* @var \Magento\AsynchronousOperations\Ui\Component\DataProvider\Operation\Retriable\SearchResult $searchResult
*/
$searchResult = $objectManager->create(
\Magento\AsynchronousOperations\Ui\Component\DataProvider\Operation\Retriable\SearchResult::class
);
$this->assertEquals(1, $searchResult->getTotalCount());
}
}
@@ -0,0 +1,31 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AsynchronousOperations\Ui\Component\DataProvider;
use Magento\TestFramework\Helper\Bootstrap;
class SearchResultTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoDataFixture Magento/AsynchronousOperations/_files/bulk.php
* @magentoDbIsolation enabled
* @magentoAppArea adminhtml
*/
public function testGetAllIds()
{
$objectManager = Bootstrap::getObjectManager();
$user = $objectManager->create(\Magento\User\Model\User::class);
$user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME);
$session = $objectManager->get(\Magento\Backend\Model\Auth\Session::class);
$session->setUser($user);
/** @var \Magento\AsynchronousOperations\Ui\Component\DataProvider\SearchResult $searchResult */
$searchResult = $objectManager->create(
\Magento\AsynchronousOperations\Ui\Component\DataProvider\SearchResult::class
);
$this->assertEquals(6, $searchResult->getTotalCount());
}
}
@@ -0,0 +1,16 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\App\ResourceConnection;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
Resolver::getInstance()->requireDataFixture('Magento/AsynchronousOperations/_files/bulk.php');
$resource = Bootstrap::getObjectManager()->get(ResourceConnection::class);
$acknowledgedBulkTable = $resource->getTableName('magento_acknowledged_bulk');
$acknowledgedBulkQuery = "INSERT INTO {$acknowledgedBulkTable} (`bulk_uuid`) VALUES ('bulk-uuid-4'), ('bulk-uuid-5');";
$resource->getConnection()->query($acknowledgedBulkQuery);
@@ -0,0 +1,9 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
Resolver::getInstance()->requireDataFixture('Magento/AsynchronousOperations/_files/bulk_rollback.php');
// when bulks are removed, acknowledged bulk table will be cleared too.
@@ -0,0 +1,121 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\Bulk\OperationInterface;
/**
* @var $resource Magento\Framework\App\ResourceConnection
*/
$resource = Bootstrap::getObjectManager()->get(\Magento\Framework\App\ResourceConnection::class);
$connection = $resource->getConnection();
$bulkTable = $resource->getTableName('magento_bulk');
$operationTable = $resource->getTableName('magento_operation');
$bulks = [
'not_started' => [
'uuid' => 'bulk-uuid-1',
'user_id' => 1,
'user_type' => \Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN,
'description' => 'Bulk Description',
'operation_count' => 1,
],
'in_progress_success' => [
'uuid' => 'bulk-uuid-2',
'user_id' => 1,
'user_type' => \Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN,
'description' => 'Bulk Description',
'operation_count' => 3,
],
'in_progress_integration' => [
'uuid' => 'bulk-uuid-2.1',
'user_id' => 100,
'user_type' => \Magento\Authorization\Model\UserContextInterface::USER_TYPE_INTEGRATION,
'description' => 'Bulk Description',
'operation_count' => 3,
],
'in_progress_failed' => [
'uuid' => 'bulk-uuid-3',
'user_id' => 1,
'user_type' => \Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN,
'description' => 'Bulk Description',
'operation_count' => 2,
],
'finish_success' => [
'uuid' => 'bulk-uuid-4',
'user_id' => 1,
'user_type' => \Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN,
'description' => 'Bulk Description',
'operation_count' => 1,
],
'finish_failed' => [
'uuid' => 'bulk-uuid-5',
'user_id' => 1,
'user_type' => \Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN,
'description' => 'Bulk Description',
'operation_count' => 2,
],
];
// Only processed operations are saved into database (i.e. operations that are not in 'open' state)
$operations = [
[
'bulk_uuid' => 'bulk-uuid-2',
'topic_name' => 'topic-3',
'serialized_data' => json_encode(['entity_id' => 2]),
'status' => OperationInterface::STATUS_TYPE_COMPLETE,
'error_code' => null,
'result_message' => null,
'operation_key' => 0
],
[
'bulk_uuid' => 'bulk-uuid-3',
'topic_name' => 'topic-3',
'serialized_data' => json_encode(['entity_id' => 3]),
'status' => OperationInterface::STATUS_TYPE_RETRIABLY_FAILED,
'error_code' => 1111,
'result_message' => 'Something went wrong during your request',
'operation_key' => 0
],
[
'bulk_uuid' => 'bulk-uuid-4',
'topic_name' => 'topic-4',
'serialized_data' => json_encode(['entity_id' => 4]),
'status' => OperationInterface::STATUS_TYPE_COMPLETE,
'error_code' => null,
'result_message' => null,
'operation_key' => 0
],
[
'bulk_uuid' => 'bulk-uuid-5',
'topic_name' => 'topic-4',
'serialized_data' => json_encode(['entity_id' => 5, 'meta_information' => 'Test']),
'status' => OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED,
'error_code' => 1111,
'result_message' => 'Something went wrong during your request',
'operation_key' => 0
],
[
'bulk_uuid' => 'bulk-uuid-5',
'topic_name' => 'topic-4',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_RETRIABLY_FAILED,
'error_code' => 2222,
'result_message' => 'Entity with ID=4 does not exist',
'operation_key' => 1
],
];
$bulkQuery = "INSERT INTO {$bulkTable} (`uuid`, `user_id`, `user_type`, `description`, `operation_count`)"
. " VALUES (:uuid, :user_id, :user_type, :description, :operation_count);";
foreach ($bulks as $bulk) {
$connection->query($bulkQuery, $bulk);
}
$operationQuery = "INSERT INTO {$operationTable}"
. " (`bulk_uuid`, `topic_name`, `serialized_data`, `status`, `error_code`, `result_message`, `operation_key`)"
. " VALUES (:bulk_uuid, :topic_name, :serialized_data, :status, :error_code, :result_message, :operation_key);";
foreach ($operations as $operation) {
$connection->query($operationQuery, $operation);
}
@@ -0,0 +1,15 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\TestFramework\Helper\Bootstrap;
/**
* @var $resource Magento\Framework\App\ResourceConnection
*/
$resource = Bootstrap::getObjectManager()->get(\Magento\Framework\App\ResourceConnection::class);
$connection = $resource->getConnection();
$bulkTable = $resource->getTableName('magento_bulk');
$connection->query("DELETE FROM {$bulkTable};");
@@ -0,0 +1,105 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\Bulk\OperationInterface;
/**
* @var $resource Magento\Framework\App\ResourceConnection
*/
$resource = Bootstrap::getObjectManager()->get(\Magento\Framework\App\ResourceConnection::class);
$connection = $resource->getConnection();
$bulkTable = $resource->getTableName('magento_bulk');
$operationTable = $resource->getTableName('magento_operation');
$bulks = [
'started_searchable' => [
'uuid' => 'bulk-uuid-searchable-6',
'user_id' => 1,
'description' => 'Bulk Description',
'operation_count' => 6,
'start_time' => '2009-10-10 00:00:00',
],
'not_started' => [
'uuid' => 'bulk-uuid-searchable-7',
'user_id' => 1,
'description' => 'Bulk Description',
'operation_count' => 3,
'start_time' => '2009-10-10 00:00:00',
],
];
// Only processed operations are saved into database (i.e. operations that are not in 'open' state)
$operations = [
[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_COMPLETE,
'error_code' => null,
'result_message' => null,
'operation_key' => 0
],
[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5, 'meta_information' => 'Test']),
'status' => OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED,
'error_code' => 1111,
'result_message' => 'Something went wrong during your request',
'operation_key' => 1
],
[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_RETRIABLY_FAILED,
'error_code' => 2222,
'result_message' => 'Entity with ID=4 does not exist',
'operation_key' => 2
],
[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_OPEN,
'error_code' => null,
'result_message' => '',
'operation_key' => 3
],
[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_OPEN,
'error_code' => null,
'result_message' => '',
'operation_key' => 4
],
[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_REJECTED,
'error_code' => null,
'result_message' => '',
'operation_key' => 5
],
];
$bulkQuery = "INSERT INTO {$bulkTable} (`uuid`, `user_id`, `description`, `operation_count`, `start_time`)"
. " VALUES (:uuid, :user_id, :description, :operation_count, :start_time);";
foreach ($bulks as $bulk) {
$connection->query($bulkQuery, $bulk);
}
$operationQuery = "INSERT INTO {$operationTable}"
. " (`bulk_uuid`, `topic_name`, `serialized_data`, `status`, `error_code`, `result_message`, `operation_key`)"
. " VALUES (:bulk_uuid, :topic_name, :serialized_data, :status, :error_code, :result_message, :operation_key);";
foreach ($operations as $operation) {
$connection->query($operationQuery, $operation);
}
@@ -0,0 +1,12 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
// when bulks are removed, acknowledged bulk table will be cleared too.';
Resolver::getInstance()->requireDataFixture('Magento/AsynchronousOperations/_files/bulk_rollback.php');
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model\ResourceModel\Role;
use Magento\Authorization\Model\UserContextInterface;
/**
* Role collection test
* @magentoAppArea adminhtml
*/
class CollectionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Authorization\Model\ResourceModel\Role\Collection
*/
protected $_collection;
protected function setUp(): void
{
$this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Authorization\Model\ResourceModel\Role\Collection::class
);
}
public function testSetUserFilter()
{
$user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\User\Model\User::class);
$user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME);
$this->_collection->setUserFilter($user->getId(), UserContextInterface::USER_TYPE_ADMIN);
$selectQueryStr = $this->_collection->getSelect()->__toString();
$this->assertStringContainsString('user_id', $selectQueryStr);
$this->assertStringContainsString('user_type', $selectQueryStr);
}
public function testSetRolesFilter()
{
$this->_collection->setRolesFilter();
$this->assertStringContainsString('role_type', $this->_collection->getSelect()->__toString());
}
public function testToOptionArray()
{
$this->assertNotEmpty($this->_collection->toOptionArray());
foreach ($this->_collection->toOptionArray() as $item) {
$this->assertArrayHasKey('value', $item);
$this->assertArrayHasKey('label', $item);
}
}
}
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model\ResourceModel\Role\Grid;
/**
* @magentoAppArea adminhtml
*/
class CollectionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Authorization\Model\ResourceModel\Role\Grid\Collection
*/
private $_collection;
protected function setUp(): void
{
$this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Authorization\Model\ResourceModel\Role\Grid\Collection::class
);
}
public function testGetItems()
{
$expectedResult = [
[
'role_type' => \Magento\Authorization\Model\Acl\Role\Group::ROLE_TYPE,
'role_name' => \Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME,
],
];
$actualResult = [];
/** @var \Magento\Reports\Model\Item $reportItem */
foreach ($this->_collection->getItems() as $reportItem) {
$actualResult[] = array_intersect_key($reportItem->getData(), $expectedResult[0]);
}
$this->assertEquals($expectedResult, $actualResult);
}
}
@@ -0,0 +1,29 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model\ResourceModel;
/**
* Role resource test
*
* @magentoAppArea adminhtml
*/
class RoleTest extends \PHPUnit\Framework\TestCase
{
public function testGetRoleUsers()
{
$role = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Authorization\Model\Role::class
);
$roleResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Authorization\Model\ResourceModel\Role::class
);
$this->assertEmpty($roleResource->getRoleUsers($role));
$role->load(\Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, 'role_name');
$this->assertNotEmpty($roleResource->getRoleUsers($role));
}
}
@@ -0,0 +1,45 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model\ResourceModel\Rules;
/**
* @magentoAppArea adminhtml
*/
class CollectionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Authorization\Model\ResourceModel\Rules\Collection
*/
protected $_collection;
protected function setUp(): void
{
$this->_collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Authorization\Model\ResourceModel\Rules\Collection::class
);
}
public function testGetByRoles()
{
$user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\User\Model\User::class);
$user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME);
$this->_collection->getByRoles($user->getRole()->getId());
$where = $this->_collection->getSelect()->getPart(\Magento\Framework\DB\Select::WHERE);
/** @var \Magento\Framework\DB\Adapter\Pdo\Mysql $connection */
$connection = $this->_collection->getConnection();
$quote = $connection->getQuoteIdentifierSymbol();
$this->assertContains("({$quote}role_id{$quote} = '" . $user->getRole()->getId() . "')", $where);
}
public function testAddSortByLength()
{
$this->_collection->addSortByLength();
$order = $this->_collection->getSelect()->getPart(\Magento\Framework\DB\Select::ORDER);
$this->assertContains(['length', 'DESC'], $order);
}
}
@@ -0,0 +1,31 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model;
/**
* @magentoAppArea adminhtml
*/
class RoleTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Authorization\Model\Role
*/
protected $_model = null;
protected function setUp(): void
{
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create(\Magento\Authorization\Model\Role::class);
}
public function testGetRoleUsers()
{
$this->assertEmpty($this->_model->getRoleUsers());
$this->_model->load(\Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, 'role_name');
$this->assertNotEmpty($this->_model->getRoleUsers());
}
}
@@ -0,0 +1,97 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model;
/**
* @magentoAppArea adminhtml
*/
class RulesTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Authorization\Model\Rules
*/
protected $_model;
/**
* @var \Magento\User\Model\User
*/
protected $user;
protected function setUp(): void
{
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Authorization\Model\Rules::class
);
$this->user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\User\Model\User::class
);
}
/**
* @magentoDbIsolation enabled
*/
public function testCRUD()
{
$this->_model
->setRoleType('G')
->setResourceId('Magento_Backend::all')
->setPrivileges("")
->setAssertId(0)
->setRoleId(1)
->setPermission('allow');
$crud = new \Magento\TestFramework\Entity($this->_model, ['permission' => 'deny']);
$crud->testCrud();
}
/**
* @magentoDbIsolation enabled
*/
public function testInitialUserPermissions()
{
$expectedDefaultPermissions = ['Magento_Backend::all'];
$this->_checkExistingPermissions($expectedDefaultPermissions);
}
/**
* @covers \Magento\Authorization\Model\Rules::saveRel
* @magentoDbIsolation enabled
*/
public function testSetAllowForAllResources()
{
$resources = ['Magento_Backend::all'];
$this->user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME);
$roleId = $this->user->getRole()->getRoleId();
$this->_model->setRoleId($roleId)->setResources($resources)->saveRel();
$expectedPermissions = ['Magento_Backend::all'];
$this->_checkExistingPermissions($expectedPermissions);
}
/**
* Ensure that only expected permissions are set.
*/
protected function _checkExistingPermissions($expectedDefaultPermissions)
{
$connection = $this->_model->getResource()->getConnection();
$this->user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME);
$roleId = $this->user->getRole()->getRoleId();
$ruleSelect = $connection->select()
->from($this->_model->getResource()->getMainTable())
->where('role_id = ?', $roleId);
$rules = $ruleSelect->query()->fetchAll();
$actualPermissions = [];
foreach ($rules as $rule) {
$actualPermissions[] = $rule['resource_id'];
$this->assertEquals(
'allow',
$rule['permission'],
"Permission for '{$rule['resource_id']}' resource should be 'allow'"
);
}
$this->assertEquals($expectedDefaultPermissions, $actualPermissions, 'Default permissions are invalid');
}
}
@@ -0,0 +1,126 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\App;
use Magento\TestFramework\Bootstrap;
/**
* Test class for \Magento\Backend\App\AbstractAction.
* @magentoAppArea adminhtml
*/
class AbstractActionTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/**
* Check redirection to startup page for logged user
* @magentoConfigFixture current_store admin/security/use_form_key 1
* @magentoAppIsolation enabled
*/
public function testPreDispatchWithEmptyUrlRedirectsToStartupPage()
{
$this->markTestSkipped('Session destruction doesn\'t work');
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\Config\ScopeInterface::class
)->setCurrentScope(
\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
);
$this->dispatch('backend');
/** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */
$backendUrlModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Backend\Model\UrlInterface::class
);
$url = $backendUrlModel->getStartupPageUrl();
$expected = $backendUrlModel->getUrl($url);
$this->assertRedirect($this->stringStartsWith($expected));
}
/**
* Check login redirection
*
* @magentoDbIsolation enabled
*/
public function testInitAuthentication()
{
/**
* Logout current session
*/
$this->_auth->logout();
/** @var \Magento\Framework\Data\Form\FormKey $formKey */
$formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class);
$postLogin = [
'login' => [
'username' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
'password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
],
'form_key' => $formKey->getFormKey(),
];
$this->getRequest()->setPostValue($postLogin);
$this->dispatch('backend/admin/system_account/index');
$expected = 'backend/admin/system_account/index';
$this->assertRedirect($this->stringContains($expected));
}
/**
* Check layout attribute "acl" for check access to
*
* @param string $blockName
* @param string $resource
* @param bool $isLimitedAccess
* @dataProvider nodesWithAcl
*/
public function testAclInNodes($blockName, $resource, $isLimitedAccess)
{
/** @var $noticeInbox \Magento\AdminNotification\Model\Inbox */
$noticeInbox = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\AdminNotification\Model\Inbox::class
);
if (!$noticeInbox->loadLatestNotice()->getId()) {
$noticeInbox->addCritical('Test notice', 'Test description');
}
$this->_auth->login(
\Magento\TestFramework\Bootstrap::ADMIN_NAME,
\Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
);
/** @var $acl \Magento\Framework\Acl */
$acl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Acl\Builder::class)
->getAcl();
if ($isLimitedAccess) {
$acl->deny(Bootstrap::ADMIN_ROLE_ID, $resource);
}
$this->dispatch('backend/admin/dashboard');
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
$actualBlocks = $layout->getAllBlocks();
$this->assertNotEmpty($actualBlocks);
if ($isLimitedAccess) {
$this->assertNotContains($blockName, array_keys($actualBlocks));
} else {
$this->assertContains($blockName, array_keys($actualBlocks));
}
}
/**
* Data provider with expected blocks with acl properties
*
* @return array
*/
public function nodesWithAcl()
{
return [
['notification_window', 'Magento_AdminNotification::show_toolbar', true],
['notification_window', 'Magento_AdminNotification::show_toolbar', false]
];
}
}
@@ -0,0 +1,49 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Backend\App\Area;
use PHPUnit\Framework\TestCase;
use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoAppArea adminhtml
*/
class FrontNameResolverTest extends TestCase
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
/**
* @var FrontNameResolver
*/
protected $model;
/**
* @inheritDoc
*/
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->model = $this->objectManager->create(
FrontNameResolver::class
);
$_SERVER['HTTP_HOST'] = 'localhost';
}
/**
* @magentoDbIsolation enabled
* @magentoConfigFixture current_store web/unsecure/base_url http://example.com/
*/
public function testIsHostBackend()
{
$this->assertTrue($this->model->isHostBackend());
}
}
@@ -0,0 +1,435 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Backend\App\Request;
use Magento\Backend\App\AbstractAction;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\Auth;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Phrase;
use Magento\TestFramework\Request;
use Magento\TestFramework\Response;
use PHPUnit\Framework\TestCase;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Bootstrap as TestBootstrap;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\App\Response\Http as HttpResponse;
use Laminas\Stdlib\Parameters;
use Magento\Backend\Model\UrlInterface as BackendUrl;
use Magento\Framework\App\Response\HttpFactory as HttpResponseFactory;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class BackendValidatorTest extends TestCase
{
private const AWARE_VALIDATION_PARAM = 'test_param';
private const AWARE_LOCATION_VALUE = 'test1';
private const CSRF_AWARE_MESSAGE = 'csrf_aware';
/**
* @var ActionInterface
*/
private $mockUnawareAction;
/**
* @var AbstractAction
*/
private $mockAwareAction;
/**
* @var BackendValidator
*/
private $validator;
/**
* @var Request
*/
private $request;
/**
* @var FormKey
*/
private $formKey;
/**
* @var BackendUrl
*/
private $url;
/**
* @var Auth
*/
private $auth;
/**
* @var CsrfAwareActionInterface
*/
private $mockCsrfAwareAction;
/**
* @var HttpResponseFactory
*/
private $httpResponseFactory;
/**
* @return ActionInterface
*/
private function createUnawareAction(): ActionInterface
{
return new class implements ActionInterface {
/**
* @inheritDoc
*/
public function execute()
{
throw new NotFoundException(new Phrase('Not implemented'));
}
};
}
/**
* @return AbstractAction
*/
private function createAwareAction(): AbstractAction
{
$l = self::AWARE_LOCATION_VALUE;
$p = self::AWARE_VALIDATION_PARAM;
return new class($l, $p) extends AbstractAction{
/**
* @var string
*/
private $locationValue;
/**
* @var string
*/
private $param;
/**
* @param string $locationValue
* @param string $param
*/
public function __construct(
string $locationValue,
string $param
) {
parent::__construct(
Bootstrap::getObjectManager()->get(Context::class)
);
$this->locationValue= $locationValue;
$this->param = $param;
}
/**
* @inheritDoc
*/
public function execute()
{
throw new NotFoundException(new Phrase('Not implemented'));
}
/**
* @inheritDoc
*/
public function _processUrlKeys()
{
if ($this->_request->getParam($this->param)) {
return true;
} else {
/** @var Response $response */
$response = $this->_response;
$response->setHeader('Location', $this->locationValue);
return false;
}
}
};
}
/**
* @return CsrfAwareActionInterface
*/
private function createCsrfAwareAction(): CsrfAwareActionInterface
{
$r = Bootstrap::getObjectManager()
->get(ResponseInterface::class);
$m = self::CSRF_AWARE_MESSAGE;
return new class ($r, $m) implements CsrfAwareActionInterface {
/**
* @var ResponseInterface
*/
private $response;
/**
* @var string
*/
private $message;
/**
* @param ResponseInterface $response
* @param string $message
*/
public function __construct(
ResponseInterface $response,
string $message
) {
$this->response = $response;
$this->message = $message;
}
/**
* @inheritDoc
*/
public function execute()
{
return $this->response;
}
/**
* @inheritDoc
*/
public function createCsrfValidationException(
RequestInterface $request
): ?InvalidRequestException {
return new InvalidRequestException(
$this->response,
[new Phrase($this->message)]
);
}
/**
* @inheritDoc
*/
public function validateForCsrf(RequestInterface $request): ?bool
{
return false;
}
};
}
/**
* @inheritDoc
*/
protected function setUp(): void
{
$objectManager = Bootstrap::getObjectManager();
$this->request = $objectManager->get(RequestInterface::class);
$this->validator = $objectManager->get(BackendValidator::class);
$this->mockUnawareAction = $this->createUnawareAction();
$this->mockAwareAction = $this->createAwareAction();
$this->formKey = $objectManager->get(FormKey::class);
$this->url = $objectManager->get(BackendUrl::class);
$this->auth = $objectManager->get(Auth::class);
$this->mockCsrfAwareAction = $this->createCsrfAwareAction();
$this->httpResponseFactory = $objectManager->get(
HttpResponseFactory::class
);
}
/**
* @magentoConfigFixture admin/security/use_form_key 1
* @magentoAppArea adminhtml
*/
public function testValidateWithValidKey()
{
$this->request->setMethod(HttpRequest::METHOD_GET);
$this->auth->login(
TestBootstrap::ADMIN_NAME,
TestBootstrap::ADMIN_PASSWORD
);
$this->request->setParams([
BackendUrl::SECRET_KEY_PARAM_NAME => $this->url->getSecretKey(),
]);
$this->validator->validate(
$this->request,
$this->mockUnawareAction
);
}
/**
*
* @magentoConfigFixture admin/security/use_form_key 1
* @magentoAppArea adminhtml
*/
public function testValidateWithInvalidKey()
{
$this->expectException(\Magento\Framework\App\Request\InvalidRequestException::class);
$invalidKey = $this->url->getSecretKey() .'Invalid';
$this->request->setParams([
BackendUrl::SECRET_KEY_PARAM_NAME => $invalidKey,
]);
$this->request->setMethod(HttpRequest::METHOD_GET);
$this->auth->login(
TestBootstrap::ADMIN_NAME,
TestBootstrap::ADMIN_PASSWORD
);
$this->validator->validate(
$this->request,
$this->mockUnawareAction
);
}
/**
*
* @magentoConfigFixture admin/security/use_form_key 0
* @magentoAppArea adminhtml
*/
public function testValidateWithInvalidFormKey()
{
$this->expectException(\Magento\Framework\App\Request\InvalidRequestException::class);
$this->request->setPost(
new Parameters(['form_key' => $this->formKey->getFormKey() .'1'])
);
$this->request->setMethod(HttpRequest::METHOD_POST);
$this->validator->validate(
$this->request,
$this->mockUnawareAction
);
}
/**
* @magentoConfigFixture admin/security/use_form_key 0
* @magentoAppArea adminhtml
*/
public function testValidateInvalidWithAwareAction()
{
$this->request->setParams([self::AWARE_VALIDATION_PARAM => '']);
/** @var InvalidRequestException|null $caught */
$caught = null;
try {
$this->validator->validate(
$this->request,
$this->mockAwareAction
);
} catch (InvalidRequestException $exception) {
$caught = $exception;
}
$this->assertNotNull($caught);
/** @var Response $response */
$response = $caught->getReplaceResult();
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(
self::AWARE_LOCATION_VALUE,
$response->getHeader('Location')->getFieldValue()
);
$this->assertNull($caught->getMessages());
}
/**
* @magentoAppArea adminhtml
*/
public function testValidateValidWithAwareAction()
{
$this->request->setParams(
[self::AWARE_VALIDATION_PARAM => '1']
);
$this->validator->validate(
$this->request,
$this->mockAwareAction
);
}
/**
* @magentoConfigFixture admin/security/use_form_key 1
* @magentoAppArea adminhtml
*/
public function testValidateWithCsrfAwareAction()
{
//Setting up request that would be valid for default validation.
$this->request->setMethod(HttpRequest::METHOD_GET);
$this->auth->login(
TestBootstrap::ADMIN_NAME,
TestBootstrap::ADMIN_PASSWORD
);
$this->request->setParams([
BackendUrl::SECRET_KEY_PARAM_NAME => $this->url->getSecretKey(),
]);
/** @var InvalidRequestException|null $caught */
$caught = null;
try {
$this->validator->validate(
$this->request,
$this->mockCsrfAwareAction
);
} catch (InvalidRequestException $exception) {
$caught = $exception;
}
//Checking that custom validation was called and invalidated
//valid request.
$this->assertNotNull($caught);
$this->assertCount(1, $caught->getMessages());
$this->assertEquals(
self::CSRF_AWARE_MESSAGE,
$caught->getMessages()[0]->getText()
);
}
public function testInvalidAjaxRequest()
{
//Setting up AJAX request with invalid secret key.
$this->request->setMethod(HttpRequest::METHOD_GET);
$this->auth->login(
TestBootstrap::ADMIN_NAME,
TestBootstrap::ADMIN_PASSWORD
);
$this->request->setParams([
BackendUrl::SECRET_KEY_PARAM_NAME => 'invalid',
'isAjax' => '1'
]);
/** @var InvalidRequestException|null $caught */
$caught = null;
try {
$this->validator->validate(
$this->request,
$this->mockUnawareAction
);
} catch (InvalidRequestException $exception) {
$caught = $exception;
}
$this->assertNotNull($caught);
$this->assertInstanceOf(
ResultInterface::class,
$caught->getReplaceResult()
);
/** @var ResultInterface $result */
$result = $caught->getReplaceResult();
/** @var HttpResponse $response */
$response = $this->httpResponseFactory->create();
$result->renderResult($response);
$this->assertEmpty($response->getBody());
$this->assertEquals(401, $response->getHttpResponseCode());
}
}
@@ -0,0 +1,99 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\App;
/**
* @magentoAppArea adminhtml
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class RouterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\App\Router
*/
protected $model;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
protected function setUp(): void
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->model = $this->objectManager->create(\Magento\Backend\App\Router::class);
}
public function testRouterCanProcessRequestsWithProperPathInfo()
{
$request = $this->createMock(\Magento\Framework\App\Request\Http::class);
$request->expects($this->once())->method('getPathInfo')->willReturn('backend/admin/dashboard');
$this->assertInstanceOf(\Magento\Backend\Controller\Adminhtml\Dashboard::class, $this->model->match($request));
}
/**
* @param string $module
* @param string $controller
* @param string $className
*
* @dataProvider getControllerClassNameDataProvider
*/
public function testGetControllerClassName($module, $controller, $className)
{
$this->assertEquals($className, $this->model->getActionClassName($module, $controller));
}
public function getControllerClassNameDataProvider()
{
return [
['Magento_TestModule', 'controller', \Magento\TestModule\Controller\Adminhtml\Controller::class],
];
}
public function testMatchCustomNoRouteAction()
{
if (!\Magento\TestFramework\Helper\Bootstrap::canTestHeaders()) {
$this->markTestSkipped('Can\'t test get match without sending headers');
}
$routers = [
'testmodule' => [
'frontName' => 'testfixture',
'id' => 'testfixture',
'modules' => ['Magento_TestFixture'],
],
];
$routeConfig = $this->getMockBuilder(\Magento\Framework\App\Route\Config::class)
->setMethods(['_getRoutes'])
->setConstructorArgs(
[
'reader' => $this->objectManager->get(\Magento\Framework\App\Route\Config\Reader::class),
'cache' => $this->objectManager->get(\Magento\Framework\Config\CacheInterface::class),
'configScope' => $this->objectManager->get(\Magento\Framework\Config\ScopeInterface::class),
'areaList' => $this->objectManager->get(\Magento\Framework\App\AreaList::class),
'cacheId' => 'RoutesConfig'
]
)
->getMock();
$routeConfig->expects($this->any())->method('_getRoutes')->willReturn($routers);
$defaultRouter = $this->objectManager->create(
\Magento\Backend\App\Router::class,
['routeConfig' => $routeConfig]
);
/** @var $request \Magento\TestFramework\Request */
$request = $this->objectManager->get(\Magento\TestFramework\Request::class);
$request->setPathInfo('backend/testfixture/test_controller');
$controller = $defaultRouter->match($request);
$this->assertInstanceOf(\Magento\TestFixture\Controller\Adminhtml\Noroute::class, $controller);
$this->assertEquals('noroute', $request->getActionName());
}
}
@@ -0,0 +1,67 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Backend\Block\Dashboard\Chart;
use Magento\Backend\ViewModel\ChartsPeriod;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\LayoutInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Helper\Xpath;
use PHPUnit\Framework\TestCase;
/**
* Checks chart periods on Magento dashboard
*
* @magentoAppArea adminhtml
*/
class PeriodTest extends TestCase
{
/** @var ObjectManagerInterface */
private $objectManager;
/** @var Template */
private $block;
/** @var LayoutInterface */
private $layout;
/**
* @inheritdoc
*/
public function setUp(): void
{
parent::setUp();
$this->objectManager = Bootstrap::getObjectManager();
$this->layout = $this->objectManager->get(LayoutInterface::class);
$this->block = $this->layout->createBlock(Template::class);
$this->block->setTemplate("Magento_Backend::dashboard/chart/period.phtml");
$this->block->setData('view_model', $this->objectManager->get(ChartsPeriod::class));
}
/**
* @return void
*/
public function testChartPeriodOptions(): void
{
$html = $this->block->toHtml();
$dropDownList = [
__('Today'),
__('Last 24 Hours'),
__('Last 7 Days'),
__('Current Month'),
__('YTD'),
__('2YTD')
];
foreach ($dropDownList as $item) {
$xPath = "//select[@id='dashboard_chart_period']/option[normalize-space(text())='{$item}']";
$this->assertEquals(1, Xpath::getElementsCountForXpath($xPath, $html));
}
}
}
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Dashboard\Orders;
use Magento\Backend\Block\Template\Context;
class GridTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Grid
*/
private $block;
protected function setUp(): void
{
parent::setUp();
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$block = $this->createMock(\Magento\Backend\Block\Dashboard\Orders\Grid::class);
$layout = $this->createMock(\Magento\Framework\View\LayoutInterface::class);
$layout->expects($this->atLeastOnce())->method('getChildName')->willReturn('test');
$layout->expects($this->atLeastOnce())->method('getBlock')->willReturn($block);
$context = $objectManager->create(Context::class, ['layout' => $layout]);
$this->block = $objectManager->create(Grid::class, ['context' => $context]);
}
/**
* @magentoDataFixture Magento/Sales/_files/order.php
*/
public function testGetPreparedCollection()
{
$collection = $this->block->getPreparedCollection();
foreach ($collection->getItems() as $item) {
if ($item->getIncrementId() == '100000001') {
$this->assertEquals('firstname lastname', $item->getCustomer());
}
}
}
}
@@ -0,0 +1,68 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Dashboard\Tab\Products;
use Magento\TestFramework\Helper\Bootstrap as BootstrapHelper;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\LayoutInterface;
use Magento\Backend\Block\Dashboard\Tab\Products\Viewed as ViewedProductsTabBlock;
use Magento\Catalog\Model\ProductRepository;
use Magento\Framework\Event\ManagerInterface as EventManager;
/**
* @magentoAppArea frontend
*/
class ViewedTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerInterface
*/
private $objectManager;
/**
* @var LayoutInterface
*/
private $layout;
/**
* @var ProductRepository
*/
private $productRepository;
/**
* @var EventManager
*/
private $eventManager;
protected function setUp(): void
{
$this->objectManager = BootstrapHelper::getObjectManager();
$this->layout = $this->objectManager->get(LayoutInterface::class);
$this->productRepository = $this->objectManager->get(ProductRepository::class);
$this->eventManager = $this->objectManager->get(EventManager::class);
}
/**
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture default/reports/options/enabled 1
*/
public function testGetPreparedCollectionProductPrice()
{
/** @var ViewedProductsTabBlock $viewedProductsTabBlock */
$viewedProductsTabBlock = $this->layout->createBlock(ViewedProductsTabBlock::class);
$product = $this->productRepository->getById(1);
$this->eventManager->dispatch('catalog_controller_product_view', ['product' => $product]);
$collection = $viewedProductsTabBlock->getPreparedCollection();
$this->assertEquals(
10,
$collection->getFirstItem()->getDataByKey('price')
);
}
}
@@ -0,0 +1,169 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block;
use Magento\Framework\App\State;
use Magento\Framework\Component\ComponentRegistrar;
/**
* Test class for \Magento\Backend\Block\Menu
* @magentoAppArea adminhtml
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class MenuTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\Menu $blockMenu
*/
protected $blockMenu;
/** @var \Magento\Framework\App\Cache\Type\Config $configCacheType */
protected $configCacheType;
/**
* @var array
*/
protected $backupRegistrar;
/**
* @var \Magento\Backend\Model\Menu\Config
*/
private $menuConfig;
protected function setUp(): void
{
$this->configCacheType = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Framework\App\Cache\Type\Config::class
);
$this->configCacheType->save('', \Magento\Backend\Model\Menu\Config::CACHE_MENU_OBJECT);
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
$paths = $reflection->getProperty('paths');
$paths->setAccessible(true);
$this->backupRegistrar = $paths->getValue();
$paths->setAccessible(false);
$this->menuConfig = $this->prepareMenuConfig();
$this->blockMenu = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Backend\Block\Menu::class,
['menuConfig' => $this->menuConfig]
);
}
/**
* Verify that Admin Navigation Menu elements have correct titles & are located on correct levels
*/
public function testRenderNavigation()
{
$menuHtml = $this->blockMenu->renderNavigation($this->menuConfig->getMenu(), 0, 12);
$menu = new \SimpleXMLElement($menuHtml);
$item = $menu->xpath('/ul/li/a/span')[0];
$this->assertEquals('System', (string)$item, '"System" item is absent or located on wrong menu level.');
$item = $menu->xpath('/ul//ul/li/strong/span')[0];
$this->assertEquals('Report', (string)$item, '"Report" item is absent or located on wrong menu level.');
$liTitles = [
'Private Sales',
'Invite',
'Invited Customers',
];
foreach ($menu->xpath('/ul//ul//ul/li/a/span') as $sortOrder => $item) {
if ($sortOrder>2) {
break;
}
$this->assertEquals(
$liTitles[$sortOrder],
(string)$item,
'"' . $liTitles[$sortOrder] . '" item is absent or located on wrong menu level.'
);
}
// test column break if submenu contain more than 12 node
$this->assertStringContainsString('<li class="column">', $menuHtml);
}
/**
* @return \Magento\Backend\Model\Menu\Config
*/
protected function prepareMenuConfig()
{
$this->loginAdminUser();
$componentRegistrar = new \Magento\Framework\Component\ComponentRegistrar();
$libraryPath = $componentRegistrar->getPath(ComponentRegistrar::LIBRARY, 'magento/framework');
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
$paths = $reflection->getProperty('paths');
$paths->setAccessible(true);
$paths->setValue(
null,
[
ComponentRegistrar::MODULE => [],
ComponentRegistrar::THEME => [],
ComponentRegistrar::LANGUAGE => [],
ComponentRegistrar::LIBRARY => []
]
);
$paths->setAccessible(false);
ComponentRegistrar::register(ComponentRegistrar::LIBRARY, 'magento/framework', $libraryPath);
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Magento_Backend',
__DIR__ . '/_files/menu/Magento/Backend'
);
/* @var $validationState \Magento\Framework\App\Arguments\ValidationState */
$validationState = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Framework\App\Arguments\ValidationState::class,
['appMode' => State::MODE_DEFAULT]
);
/* @var $configReader \Magento\Backend\Model\Menu\Config\Reader */
$configReader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Backend\Model\Menu\Config\Reader::class,
['validationState' => $validationState]
);
return \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Backend\Model\Menu\Config::class,
[
'configReader' => $configReader,
'configCacheType' => $this->configCacheType
]
);
}
/**
* @return void
*/
protected function loginAdminUser()
{
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Backend\Model\UrlInterface::class)
->turnOffSecretKey();
$auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Auth::class);
$auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
}
/**
* @return void
*/
protected function tearDown(): void
{
$this->configCacheType->save('', \Magento\Backend\Model\Menu\Config::CACHE_MENU_OBJECT);
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
$paths = $reflection->getProperty('paths');
$paths->setAccessible(true);
$paths->setValue(null, $this->backupRegistrar);
$paths->setAccessible(false);
}
}
@@ -0,0 +1,54 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Page;
/**
* Test \Magento\Backend\Block\Page\Footer
*
* @magentoAppArea adminhtml
*/
class FooterTest extends \PHPUnit\Framework\TestCase
{
/**
* Test Product Version Value
*/
const TEST_PRODUCT_VERSION = '222.333.444';
/**
* @var \Magento\Backend\Block\Page\Footer
*/
protected $block;
protected function setUp(): void
{
parent::setUp();
$productMetadataMock = $this->getMockBuilder(\Magento\Framework\App\ProductMetadata::class)
->setMethods(['getVersion'])
->disableOriginalConstructor()
->getMock();
$productMetadataMock->expects($this->once())
->method('getVersion')
->willReturn($this::TEST_PRODUCT_VERSION);
$this->block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\Backend\Block\Page\Footer::class,
'',
['productMetadata' => $productMetadataMock]
);
}
public function testToHtml()
{
$footerContent = $this->block->toHtml();
$this->assertStringContainsString(
'ver. ' . $this::TEST_PRODUCT_VERSION,
$footerContent,
'No or wrong product version.'
);
}
}
@@ -0,0 +1,36 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Page;
/**
* Test \Magento\Backend\Block\Page\Header
* @magentoAppArea adminhtml
*/
class HeaderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\Page\Header
*/
protected $_block;
protected function setUp(): void
{
parent::setUp();
$this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\Backend\Block\Page\Header::class
);
}
public function testGetHomeLink()
{
$expected = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Backend\Helper\Data::class
)->getHomePageUrl();
$this->assertEquals($expected, $this->_block->getHomeLink());
}
}
@@ -0,0 +1,89 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Account\Edit;
/**
* @magentoAppArea adminhtml
*/
class FormTest extends \PHPUnit\Framework\TestCase
{
public function testPrepareForm()
{
$user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\User\Model\User::class
)->loadByUsername(
\Magento\TestFramework\Bootstrap::ADMIN_NAME
);
/** @var $session \Magento\Backend\Model\Auth\Session */
$session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Backend\Model\Auth\Session::class
);
$session->setUser($user);
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var \Magento\Backend\Block\System\Account\Edit\Form */
$block = $layout->createBlock(\Magento\Backend\Block\System\Account\Edit\Form::class);
$block->toHtml();
$form = $block->getForm();
$this->assertInstanceOf(\Magento\Framework\Data\Form::class, $form);
$this->assertEquals('post', $form->getData('method'));
$this->assertEquals($block->getUrl('adminhtml/system_account/save'), $form->getData('action'));
$this->assertEquals('edit_form', $form->getId());
$this->assertTrue($form->getUseContainer());
$expectedFieldset = [
'username' => [
'name' => 'username',
'type' => 'text',
'required' => true,
'value' => $user->getData('username'),
],
'firstname' => [
'name' => 'firstname',
'type' => 'text',
'required' => true,
'value' => $user->getData('firstname'),
],
'lastname' => [
'name' => 'lastname',
'type' => 'text',
'required' => true,
'value' => $user->getData('lastname'),
],
'email' => [
'name' => 'email',
'type' => 'text',
'required' => true,
'value' => $user->getData('email'),
],
'password' => ['name' => 'password', 'type' => 'password', 'required' => false],
'confirmation' => ['name' => 'password_confirmation', 'type' => 'password', 'required' => false],
'interface_locale' => ['name' => 'interface_locale', 'type' => 'select', 'required' => false],
];
foreach ($expectedFieldset as $fieldId => $field) {
$element = $form->getElement($fieldId);
$this->assertInstanceOf(\Magento\Framework\Data\Form\Element\AbstractElement::class, $element);
$this->assertEquals($field['name'], $element->getName(), 'Wrong \'' . $fieldId . '\' field name');
$this->assertEquals($field['type'], $element->getType(), 'Wrong \'' . $fieldId . ' field type');
$this->assertEquals(
$field['required'],
$element->getData('required'),
'Wrong \'' . $fieldId . '\' requirement state'
);
if (array_key_exists('value', $field)) {
$this->assertEquals($field['value'], $element->getData('value'), 'Wrong \'' . $fieldId . '\' value');
}
}
}
}
@@ -0,0 +1,47 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Design\Edit\Tab;
/**
* Test class for \Magento\Backend\Block\System\Design\Edit\Tab\General
* @magentoAppArea adminhtml
*/
class GeneralTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoAppIsolation enabled
*/
public function testPrepareForm()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(
\Magento\Framework\View\DesignInterface::class
)->setArea(
\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
)->setDefaultDesignTheme();
$objectManager->get(
\Magento\Framework\Registry::class
)->register(
'design',
$objectManager->create(\Magento\Framework\App\DesignInterface::class)
);
$layout = $objectManager->create(\Magento\Framework\View\Layout::class);
$block = $layout->addBlock(\Magento\Backend\Block\System\Design\Edit\Tab\General::class);
$prepareFormMethod = new \ReflectionMethod(
\Magento\Backend\Block\System\Design\Edit\Tab\General::class,
'_prepareForm'
);
$prepareFormMethod->setAccessible(true);
$prepareFormMethod->invoke($block);
$form = $block->getForm();
foreach (['date_from', 'date_to'] as $id) {
$element = $form->getElement($id);
$this->assertNotNull($element);
$this->assertNotEmpty($element->getDateFormat());
}
}
}
@@ -0,0 +1,32 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Store;
/**
* @magentoAppArea adminhtml
*/
class DeleteTest extends \PHPUnit\Framework\TestCase
{
public function testGetHeaderText()
{
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var $block \Magento\Backend\Block\System\Store\Delete */
$block = $layout->createBlock(\Magento\Backend\Block\System\Store\Delete::class, 'block');
$dataObject = new \Magento\Framework\DataObject();
$form = $block->getChildBlock('form');
$form->setDataObject($dataObject);
$expectedValue = 'header_text_test';
$this->assertStringNotContainsString($expectedValue, (string)$block->getHeaderText());
$dataObject->setName($expectedValue);
$this->assertStringContainsString($expectedValue, (string)$block->getHeaderText());
}
}
@@ -0,0 +1,60 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Store\Edit\Form;
/**
* @magentoAppIsolation enabled
* @magentoAppArea adminhtml
*/
class GroupTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\System\Store\Edit\Form\Group
*/
protected $_block;
protected function setUp(): void
{
parent::setUp();
$registryData = [
'store_type' => 'group',
'store_data' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Store\Model\Store::class
),
'store_action' => 'add',
];
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
foreach ($registryData as $key => $value) {
$objectManager->get(\Magento\Framework\Registry::class)->register($key, $value);
}
/** @var $layout \Magento\Framework\View\Layout */
$layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class);
$this->_block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit\Form\Group::class);
$this->_block->toHtml();
}
protected function tearDown(): void
{
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action');
}
public function testPrepareForm()
{
$form = $this->_block->getForm();
$this->assertEquals('group_fieldset', $form->getElement('group_fieldset')->getId());
$this->assertEquals('group_name', $form->getElement('group_name')->getId());
$this->assertEquals('group', $form->getElement('store_type')->getValue());
}
}
@@ -0,0 +1,60 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Store\Edit\Form;
/**
* @magentoAppIsolation enabled
* @magentoAppArea adminhtml
*/
class StoreTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\System\Store\Edit\Form\Store
*/
protected $_block;
protected function setUp(): void
{
parent::setUp();
$registryData = [
'store_type' => 'store',
'store_data' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Store\Model\Store::class
),
'store_action' => 'add',
];
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
foreach ($registryData as $key => $value) {
$objectManager->get(\Magento\Framework\Registry::class)->register($key, $value);
}
/** @var $layout \Magento\Framework\View\Layout */
$layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class);
$this->_block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit\Form\Store::class);
$this->_block->toHtml();
}
protected function tearDown(): void
{
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action');
}
public function testPrepareForm()
{
$form = $this->_block->getForm();
$this->assertEquals('store_fieldset', $form->getElement('store_fieldset')->getId());
$this->assertEquals('store_name', $form->getElement('store_name')->getId());
$this->assertEquals('store', $form->getElement('store_type')->getValue());
}
}
@@ -0,0 +1,58 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Store\Edit\Form;
/**
* @magentoAppIsolation enabled
* @magentoAppArea adminhtml
*/
class WebsiteTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\System\Store\Edit\Form\Website
*/
protected $_block;
protected function setUp(): void
{
parent::setUp();
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$registryData = [
'store_type' => 'website',
'store_data' => $objectManager->create(\Magento\Store\Model\Website::class),
'store_action' => 'add',
];
foreach ($registryData as $key => $value) {
$objectManager->get(\Magento\Framework\Registry::class)->register($key, $value);
}
/** @var $layout \Magento\Framework\View\Layout */
$layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class);
$this->_block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit\Form\Website::class);
$this->_block->toHtml();
}
protected function tearDown(): void
{
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action');
}
public function testPrepareForm()
{
$form = $this->_block->getForm();
$this->assertEquals('website_fieldset', $form->getElement('website_fieldset')->getId());
$this->assertEquals('website_name', $form->getElement('website_name')->getId());
$this->assertEquals('website', $form->getElement('store_type')->getValue());
}
}
@@ -0,0 +1,140 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Store;
/**
* @magentoAppArea adminhtml
*/
class EditTest extends \PHPUnit\Framework\TestCase
{
protected function tearDown(): void
{
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_type');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_data');
$objectManager->get(\Magento\Framework\Registry::class)->unregister('store_action');
}
/**
* @param $registryData
*/
protected function _initStoreTypesInRegistry($registryData)
{
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
foreach ($registryData as $key => $value) {
if ($key == 'store_data') {
$value = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create($value);
}
$objectManager->get(\Magento\Framework\Registry::class)->register($key, $value);
}
}
/**
* @magentoAppIsolation enabled
* @param $registryData
* @param $expected
* @dataProvider getStoreTypesForLayout
*/
public function testStoreTypeFormCreated($registryData, $expected)
{
$this->_initStoreTypesInRegistry($registryData);
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var $block \Magento\Backend\Block\System\Store\Edit */
$block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit::class, 'block');
$block->setArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE);
$this->assertInstanceOf($expected, $block->getChildBlock('form'));
}
/**
* @return array
*/
public function getStoreTypesForLayout()
{
return [
[
['store_type' => 'website', 'store_data' => \Magento\Store\Model\Website::class],
\Magento\Backend\Block\System\Store\Edit\Form\Website::class,
],
[
['store_type' => 'group', 'store_data' => \Magento\Store\Model\Store::class],
\Magento\Backend\Block\System\Store\Edit\Form\Group::class
],
[
['store_type' => 'store', 'store_data' => \Magento\Store\Model\Store::class],
\Magento\Backend\Block\System\Store\Edit\Form\Store::class
]
];
}
/**
* @magentoAppIsolation enabled
* @param $registryData
* @param $expected
* @dataProvider getStoreDataForBlock
*/
public function testGetHeaderText($registryData, $expected)
{
$this->_initStoreTypesInRegistry($registryData);
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var $block \Magento\Backend\Block\System\Store\Edit */
$block = $layout->createBlock(\Magento\Backend\Block\System\Store\Edit::class, 'block');
$block->setArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE);
$this->assertEquals($expected, $block->getHeaderText());
}
/**
* @return array
*/
public function getStoreDataForBlock()
{
return [
[
[
'store_type' => 'website',
'store_data' => \Magento\Store\Model\Website::class,
'store_action' => 'add',
],
'New Web Site',
],
[
[
'store_type' => 'website',
'store_data' => \Magento\Store\Model\Website::class,
'store_action' => 'edit',
],
'Edit Web Site'
],
[
['store_type' => 'group', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'add'],
'New Store'
],
[
['store_type' => 'group', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'edit'],
'Edit Store'
],
[
['store_type' => 'store', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'add'],
'New Store View'
],
[
['store_type' => 'store', 'store_data' => \Magento\Store\Model\Store::class, 'store_action' => 'edit'],
'Edit Store View'
]
];
}
}
@@ -0,0 +1,59 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block;
/**
* Test class for \Magento\Backend\Block\Template.
*
* @magentoAppArea adminhtml
*/
class TemplateTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\Template
*/
protected $_block;
protected function setUp(): void
{
parent::setUp();
$this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\Backend\Block\Template::class
);
}
/**
* @covers \Magento\Backend\Block\Template::getFormKey
*/
public function testGetFormKey()
{
$this->assertGreaterThan(15, strlen($this->_block->getFormKey()));
}
/**
* @magentoAppArea adminhtml
* @covers \Magento\Backend\Block\Template::isOutputEnabled
* @magentoConfigFixture current_store advanced/modules_disable_output/dummy 1
*/
public function testIsOutputEnabledTrue()
{
$this->_block->setData('module_name', 'dummy');
$this->assertFalse($this->_block->isOutputEnabled('dummy'));
}
/**
* @magentoAppArea adminhtml
* @covers \Magento\Backend\Block\Template::isOutputEnabled
* @magentoConfigFixture current_store advanced/modules_disable_output/dummy 0
*/
public function testIsOutputEnabledFalse()
{
$this->_block->setData('module_name', 'dummy');
$this->assertTrue($this->_block->isOutputEnabled('dummy'));
}
}
@@ -0,0 +1,95 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Backend\Block\Widget\Button;
use Magento\Framework\View\LayoutInterface;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
/**
* Testing SplitButton widget
*
* @magentoAppArea adminhtml
*/
class SplitButtonTest extends TestCase
{
/**
* @var LayoutInterface
*/
private $layout;
/**
* @inheritDoc
*/
protected function setUp(): void
{
$objectManager = Bootstrap::getObjectManager();
$this->layout = $objectManager->get(LayoutInterface::class);
}
/**
* Create the block.
*
* @return SplitButton
*/
private function createBlock(): SplitButton
{
/** @var SplitButton $block */
$block = $this->layout->createBlock(SplitButton::class, 'button_block');
$block->setLayout($this->layout);
return $block;
}
/**
* Test resulting button HTML.
*
* @return void
*/
public function testToHtml(): void
{
$block = $this->createBlock();
$block->addData(
[
'title' => 'A button',
'label' => 'A button',
'has_split' => true,
'button_class' => 'aclass',
'id' => 'split-button',
'disabled' => false,
'class' => 'aclass',
'data_attribute' => ['bind' => ['var' => 'val']],
'options' => [
[
'disabled' => false,
'title' => 'An option',
'label' => 'An option',
'onclick' => $onclick = 'console.log("option")',
'style' => 'width: 100px'
]
],
'dropdown_button_aria_label' => 'Split button options',
]
);
$html = $block->toHtml();
$this->assertStringContainsString('<button ', $html);
$this->assertStringContainsString('<span>A button</span>', $html);
$this->assertStringNotContainsString('onclick=', $html);
$this->assertStringNotContainsString('style=', $html);
$this->assertMatchesRegularExpression(
'/\<script.*?\>.*?' . preg_quote($onclick) . '.*?\<\/script\>/ims',
$html
);
$this->assertStringContainsString('width', $html);
$this->assertStringContainsString('100px', $html);
$this->assertStringContainsString('aria-label="Split button options"', $html);
}
}
@@ -0,0 +1,83 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Backend\Block\Widget;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
use Magento\Framework\View\LayoutInterface;
/**
* Test for the button widget.
*
* @magentoAppArea adminhtml
*/
class ButtonTest extends TestCase
{
/**
* @var LayoutInterface
*/
private $layout;
/**
* @inheritDoc
*/
protected function setUp(): void
{
$objectManager = Bootstrap::getObjectManager();
$this->layout = $objectManager->get(LayoutInterface::class);
}
/**
* Create the block.
*
* @return Button
*/
private function createBlock(): Button
{
/** @var Button $block */
$block = $this->layout->createBlock(Button::class, 'button_block');
$block->setLayout($this->layout);
return $block;
}
/**
* Test resulting button HTML.
*
* @return void
*/
public function testToHtml(): void
{
$block = $this->createBlock();
$block->addData(
[
'type' => 'button',
'onclick' => 'console.log("Button pressed!")',
'disabled' => false,
'title' => 'A button',
'label' => 'A button',
'class' => 'button',
'id' => 'button',
'element_name' => 'some-name',
'value' => 'Press a button',
'data-style' => 'width: 100px',
'style' => 'height: 200px'
]
);
$html = $block->toHtml();
$this->assertStringContainsString('<button ', $html);
$this->assertStringContainsString('<span>A button</span>', $html);
$this->assertStringNotContainsString('onclick=', $html);
$this->assertStringNotContainsString('style=', $html);
$this->assertMatchesRegularExpression('/\<script.*?\>.*?' .preg_quote($block->getOnClick()) .'.*?\<\/script\>/ims', $html);
$this->assertStringContainsString('height', $html);
$this->assertStringContainsString('200px', $html);
}
}
@@ -0,0 +1,89 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget;
/**
* @magentoAppArea adminhtml
*/
class ContainerTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoAppIsolation enabled
*/
public function testPseudoConstruct()
{
/** @var $block \Magento\Backend\Block\Widget\Container */
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\Backend\Block\Widget\Container::class,
'',
[
'data' => [
\Magento\Backend\Block\Widget\Container::PARAM_CONTROLLER => 'one',
\Magento\Backend\Block\Widget\Container::PARAM_HEADER_TEXT => 'two',
]
]
);
$this->assertStringEndsWith('one', $block->getHeaderCssClass());
$this->assertStringContainsString('two', $block->getHeaderText());
}
/**
* @magentoAppIsolation enabled
*/
public function testGetButtonsHtml()
{
$titles = [1 => 'Title 1', 'Title 2', 'Title 3'];
$block = $this->_buildBlock($titles);
$html = $block->getButtonsHtml('header');
$this->assertStringContainsString('<button', $html);
foreach ($titles as $title) {
$this->assertStringContainsString($title, $html);
}
}
/**
* @magentoAppIsolation enabled
*/
public function testUpdateButton()
{
$originalTitles = [1 => 'Title 1', 'Title 2', 'Title 3'];
$newTitles = [1 => 'Button A', 'Button B', 'Button C'];
$block = $this->_buildBlock($originalTitles);
foreach ($newTitles as $id => $newTitle) {
$block->updateButton($id, 'title', $newTitle);
}
$html = $block->getButtonsHtml('header');
foreach ($newTitles as $newTitle) {
$this->assertStringContainsString($newTitle, $html);
}
}
/**
* Composes a container with several buttons in it
*
* @param array $titles
* @param string $blockName
* @return \Magento\Backend\Block\Widget\Container
*/
protected function _buildBlock($titles, $blockName = 'block')
{
/** @var $layout \Magento\Framework\View\LayoutInterface */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var $block \Magento\Backend\Block\Widget\Container */
$block = $layout->createBlock(\Magento\Backend\Block\Widget\Container::class, $blockName);
foreach ($titles as $id => $title) {
$block->addButton($id, ['title' => $title], 0, 0, 'header');
}
$block->setLayout($layout);
return $block;
}
}
@@ -0,0 +1,54 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Form;
/**
* @magentoAppArea adminhtml
*/
class ContainerTest extends \PHPUnit\Framework\TestCase
{
public function testGetFormHtml()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
// Create block with blocking _prepateLayout(), which is used by block to instantly add 'form' child
/** @var $block \Magento\Backend\Block\Widget\Form\Container */
$block = $this->getMockBuilder(\Magento\Backend\Block\Widget\Form\Container::class)
->setMethods(['_prepareLayout'])
->setConstructorArgs([$objectManager->create(\Magento\Backend\Block\Widget\Context::class)])
->getMock();
$layout->addBlock($block, 'block');
$form = $layout->addBlock(\Magento\Framework\View\Element\Text::class, 'form', 'block');
$expectedHtml = '<b>html</b>';
$this->assertNotEquals($expectedHtml, $block->getFormHtml());
$form->setText($expectedHtml);
$this->assertEquals($expectedHtml, $block->getFormHtml());
}
public function testPseudoConstruct()
{
/** @var $block \Magento\Backend\Block\Widget\Form\Container */
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\Backend\Block\Widget\Form\Container::class,
'',
[
'data' => [
\Magento\Backend\Block\Widget\Container::PARAM_CONTROLLER => 'user',
\Magento\Backend\Block\Widget\Form\Container::PARAM_MODE => 'edit',
\Magento\Backend\Block\Widget\Form\Container::PARAM_BLOCK_GROUP => 'Magento_User'
]
]
);
$this->assertInstanceOf(\Magento\User\Block\User\Edit\Form::class, $block->getChildBlock('form'));
}
}
@@ -0,0 +1,46 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget;
/**
* Test class for \Magento\Backend\Block\Widget\Form
* @magentoAppArea adminhtml
*/
class FormTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoAppIsolation enabled
*/
public function testSetFieldset()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(
\Magento\Framework\View\DesignInterface::class
)->setArea(
\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
)->setDefaultDesignTheme();
$layout = $objectManager->create(\Magento\Framework\View\Layout::class);
$formBlock = $layout->addBlock(\Magento\Backend\Block\Widget\Form::class);
$fieldSet = $objectManager->create(\Magento\Framework\Data\Form\Element\Fieldset::class);
$arguments = [
'data' => [
'attribute_code' => 'date',
'backend_type' => 'datetime',
'frontend_input' => 'date',
'frontend_label' => 'Date',
],
];
$attributes = [$objectManager->create(\Magento\Eav\Model\Entity\Attribute::class, $arguments)];
$method = new \ReflectionMethod(\Magento\Backend\Block\Widget\Form::class, '_setFieldset');
$method->setAccessible(true);
$method->invoke($formBlock, $attributes, $fieldSet);
$fields = $fieldSet->getElements();
$this->assertCount(1, $fields);
$this->assertInstanceOf(\Magento\Framework\Data\Form\Element\Date::class, $fields[0]);
$this->assertNotEmpty($fields[0]->getDateFormat());
}
}
@@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
use Magento\Backend\Block\Widget\Grid\Column;
use Magento\Framework\DataObject;
use Magento\Framework\Phrase;
use Magento\Framework\Phrase\RendererInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
class ActionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
*/
private $objectManager;
/**
* @var RendererInterface
*/
private $origRenderer;
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->origRenderer = Phrase::getRenderer();
/** @var RendererInterface|PHPUnit\Framework\MockObject_MockObject $rendererMock */
$rendererMock = $this->getMockForAbstractClass(RendererInterface::class);
$rendererMock->expects($this->any())
->method('render')
->willReturnCallback(
function ($input) {
return end($input) . ' translated';
}
);
Phrase::setRenderer($rendererMock);
}
protected function tearDown(): void
{
Phrase::setRenderer($this->origRenderer);
}
/**
* @param array $columnData
* @param array $rowData
* @param string $expected
* @dataProvider renderDataProvider
*/
public function testRender($columnData, $rowData, $expected)
{
/** @var Text $renderer */
$renderer = $this->objectManager->create(Action::class);
/** @var Column $column */
$column = $this->objectManager->create(
Column::class,
[
'data' => $columnData
]
);
/** @var DataObject $row */
$row = $this->objectManager->create(
DataObject::class,
[
'data' => $rowData
]
);
$this->assertStringContainsString(
$expected,
$renderer->setColumn($column)->render($row)
);
}
/**
* @return array
*/
public function renderDataProvider(): array
{
return [
[
[
'index' => 'type',
'type' => 'action',
'actions' => [
'rollback_action'=> [
'caption' => 'Rollback', 'href'=>'#', 'onclick' => 'alert("test")'
]
]
],
[],
'alert("test")'
],
];
}
}
@@ -0,0 +1,142 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid\Column\Renderer;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
use Magento\Backend\Block\Widget\Grid\Column;
use Magento\Framework\DataObject;
use Magento\Framework\Phrase;
use Magento\Framework\Phrase\RendererInterface;
class TextTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
*/
private $objectManager;
/**
* @var RendererInterface
*/
private $origRenderer;
protected function setUp(): void
{
$this->objectManager = Bootstrap::getObjectManager();
$this->origRenderer = Phrase::getRenderer();
/** @var RendererInterface|PHPUnit\Framework\MockObject_MockObject $rendererMock */
$rendererMock = $this->getMockForAbstractClass(RendererInterface::class);
$rendererMock->expects($this->any())
->method('render')
->willReturnCallback(
function ($input) {
return end($input) . ' translated';
}
);
Phrase::setRenderer($rendererMock);
}
protected function tearDown(): void
{
Phrase::setRenderer($this->origRenderer);
}
/**
* @param array $columnData
* @param array $rowData
* @param string $expected
* @dataProvider renderDataProvider
*/
public function testRender($columnData, $rowData, $expected)
{
/** @var Text $renderer */
$renderer = $this->objectManager->create(Text::class);
/** @var Column $column */
$column = $this->objectManager->create(
Column::class,
[
'data' => $columnData
]
);
/** @var DataObject $row */
$row = $this->objectManager->create(
DataObject::class,
[
'data' => $rowData
]
);
$this->assertEquals(
$expected,
$renderer->setColumn($column)->render($row)
);
}
/**
* @return array
*/
public function renderDataProvider()
{
return [
[
[
'index' => 'title',
'translate' => true
],
[
'title' => 'String'
],
'String translated'
],
[
[
'index' => 'title'
],
[
'title' => 'Doesn\'t need to be translated'
],
'Doesn&#039;t need to be translated'
],
[
[
'format' => '#$subscriber_id $customer_name ($subscriber_email)'
],
[
'subscriber_id' => '10',
'customer_name' => 'John Doe',
'subscriber_email' => 'john@doe.com'
],
'#10 John Doe (john@doe.com)'
],
[
[
'format' => '$customer_name, email: $subscriber_email',
'translate' => true
],
[
'customer_name' => 'John Doe',
'subscriber_email' => 'john@doe.com'
],
'John Doe, email: john@doe.com translated'
],
[
[
'format' => 'String',
'translate' => true
],
[],
'String translated'
],
[
[
'format' => 'Doesn\'t need to be translated'
],
[],
'Doesn&#039;t need to be translated'
]
];
}
}
@@ -0,0 +1,64 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid;
/**
* @magentoAppArea adminhtml
*/
class ColumnSetTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\Widget\Grid\ColumnSet
*/
protected $_block;
/**
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $_layoutMock;
/**
* @var \PHPUnit\Framework\MockObject\MockObject
*/
protected $_columnMock;
protected function setUp(): void
{
parent::setUp();
$this->_columnMock = $this->createPartialMock(
\Magento\Backend\Block\Widget\Grid\Column::class,
['setSortable', 'setRendererType', 'setFilterType', 'addHeaderCssClass', 'setGrid']
);
$this->_layoutMock = $this->createMock(\Magento\Framework\View\Layout::class);
$this->_layoutMock->expects(
$this->any()
)->method(
'getChildBlocks'
)->willReturn(
[$this->_columnMock]
);
$context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Framework\View\Element\Template\Context::class,
['layout' => $this->_layoutMock]
);
$this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\Backend\Block\Widget\Grid\ColumnSet::class,
'',
['context' => $context]
);
$this->_block->setTemplate(null);
}
public function testBeforeToHtmlAddsClassToLastColumn()
{
$this->_columnMock->expects($this->any())->method('addHeaderCssClass')->with($this->equalTo('last'));
$this->_block->toHtml();
}
}
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid;
/**
* @magentoAppArea adminhtml
*/
class ContainerTest extends \PHPUnit\Framework\TestCase
{
public function testPseudoConstruct()
{
/** @var $block \Magento\Backend\Block\Widget\Grid\Container */
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\Backend\Block\Widget\Grid\Container::class,
'',
[
'data' => [
\Magento\Backend\Block\Widget\Container::PARAM_CONTROLLER => 'widget',
\Magento\Backend\Block\Widget\Container::PARAM_HEADER_TEXT => 'two',
\Magento\Backend\Block\Widget\Grid\Container::PARAM_BLOCK_GROUP => 'Magento_Backend',
\Magento\Backend\Block\Widget\Grid\Container::PARAM_BUTTON_NEW => 'four',
\Magento\Backend\Block\Widget\Grid\Container::PARAM_BUTTON_BACK => 'five',
]
]
);
$this->assertStringEndsWith('widget', $block->getHeaderCssClass());
$this->assertStringContainsString('two', $block->getHeaderText());
$this->assertInstanceOf(\Magento\Backend\Block\Widget\Grid::class, $block->getChildBlock('grid'));
$this->assertEquals('four', $block->getAddButtonLabel());
$this->assertEquals('five', $block->getBackButtonLabel());
}
}
@@ -0,0 +1,144 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid;
use Laminas\Stdlib\Parameters;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Data\Collection;
use Magento\Framework\Filesystem;
use Magento\Framework\View\LayoutInterface;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
/**
* @magentoAppArea adminhtml
*/
class ExtendedTest extends TestCase
{
/**
* @var Extended
*/
protected $_block;
/**
* @var LayoutInterface
*/
protected $_layoutMock;
/**
* @inheritDoc
*/
protected function setUp(): void
{
parent::setUp();
$this->_layoutMock = Bootstrap::getObjectManager()->create(
LayoutInterface::class
);
$context = Bootstrap::getObjectManager()->create(
Context::class,
['layout' => $this->_layoutMock]
);
$this->_block = $this->_layoutMock->createBlock(
Extended::class,
'grid',
['context' => $context]
);
$this->_block->addColumn('column1', ['id' => 'columnId1']);
$this->_block->addColumn('column2', ['id' => 'columnId2']);
}
/**
* @magentoAppIsolation enabled
*/
public function testAddColumnAddsChildToColumnSet()
{
$this->assertInstanceOf(
Column::class,
$this->_block->getColumnSet()->getChildBlock('column1')
);
$this->assertCount(2, $this->_block->getColumnSet()->getChildNames());
}
/**
* @magentoAppIsolation enabled
*/
public function testRemoveColumn()
{
$this->assertCount(2, $this->_block->getColumnSet()->getChildNames());
$this->_block->removeColumn('column1');
$this->assertCount(1, $this->_block->getColumnSet()->getChildNames());
}
/**
* @magentoAppIsolation enabled
*/
public function testSortColumnsByOrder()
{
$columnNames = $this->_block->getLayout()->getChildNames($this->_block->getColumnSet()->getNameInLayout());
$this->assertEquals($this->_block->getColumn('column1')->getNameInLayout(), $columnNames[0]);
$this->_block->addColumnsOrder('column1', 'column2');
$this->_block->sortColumnsByOrder();
$columnNames = $this->_block->getLayout()->getChildNames($this->_block->getColumnSet()->getNameInLayout());
$this->assertEquals($this->_block->getColumn('column2')->getNameInLayout(), $columnNames[0]);
}
/**
* @magentoAppIsolation enabled
*/
public function testGetMainButtonsHtmlReturnsEmptyStringIfFiltersArentVisible()
{
$this->_block->setFilterVisibility(false);
$this->assertEquals('', $this->_block->getMainButtonsHtml());
}
/**
* Checks that template does not have redundant div close tag
*
* @return void
*/
public function testExtendedTemplateMarkup(): void
{
$mockCollection = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$this->_block->setCollection($mockCollection);
$this->_block->getRequest()
->setQuery(
Bootstrap::getObjectManager()
->create(
Parameters::class,
[
'values' => [
'ajax' => true
]
]
)
);
$html = $this->_block->getHtml();
$html = str_replace(["\n", " "], '', $html);
$this->assertStringEndsWith("</table></div>", $html);
}
public function testGetCsvFileStartsWithBOM(): void
{
$collection = Bootstrap::getObjectManager()->create(Collection::class);
$this->_block->setCollection($collection);
$data = $this->_block->getCsvFile();
$filesystem = Bootstrap::getObjectManager()->get(Filesystem::class);
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
self::assertTrue($directory->isFile($data['value']));
self::assertStringStartsWith(
pack('CCC', 0xef, 0xbb, 0xbf),
$directory->readFile($data['value'])
);
$directory->delete($data['value']);
}
}
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid;
/**
* @magentoAppArea adminhtml
*/
class ItemTest extends \PHPUnit\Framework\TestCase
{
public function testGetAdditionalActionBlock()
{
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var $block \Magento\Backend\Block\Widget\Grid\Massaction\Item */
$block = $layout->createBlock(\Magento\Backend\Block\Widget\Grid\Massaction\Item::class, 'block');
$expected = $layout->addBlock(\Magento\Framework\View\Element\Template::class, 'additional_action', 'block');
$this->assertSame($expected, $block->getAdditionalActionBlock());
}
}
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid\Massaction;
class AdditionalTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoAppArea adminhtml
*/
public function testToHtml()
{
$interpreter = $this->createMock(\Magento\Framework\View\Layout\Argument\Interpreter\Options::class);
/**
* @var Additional $block
*/
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Backend\Block\Widget\Grid\Massaction\Additional::class,
['optionsInterpreter' => $interpreter]
);
$modelClass = \Magento\Backend\Block\Widget\Grid\Massaction::class;
$data = [
'fields' => [
'field1' => ['type' => 'select', 'values' => $modelClass, 'class' => 'custom_class'],
],
];
$block->setData($data);
$evaluatedValues = [
['value' => 'value1', 'label' => 'label 1'],
['value' => 'value2', 'label' => 'label 2'],
];
$interpreter->expects(
$this->once()
)->method(
'evaluate'
)->with(
['model' => $modelClass]
)->willReturn(
$evaluatedValues
);
$block->setNameInLayout('test_block_name');
$html = $block->toHtml();
$this->assertStringMatchesFormat(
'%acustom_class absolute-advice%avalue="value1"%slabel 1%avalue="value2"%slabel 2%a',
$html
);
}
}
@@ -0,0 +1,181 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget\Grid;
use Magento\TestFramework\App\State;
/**
* @magentoAppArea adminhtml
* @magentoComponentsDir Magento/Backend/Block/_files/design
* @magentoDbIsolation enabled
*/
class MassactionTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Backend\Block\Widget\Grid\Massaction
*/
protected $_block;
/**
* @var \Magento\Framework\View\LayoutInterface
*/
protected $_layout;
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
private $objectManager;
/**
* @var string
*/
private $mageMode;
protected function setUp(): void
{
parent::setUp();
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->mageMode = $this->objectManager->get(State::class)->getMode();
/** @var \Magento\Theme\Model\Theme\Registration $registration */
$registration = $this->objectManager->get(\Magento\Theme\Model\Theme\Registration::class);
$registration->register();
$this->objectManager->get(\Magento\Framework\View\DesignInterface::class)
->setDesignTheme('BackendTest/test_default');
}
protected function tearDown(): void
{
$this->objectManager->get(State::class)->setMode($this->mageMode);
}
/**
* @param string $mageMode
*/
private function loadLayout($mageMode = State::MODE_DEVELOPER)
{
$this->objectManager->get(State::class)->setMode($mageMode);
$this->_layout = $this->objectManager->create(
\Magento\Framework\View\LayoutInterface::class,
['area' => 'adminhtml']
);
$this->_layout->getUpdate()->load('layout_test_grid_handle');
$this->_layout->generateXml();
$this->_layout->generateElements();
$this->_block = $this->_layout->getBlock('admin.test.grid.massaction');
$this->assertNotFalse($this->_block, 'Could not load the block for testing');
}
public function testMassactionDefaultValues()
{
$this->loadLayout();
/** @var $blockEmpty \Magento\Backend\Block\Widget\Grid\Massaction */
$blockEmpty = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\View\LayoutInterface::class)
->createBlock(\Magento\Backend\Block\Widget\Grid\Massaction::class);
$this->assertEmpty($blockEmpty->getItems());
$this->assertEquals(0, $blockEmpty->getCount());
$this->assertSame('[]', $blockEmpty->getItemsJson());
$this->assertFalse($blockEmpty->isAvailable());
}
/**
* @param string $mageMode
* @param int $expectedCount
* @dataProvider getCountDataProvider
*/
public function testGetCount($mageMode, $expectedCount)
{
$this->loadLayout($mageMode);
$this->assertEquals($expectedCount, $this->_block->getCount());
}
/**
* @return array
*/
public function getCountDataProvider()
{
return [
[
'mageMode' => State::MODE_DEVELOPER,
'expectedCount' => 3,
],
[
'mageMode' => State::MODE_DEFAULT,
'expectedCount' => 3,
],
[
'mageMode' => State::MODE_PRODUCTION,
'expectedCount' => 2,
],
];
}
/**
* @param string $itemId
* @param array $expectedItem
* @dataProvider getItemsDataProvider
*/
public function testGetItems($itemId, $expectedItem)
{
$this->loadLayout();
$items = $this->_block->getItems();
$this->assertCount(3, $items);
$this->assertArrayHasKey($itemId, $items);
$actualItem = $items[$itemId];
$this->assertEquals($expectedItem['id'], $actualItem->getId());
$this->assertEquals($expectedItem['label'], $actualItem->getLabel());
$this->assertMatchesRegularExpression($expectedItem['url'], $actualItem->getUrl());
$this->assertEquals($expectedItem['selected'], $actualItem->getSelected());
$this->assertEquals($expectedItem['blockname'], $actualItem->getBlockName());
}
/**
* @return array
*/
public function getItemsDataProvider()
{
return [
[
'option_id1',
[
'id' => 'option_id1',
'label' => 'Option One',
'url' => '#http:\/\/localhost\/index\.php\/(?:key\/([\w\d]+)\/)?#',
'selected' => false,
'blockname' => ''
],
],
[
'option_id2',
[
'id' => 'option_id2',
'label' => 'Option Two',
'url' => '#http:\/\/localhost\/index\.php\/(?:key\/([\w\d]+)\/)?#',
'selected' => false,
'blockname' => ''
]
],
[
'option_id3',
[
'id' => 'option_id3',
'label' => 'Option Three',
'url' => '#http:\/\/localhost\/index\.php\/(?:key\/([\w\d]+)\/)?#',
'selected' => false,
'blockname' => ''
]
]
];
}
}
@@ -0,0 +1,160 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Backend\Block\Widget;
use Magento\Backend\Block\Widget\Grid\ColumnSet;
use Magento\Backend\Block\Widget\Grid\Extended;
use Magento\Backend\Model\Widget\Grid\Row\UrlGeneratorFactory;
use Magento\Backend\Model\Widget\Grid\SubTotals;
use Magento\Backend\Model\Widget\Grid\Totals;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Json\Helper\Data;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Layout;
use Magento\Framework\View\LayoutInterface;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* @magentoAppArea adminhtml
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GridTest extends TestCase
{
/**
* @var ColumnSet
*/
private $block;
/**
* @var LayoutInterface|MockObject
*/
private $layoutMock;
/**
* @var ColumnSet|MockObject
*/
private $columnSetMock;
/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->layoutMock = $this->getMockBuilder(Layout::class)
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->disallowMockingUnknownTypes()
->onlyMethods(['getChildName', 'getBlock', 'createBlock', 'renameElement', 'unsetChild', 'setChild'])
->addMethods(['helper'])
->getMock();
$this->columnSetMock = $this->getColumnSetMock();
$returnValueMap = [
['grid', 'grid.columnSet', 'grid.columnSet'],
['grid', 'reset_filter_button', 'reset_filter_button'],
['grid', 'search_button', 'search_button'],
];
$this->layoutMock->expects($this->any())
->method('getChildName')
->willReturnMap($returnValueMap);
$this->layoutMock->expects($this->any())
->method('getBlock')
->with('grid.columnSet')
->willReturn($this->columnSetMock);
$this->layoutMock->expects($this->any())
->method('createBlock')
->with(Button::class)
->willReturn(Bootstrap::getObjectManager()->get(LayoutInterface::class)->createBlock(Button::class));
$this->layoutMock->expects($this->any())
->method('helper')->with(Data::class)
->willReturn(Bootstrap::getObjectManager()->get(Data::class));
$this->block = Bootstrap::getObjectManager()
->get(LayoutInterface::class)
->createBlock(Grid::class);
$this->block->setLayout($this->layoutMock);
$this->block->setNameInLayout('grid');
}
/**
* Retrieve the mocked column set block instance
*
* @return ColumnSet|MockObject
*/
private function getColumnSetMock()
{
$objectManager = Bootstrap::getObjectManager();
$directoryList = $objectManager->create(
DirectoryList::class,
['root' => __DIR__]
);
return $this->getMockBuilder(ColumnSet::class)
->setConstructorArgs(
[
$objectManager->create(
\Magento\Framework\View\Element\Template\Context::class,
[
'filesystem' => $objectManager->create(
Filesystem::class,
['directoryList' => $directoryList]
)
]
),
$objectManager->create(UrlGeneratorFactory::class),
$objectManager->create(SubTotals::class),
$objectManager->create(Totals::class)
]
)
->getMock();
}
/**
* @return void
*/
public function testToHtmlPreparesColumns(): void
{
$this->columnSetMock->expects($this->once())->method('setRendererType');
$this->columnSetMock->expects($this->once())->method('setFilterType');
$this->columnSetMock->expects($this->once())->method('setSortable');
$this->block->setColumnRenderers(['filter' => 'Filter_Class']);
$this->block->setColumnFilters(['filter' => 'Filter_Class']);
$this->block->setSortable(false);
$this->block->toHtml();
}
/**
* @return void
*/
public function testGetMainButtonsHtmlReturnsEmptyStringIfFiltersArentVisible(): void
{
$this->columnSetMock->expects($this->once())->method('isFilterVisible')->willReturn(false);
$this->block->getMainButtonsHtml();
}
/**
* @return void
*/
public function testGetMassactionBlock(): void
{
/** @var $layout Layout */
$layout = Bootstrap::getObjectManager()->get(
LayoutInterface::class
);
/** @var $block Grid */
$block = $layout->createBlock(Extended::class, 'block');
$child = $layout->addBlock(Template::class, 'massaction', 'block');
$this->assertSame($child, $block->getMassactionBlock());
}
}
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Widget;
/**
* @magentoAppArea adminhtml
*/
class TabsTest extends \PHPUnit\Framework\TestCase
{
/**
* @magentoAppIsolation enabled
*/
public function testAddTab()
{
/** @var $widgetInstance \Magento\Widget\Model\Widget\Instance */
$widgetInstance = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Widget\Model\Widget\Instance::class
);
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get(\Magento\Framework\Registry::class)->register('current_widget_instance', $widgetInstance);
/** @var $layout \Magento\Framework\View\Layout */
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
);
/** @var $block \Magento\Backend\Block\Widget\Tabs */
$block = $layout->createBlock(\Magento\Backend\Block\Widget\Tabs::class, 'block');
$layout->addBlock(\Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Main::class, 'child_tab', 'block');
$block->addTab('tab_id', 'child_tab');
$this->assertEquals(['tab_id'], $block->getTabsIds());
}
}
@@ -0,0 +1,72 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block;
/**
* Test class for \Magento\Backend\Block\Widget
*
* @magentoAppArea adminhtml
*/
class WidgetTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers \Magento\Backend\Block\Widget::getButtonHtml
*/
public function testGetButtonHtml()
{
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Framework\View\Layout::class,
['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE]
);
$layout->getUpdate()->load();
$layout->generateXml()->generateElements();
$widget = $layout->createBlock(\Magento\Backend\Block\Widget::class);
$this->assertMatchesRegularExpression(
'/\<button.*\>[\s\S]*Button Label[\s\S]*<\/button>'
. '.*?\<script.*?\>.*?this\.form\.submit\(\).*?\<\/script\>/is',
$widget->getButtonHtml('Button Label', 'this.form.submit()')
);
}
/**
* Case when two buttons will be created in same parent block
*
* @covers \Magento\Backend\Block\Widget::getButtonHtml
*/
public function testGetButtonHtmlForTwoButtonsInOneBlock()
{
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Framework\View\Layout::class,
['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE]
);
$layout->getUpdate()->load();
$layout->generateXml()->generateElements();
$widget = $layout->createBlock(\Magento\Backend\Block\Widget::class);
$this->assertMatchesRegularExpression(
'/<button.*\>[\s\S]*Button Label[\s\S]*<\/button>'
. '.*?\<script.*?\>.*?this\.form\.submit\(\).*?\<\/script\>/ius',
$widget->getButtonHtml('Button Label', 'this.form.submit()')
);
$this->assertMatchesRegularExpression(
'/<button.*\>[\s\S]*Button Label2[\s\S]*<\/button>'
. '.*?\<script.*?\>.*?this\.form\.submit\(\).*?\<\/script\>/ius',
$widget->getButtonHtml('Button Label2', 'this.form.submit()')
);
}
public function testGetSuffixId()
{
$block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create(\Magento\Backend\Block\Widget::class);
$this->assertStringEndsNotWith('_test', $block->getSuffixId('suffix'));
$this->assertStringEndsWith('_test', $block->getSuffixId('test'));
}
}
@@ -0,0 +1,74 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<block class="Magento\Backend\Block\Widget\Grid" name="admin.test.grid">
<arguments>
<argument name="dataSource" xsi:type="object">Magento\Framework\Data\Collection</argument>
</arguments>
<block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="admin.test.grid.columnSet">
<block class="Magento\Backend\Block\Widget\Grid\Column" as="product_name">
<arguments>
<argument name="header" xsi:type="string" translate="true">Product name 1</argument>
<argument name="id" xsi:type="string">product_name</argument>
<argument name="index" xsi:type="string">product_name</argument>
<argument name="type" xsi:type="string">text</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="description">
<arguments>
<argument name="header" xsi:type="string" translate="true">User Description</argument>
<argument name="id" xsi:type="string">description</argument>
<argument name="index" xsi:type="string">description</argument>
<argument name="type" xsi:type="string">text</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="qty">
<arguments>
<argument name="header" xsi:type="string" translate="true">Qty</argument>
<argument name="id" xsi:type="string">qty</argument>
<argument name="index" xsi:type="string">qty</argument>
<argument name="type" xsi:type="string">number</argument>
<argument name="width" xsi:type="string">60</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="added_at">
<arguments>
<argument name="header" xsi:type="string" translate="true">Date Added</argument>
<argument name="id" xsi:type="string">added_at</argument>
<argument name="index" xsi:type="string">added_at</argument>
<argument name="type" xsi:type="string">date</argument>
<argument name="gmtoffset" xsi:type="string">1</argument>
</arguments>
</block>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Massaction" as="grid.massaction" name='admin.test.grid.massaction'>
<arguments>
<argument name="massaction_id_field" xsi:type="string">test_id</argument>
<argument name="form_field_name" xsi:type="string">test_id</argument>
<argument name="use_select_all" xsi:type="string">1</argument>
<argument name="options" xsi:type="array">
<item name="option_id1" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Option One</item>
<item name="url" xsi:type="string">*/*/option1</item>
<item name="complete" xsi:type="string" translate="true">Test</item>
</item>
<item name="option_id2" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Option Two</item>
<item name="url" xsi:type="string">*/*/option2</item>
<item name="confirm" xsi:type="string" translate="true">Are you sure?</item>
</item>
<item name="option_id3" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Option Three</item>
<item name="url" xsi:type="string">*/*/option3</item>
<item name="visible" xsi:type="object">Magento\Backend\Block\Cache\Grid\Massaction\ProductionModeVisibilityChecker</item>
</item>
</argument>
</arguments>
</block>
</block>
</layout>
@@ -0,0 +1,9 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/BackendTest/test_default', __DIR__);
@@ -0,0 +1,9 @@
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>Magento Test backend</title>
</theme>
@@ -0,0 +1,9 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Backend\Model\UrlInterface::class
)->turnOffSecretKey();
@@ -0,0 +1,9 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Backend\Model\UrlInterface::class
)->turnOnSecretKey();

Some files were not shown because too many files have changed in this diff Show More