|
8 | 8 | namespace Magento\Bundle\Test\Unit\Pricing\Adjustment;
|
9 | 9 |
|
10 | 10 | use Magento\Bundle\Model\Option;
|
| 11 | +use Magento\Bundle\Model\Product\Price; |
11 | 12 | use Magento\Bundle\Model\Product\Type;
|
12 | 13 | use Magento\Bundle\Model\ResourceModel\Option\Collection;
|
13 | 14 | use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection;
|
@@ -109,6 +110,8 @@ protected function setUp(): void
|
109 | 110 |
|
110 | 111 | $this->product = $this->getMockBuilder(Product::class)
|
111 | 112 | ->disableOriginalConstructor()
|
| 113 | + ->addMethods(['getPriceType']) |
| 114 | + ->onlyMethods(['getTypeInstance', 'isSalable']) |
112 | 115 | ->getMock();
|
113 | 116 | $this->optionsCollection = $this->getMockBuilder(Collection::class)
|
114 | 117 | ->disableOriginalConstructor()
|
@@ -142,6 +145,54 @@ public function testGetPriceList(): void
|
142 | 145 | {
|
143 | 146 | $optionId = 1;
|
144 | 147 |
|
| 148 | + $this->typeInstance->expects($this->any()) |
| 149 | + ->method('getOptionsCollection') |
| 150 | + ->with($this->product) |
| 151 | + ->willReturn($this->optionsCollection); |
| 152 | + $this->product->expects($this->any()) |
| 153 | + ->method('getTypeInstance') |
| 154 | + ->willReturn($this->typeInstance); |
| 155 | + $this->product->expects($this->once()) |
| 156 | + ->method('getPriceType')->willReturn(Price::PRICE_TYPE_FIXED); |
| 157 | + $this->optionsCollection->expects($this->once()) |
| 158 | + ->method('getIterator') |
| 159 | + ->willReturn(new \ArrayIterator([$this->option])); |
| 160 | + $this->option->expects($this->once()) |
| 161 | + ->method('getOptionId') |
| 162 | + ->willReturn($optionId); |
| 163 | + $this->typeInstance->expects($this->once()) |
| 164 | + ->method('getSelectionsCollection') |
| 165 | + ->with([$optionId], $this->product) |
| 166 | + ->willReturn($this->selectionCollection); |
| 167 | + $this->option->expects($this->once()) |
| 168 | + ->method('isMultiSelection') |
| 169 | + ->willReturn(true); |
| 170 | + $this->storeManager->expects($this->once()) |
| 171 | + ->method('getStore') |
| 172 | + ->willReturn($this->store); |
| 173 | + $this->store->expects($this->once()) |
| 174 | + ->method('getWebsiteId') |
| 175 | + ->willReturn(0); |
| 176 | + $this->websiteRepository->expects($this->once()) |
| 177 | + ->method('getDefault') |
| 178 | + ->willReturn($this->website); |
| 179 | + $this->website->expects($this->once()) |
| 180 | + ->method('getId') |
| 181 | + ->willReturn(1); |
| 182 | + $this->selectionCollection->expects($this->once()) |
| 183 | + ->method('getIterator') |
| 184 | + ->willReturn(new \ArrayIterator([])); |
| 185 | + $this->selectionCollection->expects($this->never()) |
| 186 | + ->method('setFlag') |
| 187 | + ->with('has_stock_status_filter', true); |
| 188 | + |
| 189 | + $this->model->getPriceList($this->product, false, false); |
| 190 | + } |
| 191 | + |
| 192 | + public function testGetPriceListForFixedPriceType(): void |
| 193 | + { |
| 194 | + $optionId = 1; |
| 195 | + |
145 | 196 | $this->typeInstance->expects($this->any())
|
146 | 197 | ->method('getOptionsCollection')
|
147 | 198 | ->with($this->product)
|
|
0 commit comments