From 358873fd7b195d8f14306df840a6e964cf0a8553 Mon Sep 17 00:00:00 2001 From: stolentine <75437860+stolentine@users.noreply.github.com> Date: Wed, 7 Dec 2022 19:31:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8=20(#5?= =?UTF-8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Storozhuk Valentine --- .gitattributes | 10 ++++++++++ src/Downloader/CurlDownloader.php | 4 ++-- src/Downloader/CurlDownloaderResponse.php | 7 ++++++- src/Pipeline/State/StateParameter.php | 14 ++++++++++++++ src/Pipeline/Task/CleanupTask.php | 5 +++-- src/Pipeline/Task/DataAbstractTask.php | 3 ++- src/Pipeline/Task/DownloadTask.php | 9 +++++---- src/Pipeline/Task/InformDeltaTask.php | 7 ++++--- src/Pipeline/Task/InformFullTask.php | 3 ++- src/Pipeline/Task/PrepareFolderTask.php | 5 +++-- src/Pipeline/Task/ProcessSwitchTask.php | 3 ++- src/Pipeline/Task/SaveFiasFilesTask.php | 5 +++-- src/Pipeline/Task/SelectFilesToProceedTask.php | 7 ++++--- src/Pipeline/Task/Task.php | 10 ---------- src/Pipeline/Task/UnpackTask.php | 9 +++++---- src/Pipeline/Task/VersionGetTask.php | 3 ++- src/Pipeline/Task/VersionSetTask.php | 3 ++- tests/src/Downloader/CurlDownloaderTest.php | 6 +++--- tests/src/Pipeline/Task/CleanupTaskTest.php | 8 ++++---- tests/src/Pipeline/Task/DataDeleteTaskTest.php | 4 ++-- tests/src/Pipeline/Task/DataInsertTaskTest.php | 8 ++++---- tests/src/Pipeline/Task/DataUpsertTaskTest.php | 4 ++-- tests/src/Pipeline/Task/DownloadTaskTest.php | 10 +++++----- tests/src/Pipeline/Task/InformDeltaTaskTest.php | 10 +++++----- tests/src/Pipeline/Task/InformFullTaskTest.php | 4 ++-- tests/src/Pipeline/Task/PrepareFolderTaskTest.php | 6 +++--- tests/src/Pipeline/Task/SaveFiasFilesTaskTest.php | 6 +++--- .../Pipeline/Task/SelectFilesToProceedTaskTest.php | 12 ++++++------ tests/src/Pipeline/Task/UnpackTaskTest.php | 10 +++++----- tests/src/Pipeline/Task/VersionGetTaskTest.php | 4 ++-- tests/src/Pipeline/Task/VersionSetTaskTest.php | 6 +++--- 31 files changed, 118 insertions(+), 87 deletions(-) create mode 100644 .gitattributes create mode 100644 src/Pipeline/State/StateParameter.php diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..500c0ef2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +/.github export-ignore +/docker export-ignore +/generator export-ignore +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php-cs-fixer.dist.php export-ignore +/Makefile export-ignore +/phpunit.xml.dist export-ignore +/psalm.xml export-ignore diff --git a/src/Downloader/CurlDownloader.php b/src/Downloader/CurlDownloader.php index 6a8418cb..7464a983 100644 --- a/src/Downloader/CurlDownloader.php +++ b/src/Downloader/CurlDownloader.php @@ -49,7 +49,7 @@ public function download(string $url, \SplFileInfo $localFile): void $response = new CurlDownloaderResponse(); for ($i = 0; $i < $this->maxAttempts; ++$i) { $response = $this->runRequest($url, $options); - if ($response->isOk() && $response->getError() === null) { + if ($response->isOk() && !$response->hasError()) { break; } // в случае ошибки пробуем скачать файл еще раз, @@ -69,7 +69,7 @@ public function download(string $url, \SplFileInfo $localFile): void fclose($options[\CURLOPT_FILE]); - if ($response->getError() !== null) { + if ($response->hasError()) { $message = sprintf( "There was an error while downloading '%s': %s.", $url, diff --git a/src/Downloader/CurlDownloaderResponse.php b/src/Downloader/CurlDownloaderResponse.php index 94d39d1e..fa49a76c 100644 --- a/src/Downloader/CurlDownloaderResponse.php +++ b/src/Downloader/CurlDownloaderResponse.php @@ -25,7 +25,7 @@ public function __construct(?array $rawCurlResponse = null) $this->statusCode = isset($rawCurlResponse[0]) ? (int) $rawCurlResponse[0] : 0; $this->isOk = $this->statusCode >= 200 && $this->statusCode < 300; $this->headers = isset($rawCurlResponse[1]) ? $this->extractHeadersFromContent($rawCurlResponse[1]) : []; - $this->error = isset($rawCurlResponse[2]) ? (string) $rawCurlResponse[2] : null; + $this->error = isset($rawCurlResponse[2]) && !empty($rawCurlResponse[2]) ? (string) $rawCurlResponse[2] : null; } public function getStatusCode(): int @@ -43,6 +43,11 @@ public function getError(): ?string return $this->error; } + public function hasError(): bool + { + return $this->error !== null; + } + /** * @return array */ diff --git a/src/Pipeline/State/StateParameter.php b/src/Pipeline/State/StateParameter.php new file mode 100644 index 00000000..c86dc695 --- /dev/null +++ b/src/Pipeline/State/StateParameter.php @@ -0,0 +1,14 @@ +getParameter(Task::DOWNLOAD_TO_FILE_PARAM), - $state->getParameter(Task::EXTRACT_TO_FOLDER_PARAM), + $state->getParameter(StateParameter::DOWNLOAD_TO_FILE), + $state->getParameter(StateParameter::EXTRACT_TO_FOLDER), ]; $toRemove = array_diff($toRemove, [null]); diff --git a/src/Pipeline/Task/DataAbstractTask.php b/src/Pipeline/Task/DataAbstractTask.php index 71ac0844..b756fa19 100644 --- a/src/Pipeline/Task/DataAbstractTask.php +++ b/src/Pipeline/Task/DataAbstractTask.php @@ -10,6 +10,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\Exception\XmlException; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Storage\Storage; use Liquetsoft\Fias\Component\XmlReader\XmlReader; use Psr\Log\LogLevel; @@ -65,7 +66,7 @@ abstract protected function processItem(object $item): void; */ public function run(State $state): void { - $allFiles = $state->getParameter(Task::FILES_TO_PROCEED); + $allFiles = $state->getParameter(StateParameter::FILES_TO_PROCEED); $allFiles = \is_array($allFiles) ? $allFiles : []; foreach ($allFiles as $file) { diff --git a/src/Pipeline/Task/DownloadTask.php b/src/Pipeline/Task/DownloadTask.php index 41acfab0..edf1f27e 100644 --- a/src/Pipeline/Task/DownloadTask.php +++ b/src/Pipeline/Task/DownloadTask.php @@ -8,6 +8,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\FiasInformer\InformerResponse; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Psr\Log\LogLevel; /** @@ -33,17 +34,17 @@ public function __construct(Downloader $downloader) */ public function run(State $state): void { - $info = $state->getParameter(Task::FIAS_INFO_PARAM); + $info = $state->getParameter(StateParameter::FIAS_INFO); if (!($info instanceof InformerResponse)) { throw new TaskException( - "State parameter '" . Task::FIAS_INFO_PARAM . "' must be an '" . InformerResponse::class . "' instance for '" . self::class . "'." + "State parameter '" . StateParameter::FIAS_INFO . "' must be an '" . InformerResponse::class . "' instance for '" . self::class . "'." ); } - $localFile = $state->getParameter(Task::DOWNLOAD_TO_FILE_PARAM); + $localFile = $state->getParameter(StateParameter::DOWNLOAD_TO_FILE); if (!($localFile instanceof \SplFileInfo)) { throw new TaskException( - "State parameter '" . Task::DOWNLOAD_TO_FILE_PARAM . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." + "State parameter '" . StateParameter::DOWNLOAD_TO_FILE . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." ); } diff --git a/src/Pipeline/Task/InformDeltaTask.php b/src/Pipeline/Task/InformDeltaTask.php index 1867a237..f7c8c810 100644 --- a/src/Pipeline/Task/InformDeltaTask.php +++ b/src/Pipeline/Task/InformDeltaTask.php @@ -7,6 +7,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\FiasInformer\FiasInformer; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Psr\Log\LogLevel; /** @@ -32,10 +33,10 @@ public function __construct(FiasInformer $informer) */ public function run(State $state): void { - $version = (int) $state->getParameter(Task::FIAS_VERSION_PARAM); + $version = (int) $state->getParameter(StateParameter::FIAS_VERSION); if (!$version) { throw new TaskException( - "State parameter '" . Task::FIAS_VERSION_PARAM . "' is required for '" . self::class . "'." + "State parameter '" . StateParameter::FIAS_VERSION . "' is required for '" . self::class . "'." ); } @@ -61,6 +62,6 @@ public function run(State $state): void ); } - $state->setAndLockParameter(Task::FIAS_INFO_PARAM, $info); + $state->setAndLockParameter(StateParameter::FIAS_INFO, $info); } } diff --git a/src/Pipeline/Task/InformFullTask.php b/src/Pipeline/Task/InformFullTask.php index eb688758..225e1691 100644 --- a/src/Pipeline/Task/InformFullTask.php +++ b/src/Pipeline/Task/InformFullTask.php @@ -7,6 +7,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\FiasInformer\FiasInformer; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Psr\Log\LogLevel; /** @@ -48,6 +49,6 @@ public function run(State $state): void ] ); - $state->setAndLockParameter(Task::FIAS_INFO_PARAM, $info); + $state->setAndLockParameter(StateParameter::FIAS_INFO, $info); } } diff --git a/src/Pipeline/Task/PrepareFolderTask.php b/src/Pipeline/Task/PrepareFolderTask.php index ee992a17..95f678a2 100644 --- a/src/Pipeline/Task/PrepareFolderTask.php +++ b/src/Pipeline/Task/PrepareFolderTask.php @@ -5,6 +5,7 @@ namespace Liquetsoft\Fias\Component\Pipeline\Task; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Marvin255\FileSystemHelper\FileSystemFactory; use Marvin255\FileSystemHelper\FileSystemHelperInterface; use Psr\Log\LogLevel; @@ -56,7 +57,7 @@ public function run(State $state): void $this->log(LogLevel::INFO, "Creating '{$this->folder->getRealPath()}/extracted' folder."); $this->fs->mkdir($extractToFolder); - $state->setAndLockParameter(Task::DOWNLOAD_TO_FILE_PARAM, $downloadToFile); - $state->setAndLockParameter(Task::EXTRACT_TO_FOLDER_PARAM, $extractToFolder); + $state->setAndLockParameter(StateParameter::DOWNLOAD_TO_FILE, $downloadToFile); + $state->setAndLockParameter(StateParameter::EXTRACT_TO_FOLDER, $extractToFolder); } } diff --git a/src/Pipeline/Task/ProcessSwitchTask.php b/src/Pipeline/Task/ProcessSwitchTask.php index d11b2cb3..98860abf 100644 --- a/src/Pipeline/Task/ProcessSwitchTask.php +++ b/src/Pipeline/Task/ProcessSwitchTask.php @@ -6,6 +6,7 @@ use Liquetsoft\Fias\Component\FilesDispatcher\FilesDispatcher; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Psr\Log\LogLevel; use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; @@ -48,7 +49,7 @@ public function __construct( */ public function run(State $state): void { - $rawFiles = $state->getParameter(Task::FILES_TO_PROCEED); + $rawFiles = $state->getParameter(StateParameter::FILES_TO_PROCEED); $files = []; if (\is_array($rawFiles)) { $files = array_map( diff --git a/src/Pipeline/Task/SaveFiasFilesTask.php b/src/Pipeline/Task/SaveFiasFilesTask.php index efb743b4..8170da02 100644 --- a/src/Pipeline/Task/SaveFiasFilesTask.php +++ b/src/Pipeline/Task/SaveFiasFilesTask.php @@ -5,6 +5,7 @@ namespace Liquetsoft\Fias\Component\Pipeline\Task; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Marvin255\FileSystemHelper\FileSystemFactory; use Marvin255\FileSystemHelper\FileSystemHelperInterface; use Psr\Log\LogLevel; @@ -33,11 +34,11 @@ public function __construct(?string $moveArchiveTo, ?string $moveExtractedTo) $this->movePaths = []; if ($moveArchiveTo !== null) { - $this->movePaths[Task::DOWNLOAD_TO_FILE_PARAM] = $moveArchiveTo; + $this->movePaths[StateParameter::DOWNLOAD_TO_FILE] = $moveArchiveTo; } if ($moveExtractedTo !== null) { - $this->movePaths[Task::EXTRACT_TO_FOLDER_PARAM] = $moveExtractedTo; + $this->movePaths[StateParameter::EXTRACT_TO_FOLDER] = $moveExtractedTo; } $this->fs = FileSystemFactory::create(); diff --git a/src/Pipeline/Task/SelectFilesToProceedTask.php b/src/Pipeline/Task/SelectFilesToProceedTask.php index ba5d5919..260ec8ea 100644 --- a/src/Pipeline/Task/SelectFilesToProceedTask.php +++ b/src/Pipeline/Task/SelectFilesToProceedTask.php @@ -8,6 +8,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\Filter\Filter; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Psr\Log\LogLevel; class SelectFilesToProceedTask implements LoggableTask, Task @@ -32,7 +33,7 @@ public function __construct(EntityManager $entityManager, ?Filter $filter = null */ public function run(State $state): void { - $folderParameter = $state->getParameter(Task::EXTRACT_TO_FOLDER_PARAM); + $folderParameter = $state->getParameter(StateParameter::EXTRACT_TO_FOLDER); $extractToFolder = $this->checkDirectory($folderParameter); $this->log( @@ -41,7 +42,7 @@ public function run(State $state): void ); $files = $this->getFilesForProceedFromFolder($extractToFolder); - $state->setAndLockParameter(Task::FILES_TO_PROCEED, $files); + $state->setAndLockParameter(StateParameter::FILES_TO_PROCEED, $files); $this->log( LogLevel::INFO, @@ -65,7 +66,7 @@ private function checkDirectory($parameterValue): \SplFileInfo { if (!($parameterValue instanceof \SplFileInfo)) { throw new TaskException( - "State parameter '" . Task::EXTRACT_TO_FOLDER_PARAM . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." + "State parameter '" . StateParameter::EXTRACT_TO_FOLDER . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." ); } diff --git a/src/Pipeline/Task/Task.php b/src/Pipeline/Task/Task.php index 5fdbbf46..222e0e36 100644 --- a/src/Pipeline/Task/Task.php +++ b/src/Pipeline/Task/Task.php @@ -12,16 +12,6 @@ */ interface Task { - public const FIAS_VERSION_PARAM = 'fias_version'; - - public const FIAS_INFO_PARAM = 'fias_info'; - - public const DOWNLOAD_TO_FILE_PARAM = 'download_to'; - - public const EXTRACT_TO_FOLDER_PARAM = 'extract_to'; - - public const FILES_TO_PROCEED = 'files_to_proceed'; - /** * Запускает задачу на исполнение. * diff --git a/src/Pipeline/Task/UnpackTask.php b/src/Pipeline/Task/UnpackTask.php index 9adf923f..ceacd484 100644 --- a/src/Pipeline/Task/UnpackTask.php +++ b/src/Pipeline/Task/UnpackTask.php @@ -6,6 +6,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Unpacker\Unpacker; use Psr\Log\LogLevel; @@ -31,17 +32,17 @@ public function __construct(Unpacker $unpacker) */ public function run(State $state): void { - $source = $state->getParameter(Task::DOWNLOAD_TO_FILE_PARAM); + $source = $state->getParameter(StateParameter::DOWNLOAD_TO_FILE); if (!($source instanceof \SplFileInfo)) { throw new TaskException( - "State parameter '" . Task::DOWNLOAD_TO_FILE_PARAM . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." + "State parameter '" . StateParameter::DOWNLOAD_TO_FILE . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." ); } - $destination = $state->getParameter(Task::EXTRACT_TO_FOLDER_PARAM); + $destination = $state->getParameter(StateParameter::EXTRACT_TO_FOLDER); if (!($destination instanceof \SplFileInfo)) { throw new TaskException( - "State parameter '" . Task::EXTRACT_TO_FOLDER_PARAM . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." + "State parameter '" . StateParameter::EXTRACT_TO_FOLDER . "' must be an '" . \SplFileInfo::class . "' instance for '" . self::class . "'." ); } diff --git a/src/Pipeline/Task/VersionGetTask.php b/src/Pipeline/Task/VersionGetTask.php index 3b1ab59b..592e9a71 100644 --- a/src/Pipeline/Task/VersionGetTask.php +++ b/src/Pipeline/Task/VersionGetTask.php @@ -6,6 +6,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\VersionManager\VersionManager; /** @@ -34,6 +35,6 @@ public function run(State $state): void throw new TaskException('There is no version of FIAS installed.'); } - $state->setAndLockParameter(Task::FIAS_VERSION_PARAM, $version->getVersion()); + $state->setAndLockParameter(StateParameter::FIAS_VERSION, $version->getVersion()); } } diff --git a/src/Pipeline/Task/VersionSetTask.php b/src/Pipeline/Task/VersionSetTask.php index cb40bdb0..bf4fc27c 100644 --- a/src/Pipeline/Task/VersionSetTask.php +++ b/src/Pipeline/Task/VersionSetTask.php @@ -6,6 +6,7 @@ use Liquetsoft\Fias\Component\FiasInformer\InformerResponse; use Liquetsoft\Fias\Component\Pipeline\State\State; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\VersionManager\VersionManager; /** @@ -28,7 +29,7 @@ public function __construct(VersionManager $versionManager) */ public function run(State $state): void { - $version = $state->getParameter(Task::FIAS_INFO_PARAM); + $version = $state->getParameter(StateParameter::FIAS_INFO); if ($version instanceof InformerResponse && $version->hasResult()) { $this->versionManager->setCurrentVersion($version); diff --git a/tests/src/Downloader/CurlDownloaderTest.php b/tests/src/Downloader/CurlDownloaderTest.php index 58fc554a..70e073fe 100644 --- a/tests/src/Downloader/CurlDownloaderTest.php +++ b/tests/src/Downloader/CurlDownloaderTest.php @@ -33,9 +33,9 @@ public function testDownload(): void function (array $options) use ($source) { if ( !empty($options[\CURLOPT_HEADER]) - || $options[\CURLOPT_URL] === $source - && \is_resource($options[\CURLOPT_FILE]) - && !empty($options[\CURLOPT_CONNECT_ONLY]) + || ($options[\CURLOPT_URL] === $source + && \is_resource($options[\CURLOPT_FILE]) + && !empty($options[\CURLOPT_CONNECT_ONLY])) ) { return [200, '', null]; } diff --git a/tests/src/Pipeline/Task/CleanupTaskTest.php b/tests/src/Pipeline/Task/CleanupTaskTest.php index d7bab61d..c03a27e6 100644 --- a/tests/src/Pipeline/Task/CleanupTaskTest.php +++ b/tests/src/Pipeline/Task/CleanupTaskTest.php @@ -4,8 +4,8 @@ namespace Liquetsoft\Fias\Component\Tests\Pipeline\Task; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\CleanupTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Tests\BaseCase; /** @@ -32,8 +32,8 @@ public function testRun(): void $state = $this->createDefaultStateMock( [ - Task::DOWNLOAD_TO_FILE_PARAM => $downloadTo, - Task::EXTRACT_TO_FOLDER_PARAM => $extractTo, + StateParameter::DOWNLOAD_TO_FILE => $downloadTo, + StateParameter::EXTRACT_TO_FOLDER => $extractTo, ] ); @@ -56,7 +56,7 @@ public function testRunEmptyFiles(): void $state = $this->createDefaultStateMock( [ - Task::DOWNLOAD_TO_FILE_PARAM => $downloadTo, + StateParameter::DOWNLOAD_TO_FILE => $downloadTo, ] ); diff --git a/tests/src/Pipeline/Task/DataDeleteTaskTest.php b/tests/src/Pipeline/Task/DataDeleteTaskTest.php index d0471f5e..02dc686d 100644 --- a/tests/src/Pipeline/Task/DataDeleteTaskTest.php +++ b/tests/src/Pipeline/Task/DataDeleteTaskTest.php @@ -6,8 +6,8 @@ use Liquetsoft\Fias\Component\EntityDescriptor\EntityDescriptor; use Liquetsoft\Fias\Component\EntityManager\EntityManager; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\DataDeleteTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Serializer\FiasSerializer; use Liquetsoft\Fias\Component\Storage\Storage; use Liquetsoft\Fias\Component\Tests\BaseCase; @@ -67,7 +67,7 @@ function (DataDeleteTaskMock $object) use (&$insertedData): void { $state = $this->createDefaultStateMock( [ - Task::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], + StateParameter::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], ] ); diff --git a/tests/src/Pipeline/Task/DataInsertTaskTest.php b/tests/src/Pipeline/Task/DataInsertTaskTest.php index dc1fd331..d242a0fc 100644 --- a/tests/src/Pipeline/Task/DataInsertTaskTest.php +++ b/tests/src/Pipeline/Task/DataInsertTaskTest.php @@ -7,8 +7,8 @@ use Liquetsoft\Fias\Component\EntityDescriptor\EntityDescriptor; use Liquetsoft\Fias\Component\EntityManager\EntityManager; use Liquetsoft\Fias\Component\Exception\TaskException; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\DataInsertTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Serializer\FiasSerializer; use Liquetsoft\Fias\Component\Storage\Storage; use Liquetsoft\Fias\Component\Tests\BaseCase; @@ -69,7 +69,7 @@ function (DataInsertTaskMock $object) use (&$insertedData): void { $state = $this->createDefaultStateMock( [ - Task::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], + StateParameter::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], ] ); @@ -124,7 +124,7 @@ function (DataInsertTaskMock $object) use (&$insertedData): void { $state = $this->createDefaultStateMock( [ - Task::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], + StateParameter::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], ] ); @@ -186,7 +186,7 @@ function (DataInsertTaskMock $object) use (&$insertedData): void { $state = $this->createDefaultStateMock( [ - Task::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], + StateParameter::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], ] ); diff --git a/tests/src/Pipeline/Task/DataUpsertTaskTest.php b/tests/src/Pipeline/Task/DataUpsertTaskTest.php index 5d87e290..33e07cb7 100644 --- a/tests/src/Pipeline/Task/DataUpsertTaskTest.php +++ b/tests/src/Pipeline/Task/DataUpsertTaskTest.php @@ -6,8 +6,8 @@ use Liquetsoft\Fias\Component\EntityDescriptor\EntityDescriptor; use Liquetsoft\Fias\Component\EntityManager\EntityManager; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\DataUpsertTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Serializer\FiasSerializer; use Liquetsoft\Fias\Component\Storage\Storage; use Liquetsoft\Fias\Component\Tests\BaseCase; @@ -67,7 +67,7 @@ function (DataUpsertTaskMock $object) use (&$insertedData): void { $state = $this->createDefaultStateMock( [ - Task::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], + StateParameter::FILES_TO_PROCEED => [__DIR__ . '/_fixtures/data.xml'], ] ); diff --git a/tests/src/Pipeline/Task/DownloadTaskTest.php b/tests/src/Pipeline/Task/DownloadTaskTest.php index a69fb5e2..ca1fa5cd 100644 --- a/tests/src/Pipeline/Task/DownloadTaskTest.php +++ b/tests/src/Pipeline/Task/DownloadTaskTest.php @@ -7,8 +7,8 @@ use Liquetsoft\Fias\Component\Downloader\Downloader; use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\FiasInformer\InformerResponse; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\DownloadTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Tests\BaseCase; use PHPUnit\Framework\MockObject\MockObject; @@ -49,8 +49,8 @@ function (\SplFileInfo $file) use ($filePath) { $state = $this->createDefaultStateMock( [ - Task::FIAS_INFO_PARAM => $informerResult, - Task::DOWNLOAD_TO_FILE_PARAM => $file, + StateParameter::FIAS_INFO => $informerResult, + StateParameter::DOWNLOAD_TO_FILE => $file, ] ); @@ -71,7 +71,7 @@ public function testRunNoFiasInfoException(): void $state = $this->createDefaultStateMock( [ - Task::DOWNLOAD_TO_FILE_PARAM => new \SplFileInfo(__DIR__ . '/test.file'), + StateParameter::DOWNLOAD_TO_FILE => new \SplFileInfo(__DIR__ . '/test.file'), ] ); @@ -97,7 +97,7 @@ public function testRunNoDownloadToInfoException(): void $state = $this->createDefaultStateMock( [ - Task::FIAS_INFO_PARAM => $informerResult, + StateParameter::FIAS_INFO => $informerResult, ] ); diff --git a/tests/src/Pipeline/Task/InformDeltaTaskTest.php b/tests/src/Pipeline/Task/InformDeltaTaskTest.php index 2afcfa5b..cc2f7e8d 100644 --- a/tests/src/Pipeline/Task/InformDeltaTaskTest.php +++ b/tests/src/Pipeline/Task/InformDeltaTaskTest.php @@ -8,8 +8,8 @@ use Liquetsoft\Fias\Component\FiasInformer\FiasInformer; use Liquetsoft\Fias\Component\FiasInformer\InformerResponse; use Liquetsoft\Fias\Component\Pipeline\State\ArrayState; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\InformDeltaTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Tests\BaseCase; use PHPUnit\Framework\MockObject\MockObject; @@ -39,12 +39,12 @@ public function testRun(): void $informer->method('getDeltaInfo')->with($this->equalTo($version))->willReturn($informerResult); $state = new ArrayState(); - $state->setAndLockParameter(Task::FIAS_VERSION_PARAM, $version); + $state->setAndLockParameter(StateParameter::FIAS_VERSION, $version); $task = new InformDeltaTask($informer); $task->run($state); - $this->assertSame($informerResult, $state->getParameter(Task::FIAS_INFO_PARAM)); + $this->assertSame($informerResult, $state->getParameter(StateParameter::FIAS_INFO)); } /** @@ -83,11 +83,11 @@ public function testRunNoResponseComplete(): void $informer->method('getDeltaInfo')->with($this->equalTo($version))->willReturn($informerResult); $state = new ArrayState(); - $state->setAndLockParameter(Task::FIAS_VERSION_PARAM, $version); + $state->setAndLockParameter(StateParameter::FIAS_VERSION, $version); $task = new InformDeltaTask($informer); $task->run($state); - $this->assertSame($informerResult, $state->getParameter(Task::FIAS_INFO_PARAM)); + $this->assertSame($informerResult, $state->getParameter(StateParameter::FIAS_INFO)); } } diff --git a/tests/src/Pipeline/Task/InformFullTaskTest.php b/tests/src/Pipeline/Task/InformFullTaskTest.php index d3e86869..7b644de7 100644 --- a/tests/src/Pipeline/Task/InformFullTaskTest.php +++ b/tests/src/Pipeline/Task/InformFullTaskTest.php @@ -8,8 +8,8 @@ use Liquetsoft\Fias\Component\FiasInformer\FiasInformer; use Liquetsoft\Fias\Component\FiasInformer\InformerResponse; use Liquetsoft\Fias\Component\Pipeline\State\ArrayState; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\InformFullTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Tests\BaseCase; use PHPUnit\Framework\MockObject\MockObject; @@ -41,7 +41,7 @@ public function testRun(): void $task = new InformFullTask($informer); $task->run($state); - $this->assertSame($informerResult, $state->getParameter(Task::FIAS_INFO_PARAM)); + $this->assertSame($informerResult, $state->getParameter(StateParameter::FIAS_INFO)); } /** diff --git a/tests/src/Pipeline/Task/PrepareFolderTaskTest.php b/tests/src/Pipeline/Task/PrepareFolderTaskTest.php index 8c59a587..681d6ab9 100644 --- a/tests/src/Pipeline/Task/PrepareFolderTaskTest.php +++ b/tests/src/Pipeline/Task/PrepareFolderTaskTest.php @@ -5,8 +5,8 @@ namespace Liquetsoft\Fias\Component\Tests\Pipeline\Task; use Liquetsoft\Fias\Component\Pipeline\State\ArrayState; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\PrepareFolderTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Tests\BaseCase; /** @@ -30,8 +30,8 @@ public function testRun(): void $task = new PrepareFolderTask($pathToPrepare); $task->run($state); - $downloadFile = $state->getParameter(Task::DOWNLOAD_TO_FILE_PARAM); - $extractToFolder = $state->getParameter(Task::EXTRACT_TO_FOLDER_PARAM); + $downloadFile = $state->getParameter(StateParameter::DOWNLOAD_TO_FILE); + $extractToFolder = $state->getParameter(StateParameter::EXTRACT_TO_FOLDER); $this->assertInstanceOf(\SplFileInfo::class, $downloadFile); $this->assertInstanceOf(\SplFileInfo::class, $extractToFolder); diff --git a/tests/src/Pipeline/Task/SaveFiasFilesTaskTest.php b/tests/src/Pipeline/Task/SaveFiasFilesTaskTest.php index 2538e319..eeb8e373 100644 --- a/tests/src/Pipeline/Task/SaveFiasFilesTaskTest.php +++ b/tests/src/Pipeline/Task/SaveFiasFilesTaskTest.php @@ -4,8 +4,8 @@ namespace Liquetsoft\Fias\Component\Tests\Pipeline\Task; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\SaveFiasFilesTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Tests\BaseCase; /** @@ -32,8 +32,8 @@ public function testRun(): void $state = $this->createDefaultStateMock( [ - Task::DOWNLOAD_TO_FILE_PARAM => new \SplFileInfo($sourceFile), - Task::EXTRACT_TO_FOLDER_PARAM => new \SplFileInfo($sourceDir), + StateParameter::DOWNLOAD_TO_FILE => new \SplFileInfo($sourceFile), + StateParameter::EXTRACT_TO_FOLDER => new \SplFileInfo($sourceDir), ] ); diff --git a/tests/src/Pipeline/Task/SelectFilesToProceedTaskTest.php b/tests/src/Pipeline/Task/SelectFilesToProceedTaskTest.php index af0182e7..b7c29fed 100644 --- a/tests/src/Pipeline/Task/SelectFilesToProceedTaskTest.php +++ b/tests/src/Pipeline/Task/SelectFilesToProceedTaskTest.php @@ -9,8 +9,8 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\Filter\Filter; use Liquetsoft\Fias\Component\Pipeline\State\ArrayState; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\SelectFilesToProceedTask; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; use Liquetsoft\Fias\Component\Tests\BaseCase; use PHPUnit\Framework\MockObject\MockObject; @@ -50,7 +50,7 @@ public function testRunNonExitedUnpackToException(): void $state = $this->createDefaultStateMock( [ - Task::EXTRACT_TO_FOLDER_PARAM => new \SplFileInfo(__DIR__ . '/test'), + StateParameter::EXTRACT_TO_FOLDER => new \SplFileInfo(__DIR__ . '/test'), ] ); @@ -93,7 +93,7 @@ public function testRun(): void ); $state = new ArrayState(); - $state->setAndLockParameter(Task::EXTRACT_TO_FOLDER_PARAM, new \SplFileInfo($fixturesFolder)); + $state->setAndLockParameter(StateParameter::EXTRACT_TO_FOLDER, new \SplFileInfo($fixturesFolder)); $task = new SelectFilesToProceedTask($entityManager); $task->run($state); @@ -105,7 +105,7 @@ public function testRun(): void $fixturesFolder . '/nested/SelectFilesToProceedTaskTest_nested_delete.xml', $fixturesFolder . '/nested/SelectFilesToProceedTaskTest_nested_insert.xml', ], - $state->getParameter(Task::FILES_TO_PROCEED) + $state->getParameter(StateParameter::FILES_TO_PROCEED) ); } @@ -143,7 +143,7 @@ function (\SplFileInfo $file) use ($fixturesFolder) { ); $state = new ArrayState(); - $state->setAndLockParameter(Task::EXTRACT_TO_FOLDER_PARAM, new \SplFileInfo($fixturesFolder)); + $state->setAndLockParameter(StateParameter::EXTRACT_TO_FOLDER, new \SplFileInfo($fixturesFolder)); $task = new SelectFilesToProceedTask($entityManager, $filter); $task->run($state); @@ -152,7 +152,7 @@ function (\SplFileInfo $file) use ($fixturesFolder) { [ $fixturesFolder . '/nested/SelectFilesToProceedTaskTest_nested_insert.xml', ], - $state->getParameter(Task::FILES_TO_PROCEED) + $state->getParameter(StateParameter::FILES_TO_PROCEED) ); } } diff --git a/tests/src/Pipeline/Task/UnpackTaskTest.php b/tests/src/Pipeline/Task/UnpackTaskTest.php index 2846a214..1ed6f228 100644 --- a/tests/src/Pipeline/Task/UnpackTaskTest.php +++ b/tests/src/Pipeline/Task/UnpackTaskTest.php @@ -5,7 +5,7 @@ namespace Liquetsoft\Fias\Component\Tests\Pipeline\Task; use Liquetsoft\Fias\Component\Exception\TaskException; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\UnpackTask; use Liquetsoft\Fias\Component\Tests\BaseCase; use Liquetsoft\Fias\Component\Unpacker\Unpacker; @@ -49,8 +49,8 @@ function (\SplFileInfo $destination) use ($destinationPath) { $state = $this->createDefaultStateMock( [ - Task::DOWNLOAD_TO_FILE_PARAM => $source, - Task::EXTRACT_TO_FOLDER_PARAM => $destination, + StateParameter::DOWNLOAD_TO_FILE => $source, + StateParameter::EXTRACT_TO_FOLDER => $destination, ] ); @@ -73,7 +73,7 @@ public function testRunNoSourceException(): void $state = $this->createDefaultStateMock( [ - Task::EXTRACT_TO_FOLDER_PARAM => $destination, + StateParameter::EXTRACT_TO_FOLDER => $destination, ] ); @@ -97,7 +97,7 @@ public function testRunNoDestinationException(): void $state = $this->createDefaultStateMock( [ - Task::DOWNLOAD_TO_FILE_PARAM => $source, + StateParameter::DOWNLOAD_TO_FILE => $source, ] ); diff --git a/tests/src/Pipeline/Task/VersionGetTaskTest.php b/tests/src/Pipeline/Task/VersionGetTaskTest.php index e583e3d8..c6101c42 100644 --- a/tests/src/Pipeline/Task/VersionGetTaskTest.php +++ b/tests/src/Pipeline/Task/VersionGetTaskTest.php @@ -7,7 +7,7 @@ use Liquetsoft\Fias\Component\Exception\TaskException; use Liquetsoft\Fias\Component\FiasInformer\InformerResponse; use Liquetsoft\Fias\Component\Pipeline\State\ArrayState; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\VersionGetTask; use Liquetsoft\Fias\Component\Tests\BaseCase; use Liquetsoft\Fias\Component\VersionManager\VersionManager; @@ -44,7 +44,7 @@ public function testRun(): void $task = new VersionGetTask($versionManager); $task->run($state); - $this->assertSame($version, $state->getParameter(Task::FIAS_VERSION_PARAM)); + $this->assertSame($version, $state->getParameter(StateParameter::FIAS_VERSION)); } /** diff --git a/tests/src/Pipeline/Task/VersionSetTaskTest.php b/tests/src/Pipeline/Task/VersionSetTaskTest.php index e6b750cc..852b8906 100644 --- a/tests/src/Pipeline/Task/VersionSetTaskTest.php +++ b/tests/src/Pipeline/Task/VersionSetTaskTest.php @@ -5,7 +5,7 @@ namespace Liquetsoft\Fias\Component\Tests\Pipeline\Task; use Liquetsoft\Fias\Component\FiasInformer\InformerResponse; -use Liquetsoft\Fias\Component\Pipeline\Task\Task; +use Liquetsoft\Fias\Component\Pipeline\State\StateParameter; use Liquetsoft\Fias\Component\Pipeline\Task\VersionSetTask; use Liquetsoft\Fias\Component\Tests\BaseCase; use Liquetsoft\Fias\Component\VersionManager\VersionManager; @@ -35,7 +35,7 @@ public function testRun(): void $state = $this->createDefaultStateMock( [ - Task::FIAS_INFO_PARAM => $response, + StateParameter::FIAS_INFO => $response, ] ); @@ -64,7 +64,7 @@ public function testRunNoResult(): void $state = $this->createDefaultStateMock( [ - Task::FIAS_INFO_PARAM => $response, + StateParameter::FIAS_INFO => $response, ] );