|
| 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\Swatches\Helper; |
| 9 | + |
| 10 | +use Magento\Catalog\Api\ProductRepositoryInterface; |
| 11 | +use Magento\Framework\ObjectManagerInterface; |
| 12 | +use Magento\TestFramework\Helper\Bootstrap; |
| 13 | +use PHPUnit\Framework\TestCase; |
| 14 | + |
| 15 | +/** |
| 16 | + * Tests for product swatch attribute helper. |
| 17 | + * |
| 18 | + * @see \Magento\Swatches\Helper\Data |
| 19 | + * @magentoDbIsolation enabled |
| 20 | + */ |
| 21 | +class DataTest extends TestCase |
| 22 | +{ |
| 23 | + /** @var ObjectManagerInterface */ |
| 24 | + private $objectManager; |
| 25 | + |
| 26 | + /** @var Data */ |
| 27 | + private $helper; |
| 28 | + |
| 29 | + /** @var ProductRepositoryInterface */ |
| 30 | + private $productRepository; |
| 31 | + |
| 32 | + /** |
| 33 | + * @inheritdoc |
| 34 | + */ |
| 35 | + protected function setUp(): void |
| 36 | + { |
| 37 | + parent::setUp(); |
| 38 | + |
| 39 | + $this->objectManager = Bootstrap::getObjectManager(); |
| 40 | + $this->helper = $this->objectManager->get(Data::class); |
| 41 | + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); |
| 42 | + $this->productRepository->cleanCache(); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php |
| 47 | + * @return void |
| 48 | + */ |
| 49 | + public function testGetSwatchAttributesAsArray(): void |
| 50 | + { |
| 51 | + $product = $this->productRepository->get('simple2'); |
| 52 | + $this->assertEmpty($this->helper->getSwatchAttributesAsArray($product)); |
| 53 | + } |
| 54 | +} |
0 commit comments