@@ -281,6 +281,9 @@ public function testBindValueToEntityRecordExists()
281
281
$ this ->resource ->bindValueToEntity ($ valueId , $ entityId );
282
282
}
283
283
284
+ /**
285
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
286
+ */
284
287
public function testLoadGallery ()
285
288
{
286
289
$ productId = 5 ;
@@ -329,7 +332,8 @@ public function testLoadGallery()
329
332
'main.value_id = entity.value_id ' ,
330
333
['entity_id ' ]
331
334
)->willReturnSelf ();
332
- $ this ->product ->expects ($ this ->at (0 ))->method ('getData ' )->with ('entity_id ' )->willReturn ($ productId );
335
+ $ this ->product ->expects ($ this ->at (0 ))->method ('getData ' )
336
+ ->with ('entity_id ' )->willReturn ($ productId );
333
337
$ this ->product ->expects ($ this ->at (1 ))->method ('getStoreId ' )->will ($ this ->returnValue ($ storeId ));
334
338
$ this ->connection ->expects ($ this ->exactly (2 ))->method ('quoteInto ' )->withConsecutive (
335
339
['value.store_id = ? ' ],
@@ -338,26 +342,50 @@ public function testLoadGallery()
338
342
'value.store_id = ' . $ storeId ,
339
343
'default_value.store_id = ' . 0
340
344
);
345
+ $ this ->connection ->expects ($ this ->any ())->method ('getIfNullSql ' )->will (
346
+ $ this ->returnValueMap ([
347
+ [
348
+ '`value`.`label` ' ,
349
+ '`default_value`.`label` ' ,
350
+ 'IFNULL(`value`.`label`, `default_value`.`label`) '
351
+ ],
352
+ [
353
+ '`value`.`position` ' ,
354
+ '`default_value`.`position` ' ,
355
+ 'IFNULL(`value`.`position`, `default_value`.`position`) '
356
+ ],
357
+ [
358
+ '`value`.`disabled` ' ,
359
+ '`default_value`.`disabled` ' ,
360
+ 'IFNULL(`value`.`disabled`, `default_value`.`disabled`) '
361
+ ]
362
+ ])
363
+ );
341
364
$ this ->select ->expects ($ this ->at (2 ))->method ('joinLeft ' )->with (
342
365
['value ' => $ getTableReturnValue ],
343
366
$ quoteInfoReturnValue ,
344
- [
345
- 'label ' ,
346
- 'position ' ,
347
- 'disabled '
348
- ]
367
+ []
349
368
)->willReturnSelf ();
350
369
$ this ->select ->expects ($ this ->at (3 ))->method ('joinLeft ' )->with (
351
370
['default_value ' => $ getTableReturnValue ],
352
371
$ quoteDefaultInfoReturnValue ,
353
- [' label_default ' => ' label ' , ' position_default ' => ' position ' , ' disabled_default ' => ' disabled ' ]
372
+ []
354
373
)->willReturnSelf ();
355
- $ this ->select ->expects ($ this ->at (4 ))->method ('where ' )->with (
374
+ $ this ->select ->expects ($ this ->at (4 ))->method ('columns ' )->with ([
375
+ 'label ' => 'IFNULL(`value`.`label`, `default_value`.`label`) ' ,
376
+ 'position ' => 'IFNULL(`value`.`position`, `default_value`.`position`) ' ,
377
+ 'disabled ' => 'IFNULL(`value`.`disabled`, `default_value`.`disabled`) ' ,
378
+ 'label_default ' => 'default_value.label ' ,
379
+ 'position_default ' => 'default_value.position ' ,
380
+ 'disabled_default ' => 'default_value.disabled '
381
+ ])->willReturnSelf ();
382
+ $ this ->select ->expects ($ this ->at (5 ))->method ('where ' )->with (
356
383
'main.attribute_id = ? ' ,
357
384
$ attributeId
358
385
)->willReturnSelf ();
359
- $ this ->select ->expects ($ this ->at (5 ))->method ('where ' )->with ('main.disabled = 0 ' )->willReturnSelf ();
360
- $ this ->select ->expects ($ this ->at (7 ))->method ('where ' )
386
+ $ this ->select ->expects ($ this ->at (6 ))->method ('where ' )
387
+ ->with ('main.disabled = 0 ' )->willReturnSelf ();
388
+ $ this ->select ->expects ($ this ->at (8 ))->method ('where ' )
361
389
->with ('entity.entity_id = ? ' , $ productId )
362
390
->willReturnSelf ();
363
391
$ this ->select ->expects ($ this ->once ())->method ('order ' )
0 commit comments