@@ -226,6 +226,14 @@ public function testCustomField() {
226226 'field_custom_text ' => 'Blue ' ,
227227 ]);
228228 $ order_item3 ->save ();
229+ $ order_item4 = OrderItem::create ([
230+ 'type ' => 'default ' ,
231+ 'quantity ' => 4 ,
232+ 'unit_price ' => new Price ('12.00 ' , 'USD ' ),
233+ 'purchased_entity ' => $ this ->variation1 ,
234+ 'field_custom_text ' => '' ,
235+ ]);
236+ $ order_item4 ->save ();
229237
230238 // Same purchased entity, different custom text, no match.
231239 $ matches = $ this ->orderItemMatcher ->matchAll ($ order_item1 , [$ order_item2 ]);
@@ -239,21 +247,31 @@ public function testCustomField() {
239247 $ this ->assertNotEmpty ($ match );
240248 $ this ->assertEquals ($ match , $ order_item3 );
241249
242- // Item with missing custom text does not match.
243- $ order_item4 = OrderItem::create ([
250+ // Item with missing custom text, no match.
251+ $ order_item5 = OrderItem::create ([
244252 'type ' => 'default ' ,
245253 'quantity ' => 5 ,
246254 'unit_price ' => new Price ('12.00 ' , 'USD ' ),
247255 'purchased_entity ' => $ this ->variation1 ,
248256 ]);
249- $ order_item4 ->save ();
250-
251- $ matches = $ this ->orderItemMatcher ->matchAll ($ order_item4 , [
257+ $ matches = $ this ->orderItemMatcher ->matchAll ($ order_item5 , [
252258 $ order_item1 ,
253259 $ order_item2 ,
254260 $ order_item3 ,
255261 ]);
256262 $ this ->assertEmpty ($ matches );
263+
264+ // Empty custom text on both sides, match.
265+ $ order_item6 = OrderItem::create ([
266+ 'type ' => 'default ' ,
267+ 'quantity ' => 5 ,
268+ 'unit_price ' => new Price ('12.00 ' , 'USD ' ),
269+ 'purchased_entity ' => $ this ->variation1 ,
270+ 'field_custom_text ' => '' ,
271+ ]);
272+ $ match = $ this ->orderItemMatcher ->match ($ order_item6 , [$ order_item4 ]);
273+ $ this ->assertNotEmpty ($ match );
274+ $ this ->assertEquals ($ match , $ order_item4 );
257275 }
258276
259277}
0 commit comments