File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
app/code/Magento/Customer Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ public function beforeExecute(ActionInterface $subject)
110110
111111 if (!$ this ->isFrontendRequest ()
112112 || !$ this ->isPostRequest ()
113+ || $ this ->isLogoutRequest ()
113114 || !$ this ->isSessionUpdateRegisteredFor ($ customerId )) {
114115 return ;
115116 }
@@ -146,6 +147,11 @@ private function isPostRequest(): bool
146147 return $ this ->request instanceof HttpRequestInterface && $ this ->request ->isPost ();
147148 }
148149
150+ private function isLogoutRequest (): bool
151+ {
152+ return $ this ->request ->getRequestUri () === '/customer/account/logout/ ' ;
153+ }
154+
149155 /**
150156 * Check if the current application area is frontend.
151157 *
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ protected function setUp(): void
8484 $ this ->customerRepositoryMock = $ this ->getMockForAbstractClass (CustomerRepositoryInterface::class);
8585 $ this ->actionMock = $ this ->getMockForAbstractClass (ActionInterface::class);
8686 $ this ->requestMock = $ this ->getMockBuilder (RequestStubInterface::class)
87+ ->addMethods (['getRequestUri ' ])
8788 ->getMockForAbstractClass ();
8889 $ this ->requestMock ->method ('isPost ' )->willReturn (true );
8990
@@ -153,4 +154,15 @@ public function testBeforeDispatchWithNoCustomerFound()
153154
154155 $ this ->plugin ->beforeExecute ($ this ->actionMock );
155156 }
157+
158+ public function testBeforeExecuteForLogoutRequest ()
159+ {
160+ $ this ->requestMock ->method ('getRequestUri ' )->willReturn ('/customer/account/logout/ ' );
161+
162+ $ this ->sessionMock ->expects ($ this ->never ())->method ('regenerateId ' );
163+ $ this ->sessionMock ->expects ($ this ->never ())->method ('setCustomerData ' );
164+ $ this ->sessionMock ->expects ($ this ->never ())->method ('setCustomerGroupId ' );
165+
166+ $ this ->plugin ->beforeExecute ($ this ->actionMock );
167+ }
156168}
You can’t perform that action at this time.
0 commit comments