|
| 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\Customer\Ui\Component\Listing; |
| 9 | + |
| 10 | +use Magento\TestFramework\Helper\Bootstrap; |
| 11 | +use PHPUnit\Framework\TestCase; |
| 12 | + |
| 13 | +/** |
| 14 | + * Test for \Magento\Customer\Ui\Component\Listing\AttributeRepository. |
| 15 | + * |
| 16 | + * @magentoAppArea adminhtml |
| 17 | + */ |
| 18 | +class AttributeRepositoryTest extends TestCase |
| 19 | +{ |
| 20 | + /** |
| 21 | + * @var AttributeRepository |
| 22 | + */ |
| 23 | + private $model; |
| 24 | + |
| 25 | + /** |
| 26 | + * @inheritdoc |
| 27 | + */ |
| 28 | + protected function setUp(): void |
| 29 | + { |
| 30 | + $this->model = Bootstrap::getObjectManager()->create(AttributeRepository::class); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Test for get store_id option array |
| 35 | + * |
| 36 | + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php |
| 37 | + * @return void |
| 38 | + */ |
| 39 | + public function testGetOptionArray(): void |
| 40 | + { |
| 41 | + $result = $this->model->getMetadataByCode('store_id'); |
| 42 | + |
| 43 | + $this->assertTrue(isset($result['options']['1']['value'])); |
| 44 | + $this->assertEquals( |
| 45 | + ['Default Store View', 'Fixture Store'], |
| 46 | + $this->getStoreViewLabels($result['options'][1]['value']) |
| 47 | + ); |
| 48 | + |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Returns prepared store view labels |
| 53 | + * |
| 54 | + * @param array $storeViewsData |
| 55 | + * @return array |
| 56 | + */ |
| 57 | + private function getStoreViewLabels(array $storeViewsData): array |
| 58 | + { |
| 59 | + $result = []; |
| 60 | + foreach ($storeViewsData as $storeView) { |
| 61 | + $result[] = str_replace("\xc2\xa0", '', $storeView['label']); |
| 62 | + } |
| 63 | + |
| 64 | + return $result; |
| 65 | + } |
| 66 | +} |
0 commit comments