Skip to content

Commit a071b25

Browse files
committed
magento/magento2#: Remove a redundant call to DB for guest session
1 parent 7bfc990 commit a071b25

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

app/code/Magento/Customer/Test/Unit/Model/SessionTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
use Magento\Framework\App\Response\Http;
1919
use Magento\Framework\Event\ManagerInterface;
2020
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
21+
use Magento\Framework\Url;
2122
use Magento\Framework\UrlFactory;
2223
use PHPUnit\Framework\MockObject\MockObject;
24+
use PHPUnit\Framework\TestCase;
2325

2426
/**
2527
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2628
*/
27-
class SessionTest extends \PHPUnit\Framework\TestCase
29+
class SessionTest extends TestCase
2830
{
2931
/**
3032
* @var ResourceCustomer|MockObject
@@ -85,11 +87,11 @@ protected function setUp()
8587
$this->urlFactoryMock = $this->createMock(UrlFactory::class);
8688
$this->customerFactoryMock = $this->getMockBuilder(CustomerFactory::class)
8789
->disableOriginalConstructor()
88-
->setMethods(['create'])
90+
->setMethods(['create', 'save'])
8991
->getMock();
9092
$this->_customerResourceMock = $this->getMockBuilder(ResourceCustomer::class)
9193
->disableOriginalConstructor()
92-
->setMethods(['load'])
94+
->setMethods(['load', 'save'])
9395
->getMock();
9496
$this->customerRepositoryMock = $this->createMock(CustomerRepositoryInterface::class);
9597
$helper = new ObjectManagerHelper($this);
@@ -164,7 +166,7 @@ public function testSetCustomerDataAsLoggedIn()
164166
*/
165167
public function testAuthenticate()
166168
{
167-
$urlMock = $this->createMock(\Magento\Framework\Url::class);
169+
$urlMock = $this->createMock(Url::class);
168170
$urlMock->expects($this->exactly(2))
169171
->method('getUrl')
170172
->willReturn('');
@@ -216,15 +218,12 @@ protected function prepareLoginDataMock($customerId)
216218

217219
$customerMock = $this->createPartialMock(
218220
Customer::class,
219-
['getId', 'isConfirmationRequired', 'getConfirmation', 'updateData', 'getGroupId']
221+
['getId', 'getConfirmation', 'updateData', 'getGroupId']
220222
);
221-
$customerMock->expects($this->once())
223+
$customerMock->expects($this->exactly(3))
222224
->method('getId')
223225
->will($this->returnValue($customerId));
224226
$customerMock->expects($this->once())
225-
->method('isConfirmationRequired')
226-
->will($this->returnValue(true));
227-
$customerMock->expects($this->never())
228227
->method('getConfirmation')
229228
->will($this->returnValue($customerId));
230229

@@ -290,6 +289,7 @@ public function testSetCustomerRemovesFlagThatShowsIfCustomerIsEmulated()
290289
$this->_storageMock->expects($this->once())->method('unsIsCustomerEmulated');
291290
$this->_model->setCustomer($customerMock);
292291
}
292+
293293
/**
294294
* Test "getCustomer()" for guest user
295295
*

0 commit comments

Comments
 (0)