47 $this->persistentHelperMock = $this->createMock(\
Magento\Persistent\Helper\Data::class);
48 $this->persistentSessionMock = $this->createMock(\
Magento\Persistent\Helper\Session::class);
49 $this->checkoutSessionMock = $this->createMock(\
Magento\Checkout\Model\Session::class);
50 $this->maskFactoryMock = $this->createPartialMock(
51 \
Magento\Quote\Model\QuoteIdMaskFactory::class,
52 [
'create',
'__wakeup']
54 $this->customerSessionMock = $this->createMock(\
Magento\Customer\Model\Session::class);
55 $this->subjectMock = $this->createMock(\
Magento\Checkout\Model\DefaultConfigProvider::class);
57 $this->plugin = new \Magento\Persistent\Model\Checkout\ConfigProviderPlugin(
58 $this->persistentHelperMock,
59 $this->persistentSessionMock,
60 $this->checkoutSessionMock,
61 $this->maskFactoryMock,
62 $this->customerSessionMock
77 $this->persistentHelperMock->expects($this->once())->method(
'isEnabled')->willReturn($persistenceEnabled);
78 $this->persistentSessionMock->expects($this->any())->method(
'isPersistent')->willReturn($isPersistent);
79 $this->customerSessionMock->expects($this->any())->method(
'isLoggedIn')->willReturn($isLoggedIn);
80 $this->maskFactoryMock->expects($this->never())->method(
'create');
81 $this->assertEquals(
$result, $this->plugin->afterGetConfig($this->subjectMock,
$result));
101 $expectedResult[
'quoteData'][
'entity_id'] = $maskedId;
103 $this->persistentHelperMock->expects($this->once())->method(
'isEnabled')->willReturn(
true);
104 $this->persistentSessionMock->expects($this->once())->method(
'isPersistent')->willReturn(
true);
105 $this->customerSessionMock->expects($this->once())->method(
'isLoggedIn')->willReturn(
false);
107 $quoteMaskMock = $this->createPartialMock(\
Magento\Quote\Model\QuoteIdMask::class, [
'load',
'getMaskedId']);
108 $this->maskFactoryMock->expects($this->once())->method(
'create')->willReturn($quoteMaskMock);
109 $quoteMock = $this->createMock(\
Magento\Quote\Model\Quote::class);
111 $this->checkoutSessionMock->expects($this->once())->method(
'getQuote')->willReturn($quoteMock);
112 $quoteMaskMock->expects($this->once())->method(
'load')->willReturnSelf();
113 $quoteMaskMock->expects($this->once())->method(
'getMaskedId')->willReturn($maskedId);
114 $this->assertEquals($expectedResult, $this->plugin->afterGetConfig($this->subjectMock,
$result));
testAfterGetConfigPositive()
testAfterGetConfigNegative($persistenceEnabled, $isPersistent, $isLoggedIn)