Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ protected function getOptionArray(array $options)
{
/** @var \Magento\Customer\Api\Data\OptionInterface $option */
foreach ($options as &$option) {
$value = $option->getValue();
if (is_array($option->getOptions())) {
$value = $this->getOptionArray($option->getOptions());
}
$option = [
'label' => (string)$option->getLabel(),
'value' => $option->getValue(),
'value' => $value,
'__disableTmpl' => true
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Customer\Ui\Component\Listing;

use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;

/**
* Test for \Magento\Customer\Ui\Component\Listing\AttributeRepository.
*
* @magentoAppArea adminhtml
*/
class AttributeRepositoryTest extends TestCase
{
/**
* @var AttributeRepository
*/
private $model;

/**
* @inheritdoc
*/
protected function setUp(): void
{
$this->model = Bootstrap::getObjectManager()->create(AttributeRepository::class);
}

/**
* Test for get store_id option array
*
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
* @return void
*/
public function testGetOptionArray(): void
{
$result = $this->model->getMetadataByCode('store_id');

$this->assertTrue(isset($result['options']['1']['value']));
$this->assertEquals(
['Default Store View', 'Fixture Store'],
$this->getStoreViewLabels($result['options'][1]['value'])
);
}

/**
* Returns prepared store view labels
*
* @param array $storeViewsData
* @return array
*/
private function getStoreViewLabels(array $storeViewsData): array
{
$result = [];
foreach ($storeViewsData as $storeView) {
$result[] = str_replace("\xc2\xa0", '', $storeView['label']);
}

return $result;
}
}