Skip to content

Commit c73d129

Browse files
author
Anna Bukatar
committed
ACP2E-1763: Issue with Cart when logged in as customer from admin
1 parent e1b12e9 commit c73d129

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Persistent\Test\Unit\Model\Plugin;
9+
10+
use Magento\Persistent\Model\Plugin\LoginAsCustomerCleanUp;
11+
use Magento\Persistent\Helper\Session as PersistentSession;
12+
use Magento\LoginAsCustomerApi\Api\AuthenticateCustomerBySecretInterface;
13+
use PHPUnit\Framework\MockObject\MockObject;
14+
use PHPUnit\Framework\TestCase;
15+
16+
class LoginAsCustomerCleanUpTest extends TestCase
17+
{
18+
/**
19+
* @var LoginAsCustomerCleanUp
20+
*/
21+
protected $plugin;
22+
23+
/**
24+
* @var MockObject
25+
*/
26+
protected $subjectMock;
27+
28+
/**
29+
* @var MockObject
30+
*/
31+
protected $persistentSessionMock;
32+
33+
/**
34+
* @var MockObject
35+
*/
36+
protected $persistentSessionModelMock;
37+
38+
protected function setUp(): void
39+
{
40+
$this->persistentSessionMock = $this->createMock(PersistentSession::class);
41+
$this->persistentSessionModelMock = $this->createMock(\Magento\Persistent\Model\Session::class);
42+
$this->persistentSessionMock->method('getSession')->willReturn($this->persistentSessionModelMock);
43+
$this->subjectMock = $this->createMock(AuthenticateCustomerBySecretInterface::class);
44+
$this->plugin = new LoginAsCustomerCleanUp($this->persistentSessionMock);
45+
}
46+
47+
public function testBeforeExecute()
48+
{
49+
$key = 'key';
50+
$this->persistentSessionMock->expects($this->once())->method('isPersistent')->willReturn(true);
51+
$this->persistentSessionModelMock->expects($this->once())->method('removePersistentCookie');
52+
$result = $this->plugin->beforeExecute($this->subjectMock, $key);
53+
$this->assertEquals($key, $result);
54+
}
55+
}

app/code/Magento/Persistent/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"magento/module-quote": "*",
1515
"magento/module-store": "*"
1616
},
17+
"suggest": {
18+
"magento/module-login-as-customer-api": "*"
19+
},
1720
"type": "magento2-module",
1821
"license": [
1922
"OSL-3.0",

0 commit comments

Comments
 (0)