|
| 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\PageBuilder\Test\Unit\Model; |
| 9 | + |
| 10 | +use Magento\PageBuilder\Model\WidgetInitializerConfig; |
| 11 | +use PHPUnit\Framework\TestCase; |
| 12 | + |
| 13 | +/** |
| 14 | + * Test for WidgetInitializerConfig |
| 15 | + */ |
| 16 | +class WidgetInitializerConfigTest extends TestCase |
| 17 | +{ |
| 18 | + /** |
| 19 | + * Test different config variation. |
| 20 | + * |
| 21 | + * @dataProvider configProvider |
| 22 | + * @param array $config |
| 23 | + * @param array $expectedConfig |
| 24 | + */ |
| 25 | + public function testGetConfig(array $config, array $expectedConfig): void |
| 26 | + { |
| 27 | + $model = new WidgetInitializerConfig( |
| 28 | + $config |
| 29 | + ); |
| 30 | + |
| 31 | + $actualConfig = $model->getConfig(); |
| 32 | + $this->assertEquals($expectedConfig, $actualConfig); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @return array |
| 37 | + */ |
| 38 | + public function configProvider(): array |
| 39 | + { |
| 40 | + return [ |
| 41 | + [ |
| 42 | + [ |
| 43 | + 'products' => [ |
| 44 | + 'default' => [ |
| 45 | + 'component' => 'test', |
| 46 | + 'appearance' => 'default', |
| 47 | + 'config' => [ |
| 48 | + 'a' => true |
| 49 | + ] |
| 50 | + ] |
| 51 | + ] |
| 52 | + ], |
| 53 | + [ |
| 54 | + '[data-content-type="products"][data-appearance="default"]' => [ |
| 55 | + 'test' => [ |
| 56 | + 'a' => true |
| 57 | + ] |
| 58 | + ] |
| 59 | + ] |
| 60 | + ], |
| 61 | + [ |
| 62 | + [ |
| 63 | + 'products' => [ |
| 64 | + 'default' => [ |
| 65 | + 'component' => 'test-component', |
| 66 | + 'appearance' => 'default', |
| 67 | + 'config' => [ |
| 68 | + 'a' => true |
| 69 | + ] |
| 70 | + ], |
| 71 | + 'another' => [ |
| 72 | + 'component' => 'another-test-component', |
| 73 | + 'appearance' => 'not_default', |
| 74 | + 'config' => [ |
| 75 | + 'b' => false |
| 76 | + ] |
| 77 | + ] |
| 78 | + ] |
| 79 | + ], |
| 80 | + [ |
| 81 | + '[data-content-type="products"][data-appearance="default"]' => [ |
| 82 | + 'test-component' => [ |
| 83 | + 'a' => true |
| 84 | + ] |
| 85 | + ], |
| 86 | + '[data-content-type="products"][data-appearance="not_default"]' => [ |
| 87 | + 'another-test-component' => [ |
| 88 | + 'b' => false |
| 89 | + ] |
| 90 | + ] |
| 91 | + ] |
| 92 | + ] |
| 93 | + ]; |
| 94 | + } |
| 95 | +} |
0 commit comments