SwatchAttributeCodesTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Swatches\Model;
  7. class SwatchAttributeCodesTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /** @var \Magento\Swatches\Model\SwatchAttributeCodes */
  10. private $swatchAttributeCodes;
  11. /**
  12. * @var \Magento\Framework\ObjectManagerInterface
  13. */
  14. private $objectManager;
  15. protected function setUp()
  16. {
  17. $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  18. $this->swatchAttributeCodes = $this->objectManager->create(
  19. \Magento\Swatches\Model\SwatchAttributeCodes::class
  20. );
  21. }
  22. /**
  23. * @magentoDbIsolation enabled
  24. * @magentoDataFixture Magento/Swatches/_files/swatch_attribute.php
  25. */
  26. public function testGetCodes()
  27. {
  28. $attribute = $this->objectManager
  29. ->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
  30. ->load('color_swatch', 'attribute_code');
  31. $expected = [
  32. $attribute->getAttributeId() => $attribute->getAttributeCode()
  33. ];
  34. $swatchAttributeCodes = $this->swatchAttributeCodes->getCodes();
  35. $this->assertEquals($expected, $swatchAttributeCodes);
  36. }
  37. }