Skip to content

Commit 05779a1

Browse files
committed
Merge branch 'ACP2E-3561' of https://github.com/adobe-commerce-tier-4/magento2ce into PR-02-11-2025
2 parents 28c0e73 + 4b97b12 commit 05779a1

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Date.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
/**
@@ -121,7 +121,7 @@ public function getValue($format = null)
121121
return '';
122122
}
123123
if (null === $format) {
124-
$format = $this->getDateFormat();
124+
$format = $this->getDateFormat() ?: $this->getFormat();
125125
$format .= ($format && $this->getTimeFormat()) ? ' ' : '';
126126
$format .= $this->getTimeFormat() ? $this->getTimeFormat() : '';
127127
}

lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -125,4 +125,45 @@ protected function getFormMock($exactly)
125125

126126
return $formMock;
127127
}
128+
129+
/**
130+
* @dataProvider providerGetValue
131+
* @param string|null $dateFormat
132+
* @param string|null $format
133+
* @param string|null $timeFormat
134+
* @param string $expectedFormat
135+
*/
136+
public function testGetValue(?string $dateFormat, ?string $format, ?string $timeFormat, string $expectedFormat)
137+
{
138+
$dateTime = new \DateTime('2025-10-13 10:36:00', new \DateTimeZone('America/Los_Angeles'));
139+
$this->model->setValue($dateTime);
140+
$this->model->setDateFormat($dateFormat);
141+
$this->model->setFormat($format);
142+
$this->model->setTimeFormat($timeFormat);
143+
144+
$this->localeDateMock->expects($this->once())
145+
->method('formatDateTime')
146+
->with(
147+
$dateTime,
148+
null,
149+
null,
150+
null,
151+
$this->equalTo($dateTime->getTimezone()),
152+
$this->equalTo($expectedFormat)
153+
)
154+
->willReturn('2025-10-13 10:36:00');
155+
156+
$this->model->getValue();
157+
}
158+
159+
public function providerGetValue()
160+
{
161+
return [
162+
[null, 'yyyy-mm-dd', 'hh:mm:ss', 'yyyy-mm-dd hh:mm:ss'],
163+
[null, 'yy-mm-dd', null, 'yy-mm-dd'],
164+
['yyyy-mm-dd', null, null, 'yyyy-mm-dd'],
165+
['yyyy-mm-dd', 'yy-mm-dd', 'hh:mm:ss', 'yyyy-mm-dd hh:mm:ss'],
166+
['yyyy-mm-dd', 'yy-mm-dd', null, 'yyyy-mm-dd']
167+
];
168+
}
128169
}

0 commit comments

Comments
 (0)