|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright © Magento, Inc. All rights reserved. |
| 5 | + * See COPYING.txt for license details. |
| 6 | + */ |
| 7 | +declare(strict_types=1); |
| 8 | + |
| 9 | +namespace Magento\Customer\Ui\Component\Listing\Column; |
| 10 | + |
| 11 | +use Magento\TestFramework\Helper\Bootstrap; |
| 12 | +use PHPUnit\Framework\TestCase; |
| 13 | + |
| 14 | +/** |
| 15 | + * Tests for \Magento\Customer\Ui\Component\Listing\Column\Confirmation. |
| 16 | + */ |
| 17 | +class ConfirmationTest extends TestCase |
| 18 | +{ |
| 19 | + /** |
| 20 | + * Test subject. |
| 21 | + * |
| 22 | + * @var Confirmation |
| 23 | + */ |
| 24 | + private $confirmation; |
| 25 | + |
| 26 | + /** |
| 27 | + * @inheritdoc |
| 28 | + */ |
| 29 | + protected function setUp(): void |
| 30 | + { |
| 31 | + $this->confirmation = Bootstrap::getObjectManager()->create( |
| 32 | + Confirmation::class, |
| 33 | + [ |
| 34 | + 'components' => [], |
| 35 | + 'data' => ['name' => 'confirmation'], |
| 36 | + ] |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Verify Confirmation::prepareDataSource() won't throw exception in case requested website doesn't exist. |
| 42 | + * |
| 43 | + * @param array $customerDataSource |
| 44 | + * @param array $expectedResult |
| 45 | + * @magentoConfigFixture base_website customer/create_account/confirm 1 |
| 46 | + * @dataProvider customersDataProvider |
| 47 | + * |
| 48 | + * @return void |
| 49 | + */ |
| 50 | + public function testPrepareDataSource(array $customerDataSource, array $expectedResult): void |
| 51 | + { |
| 52 | + $result = $this->confirmation->prepareDataSource($customerDataSource); |
| 53 | + |
| 54 | + self::assertEquals($expectedResult, $result); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * CustomerDataSource data provider. |
| 59 | + * |
| 60 | + * @return array |
| 61 | + */ |
| 62 | + public function customersDataProvider(): array |
| 63 | + { |
| 64 | + return [ |
| 65 | + [ |
| 66 | + 'customerDataSource' => [ |
| 67 | + 'data' => [ |
| 68 | + 'items' => [ |
| 69 | + [ |
| 70 | + 'id_field_name' => 'entity_id', |
| 71 | + 'entity_id' => '1', |
| 72 | + 'name' => 'John Doe', |
| 73 | + 'email' => 'john.doe@example.com', |
| 74 | + 'group_id' => ['1'], |
| 75 | + 'created_at' => '2020-12-28 07:05:50', |
| 76 | + 'website_id' => ['1'], |
| 77 | + 'confirmation' => false, |
| 78 | + 'created_in' => 'Default Store View', |
| 79 | + ], |
| 80 | + [ |
| 81 | + 'id_field_name' => 'entity_id', |
| 82 | + 'entity_id' => '2', |
| 83 | + 'name' => 'Jane Doe', |
| 84 | + 'email' => 'jane.doe@example.com', |
| 85 | + 'group_id' => ['1'], |
| 86 | + 'created_at' => '2020-12-28 07:06:17', |
| 87 | + 'website_id' => ['999999999'], |
| 88 | + 'confirmation' => null, |
| 89 | + 'created_in' => 'CustomStoreViewWhichDoesNotExistAnymore', |
| 90 | + ], |
| 91 | + ], |
| 92 | + 'totalRecords' => 2, |
| 93 | + ], |
| 94 | + ], |
| 95 | + 'expectedResult' => [ |
| 96 | + 'data' => [ |
| 97 | + 'items' => [ |
| 98 | + [ |
| 99 | + 'id_field_name' => 'entity_id', |
| 100 | + 'entity_id' => '1', |
| 101 | + 'name' => 'John Doe', |
| 102 | + 'email' => 'john.doe@example.com', |
| 103 | + 'group_id' => ['1'], |
| 104 | + 'created_at' => '2020-12-28 07:05:50', |
| 105 | + 'website_id' => ['1'], |
| 106 | + 'confirmation' => __('Confirmation Required'), |
| 107 | + 'created_in' => 'Default Store View', |
| 108 | + ], |
| 109 | + [ |
| 110 | + 'id_field_name' => 'entity_id', |
| 111 | + 'entity_id' => '2', |
| 112 | + 'name' => 'Jane Doe', |
| 113 | + 'email' => 'jane.doe@example.com', |
| 114 | + 'group_id' => ['1'], |
| 115 | + 'created_at' => '2020-12-28 07:06:17', |
| 116 | + 'website_id' => ['999999999'], |
| 117 | + 'confirmation' => __('Confirmed'), |
| 118 | + 'created_in' => 'CustomStoreViewWhichDoesNotExistAnymore', |
| 119 | + ], |
| 120 | + ], |
| 121 | + 'totalRecords' => 2, |
| 122 | + ], |
| 123 | + ], |
| 124 | + ], |
| 125 | + ]; |
| 126 | + } |
| 127 | +} |
0 commit comments