public function run(NotificationInterface $notification) { $resourcesList = $this->sourceFilesystemAdapter->getResourcesList(); $notification->runProcess(count($resourcesList)); foreach ($resourcesList as $resource) { $result = $this->backupResource($resource, $notification); if ($result === true) { $notification->notifySuccessStepProcess($resource); } } $notification->finishProcess(); }
function it_creates_backup_with_error_while_writing_resource(SourceFilesystemAdapterInterface $sourceFilesystemAdapter, TargetFilesystemAdapterInterface $targetFilesystemAdapter, NotificationInterface $notification) { $resources = [new RemoteResource('test/1.jpg'), new RemoteResource('test/2.jpg')]; $sourceFilesystemAdapter->getResourcesList()->willReturn($resources); $sourceFilesystemAdapter->readStream($resources[0])->willReturn('resource'); $sourceFilesystemAdapter->readStream($resources[1])->willReturn('resource'); $targetFilesystemAdapter->writeStream($resources[0], 'resource')->willReturn('resource'); $targetFilesystemAdapter->writeStream($resources[1], 'resource')->willReturn(false); $this->run($notification); $notification->notifyErrorWritingResources($resources[1])->shouldBeCalledTimes(1); $notification->notifySuccessStepProcess($resources[0])->shouldBeCalledTimes(1); $notification->runProcess(count($resources))->shouldBeCalled(); $notification->finishProcess()->shouldBeCalled(); }