ltsecurityinc安防产品在线商城代码
This commit is contained in:
+135
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\SwatchesLayeredNavigation\Block\Navigation\Category;
|
||||
|
||||
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\LayeredNavigation\Block\Navigation\AbstractFiltersTest;
|
||||
|
||||
/**
|
||||
* Provides tests for custom text swatch filter in navigation block on category page.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class SwatchTextFilterTest extends AbstractFiltersTest
|
||||
{
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_text_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $attributeData
|
||||
* @param array $expectation
|
||||
* @return void
|
||||
*/
|
||||
public function testGetFiltersWithCustomAttribute(array $products, array $attributeData, array $expectation): void
|
||||
{
|
||||
$this->getCategoryFiltersAndAssert($products, $attributeData, $expectation, 'Category 999');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFiltersWithCustomAttributeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'not_used_in_navigation' => [
|
||||
'products_data' => [],
|
||||
'attribute_data' => ['is_filterable' => 0],
|
||||
'expectation' => [],
|
||||
],
|
||||
'used_in_navigation_with_results' => [
|
||||
'products_data' => [
|
||||
'simple1000' => 'Option 1',
|
||||
'simple1001' => 'Option 2',
|
||||
],
|
||||
'attribute_data' => ['is_filterable' => AbstractFilter::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS],
|
||||
'expectation' => [
|
||||
['label' => 'Option 1', 'count' => 1],
|
||||
['label' => 'Option 2', 'count' => 1],
|
||||
],
|
||||
],
|
||||
'used_in_navigation_without_results' => [
|
||||
'products_data' => [
|
||||
'simple1000' => 'Option 1',
|
||||
'simple1001' => 'Option 2',
|
||||
],
|
||||
'attribute_data' => ['is_filterable' => 2],
|
||||
'expectation' => [
|
||||
['label' => 'Option 3', 'count' => 0],
|
||||
['label' => 'Option 1', 'count' => 1],
|
||||
['label' => 'Option 2', 'count' => 1],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_text_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getActiveFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $expectation
|
||||
* @param string $filterValue
|
||||
* @param int $productsCount
|
||||
* @return void
|
||||
*/
|
||||
public function testGetActiveFiltersWithCustomAttribute(
|
||||
array $products,
|
||||
array $expectation,
|
||||
string $filterValue,
|
||||
int $productsCount
|
||||
): void {
|
||||
$this->getCategoryActiveFiltersAndAssert($products, $expectation, 'Category 999', $filterValue, $productsCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getActiveFiltersWithCustomAttributeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'filter_by_first_option_in_products_with_first_option' => [
|
||||
'products_data' => ['simple1000' => 'Option 1', 'simple1001' => 'Option 1'],
|
||||
'expectation' => ['label' => 'Option 1', 'count' => 0],
|
||||
'filter_value' => 'Option 1',
|
||||
'products_count' => 2,
|
||||
],
|
||||
'filter_by_first_option_in_products_with_different_options' => [
|
||||
'products_data' => ['simple1000' => 'Option 1', 'simple1001' => 'Option 2'],
|
||||
'expectation' => ['label' => 'Option 1', 'count' => 0],
|
||||
'filter_value' => 'Option 1',
|
||||
'products_count' => 1,
|
||||
],
|
||||
'filter_by_second_option_in_products_with_different_options' => [
|
||||
'products_data' => ['simple1000' => 'Option 1', 'simple1001' => 'Option 2'],
|
||||
'expectation' => ['label' => 'Option 2', 'count' => 0],
|
||||
'filter_value' => 'Option 2',
|
||||
'products_count' => 1,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getLayerType(): string
|
||||
{
|
||||
return Resolver::CATALOG_LAYER_CATEGORY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getAttributeCode(): string
|
||||
{
|
||||
return 'text_swatch_attribute';
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\SwatchesLayeredNavigation\Block\Navigation\Category;
|
||||
|
||||
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\LayeredNavigation\Block\Navigation\AbstractFiltersTest;
|
||||
|
||||
/**
|
||||
* Provides tests for custom text swatch filter in navigation block on category page.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class SwatchVisualFilterTest extends AbstractFiltersTest
|
||||
{
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_visual_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $attributeData
|
||||
* @param array $expectation
|
||||
* @return void
|
||||
*/
|
||||
public function testGetFiltersWithCustomAttribute(array $products, array $attributeData, array $expectation): void
|
||||
{
|
||||
$this->getCategoryFiltersAndAssert($products, $attributeData, $expectation, 'Category 999');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFiltersWithCustomAttributeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'not_used_in_navigation' => [
|
||||
'products_data' => [],
|
||||
'attribute_data' => ['is_filterable' => 0],
|
||||
'expectation' => [],
|
||||
],
|
||||
'used_in_navigation_with_results' => [
|
||||
'products_data' => [
|
||||
'simple1000' => 'option 1',
|
||||
'simple1001' => 'option 2',
|
||||
],
|
||||
'attribute_data' => ['is_filterable' => AbstractFilter::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS],
|
||||
'expectation' => [
|
||||
['label' => 'option 1', 'count' => 1],
|
||||
['label' => 'option 2', 'count' => 1],
|
||||
],
|
||||
],
|
||||
'used_in_navigation_without_results' => [
|
||||
'products_data' => [
|
||||
'simple1000' => 'option 1',
|
||||
'simple1001' => 'option 2',
|
||||
],
|
||||
'attribute_data' => ['is_filterable' => 2],
|
||||
'expectation' => [
|
||||
['label' => 'option 1', 'count' => 1],
|
||||
['label' => 'option 2', 'count' => 1],
|
||||
['label' => 'option 3', 'count' => 0],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_visual_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getActiveFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $expectation
|
||||
* @param string $filterValue
|
||||
* @param int $productsCount
|
||||
* @return void
|
||||
*/
|
||||
public function testGetActiveFiltersWithCustomAttribute(
|
||||
array $products,
|
||||
array $expectation,
|
||||
string $filterValue,
|
||||
int $productsCount
|
||||
): void {
|
||||
$this->getCategoryActiveFiltersAndAssert($products, $expectation, 'Category 999', $filterValue, $productsCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getActiveFiltersWithCustomAttributeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'filter_by_first_option_in_products_with_first_option' => [
|
||||
'products_data' => ['simple1000' => 'option 1', 'simple1001' => 'option 1'],
|
||||
'expectation' => ['label' => 'option 1', 'count' => 0],
|
||||
'filter_value' => 'option 1',
|
||||
'products_count' => 2,
|
||||
],
|
||||
'filter_by_first_option_in_products_with_different_options' => [
|
||||
'products_data' => ['simple1000' => 'option 1', 'simple1001' => 'option 2'],
|
||||
'expectation' => ['label' => 'option 1', 'count' => 0],
|
||||
'filter_value' => 'option 1',
|
||||
'products_count' => 1,
|
||||
],
|
||||
'filter_by_second_option_in_products_with_different_options' => [
|
||||
'products_data' => ['simple1000' => 'option 1', 'simple1001' => 'option 2'],
|
||||
'expectation' => ['label' => 'option 2', 'count' => 0],
|
||||
'filter_value' => 'option 2',
|
||||
'products_count' => 1,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getLayerType(): string
|
||||
{
|
||||
return Resolver::CATALOG_LAYER_CATEGORY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getAttributeCode(): string
|
||||
{
|
||||
return 'visual_swatch_attribute';
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\SwatchesLayeredNavigation\Block\Navigation\Search;
|
||||
|
||||
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\SwatchesLayeredNavigation\Block\Navigation\Category\SwatchTextFilterTest as CategorySwatchTextFilterTest;
|
||||
|
||||
/**
|
||||
* Provides tests for custom swatch text filter in navigation block on search page.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class SwatchTextFilterTest extends CategorySwatchTextFilterTest
|
||||
{
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_text_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $attributeData
|
||||
* @param array $expectation
|
||||
* @return void
|
||||
*/
|
||||
public function testGetFiltersWithCustomAttribute(
|
||||
array $products,
|
||||
array $attributeData,
|
||||
array $expectation
|
||||
): void {
|
||||
$this->getSearchFiltersAndAssert($products, $attributeData, $expectation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFiltersWithCustomAttributeDataProvider(): array
|
||||
{
|
||||
$dataProvider = parent::getFiltersWithCustomAttributeDataProvider();
|
||||
|
||||
$dataProvider = array_replace_recursive(
|
||||
$dataProvider,
|
||||
[
|
||||
'not_used_in_navigation' => [
|
||||
'attribute_data' => [
|
||||
'is_filterable_in_search' => 0,
|
||||
],
|
||||
],
|
||||
'used_in_navigation_with_results' => [
|
||||
'attribute_data' => [
|
||||
'is_filterable' => AbstractFilter::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS,
|
||||
'is_filterable_in_search' => 1,
|
||||
],
|
||||
],
|
||||
'used_in_navigation_without_results' => [
|
||||
'attribute_data' => [
|
||||
'is_filterable' => 0,
|
||||
'is_filterable_in_search' => 1,
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
//TODO uncomment after fix MC-29227
|
||||
//unset($dataProvider['used_in_navigation_without_results']['expectation'][0]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_text_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getActiveFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $expectation
|
||||
* @param string $filterValue
|
||||
* @param int $productsCount
|
||||
* @return void
|
||||
*/
|
||||
public function testGetActiveFiltersWithCustomAttribute(
|
||||
array $products,
|
||||
array $expectation,
|
||||
string $filterValue,
|
||||
int $productsCount
|
||||
): void {
|
||||
$this->getSearchActiveFiltersAndAssert($products, $expectation, $filterValue, $productsCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getLayerType(): string
|
||||
{
|
||||
return Resolver::CATALOG_LAYER_SEARCH;
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\SwatchesLayeredNavigation\Block\Navigation\Search;
|
||||
|
||||
use Magento\Catalog\Model\Layer\Filter\AbstractFilter;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\SwatchesLayeredNavigation\Block\Navigation\Category\SwatchVisualFilterTest as CategorySwatchVisualTest;
|
||||
|
||||
/**
|
||||
* Provides tests for custom visual swatch filter in navigation block on search page.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class SwatchVisualFilterTest extends CategorySwatchVisualTest
|
||||
{
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_visual_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $attributeData
|
||||
* @param array $expectation
|
||||
* @return void
|
||||
*/
|
||||
public function testGetFiltersWithCustomAttribute(
|
||||
array $products,
|
||||
array $attributeData,
|
||||
array $expectation
|
||||
): void {
|
||||
$this->getSearchFiltersAndAssert($products, $attributeData, $expectation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFiltersWithCustomAttributeDataProvider(): array
|
||||
{
|
||||
$dataProvider = parent::getFiltersWithCustomAttributeDataProvider();
|
||||
|
||||
$dataProvider = array_replace_recursive(
|
||||
$dataProvider,
|
||||
[
|
||||
'not_used_in_navigation' => [
|
||||
'attribute_data' => [
|
||||
'is_filterable_in_search' => 0,
|
||||
],
|
||||
],
|
||||
'used_in_navigation_with_results' => [
|
||||
'attribute_data' => [
|
||||
'is_filterable' => AbstractFilter::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS,
|
||||
'is_filterable_in_search' => 1,
|
||||
],
|
||||
],
|
||||
'used_in_navigation_without_results' => [
|
||||
'attribute_data' => [
|
||||
'is_filterable' => 0,
|
||||
'is_filterable_in_search' => 1,
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
//TODO uncomment after fix MC-29227
|
||||
//unset($dataProvider['used_in_navigation_without_results']['expectation'][2]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Swatches/_files/product_visual_swatch_attribute.php
|
||||
* @magentoDataFixture Magento/Catalog/_files/category_with_different_price_products.php
|
||||
* @dataProvider getActiveFiltersWithCustomAttributeDataProvider
|
||||
* @param array $products
|
||||
* @param array $expectation
|
||||
* @param string $filterValue
|
||||
* @param int $productsCount
|
||||
* @return void
|
||||
*/
|
||||
public function testGetActiveFiltersWithCustomAttribute(
|
||||
array $products,
|
||||
array $expectation,
|
||||
string $filterValue,
|
||||
int $productsCount
|
||||
): void {
|
||||
$this->getSearchActiveFiltersAndAssert($products, $expectation, $filterValue, $productsCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function getLayerType(): string
|
||||
{
|
||||
return Resolver::CATALOG_LAYER_SEARCH;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user