Skip to content

Commit 9d3f914

Browse files
rachanarachana
authored andcommitted
BUG#AC-6920:UnitTestcase with fixes
2 parents 8a0cec3 + 0abcd0e commit 9d3f914

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

app/code/Magento/QuoteGraphQl/Test/Unit/Model/Resolver/MaskedCartIdTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
1818
use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResourceModel;
1919
use Magento\QuoteGraphQl\Model\Resolver\Cart;
20+
use Magento\Quote\Model\Quote;
2021
use Magento\QuoteGraphQl\Model\Resolver\MaskedCartId;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223
use PHPUnit\Framework\TestCase;
24+
use Magento\Quote\Model\QuoteIdMask;
2325

2426
class MaskedCartIdTest extends TestCase
2527
{
@@ -63,6 +65,9 @@ class MaskedCartIdTest extends TestCase
6365
*/
6466
private Cart $cartMock;
6567

68+
private Quote $quoteMock;
69+
70+
private QuoteIdMask $quoteIdMask;
6671
/**
6772
* @var Quote|MockObject
6873
*/
@@ -87,10 +92,12 @@ protected function setUp(): void
8792
QuoteIdToMaskedQuoteIdInterface::class,
8893
['execute']
8994
);
95+
9096
$this->quoteIdMaskFactory = $this->createPartialMock(
9197
QuoteIdMaskFactory::class,
9298
['create']
9399
);
100+
<<<<<<< HEAD
94101
$this->quoteIdMaskResourceModelMock = $this->getMockBuilder(QuoteIdMaskResourceModel::class)
95102
->disableOriginalConstructor()
96103
->addMethods(
@@ -100,18 +107,39 @@ protected function setUp(): void
100107
)
101108
->onlyMethods(['save'])
102109
->getMock();
110+
=======
111+
/* $this->quoteIdMaskResourceModelMock = $this->createMock(QuoteIdMaskResourceModel::class,
112+
['setQuoteId']);*/
113+
$this->quoteIdMaskResourceModelMock = $this->getMockBuilder(QuoteIdMaskResourceModel::class)
114+
->disableOriginalConstructor()
115+
->addMethods(
116+
[
117+
'setQuoteId',
118+
])
119+
->onlyMethods(['save'])
120+
->getMock();
121+
>>>>>>> 0abcd0e7ba32642f377b80ba764baccbbe85c4b7
103122
$this->maskedCartId = new MaskedCartId(
104123
$this->quoteIdToMaskedQuoteId,
105124
$this->quoteIdMaskFactory,
106125
$this->quoteIdMaskResourceModelMock
107126
);
108127
$this->quoteMock = $this->getMockBuilder(Quote::class)
128+
<<<<<<< HEAD
109129
->disableOriginalConstructor()
110130
->getMock();
111131
$this->quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
112132
->disableOriginalConstructor()
113133
->getMock();
114134
}
135+
=======
136+
->disableOriginalConstructor()
137+
->getMock();
138+
$this->quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
139+
->disableOriginalConstructor()
140+
->getMock();
141+
}
142+
>>>>>>> 0abcd0e7ba32642f377b80ba764baccbbe85c4b7
115143

116144
public function testResolveWithoutModelInValueParameter(): void
117145
{
@@ -128,6 +156,7 @@ public function testResolve(): void
128156
->expects($this->once())
129157
->method('getId')
130158
->willReturn($cartId);
159+
<<<<<<< HEAD
131160
$this->quoteIdMaskFactory
132161
->expects($this->once())
133162
->method('create')
@@ -137,6 +166,23 @@ public function testResolve(): void
137166
->expects($this->once())
138167
->method('save')
139168
->with($this->quoteIdMask);
169+
=======
170+
171+
$this->quoteIdMaskFactory
172+
->expects($this->once())
173+
->method('create')
174+
->willReturn($this->quoteIdMask);
175+
176+
$this->quoteIdMask->setQuoteId($cartId);
177+
178+
$this->quoteIdMaskResourceModelMock
179+
->expects($this->once())
180+
->method('save')
181+
->with( $this->quoteIdMask);
182+
183+
184+
185+
>>>>>>> 0abcd0e7ba32642f377b80ba764baccbbe85c4b7
140186
$this->maskedCartId->resolve($this->fieldMock, $this->contextMock, $this->resolveInfoMock, $this->valueMock);
141187
}
142188
}

0 commit comments

Comments
 (0)