processorMock = $this->createMock(ItemToMediaUnitProcessor::class); $this->queueDispatcherInterfaceMock = $this->createMock(QueueDispatcherInterface::class); $this->queueMigrationServiceMock = $this->createMock(QueueMigrationService::class); $this->itemToMediaRdsSearcher = $this->createMock(ItemToMediaRdsSearcher::class); $this->spawnMigrationConfigServiceMock = $this->createMock(SpawnMigrationConfigService::class); $this->resultFilterFactoryMock = $this->createMock(ResultFilterFactory::class); $this->migrationConfigFactoryMock = $this->createMock(MigrationConfigFactory::class); $this->subject = new ItemToMediaRelationMigrationTask(); $this->subject->setServiceLocator( $this->getServiceLocatorMock([ ItemToMediaUnitProcessor::class => $this->processorMock, QueueMigrationService::class => $this->queueMigrationServiceMock, ItemToMediaRdsSearcher::class => $this->itemToMediaRdsSearcher, QueueDispatcherInterface::SERVICE_ID => $this->queueDispatcherInterfaceMock, SpawnMigrationConfigService::class => $this->spawnMigrationConfigServiceMock, ResultFilterFactory::class => $this->resultFilterFactoryMock, MigrationConfigFactory::class => $this->migrationConfigFactoryMock, ])); } public function testInvokeWithRespawnConfig(): void { /** @var MigrationConfig|MockObject $respawnTaskConfig */ $respawnTaskConfig = $this->createMock(MigrationConfig::class); $params['chunkSize'] = self::CHUNKSIZE_EXAMPLE; $params['start'] = self::START_EXAMPLE; $params['pickSize'] = self::PICKSIZE_EXAMPLE; $params['repeat'] = self::REPEAT_EXAMPLE; $this->queueMigrationServiceMock ->expects($this->once()) ->method('migrate') ->willReturn($respawnTaskConfig); $respawnTaskConfig ->expects($this->exactly(2)) ->method('getChunkSize'); $respawnTaskConfig ->expects($this->once()) ->method('getPickSize'); $this->migrationConfigFactoryMock ->method('create') ->willReturn(new MigrationConfig( ['start' => 0], 1, 2, true )); $this->resultFilterFactoryMock ->expects($this->once()) ->method('create') ->willReturn(new ResultFilter(['param1' => 1])); $callbackTaskInterface = $this->createMock(CallbackTaskInterface::class); $this->queueDispatcherInterfaceMock ->expects($this->once()) ->method('createTask') ->willReturn($callbackTaskInterface); $this->subject->__invoke($params); } }