+
+
+ + + + + + + + + + + + +
+
+ + + Permalink + + + +
+ +
+ + +
+ +
+
+ + Switch branches/tags +
+ +
+
+ +
+
+ +
+
+ + + +
+
+ + + + + + 2.2.4 + + + + + + 2.2.3 + + + + + + 2.2.2 + + + + + + 2.2.1 + + + + + + 2.2.0 + + + + + + 2.2.0-rc3.0 + + + + + + 2.2.0-rc2.3 + + + + + + 2.2.0-rc2.2 + + + + + + 2.2.0-rc2.1 + + + + + + 2.2.0-rc2.0 + + + + + + 2.2.0-RC1.8 + + + + + + 2.2.0-RC1.6 + + + + + + 2.2.0-RC1.5 + + + + + + 2.2.0-RC1.4 + + + + + + 2.2.0-RC1.3 + + + + + + 2.2.0-RC1.2 + + + + + + 2.2.0-RC1.1 + + + + + + 2.1.13 + + + + + + 2.1.12 + + + + + + 2.1.11 + + + + + + 2.1.10 + + + + + + 2.1.9 + + + + + + 2.1.8 + + + + + + 2.1.7 + + + + + + 2.1.6 + + + + + + 2.1.5 + + + + + + 2.1.4 + + + + + + 2.1.3 + + + + + + 2.1.2 + + + + + + 2.1.1 + + + + + + 2.1.0 + + + + + + 2.1.0-rc3 + + + + + + 2.1.0-rc2 + + + + + + 2.1.0-rc1 + + + + + + 2.0.18 + + + + + + 2.0.17 + + + + + + 2.0.16 + + + + + + 2.0.15 + + + + + + 2.0.14 + + + + + + 2.0.13 + + + + + + 2.0.12 + + + + + + 2.0.11 + + + + + + 2.0.10 + + + + + + 2.0.9 + + + + + + 2.0.8 + + + + + + 2.0.7 + + + + + + 2.0.6 + + + + + + 2.0.5 + + + + + + 2.0.4 + + + + + + 2.0.3 + + + + + + 2.0.2 + + + + + + 2.0.1 + + + + + + 2.0.0 + + + + + + 2.0.0-rc2 + + + + + + 2.0.0-rc + + + + + + 1.0.0-beta6 + + + + + + 1.0.0-beta5 + + + + + + 1.0.0-beta4 + + + + + + 1.0.0-beta3 + + + + + + 1.0.0-beta2 + + + + + + 1.0.0-beta + + + + + + 0.74.0-beta16 + + + + + + 0.74.0-beta15 + + + + + + 0.74.0-beta14 + + + + + + 0.74.0-beta13 + + + + + + 0.74.0-beta12 + + + + + + 0.74.0-beta11 + + + + + + 0.74.0-beta10 + + + + + + 0.74.0-beta9 + + + + + + 0.74.0-beta8 + + + + + + 0.74.0-beta7 + + + + + + 0.74.0-beta6 + + + + + + 0.74.0-beta5 + + + + + + 0.74.0-beta4 + + + + + + 0.74.0-beta3 + + + + + + 0.74.0-beta2 + + + + + + 0.74.0-beta1 + + + + + + 0.42.0-beta11 + + + + + + 0.42.0-beta10 + + + + + + 0.42.0-beta9 + + + + + + 0.42.0-beta8 + + + + + + 0.42.0-beta7 + + + + + + 0.42.0-beta6 + + + + + + 0.42.0-beta5 + + + + + + 0.42.0-beta4 + + + + + + 0.42.0-beta3 + + + + + + 0.42.0-beta2 + + + + + + 0.42.0-beta1 + + + + + + 0.1.0-alpha108 + + + + + + 0.1.0-alpha107 + + + + + + 0.1.0-alpha106 + + + + + + 0.1.0-alpha105 + + + + + + 0.1.0-alpha104 + + + + + + 0.1.0-alpha103 + + + + + + 0.1.0-alpha102 + + + + + + 0.1.0-alpha101 + + + + + + 0.1.0-alpha100 + + + + + + 0.1.0-alpha99 + + + + + + 0.1.0-alpha98 + + + + + + 0.1.0-alpha97 + + +
+ +
Nothing to show
+
+ +
+
+
+ +
+ + Find file + + + Copy path + +
+ +
+ + + +
+ Fetching contributors… +
+ +
+ + Cannot retrieve contributors at this time +
+
+ + +
+
+
+ +
+ Raw + Blame + History +
+ + + + +
+ +
+ 100 lines (89 sloc) + + 3.15 KB +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Test\Constraint;
use Magento\Catalog\Test\Fixture\Category;
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryEdit;
use Magento\Catalog\Test\Page\Adminhtml\CatalogCategoryIndex;
use Magento\Mtf\Constraint\AbstractConstraint;
/**
* Assert that category products grid filter works correctly.
*/
class AssertCategoryProductsGridFilter extends AbstractConstraint
{
/**
* Grid columns for tests
*
* @var array
*/
private $testFilterColumns = [
'visibility',
];
/**
* Assert that category products grid filter works correctly.
*
* @param CatalogCategoryIndex $catalogCategoryIndex
* @param CatalogCategoryEdit $catalogCategoryEdit
* @param Category $category
* @return void
*/
public function processAssert(
CatalogCategoryIndex $catalogCategoryIndex,
CatalogCategoryEdit $catalogCategoryEdit,
Category $category
) {
$catalogCategoryIndex->getTreeCategories()->selectCategory($category, true);
$categoryProducts = $category->getDataFieldConfig('category_products')['source']->getProducts();
$catalogCategoryEdit->getEditForm()->openSection('category_products');
foreach ($this->testFilterColumns as $field) {
$this->testGridFilter($categoryProducts, $catalogCategoryEdit, $field);
}
}
/**
* @param array $categoryProducts
* @param CatalogCategoryEdit $catalogCategoryEdit
* @param string $filterField
*/
private function testGridFilter(array $categoryProducts, CatalogCategoryEdit $catalogCategoryEdit, $filterField)
{
$productsByFilter = [];
foreach ($categoryProducts as $product) {
$filterValue = $product->getData($filterField);
if (!isset($productsByFilter[$filterValue])) {
$productsByFilter[$filterValue] = [];
}
$productsByFilter[$filterValue][] = $product;
}
$productsFieldset = $catalogCategoryEdit->getEditForm()->getSection('category_products');
foreach ($productsByFilter as $filterValue => $products) {
$productsFieldset->getProductGrid()->search([
'in_category' => 'Yes',
$filterField => $filterValue,
]);
$expectedRows = [];
foreach ($products as $product) {
$expectedRows[] = $product->getName();
}
$gridRows = $productsFieldset->getProductGrid()->getRowsData(['name']);
$actualRows = array_column($gridRows, 'name');
sort($expectedRows);
sort($actualRows);
\PHPUnit_Framework_Assert::assertEquals(
$expectedRows,
$actualRows,
"Category products grid filter '$filterField' does not work correctly"
);
}
}
/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Category products grid filter works correctly';
}
}
+ + + +
+ +
+ + + + + +
+ +
+ +
+
+ +