Skip to content

Commit 199e0c2

Browse files
Merge pull request #1 from nopenopenope/readme-adaption
Adapt Readme, add test and add flow for workflow.
2 parents 93bb6bd + 63995df commit 199e0c2

File tree

10 files changed

+90
-5
lines changed

10 files changed

+90
-5
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ jobs:
4343
run: "composer install --no-interaction --no-progress --no-suggest"
4444

4545
- name: "EasyCodingStandards for src"
46-
run: "vendor/bin/ecs check src --no-interaction --no-progress-bar"
46+
run: "vendor/bin/ecs check src tests --no-interaction --no-progress-bar"
4747

4848
- name: "PhpStan for src"
4949
run: "vendor/bin/phpstan analyse --error-format=checkstyle src --level=8 | cs2pr"
50+
51+
- name: "PhpStan for tests"
52+
run: "vendor/bin/phpstan analyse --error-format=checkstyle tests --level=6 | cs2pr"
53+
54+
- name: "PHPUnit Test"
55+
run: "vendor/bin/phpunit tests/BaseTest.php"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/vendor
2+
/.idea

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/phpunit.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Another example for automatic replacement in correctly formatted code:
5151
becomes
5252

5353
```php
54-
->with(...$this->consecutiveParams(
54+
->with(...$this->withConsecutive(
5555
['a', 'b'],
5656
['c', 'd'],
5757
['e', 'f']

composer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
"name": "seec/phpunit-consecutive-params",
33
"type": "library",
44
"description": "Drop-in Trait to use removed ConsecutiveParams from PhpUnit",
5-
"keywords": ["phpunit","tdd","unit testing","variadic", "consecutive params"],
5+
"keywords": [
6+
"phpunit",
7+
"tdd",
8+
"unit testing",
9+
"variadic",
10+
"consecutive params"
11+
],
612
"homepage": "https://github.com/nopenopenope/behat-test-runner",
713
"license": "GPL-3.0-or-later",
814
"minimum-stability": "dev",
@@ -15,7 +21,7 @@
1521
}
1622
],
1723
"require": {
18-
"php" : "^8.0"
24+
"php": "^8.0"
1925
},
2026
"require-dev": {
2127
"phpstan/phpstan": "^1.10",
@@ -26,5 +32,10 @@
2632
"psr-4": {
2733
"SEEC\\PhpUnit\\Helper\\": "src"
2834
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"SEEC\\PhpUnit\\Helper\\Tests\\": "tests"
39+
}
2940
}
3041
}

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ services:
1111
- "host.docker.internal:host-gateway"
1212
volumes:
1313
- ./src:/var/www/html/src
14+
- ./tests:/var/www/html/tests
1415
- ./vendor:/var/www/html/vendor
1516
- ./composer.json:/var/www/html/composer.json

docker/php/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RUN apk add -u \
1717

1818
COPY ./composer.json /var/www/html/composer.json
1919
COPY ./src /var/www/html/src
20+
COPY ./tests /var/www/html/tests
2021
COPY ./ecs.php /var/www/html/ecs.php
2122
COPY ./phpstan.neon /var/www/html/phpstan.neon
2223

src/ConsecutiveParams.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
namespace SEEC\PhpUnit\Helper;
66

7-
use PHPUnit\Framework\TestCase;
87
use function array_column;
98
use function count;
109
use PHPUnit\Framework\Constraint\Callback;
1110
use PHPUnit\Framework\Constraint\Constraint;
11+
use PHPUnit\Framework\TestCase;
1212

1313
trait ConsecutiveParams
1414
{

tests/BaseTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SEEC\PhpUnit\Helper\Tests;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use SEEC\PhpUnit\Helper\ConsecutiveParams;
9+
10+
final class TestableClass
11+
{
12+
public function foo(object $testClass): void
13+
{
14+
$testClass->setSomething(1);
15+
$testClass->setSomething(2);
16+
}
17+
}
18+
19+
final class InputClass implements InputInterface
20+
{
21+
public function setSomething(int $i): void
22+
{
23+
}
24+
}
25+
26+
interface InputInterface
27+
{
28+
public function setSomething(int $i): void;
29+
}
30+
31+
final class BaseTest extends TestCase
32+
{
33+
use ConsecutiveParams;
34+
35+
public function test_it_can_run_a_test(): void
36+
{
37+
$mockClass = $this->getMockBuilder(InputInterface::class)
38+
->onlyMethods(['setSomething'])
39+
->getMock();
40+
$mockClass->expects($this->exactly(2))
41+
->method('setSomething')
42+
->with(...$this->withConsecutive(
43+
[1],
44+
[2]
45+
));
46+
$testClass = new TestableClass();
47+
$testClass->foo($mockClass);
48+
}
49+
}

0 commit comments

Comments
 (0)