Skip to content

Commit 990f8d7

Browse files
committed
Attempt at making it compatible with PHPUnit 12
1 parent eedc4ae commit 990f8d7

22 files changed

+401
-230
lines changed

.github/workflows/php.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: PHP CI
22

3-
on: [pull_request, push]
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
47

58
jobs:
69
build-test:
@@ -59,6 +62,30 @@ jobs:
5962
- { php-version: "8.4", symfony-version: "7.1", phpunit-version: "10" }
6063
- { php-version: "8.4", symfony-version: "7.2", phpunit-version: "10" }
6164

65+
#- { php-version: "8.3", symfony-version: "6.1", phpunit-version: "11" } # Apparently conflicts with nikic/php-parser
66+
#- { php-version: "8.3", symfony-version: "6.2", phpunit-version: "11" } # Apparently conflicts with nikic/php-parser
67+
- { php-version: "8.3", symfony-version: "6.3", phpunit-version: "11" }
68+
- { php-version: "8.3", symfony-version: "6.4", phpunit-version: "11" }
69+
- { php-version: "8.3", symfony-version: "7.0", phpunit-version: "11" }
70+
- { php-version: "8.3", symfony-version: "7.1", phpunit-version: "11" }
71+
- { php-version: "8.3", symfony-version: "7.2", phpunit-version: "11" }
72+
73+
- { php-version: "8.4", symfony-version: "7.0", phpunit-version: "11" }
74+
- { php-version: "8.4", symfony-version: "7.1", phpunit-version: "11" }
75+
- { php-version: "8.4", symfony-version: "7.2", phpunit-version: "11" }
76+
77+
#- { php-version: "8.3", symfony-version: "6.1", phpunit-version: "12" } # Apparently conflicts with nikic/php-parser
78+
#- { php-version: "8.3", symfony-version: "6.2", phpunit-version: "12" } # Apparently conflicts with nikic/php-parser
79+
- { php-version: "8.3", symfony-version: "6.3", phpunit-version: "12" }
80+
- { php-version: "8.3", symfony-version: "6.4", phpunit-version: "12" }
81+
- { php-version: "8.3", symfony-version: "7.0", phpunit-version: "12" }
82+
- { php-version: "8.3", symfony-version: "7.1", phpunit-version: "12" }
83+
- { php-version: "8.3", symfony-version: "7.2", phpunit-version: "12" }
84+
85+
- { php-version: "8.4", symfony-version: "7.0", phpunit-version: "12" }
86+
- { php-version: "8.4", symfony-version: "7.1", phpunit-version: "12" }
87+
- { php-version: "8.4", symfony-version: "7.2", phpunit-version: "12" }
88+
6289
name: PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony-version }}, PHPUnit ${{ matrix.phpunit-version }}
6390
steps:
6491
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.2.1
2+
3+
* Ensure compatibility with PHPUnit 12.
4+
15
## v1.2.0
26

37
* Make sure the library is usable for PHP 8.3 and 8.4

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Particularly useful for big untested Symfony legacy projects.
66

77
This lib was originally inspired by a [tweet from @SmaineDev](https://twitter.com/SmaineDev/status/1559542937696043008), you can find him on [his Github (@ismail1432)](https://github.com/ismail1432) too.
88

9+
**ℹ Note:** This library is compatible starting with PHP 8.1, Symfony 6.1 and PHPUnit 9.6, and is tested in almost all cases (almost...).<br>There are some unusual cases where it doesn't work entirely, but it will also depend on the rest of your stack, because some dependencies might induce incompatibilities with each other that are not tested (and possibly quite hard to test) in this package.<br>That said, if you want to help making this package compatible with lower versions of PHP and Symfony, to help legacy projects have at least a suite with smoke tests, feel free to open an issue or a PR!
10+
911
## Why smoke testing
1012

1113
[Smoke testing](https://en.wikipedia.org/wiki/Smoke_testing_(software)) is a way to quickly assert whether your project is viable for *unit* or *functional* testing.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"symfony/framework-bundle": "^6.1|^7.0"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^9.6|^10.0",
28+
"phpunit/phpunit": "^9.6|^10.0|^11|^12",
2929
"symfony/maker-bundle": "^1.43"
3030
}
3131
}

fixture-app/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"symfony/yaml": "^6.1|^7.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^9.5|^10.0",
19+
"phpunit/phpunit": "^9.6|^10.0|^11|^12",
2020
"symfony/browser-kit": "^6.1|^7.0",
2121
"symfony/css-selector": "^6.1|^7.0",
2222
"symfony/maker-bundle": "^1.43",
@@ -70,7 +70,7 @@
7070
"extra": {
7171
"symfony": {
7272
"allow-contrib": false,
73-
"require": "6.1.*"
73+
"require": "6.4.*"
7474
}
7575
}
7676
}

fixture-app/src/Controller/TestRoutesController.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111

1212
class TestRoutesController extends AbstractController
1313
{
14-
/** @Route("/param/{id}", name="get_param_without_default", methods={"GET"}) */
15-
#[Route("/param/{id}", name: "get_param_without_default", methods: ["GET"])]
16-
public function getParameterWithoutDefault(string $id): Response
17-
{
18-
return new Response("Content: $id");
19-
}
20-
2114
/** @Route("/other_param/{id}", name="get_param_with_default", defaults={"id": "default_value"}, methods={"GET"}) */
2215
#[Route("/other_param/{id}", name: "get_param_with_default", defaults: ["id" => "default_value"], methods: ["GET"])]
2316
public function getParameterWithDefault(string $id): Response

fixture-app/tests/FunctionalSmokeTest.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,26 @@
77
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
88
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
99
use Symfony\Component\BrowserKit\Cookie;
10+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1011

1112
class FunctionalSmokeTest extends WebTestCase
1213
{
1314
use FunctionalSmokeTester;
1415

1516
public function testGetParameterWithoutDefault(): void
1617
{
17-
$this->runFunctionalTest(
18-
FunctionalTestData::withUrl("/param")
19-
->expectStatusCode(404)
20-
);
21-
$this->runFunctionalTest(
22-
FunctionalTestData::withUrl("/param/")
23-
->expectStatusCode(404)
24-
);
18+
try {
19+
$this->runFunctionalTest(
20+
FunctionalTestData::withUrl("/param")
21+
->expectStatusCode(404),
22+
);
23+
$this->runFunctionalTest(
24+
FunctionalTestData::withUrl("/param/")
25+
->expectStatusCode(404),
26+
);
27+
} catch (NotFoundHttpException) {
28+
$this->assertTrue(true);
29+
}
2530
}
2631

2732
public function testGetParameterWithDefault(): void

phpunit-10.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<server name="APP_ENV" value="test" force="true" />
1717
<server name="SHELL_VERBOSITY" value="-1" />
1818
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
19-
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
19+
<server name="SYMFONY_PHPUNIT_VERSION" value="10.5" />
2020
</php>
2121

2222
<testsuites>

phpunit-11.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
5+
colors="true"
6+
executionOrder="depends,defects"
7+
failOnRisky="true"
8+
failOnWarning="true"
9+
cacheDirectory=".phpunit.cache"
10+
>
11+
12+
<php>
13+
<server name="KERNEL_CLASS" value="App\Kernel" />
14+
<ini name="display_errors" value="1" />
15+
<ini name="error_reporting" value="-1" />
16+
<server name="APP_ENV" value="test" force="true" />
17+
<server name="SHELL_VERBOSITY" value="-1" />
18+
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
19+
<server name="SYMFONY_PHPUNIT_VERSION" value="11.5" />
20+
</php>
21+
22+
<testsuites>
23+
<testsuite name="default">
24+
<directory>tests</directory>
25+
</testsuite>
26+
</testsuites>
27+
28+
<source>
29+
<include>
30+
<directory suffix=".php">src</directory>
31+
</include>
32+
</source>
33+
</phpunit>

phpunit-12.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
5+
colors="true"
6+
executionOrder="depends,defects"
7+
failOnRisky="true"
8+
failOnWarning="true"
9+
cacheDirectory=".phpunit.cache"
10+
>
11+
12+
<php>
13+
<server name="KERNEL_CLASS" value="App\Kernel" />
14+
<ini name="display_errors" value="1" />
15+
<ini name="error_reporting" value="-1" />
16+
<server name="APP_ENV" value="test" force="true" />
17+
<server name="SHELL_VERBOSITY" value="-1" />
18+
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
19+
<server name="SYMFONY_PHPUNIT_VERSION" value="12.0" />
20+
</php>
21+
22+
<testsuites>
23+
<testsuite name="default">
24+
<directory>tests</directory>
25+
</testsuite>
26+
</testsuites>
27+
28+
<source>
29+
<include>
30+
<directory suffix=".php">src</directory>
31+
</include>
32+
</source>
33+
</phpunit>

0 commit comments

Comments
 (0)