8
8
use Magento \Framework \App \PageCache \FormKey ;
9
9
use Magento \Framework \App \Response \Http as HttpResponse ;
10
10
use Magento \Framework \App \ResponseInterface ;
11
+ use Magento \Framework \Exception \NoSuchEntityException ;
11
12
use Magento \Framework \Session \SidResolverInterface ;
12
13
use Magento \Framework \Stdlib \Cookie \CookieMetadataFactory ;
13
14
use Magento \Framework \Stdlib \Cookie \PublicCookieMetadata ;
@@ -32,11 +33,6 @@ class SessionTest extends \PHPUnit\Framework\TestCase
32
33
/** @var PublicCookieMetadata $cookieMetadata */
33
34
protected $ cookieMetadata ;
34
35
35
- /**
36
- * @var HttpResponse
37
- */
38
- private $ response ;
39
-
40
36
protected function setUp (): void
41
37
{
42
38
$ this ->_customerSession = Bootstrap::getObjectManager ()->create (
@@ -66,6 +62,42 @@ public function testLoginById()
66
62
$ this ->assertTrue ($ this ->_customerSession ->isLoggedIn ());
67
63
}
68
64
65
+ /**
66
+ * @param bool $expectedResult
67
+ * @param bool $isCustomerIdValid
68
+ * @param bool $isCustomerEmulated
69
+ *
70
+ * @return void
71
+ * @dataProvider getIsLoggedInDataProvider
72
+ */
73
+ public function testIsLoggedIn (
74
+ bool $ expectedResult ,
75
+ bool $ isCustomerIdValid ,
76
+ bool $ isCustomerEmulated
77
+ ): void {
78
+ if ($ isCustomerIdValid ) {
79
+ $ this ->_customerSession ->loginById (1 );
80
+ } else {
81
+ $ this ->_customerSession ->setCustomerId (1 );
82
+ $ this ->_customerSession ->setId (2 );
83
+ }
84
+ $ this ->_customerSession ->setIsCustomerEmulated ($ isCustomerEmulated );
85
+ $ this ->assertEquals ($ expectedResult , $ this ->_customerSession ->isLoggedIn ());
86
+ }
87
+
88
+ /**
89
+ * @return array
90
+ */
91
+ public function getIsLoggedInDataProvider (): array
92
+ {
93
+ return [
94
+ ['expectedResult ' => true , 'isCustomerIdValid ' => true , 'isCustomerEmulated ' => false ],
95
+ ['expectedResult ' => false , 'isCustomerIdValid ' => true , 'isCustomerEmulated ' => true ],
96
+ ['expectedResult ' => false , 'isCustomerIdValid ' => false , 'isCustomerEmulated ' => false ],
97
+ ['expectedResult ' => false , 'isCustomerIdValid ' => false , 'isCustomerEmulated ' => true ]
98
+ ];
99
+ }
100
+
69
101
public function testLoginByIdCustomerDataLoadedCorrectly ()
70
102
{
71
103
$ fixtureCustomerId = 1 ;
0 commit comments