PatternTest.php 2.02 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\Setup\Test\Unit\Fixtures\AttributeSet;

/**
 * @SuppressWarnings(PHPMD)
 */
class PatternTest extends \PHPUnit\Framework\TestCase
{
    public function testGenerateAttributeSet()
    {
        $attributeSets = [
            'name' => 'attribute set name',
            'attributes' => [
                'attribute' => [
                    [
                        'is_required' => 1,
                        'is_visible_on_front' => 1,
                        'is_visible_in_advanced_search' => 0,
                        'is_filterable' => 0,
                        'is_filterable_in_search' => 0,
                        'attribute_code' => 'attribute_1',
                        'is_searchable' => 0,
                        'frontend_label' => 'Attribute 1',
                        'frontend_input' => 'select',
                        'backend_type' => 1,
                        'default_option' => 'option 1',
                        'options' => [
                            'option' => [
                                [
                                    'label' => 'option 1',
                                    'value' => 'option_1'
                                ],
                                [
                                    'label' => 'option 2',
                                    'value' => 'option_2'
                                ]
                            ]
                        ]
                    ]
                ]
            ]
        ];
        $pattern = new \Magento\Setup\Fixtures\AttributeSet\Pattern();
        $this->assertEquals(
            $attributeSets,
            $pattern->generateAttributeSet(
                'attribute set name',
                1,
                2,
                function ($index, $attributeData) {
                    $attributeData['backend_type'] = $index;
                    return $attributeData;
                }
            )
        );
    }
}