4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
+ namespace Magento \Framework \Data \Form \Element ;
8
+
9
+ use Magento \Framework \Data \Form \ElementFactory ;
10
+ use Magento \TestFramework \Helper \Bootstrap ;
11
+
7
12
/**
8
13
* Tests for \Magento\Framework\Data\Form\Element\Date
9
14
*/
10
- namespace Magento \Framework \Data \Form \Element ;
11
-
12
15
class DateTest extends \PHPUnit \Framework \TestCase
13
16
{
14
17
/**
15
- * @var \Magento\Framework\Data\Form\ ElementFactory
18
+ * @var ElementFactory
16
19
*/
17
20
protected $ _elementFactory ;
18
21
19
22
/**
20
- * SetUp method
23
+ * @inheritdoc
21
24
*/
22
25
protected function setUp ()
23
26
{
24
- $ objectManager = \ Magento \ TestFramework \ Helper \ Bootstrap::getObjectManager ();
25
- $ this ->_elementFactory = $ objectManager ->create (\ Magento \ Framework \ Data \ Form \ ElementFactory::class);
27
+ $ objectManager = Bootstrap::getObjectManager ();
28
+ $ this ->_elementFactory = $ objectManager ->create (ElementFactory::class);
26
29
}
27
30
28
31
/**
32
+ * Test get value
33
+ *
34
+ * @param array $data
35
+ * @param string $expect
36
+ * @return void
29
37
* @dataProvider getValueDataProvider
30
38
*/
31
- public function testGetValue (array $ data , $ expect )
39
+ public function testGetValue (array $ data , string $ expect ): void
32
40
{
33
- /** @var $date \Magento\Framework\Data\Form\Element\ Date */
34
- $ date = $ this ->_elementFactory ->create (\ Magento \ Framework \ Data \ Form \ Element \ Date::class, $ data );
41
+ /** @var $date Date */
42
+ $ date = $ this ->_elementFactory ->create (Date::class, $ data );
35
43
$ this ->assertEquals ($ expect , $ date ->getValue ());
36
44
}
37
45
38
46
/**
47
+ * Get value test data provider
48
+ *
39
49
* @return array
40
50
*/
41
- public function getValueDataProvider ()
51
+ public function getValueDataProvider (): array
42
52
{
43
53
$ testTimestamp = strtotime ('2014-05-18 12:08:16 ' );
44
54
$ date = new \DateTime ('@ ' . $ testTimestamp );
@@ -56,15 +66,22 @@ public function getValueDataProvider()
56
66
'time_format ' => 'h:mm a ' ,
57
67
'value ' => $ testTimestamp ,
58
68
],
59
- $ date ->format ('g:i A ' )
69
+ $ date ->format ('g:i A ' ),
60
70
],
61
71
[
62
72
[
63
73
'date_format ' => 'MM/d/yy ' ,
64
74
'value ' => $ testTimestamp ,
65
75
],
66
- $ date ->format ('m/j/y ' )
67
- ]
76
+ $ date ->format ('m/j/y ' ),
77
+ ],
78
+ [
79
+ [
80
+ 'date_format ' => 'd-MM-Y ' ,
81
+ 'value ' => $ date ->format ('d-m-Y ' ),
82
+ ],
83
+ $ date ->format ('d-m-Y ' ),
84
+ ],
68
85
];
69
86
}
70
87
}
0 commit comments