3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Analytics \Test \Unit \Block \Adminhtml \System \Config ;
7
9
8
10
use Magento \Analytics \Block \Adminhtml \System \Config \CollectionTimeLabel ;
9
11
use Magento \Backend \Block \Template \Context ;
10
12
use Magento \Framework \Data \Form ;
11
13
use Magento \Framework \Data \Form \Element \AbstractElement ;
14
+ use Magento \Framework \Escaper ;
12
15
use Magento \Framework \Locale \ResolverInterface ;
13
16
use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
14
17
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
18
+ use PHPUnit \Framework \MockObject \MockObject ;
19
+ use PHPUnit \Framework \TestCase ;
15
20
16
- class CollectionTimeLabelTest extends \PHPUnit \Framework \TestCase
21
+ /**
22
+ * Test class for \Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel
23
+ */
24
+ class CollectionTimeLabelTest extends TestCase
17
25
{
18
26
/**
19
27
* @var CollectionTimeLabel
20
28
*/
21
29
private $ collectionTimeLabel ;
22
30
23
31
/**
24
- * @var Context|\PHPUnit_Framework_MockObject_MockObject
32
+ * @var Context|MockObject
25
33
*/
26
34
private $ contextMock ;
27
35
28
36
/**
29
- * @var TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
37
+ * @var ResolverInterface|MockObject
38
+ */
39
+ private $ localeResolverMock ;
40
+
41
+ /**
42
+ * @var Form|MockObject
43
+ */
44
+ private $ formMock ;
45
+
46
+ /**
47
+ * @var TimezoneInterface|MockObject
30
48
*/
31
49
private $ timeZoneMock ;
32
50
33
51
/**
34
- * @var AbstractElement|\PHPUnit_Framework_MockObject_MockObject
52
+ * @var AbstractElement|MockObject
35
53
*/
36
54
private $ abstractElementMock ;
37
55
38
56
/**
39
- * @var ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
57
+ * @inheritDoc
40
58
*/
41
- private $ localeResolver ;
42
-
43
59
protected function setUp ()
44
60
{
45
61
$ this ->abstractElementMock = $ this ->getMockBuilder (AbstractElement::class)
@@ -48,7 +64,7 @@ protected function setUp()
48
64
->getMock ();
49
65
50
66
$ objectManager = new ObjectManager ($ this );
51
- $ escaper = $ objectManager ->getObject (\ Magento \ Framework \ Escaper::class);
67
+ $ escaper = $ objectManager ->getObject (Escaper::class);
52
68
$ reflection = new \ReflectionClass ($ this ->abstractElementMock );
53
69
$ reflection_property = $ reflection ->getProperty ('_escaper ' );
54
70
$ reflection_property ->setAccessible (true );
@@ -64,35 +80,35 @@ protected function setUp()
64
80
$ this ->timeZoneMock = $ this ->getMockBuilder (TimezoneInterface::class)
65
81
->disableOriginalConstructor ()
66
82
->getMock ();
67
- $ this ->contextMock ->expects ($ this ->any ())
68
- ->method ('getLocaleDate ' )
83
+ $ this ->contextMock ->method ('getLocaleDate ' )
69
84
->willReturn ($ this ->timeZoneMock );
70
- $ this ->localeResolver = $ this ->getMockBuilder (ResolverInterface::class)
85
+ $ this ->localeResolverMock = $ this ->getMockBuilder (ResolverInterface::class)
71
86
->disableOriginalConstructor ()
72
87
->setMethods (['getLocale ' ])
73
88
->getMockForAbstractClass ();
74
89
75
- $ objectManager = new ObjectManager ($ this );
76
90
$ this ->collectionTimeLabel = $ objectManager ->getObject (
77
91
CollectionTimeLabel::class,
78
92
[
79
93
'context ' => $ this ->contextMock ,
80
- 'localeResolver ' => $ this ->localeResolver
94
+ 'localeResolver ' => $ this ->localeResolverMock
81
95
]
82
96
);
83
97
}
84
98
99
+ /**
100
+ * Test for \Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel::render()
101
+ */
85
102
public function testRender ()
86
103
{
87
- $ timeZone = " America/New_York " ;
104
+ $ timeZone = ' America/New_York ' ;
88
105
$ this ->abstractElementMock ->setForm ($ this ->formMock );
89
106
$ this ->timeZoneMock ->expects ($ this ->once ())
90
107
->method ('getConfigTimezone ' )
91
108
->willReturn ($ timeZone );
92
- $ this ->abstractElementMock ->expects ($ this ->any ())
93
- ->method ('getComment ' )
109
+ $ this ->abstractElementMock ->method ('getComment ' )
94
110
->willReturn ('Eastern Standard Time (America/New_York) ' );
95
- $ this ->localeResolver ->expects ($ this ->once ())
111
+ $ this ->localeResolverMock ->expects ($ this ->once ())
96
112
->method ('getLocale ' )
97
113
->willReturn ('en_US ' );
98
114
$ this ->assertRegExp (
0 commit comments