Skip to content

Commit 75dcfb0

Browse files
committed
Merge branch 'ACP2E-2259' of https://github.com/magento-l3/magento2ce into PR-VK-2023-09-29
2 parents 0350a67 + 93f0eb7 commit 75dcfb0

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

app/code/Magento/Customer/Model/Plugin/CustomerNotification.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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,18 @@ private function isPostRequest(): bool
146147
return $this->request instanceof HttpRequestInterface && $this->request->isPost();
147148
}
148149

150+
/**
151+
* Checks if the current request is a logout request.
152+
*
153+
* @return bool
154+
*/
155+
private function isLogoutRequest(): bool
156+
{
157+
return $this->request->getRouteName() === 'customer'
158+
&& $this->request->getControllerName() === 'account'
159+
&& $this->request->getActionName() === 'logout';
160+
}
161+
149162
/**
150163
* Check if the current application area is frontend.
151164
*

app/code/Magento/Customer/Test/Unit/Model/Plugin/CustomerNotificationTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPUnit\Framework\TestCase;
2222
use Psr\Log\LoggerInterface;
2323
use Magento\Framework\Session\StorageInterface;
24+
use Magento\Framework\App\Request\Http as RequestHttp;
2425

2526
/**
2627
* Unit test for CustomerNotification plugin
@@ -83,8 +84,7 @@ protected function setUp(): void
8384

8485
$this->customerRepositoryMock = $this->getMockForAbstractClass(CustomerRepositoryInterface::class);
8586
$this->actionMock = $this->getMockForAbstractClass(ActionInterface::class);
86-
$this->requestMock = $this->getMockBuilder(RequestStubInterface::class)
87-
->getMockForAbstractClass();
87+
$this->requestMock = $this->createMock(RequestHttp::class);
8888
$this->requestMock->method('isPost')->willReturn(true);
8989

9090
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
@@ -153,4 +153,17 @@ public function testBeforeDispatchWithNoCustomerFound()
153153

154154
$this->plugin->beforeExecute($this->actionMock);
155155
}
156+
157+
public function testBeforeExecuteForLogoutRequest()
158+
{
159+
$this->requestMock->method('getRouteName')->willReturn('customer');
160+
$this->requestMock->method('getControllerName')->willReturn('account');
161+
$this->requestMock->method('getActionName')->willReturn('logout');
162+
163+
$this->sessionMock->expects($this->never())->method('regenerateId');
164+
$this->sessionMock->expects($this->never())->method('setCustomerData');
165+
$this->sessionMock->expects($this->never())->method('setCustomerGroupId');
166+
167+
$this->plugin->beforeExecute($this->actionMock);
168+
}
156169
}

0 commit comments

Comments
 (0)