@@ -377,7 +377,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
377
377
$ resultValue = $ selectionCollection ;
378
378
break ;
379
379
case '_cache_instance_used_selections_ids ' :
380
- $ resultValue = [2 , 5 , 14 ];
380
+ $ resultValue = [5 ];
381
381
break ;
382
382
}
383
383
@@ -402,7 +402,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
402
402
->method ('setStoreFilter ' );
403
403
$ buyRequest ->expects ($ this ->once ())
404
404
->method ('getBundleOption ' )
405
- ->willReturn ([3 => 5 , 10 => [ 7 => 2 , 11 => 14 ] ]);
405
+ ->willReturn ([3 => 5 ]);
406
406
$ selectionCollection ->expects ($ this ->any ())
407
407
->method ('getItems ' )
408
408
->willReturn ([$ selection ]);
@@ -431,13 +431,13 @@ function ($key) use ($optionCollection, $selectionCollection) {
431
431
->willReturn ($ productType );
432
432
$ option ->expects ($ this ->at (3 ))
433
433
->method ('getId ' )
434
- ->willReturn (10 );
434
+ ->willReturn (3 );
435
435
$ option ->expects ($ this ->at (9 ))
436
436
->method ('getId ' )
437
- ->willReturn (10 );
437
+ ->willReturn (3 );
438
438
$ option ->expects ($ this ->once ())
439
439
->method ('getRequired ' )
440
- ->willReturn (true );
440
+ ->willReturn (false );
441
441
$ option ->expects ($ this ->once ())
442
442
->method ('isMultiSelection ' )
443
443
->willReturn (true );
@@ -608,7 +608,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
608
608
$ resultValue = $ selectionCollection ;
609
609
break ;
610
610
case '_cache_instance_used_selections_ids ' :
611
- $ resultValue = [2 , 5 , 14 ];
611
+ $ resultValue = [5 ];
612
612
break ;
613
613
}
614
614
@@ -633,7 +633,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
633
633
->method ('setStoreFilter ' );
634
634
$ buyRequest ->expects ($ this ->once ())
635
635
->method ('getBundleOption ' )
636
- ->willReturn ([3 => 5 , 10 => [ 7 => 2 , 11 => 14 ] ]);
636
+ ->willReturn ([3 => 5 ]);
637
637
$ selectionCollection ->expects ($ this ->any ())
638
638
->method ('getItems ' )
639
639
->willReturn ([$ selection ]);
@@ -662,13 +662,13 @@ function ($key) use ($optionCollection, $selectionCollection) {
662
662
->willReturn ($ productType );
663
663
$ option ->expects ($ this ->at (3 ))
664
664
->method ('getId ' )
665
- ->willReturn (10 );
665
+ ->willReturn (3 );
666
666
$ option ->expects ($ this ->at (9 ))
667
667
->method ('getId ' )
668
- ->willReturn (10 );
668
+ ->willReturn (3 );
669
669
$ option ->expects ($ this ->once ())
670
670
->method ('getRequired ' )
671
- ->willReturn (true );
671
+ ->willReturn (false );
672
672
$ option ->expects ($ this ->once ())
673
673
->method ('isMultiSelection ' )
674
674
->willReturn (true );
@@ -827,7 +827,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
827
827
$ resultValue = $ selectionCollection ;
828
828
break ;
829
829
case '_cache_instance_used_selections_ids ' :
830
- $ resultValue = [2 , 5 , 14 ];
830
+ $ resultValue = [5 ];
831
831
break ;
832
832
}
833
833
@@ -852,7 +852,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
852
852
->method ('setStoreFilter ' );
853
853
$ buyRequest ->expects ($ this ->once ())
854
854
->method ('getBundleOption ' )
855
- ->willReturn ([3 => 5 , 10 => [ 7 => 2 , 11 => 14 ] ]);
855
+ ->willReturn ([3 => 5 ]);
856
856
$ selectionCollection ->expects ($ this ->any ())
857
857
->method ('getItems ' )
858
858
->willReturn ([$ selection ]);
@@ -881,13 +881,13 @@ function ($key) use ($optionCollection, $selectionCollection) {
881
881
->willReturn ($ productType );
882
882
$ option ->expects ($ this ->at (3 ))
883
883
->method ('getId ' )
884
- ->willReturn (10 );
884
+ ->willReturn (3 );
885
885
$ option ->expects ($ this ->at (9 ))
886
886
->method ('getId ' )
887
- ->willReturn (10 );
887
+ ->willReturn (3 );
888
888
$ option ->expects ($ this ->once ())
889
889
->method ('getRequired ' )
890
- ->willReturn (true );
890
+ ->willReturn (false );
891
891
$ option ->expects ($ this ->once ())
892
892
->method ('isMultiSelection ' )
893
893
->willReturn (true );
@@ -1112,41 +1112,29 @@ function ($key) use ($optionCollection, $selectionCollection) {
1112
1112
$ resultValue = $ selectionCollection ;
1113
1113
break ;
1114
1114
case '_cache_instance_used_selections_ids ' :
1115
- $ resultValue = [2 , 5 , 14 ];
1115
+ $ resultValue = [5 ];
1116
1116
break ;
1117
1117
}
1118
1118
1119
1119
return $ resultValue ;
1120
1120
}
1121
1121
);
1122
- $ optionCollection ->expects ($ this ->once ())
1123
- ->method ('getItemById ' )
1124
- ->willReturn ($ option );
1125
1122
$ optionCollection ->expects ($ this ->once ())
1126
1123
->method ('appendSelections ' );
1127
1124
$ productType ->expects ($ this ->once ())
1128
1125
->method ('setStoreFilter ' );
1129
1126
$ buyRequest ->expects ($ this ->once ())
1130
1127
->method ('getBundleOption ' )
1131
- ->willReturn ([3 => 5 , 10 => [ 7 => 2 , 11 => 14 ] ]);
1128
+ ->willReturn ([3 => 5 ]);
1132
1129
$ selectionCollection ->expects ($ this ->at (0 ))
1133
1130
->method ('getItems ' )
1134
1131
->willReturn ([$ selection ]);
1135
1132
$ selectionCollection ->expects ($ this ->at (1 ))
1136
1133
->method ('getItems ' )
1137
1134
->willReturn ([]);
1138
- $ selection ->expects ($ this ->once ())
1139
- ->method ('isSalable ' )
1140
- ->willReturn (false );
1141
- $ option ->expects ($ this ->at (3 ))
1135
+ $ option ->expects ($ this ->any ())
1142
1136
->method ('getId ' )
1143
- ->willReturn (10 );
1144
- $ option ->expects ($ this ->once ())
1145
- ->method ('getRequired ' )
1146
- ->willReturn (true );
1147
- $ option ->expects ($ this ->once ())
1148
- ->method ('isMultiSelection ' )
1149
- ->willReturn (true );
1137
+ ->willReturn (3 );
1150
1138
1151
1139
$ result = $ this ->model ->prepareForCartAdvanced ($ buyRequest , $ product );
1152
1140
$ this ->assertEquals ('Please specify product option(s). ' , $ result );
@@ -1255,7 +1243,7 @@ function ($key) use ($optionCollection, $selectionCollection) {
1255
1243
$ buyRequest ->expects ($ this ->once ())
1256
1244
->method ('getBundleOption ' )
1257
1245
->willReturn ([3 => 5 ]);
1258
- $ selectionCollection ->expects ($ this ->once ())
1246
+ $ selectionCollection ->expects ($ this ->any ())
1259
1247
->method ('getItems ' )
1260
1248
->willReturn ([$ selection ]);
1261
1249
$ selection ->expects ($ this ->once ())
@@ -1901,8 +1889,7 @@ public function testGetSelectionsByIds()
1901
1889
'setPositionOrder ' ,
1902
1890
'addFilterByRequiredOptions ' ,
1903
1891
'setSelectionIdsFilter ' ,
1904
- 'joinPrices ' ,
1905
- 'getItems '
1892
+ 'joinPrices '
1906
1893
]
1907
1894
)
1908
1895
->disableOriginalConstructor ()
@@ -1971,9 +1958,6 @@ public function testGetSelectionsByIds()
1971
1958
->method ('setSelectionIdsFilter ' )
1972
1959
->with ($ selectionIds )
1973
1960
->will ($ this ->returnSelf ());
1974
- $ usedSelectionsMock ->expects ($ this ->once ())
1975
- ->method ('getItems ' )
1976
- ->willReturn ($ usedSelectionsIds );
1977
1961
1978
1962
$ usedSelectionsMock ->expects ($ this ->once ())
1979
1963
->method ('joinPrices ' )
@@ -1987,96 +1971,6 @@ public function testGetSelectionsByIds()
1987
1971
$ this ->model ->getSelectionsByIds ($ selectionIds , $ productMock );
1988
1972
}
1989
1973
1990
- /**
1991
- * @expectedException \Magento\Framework\Exception\LocalizedException
1992
- * @expectedExceptionMessage The options you selected are not available.
1993
- *
1994
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1995
- */
1996
- public function testGetSelectionsByIdsException ()
1997
- {
1998
- $ selectionIds = [1 , 2 , 3 ];
1999
- $ usedSelectionsIds = [4 , 5 ];
2000
- $ storeId = 2 ;
2001
- $ storeFilter = 'store_filter ' ;
2002
- $ productMock = $ this ->getMockBuilder ('Magento\Catalog\Model\Product ' )
2003
- ->disableOriginalConstructor ()
2004
- ->getMock ();
2005
- $ usedSelectionsMock = $ this ->getMockBuilder ('Magento\Bundle\Model\ResourceModel\Selection\Collection ' )
2006
- ->setMethods (
2007
- [
2008
- 'addAttributeToSelect ' ,
2009
- 'setFlag ' ,
2010
- 'addStoreFilter ' ,
2011
- 'setStoreId ' ,
2012
- 'setPositionOrder ' ,
2013
- 'addFilterByRequiredOptions ' ,
2014
- 'setSelectionIdsFilter ' ,
2015
- 'joinPrices ' ,
2016
- 'getItems '
2017
- ]
2018
- )
2019
- ->disableOriginalConstructor ()
2020
- ->getMock ();
2021
- $ productGetMap = [
2022
- ['_cache_instance_used_selections ' , null , null ],
2023
- ['_cache_instance_used_selections_ids ' , null , $ usedSelectionsIds ],
2024
- ['_cache_instance_store_filter ' , null , $ storeFilter ],
2025
- ];
2026
- $ productMock ->expects ($ this ->any ())
2027
- ->method ('getData ' )
2028
- ->will ($ this ->returnValueMap ($ productGetMap ));
2029
- $ productSetMap = [
2030
- ['_cache_instance_used_selections ' , $ usedSelectionsMock , $ productMock ],
2031
- ['_cache_instance_used_selections_ids ' , $ selectionIds , $ productMock ],
2032
- ];
2033
- $ productMock ->expects ($ this ->any ())
2034
- ->method ('setData ' )
2035
- ->will ($ this ->returnValueMap ($ productSetMap ));
2036
- $ productMock ->expects ($ this ->once ())
2037
- ->method ('getStoreId ' )
2038
- ->will ($ this ->returnValue ($ storeId ));
2039
-
2040
- $ this ->bundleCollection ->expects ($ this ->once ())
2041
- ->method ('create ' )
2042
- ->will ($ this ->returnValue ($ usedSelectionsMock ));
2043
-
2044
- $ usedSelectionsMock ->expects ($ this ->once ())
2045
- ->method ('addAttributeToSelect ' )
2046
- ->with ('* ' )
2047
- ->will ($ this ->returnSelf ());
2048
- $ flagMap = [
2049
- ['require_stock_items ' , true , $ usedSelectionsMock ],
2050
- ['product_children ' , true , $ usedSelectionsMock ],
2051
- ];
2052
- $ usedSelectionsMock ->expects ($ this ->any ())
2053
- ->method ('setFlag ' )
2054
- ->will ($ this ->returnValueMap ($ flagMap ));
2055
- $ usedSelectionsMock ->expects ($ this ->once ())
2056
- ->method ('addStoreFilter ' )
2057
- ->with ($ storeFilter )
2058
- ->will ($ this ->returnSelf ());
2059
- $ usedSelectionsMock ->expects ($ this ->once ())
2060
- ->method ('setStoreId ' )
2061
- ->with ($ storeId )
2062
- ->will ($ this ->returnSelf ());
2063
- $ usedSelectionsMock ->expects ($ this ->once ())
2064
- ->method ('setPositionOrder ' )
2065
- ->will ($ this ->returnSelf ());
2066
- $ usedSelectionsMock ->expects ($ this ->once ())
2067
- ->method ('addFilterByRequiredOptions ' )
2068
- ->will ($ this ->returnSelf ());
2069
- $ usedSelectionsMock ->expects ($ this ->once ())
2070
- ->method ('setSelectionIdsFilter ' )
2071
- ->with ($ selectionIds )
2072
- ->will ($ this ->returnSelf ());
2073
- $ usedSelectionsMock ->expects ($ this ->once ())
2074
- ->method ('getItems ' )
2075
- ->willReturn ($ usedSelectionsIds );
2076
-
2077
-
2078
- $ this ->model ->getSelectionsByIds ($ selectionIds , $ productMock );
2079
- }
2080
1974
/**
2081
1975
* @return void
2082
1976
*/
0 commit comments