@@ -42,7 +42,7 @@ protected function setUp(): void
42
42
*/
43
43
public function testGenerateCode (array $ data , $ length )
44
44
{
45
- $ salesRuleCouponMock = $ this ->createPartialMock (Coupon::class, ['getCharset ' ]);
45
+ $ salesRuleCouponMock = $ this ->createPartialMock (Coupon::class, ['getCharset ' , ' getCodeSeparator ' ]);
46
46
47
47
/** @var Massgenerator $massgenerator */
48
48
$ massgenerator = $ this ->objectManager ->getObject (
@@ -54,6 +54,7 @@ public function testGenerateCode(array $data, $length)
54
54
->method ('getCharset ' )
55
55
->with ($ data ['format ' ])
56
56
->willReturn ($ this ->charset );
57
+ $ salesRuleCouponMock ->method ('getCodeSeparator ' )->willReturn ('test-separator ' );
57
58
$ code = $ massgenerator ->generateCode ();
58
59
59
60
$ this ->assertSame ($ length , strlen ($ code ));
@@ -101,7 +102,7 @@ public function testGeneratePool()
101
102
'format ' => 'test-format ' ,
102
103
];
103
104
104
- $ salesRuleCouponMock = $ this ->createPartialMock (Coupon::class, ['getCharset ' ]);
105
+ $ salesRuleCouponMock = $ this ->createPartialMock (Coupon::class, ['getCharset ' , ' getCodeSeparator ' ]);
105
106
$ resourceMock = $ this ->createPartialMock (
106
107
\Magento \SalesRule \Model \ResourceModel \Coupon::class,
107
108
['exists ' , 'getIdFieldName ' ]
@@ -123,21 +124,17 @@ public function testGeneratePool()
123
124
]
124
125
);
125
126
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 ' );
141
138
/** @var Massgenerator $massgenerator */
142
139
$ massgenerator = $ this ->objectManager ->getObject (
143
140
Massgenerator::class,
@@ -173,7 +170,7 @@ public function testGeneratePoolException()
173
170
'max_attempts ' => 0 ,
174
171
];
175
172
176
- $ salesRuleCouponMock = $ this ->createPartialMock (Coupon::class, ['getCharset ' ]);
173
+ $ salesRuleCouponMock = $ this ->createPartialMock (Coupon::class, ['getCharset ' , ' getCodeSeparator ' ]);
177
174
$ resourceMock = $ this ->createPartialMock (
178
175
\Magento \SalesRule \Model \ResourceModel \Coupon::class,
179
176
['exists ' , 'getIdFieldName ' ]
@@ -186,11 +183,12 @@ public function testGeneratePoolException()
186
183
$ couponFactoryMock ->expects ($ this ->once ())
187
184
->method ('create ' )
188
185
->willReturn ($ couponMock );
189
- $ salesRuleCouponMock-> expects ( $ this -> any ())
186
+ $ salesRuleCouponMock
190
187
->method ('getCharset ' )
191
188
->with ($ data ['format ' ])
192
189
->willReturn ($ this ->charset );
193
- $ resourceMock ->expects ($ this ->any ())
190
+ $ salesRuleCouponMock ->method ('getCodeSeparator ' )->willReturn ('test-separator ' );
191
+ $ resourceMock
194
192
->method ('exists ' )
195
193
->willReturn (true );
196
194
0 commit comments