Skip to content

Commit

Permalink
Update PHPUnit and make tests green again on PHP 8
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Christoph Singer committed Oct 24, 2023
1 parent 8c8ff13 commit 8058394
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('wa72_json_rpc');
$treeBuilder = new TreeBuilder('wa72_json_rpc');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand Down
6 changes: 3 additions & 3 deletions Tests/Fixtures/app/Wa72JsonRpcBundleTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Wa72JsonRpcBundleTestKernel extends Kernel
{
public function registerBundles()
public function registerBundles(): iterable
{
return array(
new JMS\SerializerBundle\JMSSerializerBundle(),
Expand All @@ -22,15 +22,15 @@ public function registerContainerConfiguration(LoaderInterface $loader)
/**
* @return string
*/
public function getCacheDir()
public function getCacheDir(): string
{
return sys_get_temp_dir().'/Wa72JsonRpcBundle/cache';
}

/**
* @return string
*/
public function getLogDir()
public function getLogDir(): string
{
return sys_get_temp_dir().'/Wa72JsonRpcBundle/logs';
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/JsonRpcControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class JsonRpcControllerTest extends \PHPUnit\Framework\TestCase {
*/
private $controller;

public function setUp()
public function setUp(): void
{
$config = array(
'functions' => array(
Expand Down Expand Up @@ -193,7 +193,7 @@ private function makeRequest($controller, $requestdata)
/**
* Shuts the kernel down if it was used in the test.
*/
protected function tearDown()
protected function tearDown(): void
{
if (null !== $this->kernel) {
$this->kernel->shutdown();
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
}
],
"require":{
"php":">=5.4",
"symfony/framework-bundle":"^2.7|^3|^4",
"php":">=7.4",
"ext-json": "*",
"symfony/framework-bundle":"^3|^4|^5|^6",
"symfony/yaml": "*",
"jms/serializer-bundle":"^1.1|^2|^3"
"jms/serializer-bundle":"^2|^3|^4|^5"
},
"require-dev": {
"phpunit/phpunit": "^4|^5|^6|^7"
"phpunit/phpunit": "^9",
"doctrine/annotations": "^1.0"
},
"autoload":{
"psr-0":{
Expand All @@ -28,4 +30,3 @@
},
"target-dir": "Wa72/JsonRpcBundle"
}

34 changes: 16 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true" bootstrap="Tests/bootstrap.php">
<testsuites>
<testsuite name="Wa72JsonRpcBundle Test Suite">
<directory suffix="Test.php">./Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
<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">
<coverage>
<include>
<directory suffix=".php">./</directory>
</include>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Wa72JsonRpcBundle Test Suite">
<directory suffix="Test.php">./Tests/</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit 8058394

Please sign in to comment.