Skip to content

Commit 8058394

Browse files
author
Christoph Singer
committed
Update PHPUnit and make tests green again on PHP 8
with recent versions of Symfony (5, 6) and SerializerBundle (3, 4, 5). Please note that while unit tests are passing this version is not thorougly tested and may not work in real world scenarios. Last battle tested versions are Symfony 4 and SerializerBundle 2.
1 parent 8c8ff13 commit 8058394

5 files changed

Lines changed: 29 additions & 30 deletions

File tree

DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
1717
*/
1818
public function getConfigTreeBuilder()
1919
{
20-
$treeBuilder = new TreeBuilder();
21-
$rootNode = $treeBuilder->root('wa72_json_rpc');
20+
$treeBuilder = new TreeBuilder('wa72_json_rpc');
21+
$rootNode = $treeBuilder->getRootNode();
2222

2323
$rootNode
2424
->children()

Tests/Fixtures/app/Wa72JsonRpcBundleTestKernel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class Wa72JsonRpcBundleTestKernel extends Kernel
77
{
8-
public function registerBundles()
8+
public function registerBundles(): iterable
99
{
1010
return array(
1111
new JMS\SerializerBundle\JMSSerializerBundle(),
@@ -22,15 +22,15 @@ public function registerContainerConfiguration(LoaderInterface $loader)
2222
/**
2323
* @return string
2424
*/
25-
public function getCacheDir()
25+
public function getCacheDir(): string
2626
{
2727
return sys_get_temp_dir().'/Wa72JsonRpcBundle/cache';
2828
}
2929

3030
/**
3131
* @return string
3232
*/
33-
public function getLogDir()
33+
public function getLogDir(): string
3434
{
3535
return sys_get_temp_dir().'/Wa72JsonRpcBundle/logs';
3636
}

Tests/JsonRpcControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class JsonRpcControllerTest extends \PHPUnit\Framework\TestCase {
2020
*/
2121
private $controller;
2222

23-
public function setUp()
23+
public function setUp(): void
2424
{
2525
$config = array(
2626
'functions' => array(
@@ -193,7 +193,7 @@ private function makeRequest($controller, $requestdata)
193193
/**
194194
* Shuts the kernel down if it was used in the test.
195195
*/
196-
protected function tearDown()
196+
protected function tearDown(): void
197197
{
198198
if (null !== $this->kernel) {
199199
$this->kernel->shutdown();

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
}
1414
],
1515
"require":{
16-
"php":">=5.4",
17-
"symfony/framework-bundle":"^2.7|^3|^4",
16+
"php":">=7.4",
17+
"ext-json": "*",
18+
"symfony/framework-bundle":"^3|^4|^5|^6",
1819
"symfony/yaml": "*",
19-
"jms/serializer-bundle":"^1.1|^2|^3"
20+
"jms/serializer-bundle":"^2|^3|^4|^5"
2021
},
2122
"require-dev": {
22-
"phpunit/phpunit": "^4|^5|^6|^7"
23+
"phpunit/phpunit": "^9",
24+
"doctrine/annotations": "^1.0"
2325
},
2426
"autoload":{
2527
"psr-0":{
@@ -28,4 +30,3 @@
2830
},
2931
"target-dir": "Wa72/JsonRpcBundle"
3032
}
31-

phpunit.xml.dist

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit colors="true" bootstrap="Tests/bootstrap.php">
4-
<testsuites>
5-
<testsuite name="Wa72JsonRpcBundle Test Suite">
6-
<directory suffix="Test.php">./Tests/</directory>
7-
</testsuite>
8-
</testsuites>
9-
10-
<filter>
11-
<whitelist>
12-
<directory suffix=".php">./</directory>
13-
<exclude>
14-
<directory>./Resources</directory>
15-
<directory>./Tests</directory>
16-
<directory>./vendor</directory>
17-
</exclude>
18-
</whitelist>
19-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="Tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">./</directory>
6+
</include>
7+
<exclude>
8+
<directory>./Resources</directory>
9+
<directory>./Tests</directory>
10+
<directory>./vendor</directory>
11+
</exclude>
12+
</coverage>
13+
<testsuites>
14+
<testsuite name="Wa72JsonRpcBundle Test Suite">
15+
<directory suffix="Test.php">./Tests/</directory>
16+
</testsuite>
17+
</testsuites>
2018
</phpunit>

0 commit comments

Comments
 (0)