|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright 2025 Adobe |
| 4 | + * All Rights Reserved. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Customer\Ui\Component\Listing\Column; |
| 9 | + |
| 10 | +use Magento\Framework\View\Element\UiComponentFactory; |
| 11 | +use Magento\TestFramework\Helper\Bootstrap; |
| 12 | +use PHPUnit\Framework\TestCase; |
| 13 | + |
| 14 | +class DobColumnTest extends TestCase |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @var UiComponentFactory |
| 18 | + */ |
| 19 | + private $uiComponentFactory; |
| 20 | + |
| 21 | + /** |
| 22 | + * @inheritdoc |
| 23 | + */ |
| 24 | + protected function setUp(): void |
| 25 | + { |
| 26 | + $this->uiComponentFactory = Bootstrap::getObjectManager()->create(UiComponentFactory::class); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Test that dateFormat is not defined in the XML configuration for dob column. |
| 31 | + * |
| 32 | + * This test verifies that the explicit dateFormat configuration was removed from the XML |
| 33 | + * and that the date format is now handled programmatically by the ColumnFactory. |
| 34 | + * |
| 35 | + * @return void |
| 36 | + */ |
| 37 | + public function testDobColumnDoesNotHaveDateFormatInXml(): void |
| 38 | + { |
| 39 | + $xmlPath = BP . '/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml'; |
| 40 | + $this->assertFileExists($xmlPath, 'Customer listing XML file should exist'); |
| 41 | + |
| 42 | + $xmlContent = file_get_contents($xmlPath); |
| 43 | + $this->assertNotFalse($xmlContent, 'Should be able to read XML file'); |
| 44 | + |
| 45 | + $xml = simplexml_load_string($xmlContent); |
| 46 | + $this->assertNotFalse($xml, 'XML should be valid'); |
| 47 | + |
| 48 | + // Find the dob column in the XML |
| 49 | + $dobColumn = null; |
| 50 | + foreach ($xml->xpath('//column[@name="dob"]') as $column) { |
| 51 | + $dobColumn = $column; |
| 52 | + break; |
| 53 | + } |
| 54 | + |
| 55 | + $this->assertNotNull($dobColumn, 'DOB column should exist in XML'); |
| 56 | + |
| 57 | + // Verify that dateFormat is not explicitly set in the XML |
| 58 | + $dateFormatNodes = $dobColumn->xpath('.//dateFormat'); |
| 59 | + $this->assertEmpty($dateFormatNodes, 'dateFormat should not be explicitly set in XML for dob column'); |
| 60 | + |
| 61 | + // Verify that other expected settings are still present |
| 62 | + $timezoneNodes = $dobColumn->xpath('.//timezone'); |
| 63 | + $this->assertNotEmpty($timezoneNodes, 'timezone setting should still be present'); |
| 64 | + $this->assertEquals('false', (string)$timezoneNodes[0], 'timezone should be set to false'); |
| 65 | + |
| 66 | + $skipTimeZoneNodes = $dobColumn->xpath('.//skipTimeZoneConversion'); |
| 67 | + $this->assertNotEmpty($skipTimeZoneNodes, 'skipTimeZoneConversion setting should still be present'); |
| 68 | + $this->assertEquals('true', (string)$skipTimeZoneNodes[0], 'skipTimeZoneConversion should be set to true'); |
| 69 | + } |
| 70 | +} |
0 commit comments