|
22 | 22 | use Magento\Framework\EntityManager\MetadataPool; |
23 | 23 | use Magento\ImportExport\Model\Import; |
24 | 24 | use Magento\ImportExport\Test\Unit\Model\Import\AbstractImportTestCase; |
| 25 | +use Magento\Store\Model\StoreManagerInterface; |
25 | 26 | use PHPUnit\Framework\MockObject\MockObject; |
26 | 27 |
|
27 | 28 | /** |
@@ -208,6 +209,19 @@ protected function setUp(): void |
208 | 209 | ->disableOriginalConstructor() |
209 | 210 | ->onlyMethods(['getScope']) |
210 | 211 | ->getMockForAbstractClass(); |
| 212 | + |
| 213 | + $objects = [ |
| 214 | + [ |
| 215 | + Bundle\RelationsDataSaver::class, |
| 216 | + $this->createMock(Bundle\RelationsDataSaver::class) |
| 217 | + ], |
| 218 | + [ |
| 219 | + StoreManagerInterface::class, |
| 220 | + $this->createMock(StoreManagerInterface::class) |
| 221 | + ] |
| 222 | + ]; |
| 223 | + $this->objectManagerHelper->prepareObjectManager($objects); |
| 224 | + |
211 | 225 | $this->bundle = $this->objectManagerHelper->getObject( |
212 | 226 | Bundle::class, |
213 | 227 | [ |
@@ -248,9 +262,12 @@ public function testSaveData(array $skus, array $bunch, bool $allowImport): void |
248 | 262 | { |
249 | 263 | $this->entityModel->expects($this->any())->method('getBehavior')->willReturn(Import::BEHAVIOR_APPEND); |
250 | 264 | $this->entityModel->expects($this->once())->method('getNewSku')->willReturn($skus['newSku']); |
| 265 | + $callCount = 0; |
251 | 266 | $this->entityModel |
252 | 267 | ->method('getNextBunch') |
253 | | - ->willReturnOnConsecutiveCalls([$bunch]); |
| 268 | + ->willReturnCallback(function () use (&$callCount, $bunch) { |
| 269 | + return $callCount++ === 0 ? [$bunch] : null; |
| 270 | + }); |
254 | 271 | $this->entityModel->expects($this->any())->method('isRowAllowedToImport')->willReturn($allowImport); |
255 | 272 | $scope = $this->getMockBuilder(ScopeInterface::class)->getMockForAbstractClass(); |
256 | 273 | $this->scopeResolver->expects($this->any())->method('getScope')->willReturn($scope); |
@@ -321,7 +338,7 @@ public function testSaveData(array $skus, array $bunch, bool $allowImport): void |
321 | 338 | * |
322 | 339 | * @return array |
323 | 340 | */ |
324 | | - public function saveDataProvider(): array |
| 341 | + public static function saveDataProvider(): array |
325 | 342 | { |
326 | 343 | return [ |
327 | 344 | [ |
@@ -395,13 +412,12 @@ public function testSaveDataDelete(): void |
395 | 412 | $this->entityModel->expects($this->once())->method('getNewSku')->willReturn([ |
396 | 413 | 'sku' => ['sku' => 'sku', 'entity_id' => 3, 'attr_set_code' => 'Default', 'type_id' => 'bundle'] |
397 | 414 | ]); |
| 415 | + $callCount = 0; |
398 | 416 | $this->entityModel |
399 | 417 | ->method('getNextBunch') |
400 | | - ->willReturnOnConsecutiveCalls( |
401 | | - [ |
402 | | - ['bundle_values' => 'value1', 'sku' => 'sku', 'name' => 'name'] |
403 | | - ] |
404 | | - ); |
| 418 | + ->willReturnCallback(function () use (&$callCount) { |
| 419 | + return $callCount++ === 0 ? [['bundle_values' => 'value1', 'sku' => 'sku', 'name' => 'name']] : null; |
| 420 | + }); |
405 | 421 | $this->entityModel->expects($this->any())->method('isRowAllowedToImport')->willReturn(true); |
406 | 422 | $select = $this->createMock(Select::class); |
407 | 423 | $this->connection->expects($this->any())->method('select')->willReturn($select); |
|
0 commit comments