1
- <?php
1
+ <?php declare (strict_types= 1 );
2
2
/**
3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
7
namespace Magento \GoogleAnalytics \Test \Unit \Block ;
8
8
9
+ use Magento \Cookie \Helper \Cookie ;
9
10
use Magento \Framework \Escaper ;
10
11
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
11
12
use Magento \Framework \View \Element \Template \Context ;
15
16
use Magento \Sales \Model \Order ;
16
17
use Magento \Sales \Model \ResourceModel \Order \Collection ;
17
18
use Magento \Sales \Model \ResourceModel \Order \CollectionFactory ;
19
+ use Magento \Store \Api \Data \WebsiteInterface ;
18
20
use Magento \Store \Model \Store ;
19
21
use Magento \Store \Model \StoreManagerInterface ;
22
+ use PHPUnit \Framework \MockObject \MockObject ;
20
23
use PHPUnit \Framework \TestCase ;
21
24
22
25
/**
23
26
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
24
27
*/
25
- class GaTest extends \ PHPUnit \ Framework \ TestCase
28
+ class GaTest extends TestCase
26
29
{
27
30
28
31
/**
29
- * @var Ga | \PHPUnit_Framework_MockObject_MockObject
32
+ * @var Ga|MockObject
30
33
*/
31
34
protected $ gaBlock ;
32
35
33
36
/**
34
- * @var \PHPUnit_Framework_MockObject_MockObject
37
+ * @var MockObject
35
38
*/
36
39
private $ cookieHelperMock ;
37
40
38
41
/**
39
- * @var \PHPUnit_Framework_MockObject_MockObject
42
+ * @var MockObject
40
43
*/
41
44
private $ salesOrderCollectionMock ;
42
45
43
46
/**
44
- * @var \PHPUnit_Framework_MockObject_MockObject
47
+ * @var MockObject
45
48
*/
46
49
private $ storeManagerMock ;
47
50
48
51
/**
49
- * @var \PHPUnit_Framework_MockObject_MockObject
52
+ * @var MockObject
50
53
*/
51
54
private $ storeMock ;
52
55
53
56
/**
54
- * @var \PHPUnit_Framework_MockObject_MockObject
57
+ * @var MockObject
55
58
*/
56
59
private $ googleAnalyticsDataMock ;
57
60
58
- protected function setUp ()
61
+ protected function setUp (): void
59
62
{
60
63
$ objectManager = new ObjectManager ($ this );
61
64
$ contextMock = $ this ->getMockBuilder (Context::class)->disableOriginalConstructor ()->getMock ();
@@ -79,7 +82,7 @@ protected function setUp()
79
82
->disableOriginalConstructor ()
80
83
->getMock ();
81
84
82
- $ this ->cookieHelperMock = $ this ->getMockBuilder (\ Magento \ Cookie \ Helper \ Cookie::class)
85
+ $ this ->cookieHelperMock = $ this ->getMockBuilder (Cookie::class)
83
86
->disableOriginalConstructor ()
84
87
->getMock ();
85
88
@@ -135,7 +138,7 @@ public function testIsCookieRestrictionModeEnabled()
135
138
public function testGetCurrentWebsiteId ()
136
139
{
137
140
$ websiteId = 100 ;
138
- $ websiteMock = $ this ->getMockBuilder (\ Magento \ Store \ Api \ Data \ WebsiteInterface::class)->getMock ();
141
+ $ websiteMock = $ this ->getMockBuilder (WebsiteInterface::class)->getMock ();
139
142
$ websiteMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ websiteId );
140
143
$ this ->storeManagerMock ->expects ($ this ->once ())->method ('getWebsite ' )->willReturn ($ websiteMock );
141
144
$ this ->assertEquals ($ websiteId , $ this ->gaBlock ->getCurrentWebsiteId ());
@@ -185,15 +188,15 @@ public function testGetPageTrackingData()
185
188
];
186
189
$ this ->gaBlock ->setData ('page_name ' , $ pageName );
187
190
$ this ->googleAnalyticsDataMock ->expects ($ this ->once ())->method ('isAnonymizedIpActive ' )->willReturn (true );
188
-
191
+
189
192
$ this ->assertEquals ($ expectedResult , $ this ->gaBlock ->getPageTrackingData ($ accountId ));
190
193
}
191
194
192
195
/**
193
196
* Create Order mock with $orderItemCount items
194
197
*
195
198
* @param int $orderItemCount
196
- * @return Order|\PHPUnit_Framework_MockObject_MockObject
199
+ * @return Order|MockObject
197
200
*/
198
201
protected function createOrderMock ($ orderItemCount = 1 )
199
202
{
@@ -220,7 +223,7 @@ protected function createOrderMock($orderItemCount = 1)
220
223
}
221
224
222
225
/**
223
- * @return Collection | \PHPUnit_Framework_MockObject_MockObject
226
+ * @return Collection|MockObject
224
227
*/
225
228
protected function createCollectionMock ()
226
229
{
0 commit comments