Skip to content

Commit ad0f3be

Browse files
committed
Upgraded PHP version, migrated from phpspec to phpunit
1 parent 672990b commit ad0f3be

13 files changed

+111
-165
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
* text=auto
22

33
/spec export-ignore
4+
/src/*Test.php export-ignore
45
/stub export-ignore
56
/.gitattributes export-ignore
67
/.gitignore export-ignore

.github/workflows/quality-assurance.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,19 @@ on:
2020

2121
jobs:
2222
phpunit:
23-
name: PHPUnit tests on ${{ matrix.php }} ${{ matrix.composer-flags }}
23+
name: PHPUnit tests on ${{ matrix.php }}
2424
runs-on: ubuntu-latest
2525
continue-on-error: ${{ matrix.experimental }}
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
30-
composer-flags: [ '' ]
29+
php: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
3130
experimental: [false]
32-
phpunit-flags: [ '--coverage-text' ]
3331
steps:
3432
- uses: actions/checkout@v3
3533
- uses: shivammathur/setup-php@v2
3634
with:
3735
php-version: ${{ matrix.php }}
38-
coverage: pcov
3936
tools: composer:v2
40-
- run: composer update --no-progress ${{ matrix.composer-flags }}
37+
- run: composer update --no-progress
4138
- run: composer test

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@
2828
}
2929
},
3030
"require": {
31-
"php": ">=7.1"
31+
"php": "^8.0"
3232
},
3333
"scripts": {
34-
"test": "phpspec run"
34+
"test": "phpunit src"
3535
},
3636
"require-dev": {
37-
"phpspec/phpspec": ">=4.3",
38-
"friends-of-phpspec/phpspec-code-coverage": ">=4.3"
37+
"phpunit/phpunit": "^11.5"
3938
}
4039
}

spec/FingersCrossedProcessorSpec.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

spec/InterruptibleProcessorSpec.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

spec/PipelineBuilderSpec.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

spec/PipelineSpec.php

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace League\Pipeline;
5+
6+
use PHPUnit\Framework\Attributes\Test;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class FingersCrossedProcessorTest extends TestCase
10+
{
11+
#[Test]
12+
public function it_can_process_stages(): void
13+
{
14+
$pipeline = new FingersCrossedProcessor();
15+
16+
$result = $pipeline->process(
17+
2,
18+
function ($payload) { return $payload * 2; },
19+
function ($payload) { return $payload + 1; }
20+
);
21+
22+
self::assertEquals(5, $result);
23+
}
24+
}

src/InterruptibleProcessorTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace League\Pipeline;
5+
6+
use PHPUnit\Framework\Attributes\Test;
7+
use PHPUnit\Framework\TestCase;
8+
9+
class InterruptibleProcessorTest extends TestCase
10+
{
11+
#[Test]
12+
public function it_can_process_stages(): void
13+
{
14+
$pipeline = new InterruptibleProcessor(function ($payload) {
15+
return $payload < 3;
16+
});
17+
18+
$result = $pipeline->process(
19+
2,
20+
function ($payload) { return $payload * 2; },
21+
function ($payload) { return $payload + 1; }
22+
);
23+
24+
self::assertEquals(4, $result);
25+
}
26+
}

src/Pipeline.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,19 @@ class Pipeline implements PipelineInterface
88
/**
99
* @var callable[]
1010
*/
11-
private $stages = [];
11+
private array $stages;
12+
private ProcessorInterface $processor;
1213

13-
/**
14-
* @var ProcessorInterface
15-
*/
16-
private $processor;
17-
18-
public function __construct(ProcessorInterface $processor = null, callable ...$stages)
14+
public function __construct(?ProcessorInterface $processor = null, callable ...$stages)
1915
{
2016
$this->processor = $processor ?? new FingersCrossedProcessor;
2117
$this->stages = $stages;
2218
}
2319

24-
public function pipe(callable $stage): PipelineInterface
20+
public function pipe(callable $operation): PipelineInterface
2521
{
2622
$pipeline = clone $this;
27-
$pipeline->stages[] = $stage;
23+
$pipeline->stages[] = $operation;
2824

2925
return $pipeline;
3026
}

0 commit comments

Comments
 (0)