Skip to content

Commit 3a1adda

Browse files
rachanarachana
authored andcommitted
BUG#AC-6920:final testcases with fixes
1 parent 9d3f914 commit 3a1adda

File tree

2 files changed

+23
-69
lines changed

2 files changed

+23
-69
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,11 @@ private function ensureQuoteMaskExist(int $quoteId): string
103103
if ($maskedId === '') {
104104
$quoteIdMask = $this->quoteIdMaskFactory->create();
105105
$quoteIdMask->setQuoteId($quoteId);
106-
107106
$this->quoteIdMaskResourceModel->save($quoteIdMask);
108107
$maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
109108
}
110109
return $maskedId;
111110
}
112-
113111
}
114112

113+

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

Lines changed: 22 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
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;
2120
use Magento\QuoteGraphQl\Model\Resolver\MaskedCartId;
2221
use PHPUnit\Framework\MockObject\MockObject;
2322
use PHPUnit\Framework\TestCase;
24-
use Magento\Quote\Model\QuoteIdMask;
2523

2624
class MaskedCartIdTest extends TestCase
2725
{
@@ -65,9 +63,6 @@ class MaskedCartIdTest extends TestCase
6563
*/
6664
private Cart $cartMock;
6765

68-
private Quote $quoteMock;
69-
70-
private QuoteIdMask $quoteIdMask;
7166
/**
7267
* @var Quote|MockObject
7368
*/
@@ -92,54 +87,31 @@ protected function setUp(): void
9287
QuoteIdToMaskedQuoteIdInterface::class,
9388
['execute']
9489
);
95-
9690
$this->quoteIdMaskFactory = $this->createPartialMock(
9791
QuoteIdMaskFactory::class,
9892
['create']
9993
);
100-
<<<<<<< HEAD
10194
$this->quoteIdMaskResourceModelMock = $this->getMockBuilder(QuoteIdMaskResourceModel::class)
102-
->disableOriginalConstructor()
103-
->addMethods(
104-
[
105-
'setQuoteId',
106-
]
107-
)
108-
->onlyMethods(['save'])
109-
->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
95+
->disableOriginalConstructor()
96+
->addMethods(
97+
[
98+
'setQuoteId',
99+
]
100+
)
101+
->onlyMethods(['save'])
102+
->getMock();
122103
$this->maskedCartId = new MaskedCartId(
123104
$this->quoteIdToMaskedQuoteId,
124105
$this->quoteIdMaskFactory,
125106
$this->quoteIdMaskResourceModelMock
126107
);
127108
$this->quoteMock = $this->getMockBuilder(Quote::class)
128-
<<<<<<< HEAD
129-
->disableOriginalConstructor()
130-
->getMock();
109+
->disableOriginalConstructor()
110+
->getMock();
131111
$this->quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
132-
->disableOriginalConstructor()
133-
->getMock();
112+
->disableOriginalConstructor()
113+
->getMock();
134114
}
135-
=======
136-
->disableOriginalConstructor()
137-
->getMock();
138-
$this->quoteIdMask = $this->getMockBuilder(QuoteIdMask::class)
139-
->disableOriginalConstructor()
140-
->getMock();
141-
}
142-
>>>>>>> 0abcd0e7ba32642f377b80ba764baccbbe85c4b7
143115

144116
public function testResolveWithoutModelInValueParameter(): void
145117
{
@@ -153,36 +125,19 @@ public function testResolve(): void
153125
$this->valueMock = ['model' => $this->quoteMock];
154126
$cartId = 1;
155127
$this->quoteMock
156-
->expects($this->once())
157-
->method('getId')
158-
->willReturn($cartId);
159-
<<<<<<< HEAD
128+
->expects($this->once())
129+
->method('getId')
130+
->willReturn($cartId);
160131
$this->quoteIdMaskFactory
161-
->expects($this->once())
162-
->method('create')
163-
->willReturn($this->quoteIdMask);
132+
->expects($this->once())
133+
->method('create')
134+
->willReturn($this->quoteIdMask);
164135
$this->quoteIdMask->setQuoteId($cartId);
165136
$this->quoteIdMaskResourceModelMock
166-
->expects($this->once())
167-
->method('save')
168-
->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
137+
->expects($this->once())
138+
->method('save')
139+
->with($this->quoteIdMask);
186140
$this->maskedCartId->resolve($this->fieldMock, $this->contextMock, $this->resolveInfoMock, $this->valueMock);
187141
}
188142
}
143+

0 commit comments

Comments
 (0)