9
9
10
10
use Magento \Customer \Model \Session as CustomerSession ;
11
11
use Magento \Persistent \Helper \Session as PersistentSession ;
12
- use Magento \Persistent \Model \Customer \Authorization ;
12
+ use Magento \Persistent \Model \Customer \Authorization as PersistentAuthorization ;
13
13
use PHPUnit \Framework \MockObject \MockObject ;
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Magento \Customer \Model \Customer \AuthorizationComposite as CustomerAuthorizationComposite ;
15
16
16
17
/**
17
18
* A test class for the persistent customers authorization
@@ -26,15 +27,20 @@ class AuthorizationTest extends TestCase
26
27
private $ persistentSessionMock ;
27
28
28
29
/**
29
- * @var Authorization
30
+ * @var PersistentAuthorization
30
31
*/
31
- private $ authorization ;
32
+ private $ persistentCustomerAuthorization ;
32
33
33
34
/**
34
35
* @var CustomerSession|MockObject
35
36
*/
36
37
private $ customerSessionMock ;
37
38
39
+ /**
40
+ * @var CustomerAuthorizationComposite
41
+ */
42
+ private $ customerAuthorizationComposite ;
43
+
38
44
/**
39
45
* @inheritdoc
40
46
*/
@@ -50,10 +56,14 @@ protected function setUp(): void
50
56
->disableOriginalConstructor ()
51
57
->getMock ();
52
58
53
- $ this ->authorization = new Authorization (
59
+ $ this ->persistentCustomerAuthorization = new PersistentAuthorization (
54
60
$ this ->customerSessionMock ,
55
61
$ this ->persistentSessionMock
56
62
);
63
+
64
+ $ this ->customerAuthorizationComposite = new CustomerAuthorizationComposite (
65
+ [$ this ->persistentCustomerAuthorization ]
66
+ );
57
67
}
58
68
59
69
/**
@@ -71,7 +81,7 @@ public function testIsAuthorized(
71
81
): void {
72
82
$ this ->persistentSessionMock ->method ('isPersistent ' )->willReturn ($ isPersistent );
73
83
$ this ->customerSessionMock ->method ('isLoggedIn ' )->willReturn ($ isLoggedIn );
74
- $ isAllowedResult = $ this ->authorization ->isAllowed ('self ' );
84
+ $ isAllowedResult = $ this ->customerAuthorizationComposite ->isAllowed ('self ' );
75
85
76
86
$ this ->assertEquals ($ isAllowedExpectation , $ isAllowedResult );
77
87
}
0 commit comments