Skip to content

Commit ed7efb9

Browse files
committed
#28081 Add missing mock of separator that was missing
1 parent 5f09d96 commit ed7efb9

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

app/code/Magento/SalesRule/Test/Unit/Model/Coupon/MassgeneratorTest.php

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function setUp(): void
4242
*/
4343
public function testGenerateCode(array $data, $length)
4444
{
45-
$salesRuleCouponMock = $this->createPartialMock(Coupon::class, ['getCharset']);
45+
$salesRuleCouponMock = $this->createPartialMock(Coupon::class, ['getCharset', 'getCodeSeparator']);
4646

4747
/** @var Massgenerator $massgenerator */
4848
$massgenerator = $this->objectManager->getObject(
@@ -54,6 +54,7 @@ public function testGenerateCode(array $data, $length)
5454
->method('getCharset')
5555
->with($data['format'])
5656
->willReturn($this->charset);
57+
$salesRuleCouponMock->method('getCodeSeparator')->willReturn('test-separator');
5758
$code = $massgenerator->generateCode();
5859

5960
$this->assertSame($length, strlen($code));
@@ -101,7 +102,7 @@ public function testGeneratePool()
101102
'format' => 'test-format',
102103
];
103104

104-
$salesRuleCouponMock = $this->createPartialMock(Coupon::class, ['getCharset']);
105+
$salesRuleCouponMock = $this->createPartialMock(Coupon::class, ['getCharset', 'getCodeSeparator']);
105106
$resourceMock = $this->createPartialMock(
106107
\Magento\SalesRule\Model\ResourceModel\Coupon::class,
107108
['exists', 'getIdFieldName']
@@ -123,21 +124,17 @@ public function testGeneratePool()
123124
]
124125
);
125126

126-
$couponMock->expects($this->any())->method('setId')->willReturnSelf();
127-
$couponMock->expects($this->any())->method('setRuleId')->willReturnSelf();
128-
$couponMock->expects($this->any())->method('setUsageLimit')->willReturnSelf();
129-
$couponMock->expects($this->any())->method('setUsagePerCustomer')->willReturnSelf();
130-
$couponMock->expects($this->any())->method('setCreatedAt')->willReturnSelf();
131-
$couponMock->expects($this->any())->method('setType')->willReturnSelf();
132-
$couponMock->expects($this->any())->method('setCode')->willReturnSelf();
133-
$couponMock->expects($this->any())->method('save')->willReturnSelf();
134-
$couponFactoryMock->expects($this->once())
135-
->method('create')
136-
->willReturn($couponMock);
137-
$salesRuleCouponMock->expects($this->any())
138-
->method('getCharset')
139-
->with($data['format'])
140-
->willReturn($this->charset);
127+
$couponMock->method('setId')->willReturnSelf();
128+
$couponMock->method('setRuleId')->willReturnSelf();
129+
$couponMock->method('setUsageLimit')->willReturnSelf();
130+
$couponMock->method('setUsagePerCustomer')->willReturnSelf();
131+
$couponMock->method('setCreatedAt')->willReturnSelf();
132+
$couponMock->method('setType')->willReturnSelf();
133+
$couponMock->method('setCode')->willReturnSelf();
134+
$couponMock->method('save')->willReturnSelf();
135+
$couponFactoryMock->expects($this->once())->method('create')->willReturn($couponMock);
136+
$salesRuleCouponMock->method('getCharset')->with($data['format'])->willReturn($this->charset);
137+
$salesRuleCouponMock->method('getCodeSeparator')->willReturn('test-separator');
141138
/** @var Massgenerator $massgenerator */
142139
$massgenerator = $this->objectManager->getObject(
143140
Massgenerator::class,
@@ -173,7 +170,7 @@ public function testGeneratePoolException()
173170
'max_attempts' => 0,
174171
];
175172

176-
$salesRuleCouponMock = $this->createPartialMock(Coupon::class, ['getCharset']);
173+
$salesRuleCouponMock = $this->createPartialMock(Coupon::class, ['getCharset', 'getCodeSeparator']);
177174
$resourceMock = $this->createPartialMock(
178175
\Magento\SalesRule\Model\ResourceModel\Coupon::class,
179176
['exists', 'getIdFieldName']
@@ -186,11 +183,12 @@ public function testGeneratePoolException()
186183
$couponFactoryMock->expects($this->once())
187184
->method('create')
188185
->willReturn($couponMock);
189-
$salesRuleCouponMock->expects($this->any())
186+
$salesRuleCouponMock
190187
->method('getCharset')
191188
->with($data['format'])
192189
->willReturn($this->charset);
193-
$resourceMock->expects($this->any())
190+
$salesRuleCouponMock->method('getCodeSeparator')->willReturn('test-separator');
191+
$resourceMock
194192
->method('exists')
195193
->willReturn(true);
196194

0 commit comments

Comments
 (0)