Skip to content

Commit

Permalink
Updated the pipeline runner used for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Nov 21, 2023
1 parent c340893 commit 59df091
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 35 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/CSV/FingersCrossed/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public function __construct(
private ReaderInterface $reader,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
7 changes: 3 additions & 4 deletions src/CSV/FingersCrossed/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
public function __construct(
private WriterInterface $writer,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function load(): \Generator
{
Expand All @@ -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;
Expand All @@ -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()]);
}

Expand Down
3 changes: 1 addition & 2 deletions src/CSV/Safe/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public function __construct(
private ReaderInterface $reader,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
7 changes: 3 additions & 4 deletions src/CSV/Safe/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
public function __construct(
private WriterInterface $writer,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function load(): \Generator
{
Expand All @@ -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;
Expand All @@ -42,7 +41,7 @@ public function load(): \Generator
while (true) {

Check failure on line 41 in src/CSV/Safe/Loader.php

View workflow job for this annotation

GitHub Actions / phpstan

While loop condition is always true.

Check failure on line 41 in src/CSV/Safe/Loader.php

View workflow job for this annotation

GitHub Actions / phpstan

While loop condition is always true.

Check failure on line 41 in src/CSV/Safe/Loader.php

View workflow job for this annotation

GitHub Actions / phpstan

While loop condition is always true.

Check failure on line 41 in src/CSV/Safe/Loader.php

View workflow job for this annotation

GitHub Actions / phpstan

While loop condition is always true.

Check failure on line 41 in src/CSV/Safe/Loader.php

View workflow job for this annotation

GitHub Actions / phpstan

While loop condition is always 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()]);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Sheet/FingersCrossed/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public function __construct(
private string $sheetName,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sheet/FingersCrossed/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()]);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Sheet/Safe/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public function __construct(
private string $sheetName,
private int $skipLines = 0,
private LoggerInterface $logger = new NullLogger()
) {
}
) {}

public function extract(): iterable
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sheet/Safe/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,7 +45,7 @@ public function load(): \Generator
while (true) {

Check failure on line 45 in src/Sheet/Safe/Loader.php

View workflow job for this annotation

GitHub Actions / phpstan

While loop condition is always true.

Check failure on line 45 in src/Sheet/Safe/Loader.php

View workflow job for this annotation

GitHub Actions / phpstan

While loop condition is always 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()]);
}

Expand Down
17 changes: 6 additions & 11 deletions tests/functional/PipelineRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -40,8 +38,5 @@ public function run(

$source->next();
}

$rejection->teardown();
$state->teardown();
}
}

0 comments on commit 59df091

Please sign in to comment.