From 59df0914e79d4792b34a039feb0e9075fdbdc7a9 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 21 Nov 2023 14:14:42 +0100 Subject: [PATCH] Updated the pipeline runner used for tests --- composer.lock | 8 ++++---- src/CSV/FingersCrossed/Extractor.php | 3 +-- src/CSV/FingersCrossed/Loader.php | 7 +++---- src/CSV/Safe/Extractor.php | 3 +-- src/CSV/Safe/Loader.php | 7 +++---- src/Sheet/FingersCrossed/Extractor.php | 3 +-- src/Sheet/FingersCrossed/Loader.php | 4 ++-- src/Sheet/Safe/Extractor.php | 3 +-- src/Sheet/Safe/Loader.php | 4 ++-- tests/functional/PipelineRunner.php | 17 ++++++----------- 10 files changed, 24 insertions(+), 35 deletions(-) diff --git a/composer.lock b/composer.lock index 9744343..6469adc 100644 --- a/composer.lock +++ b/composer.lock @@ -1937,12 +1937,12 @@ "source": { "type": "git", "url": "https://github.com/php-etl/phpunit-extension.git", - "reference": "fd1758d8fc3d353de2b3f4e9ba0c1e7af92b19f3" + "reference": "5a612872d8a7275adc31be2c8f2f625d341b5326" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-etl/phpunit-extension/zipball/fd1758d8fc3d353de2b3f4e9ba0c1e7af92b19f3", - "reference": "fd1758d8fc3d353de2b3f4e9ba0c1e7af92b19f3", + "url": "https://api.github.com/repos/php-etl/phpunit-extension/zipball/5a612872d8a7275adc31be2c8f2f625d341b5326", + "reference": "5a612872d8a7275adc31be2c8f2f625d341b5326", "shasum": "" }, "require": { @@ -1989,7 +1989,7 @@ "issues": "https://github.com/php-etl/phpunit-extension/issues", "source": "https://github.com/php-etl/phpunit-extension/tree/main" }, - "time": "2023-11-16T15:32:17+00:00" + "time": "2023-11-21T12:56:00+00:00" }, { "name": "php-http/client-common", diff --git a/src/CSV/FingersCrossed/Extractor.php b/src/CSV/FingersCrossed/Extractor.php index 5a7a1dd..ecc1927 100644 --- a/src/CSV/FingersCrossed/Extractor.php +++ b/src/CSV/FingersCrossed/Extractor.php @@ -18,8 +18,7 @@ public function __construct( private ReaderInterface $reader, private int $skipLines = 0, private LoggerInterface $logger = new NullLogger() - ) { - } + ) {} public function extract(): iterable { diff --git a/src/CSV/FingersCrossed/Loader.php b/src/CSV/FingersCrossed/Loader.php index 7ec9185..8a655bf 100644 --- a/src/CSV/FingersCrossed/Loader.php +++ b/src/CSV/FingersCrossed/Loader.php @@ -22,8 +22,7 @@ public function __construct( private WriterInterface $writer, private LoggerInterface $logger = new NullLogger() - ) { - } + ) {} public function load(): \Generator { @@ -32,7 +31,7 @@ public function load(): \Generator $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null) ); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); return; @@ -43,7 +42,7 @@ public function load(): \Generator $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), $line), null) ); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); } diff --git a/src/CSV/Safe/Extractor.php b/src/CSV/Safe/Extractor.php index 5aca5c0..0b0021b 100644 --- a/src/CSV/Safe/Extractor.php +++ b/src/CSV/Safe/Extractor.php @@ -18,8 +18,7 @@ public function __construct( private ReaderInterface $reader, private int $skipLines = 0, private LoggerInterface $logger = new NullLogger() - ) { - } + ) {} public function extract(): iterable { diff --git a/src/CSV/Safe/Loader.php b/src/CSV/Safe/Loader.php index cd88354..27e0ca7 100644 --- a/src/CSV/Safe/Loader.php +++ b/src/CSV/Safe/Loader.php @@ -22,8 +22,7 @@ public function __construct( private WriterInterface $writer, private LoggerInterface $logger = new NullLogger() - ) { - } + ) {} public function load(): \Generator { @@ -33,7 +32,7 @@ public function load(): \Generator $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null) ); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); return; @@ -42,7 +41,7 @@ public function load(): \Generator while (true) { try { $this->writer->addRow($this->orderColumns($headers, $line)); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); } diff --git a/src/Sheet/FingersCrossed/Extractor.php b/src/Sheet/FingersCrossed/Extractor.php index 6ba9d0a..37d643d 100644 --- a/src/Sheet/FingersCrossed/Extractor.php +++ b/src/Sheet/FingersCrossed/Extractor.php @@ -21,8 +21,7 @@ public function __construct( private string $sheetName, private int $skipLines = 0, private LoggerInterface $logger = new NullLogger() - ) { - } + ) {} public function extract(): iterable { diff --git a/src/Sheet/FingersCrossed/Loader.php b/src/Sheet/FingersCrossed/Loader.php index dcdc77e..3bcbe1f 100644 --- a/src/Sheet/FingersCrossed/Loader.php +++ b/src/Sheet/FingersCrossed/Loader.php @@ -36,7 +36,7 @@ public function load(): \Generator $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null) ); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); return; @@ -47,7 +47,7 @@ public function load(): \Generator $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), $line), null) ); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); } diff --git a/src/Sheet/Safe/Extractor.php b/src/Sheet/Safe/Extractor.php index 62a9c1e..949312c 100644 --- a/src/Sheet/Safe/Extractor.php +++ b/src/Sheet/Safe/Extractor.php @@ -21,8 +21,7 @@ public function __construct( private string $sheetName, private int $skipLines = 0, private LoggerInterface $logger = new NullLogger() - ) { - } + ) {} public function extract(): iterable { diff --git a/src/Sheet/Safe/Loader.php b/src/Sheet/Safe/Loader.php index d00e6b5..7b8dac6 100644 --- a/src/Sheet/Safe/Loader.php +++ b/src/Sheet/Safe/Loader.php @@ -36,7 +36,7 @@ public function load(): \Generator $this->writer->addRow( new Row(array_map(fn ($value) => new Cell($value), array_keys($line)), null) ); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); return; @@ -45,7 +45,7 @@ public function load(): \Generator while (true) { try { $this->writer->addRow($this->orderColumns($headers, $line)); - } catch (WriterNotOpenedException|IOException $exception) { + } catch (IOException|WriterNotOpenedException $exception) { $this->logger->error('Impossible to load data to the given CSV file.', ['line' => $line, 'message' => $exception->getMessage(), 'previous' => $exception->getPrevious()]); } diff --git a/tests/functional/PipelineRunner.php b/tests/functional/PipelineRunner.php index a6058a1..060dc00 100644 --- a/tests/functional/PipelineRunner.php +++ b/tests/functional/PipelineRunner.php @@ -7,20 +7,18 @@ use Kiboko\Contract\Bucket\AcceptanceResultBucketInterface; use Kiboko\Contract\Bucket\RejectionResultBucketInterface; use Kiboko\Contract\Pipeline\PipelineRunnerInterface; -use Kiboko\Contract\Pipeline\RejectionInterface; -use Kiboko\Contract\Pipeline\StateInterface; +use Kiboko\Contract\Pipeline\StepRejectionInterface; +use Kiboko\Contract\Pipeline\StepStateInterface; final class PipelineRunner implements PipelineRunnerInterface { public function run( \Iterator $source, \Generator $async, - RejectionInterface $rejection, - StateInterface $state, - ): \Iterator { - $state->initialize(); - $rejection->initialize(); - + StepRejectionInterface $rejection, + StepStateInterface $state, + ): \Iterator + { $source->rewind(); $async->rewind(); @@ -40,8 +38,5 @@ public function run( $source->next(); } - - $rejection->teardown(); - $state->teardown(); } }