|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Weee\Model\Plugin; |
| 9 | + |
| 10 | +use Magento\Catalog\Ui\Component\Listing\Attribute\Repository; |
| 11 | +use Magento\Catalog\Ui\Component\Listing\Columns; |
| 12 | +use Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider; |
| 13 | +use Magento\Framework\View\Element\UiComponent\ContextInterface; |
| 14 | +use Magento\TestFramework\Helper\Bootstrap; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | + |
| 17 | +/** |
| 18 | + * @magentoDbIsolation enabled |
| 19 | + */ |
| 20 | +class ColumnsTest extends TestCase |
| 21 | +{ |
| 22 | + /** |
| 23 | + * @var Columns |
| 24 | + */ |
| 25 | + private $columns; |
| 26 | + |
| 27 | + /** |
| 28 | + * @inheritDoc |
| 29 | + */ |
| 30 | + protected function setUp(): void |
| 31 | + { |
| 32 | + $objectManager = Bootstrap::getObjectManager(); |
| 33 | + $attributeRepository = $objectManager->get(Repository::class); |
| 34 | + $dataProvider = $objectManager->create( |
| 35 | + ProductDataProvider::class, |
| 36 | + [ |
| 37 | + 'name' => "product_listing_data_source", |
| 38 | + 'primaryFieldName' => "entity_id", |
| 39 | + 'requestFieldName' => "id", |
| 40 | + ] |
| 41 | + ); |
| 42 | + $context = $objectManager->create(ContextInterface::class); |
| 43 | + $context->setDataProvider($dataProvider); |
| 44 | + $this->columns = $objectManager->create( |
| 45 | + Columns::class, |
| 46 | + ['attributeRepository' => $attributeRepository, 'context' => $context] |
| 47 | + ); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Check if FPT attribute column in product grid won't be sortable |
| 52 | + * |
| 53 | + * @magentoDataFixture Magento/Weee/_files/fixed_product_attribute.php |
| 54 | + */ |
| 55 | + public function testGetProductWeeeAttributesConfig() |
| 56 | + { |
| 57 | + $this->columns->prepare(); |
| 58 | + $column = $this->columns->getComponent('fixed_product_attribute'); |
| 59 | + $columnConfig = $column->getData('config'); |
| 60 | + $this->assertArrayHasKey('sortable', $columnConfig); |
| 61 | + $this->assertFalse($columnConfig['sortable']); |
| 62 | + } |
| 63 | +} |
0 commit comments