Skip to content

Commit a1f566e

Browse files
authored
Merge pull request #133 from mringler/phpunit10
Upgrade to phpunit 10
2 parents 6e9f120 + babd868 commit a1f566e

File tree

139 files changed

+1488
-1944
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+1488
-1944
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
shell: bash
9696
run: |
9797
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.symfony-version }} == '6-max' ]]; then
98-
export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml --verbose --coverage-clover=tests/coverage.xml
98+
export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml --coverage-clover=tests/coverage.xml
9999
else
100100
vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml
101101
fi

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"require-dev": {
4141
"monolog/monolog": "^1.3 || ^2.3 || ^3.0",
4242
"phpstan/phpstan": "^2.0",
43-
"phpunit/phpunit": "^9.5.0",
43+
"phpunit/phpunit": "^10.0",
4444
"spryker/code-sniffer": "^0.17.2",
4545
"psalm/phar": "^6",
4646
"mikey179/vfsstream": "^1.6",
@@ -72,7 +72,7 @@
7272
"psalm-update-baseline": "vendor/bin/psalm.phar --update-baseline",
7373
"psalm-set-baseline": "vendor/bin/psalm.phar --set-baseline=psalm-baseline.xml",
7474
"psalm-update-report": "vendor/bin/psalm.phar --report=psalm-report.xml",
75-
"test": "phpunit --colors=always",
75+
"test": "phpunit --colors=always --display-phpunit-deprecations",
7676
"test:agnostic": "@test -c tests/agnostic.phpunit.xml",
7777
"test:mysql": "@test -c tests/mysql.phpunit.xml",
7878
"test:sqlite": "@test -c tests/sqlite.phpunit.xml",

phpunit.xml.dist

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,32 @@
88
bootstrap="tests/bootstrap.php"
99
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
1010
>
11-
12-
<testsuites>
13-
<testsuite name="propel2">
14-
<directory>tests/Propel/Tests/</directory>
15-
</testsuite>
16-
</testsuites>
17-
18-
<groups>
19-
<exclude>
20-
<group>pgsql</group>
21-
<group>mysql</group>
22-
</exclude>
23-
</groups>
24-
25-
<php>
26-
<env name="DB" value="mysql"/> <!-- mysql, sqlite, pgsql -->
27-
<env name="DB_USER" value=""/>
28-
<env name="DB_PW" value=""/>
29-
</php>
30-
31-
<logging />
32-
33-
<coverage>
34-
<include>
35-
<directory>src/Propel/</directory>
36-
</include>
37-
<report>
38-
<php outputFile="tests/clover.cov" />
39-
</report>
40-
</coverage>
41-
11+
<testsuites>
12+
<testsuite name="propel2">
13+
<directory>tests/Propel/Tests/</directory>
14+
</testsuite>
15+
</testsuites>
16+
<groups>
17+
<exclude>
18+
<group>pgsql</group>
19+
<group>mysql</group>
20+
</exclude>
21+
</groups>
22+
<php>
23+
<!-- DB is one of mysql, sqlite, pgsql -->
24+
<env name="DB" value="mysql"/>
25+
<env name="DB_USER" value=""/>
26+
<env name="DB_PW" value=""/>
27+
</php>
28+
<logging/>
29+
<coverage>
30+
<report>
31+
<php outputFile="tests/clover.cov"/>
32+
</report>
33+
</coverage>
34+
<source>
35+
<include>
36+
<directory>src/Propel/</directory>
37+
</include>
38+
</source>
4239
</phpunit>

src/Propel/Common/Config/ConfigurationManager.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
use function getcwd;
2727
use function implode;
2828
use function in_array;
29+
use function is_array;
2930
use function is_dir;
31+
use function is_int;
3032
use function is_string;
3133
use function ksort;
3234
use function str_ends_with;
@@ -74,9 +76,8 @@ public function __construct(?string $path = null, ?array $extraConf = [])
7476
throw new RuntimeException('Cannot get the current working directory');
7577
}
7678
}
77-
if ($extraConf === null) {
78-
$extraConf = [];
79-
}
79+
$extraConf = static::deflateConfigurationArray($extraConf ?? []);
80+
8081
$this->config = $this->loadConfig($path, $extraConf);
8182
$this->process();
8283
}
@@ -407,7 +408,7 @@ private function cleanupConnections(): void
407408
}
408409

409410
/**
410-
* @param array<string, mixed> $maybeKeyValues
411+
* @param array<mixed> $maybeKeyValues
411412
* @param string $separator
412413
*
413414
* @throws \RuntimeException
@@ -422,6 +423,14 @@ public static function deflateConfigurationArray(array $maybeKeyValues, string $
422423
$deflatedConfigs = [];
423424
$wrapArray = fn (array $config, string $key) => [$key => $config];
424425
foreach ($maybeKeyValues as $maybePath => $payload) {
426+
if (is_array($payload)) {
427+
$payload = static::deflateConfigurationArray($payload, $separator);
428+
}
429+
if (is_int($maybePath)) {
430+
$deflatedConfigs[] = [$maybePath => $payload];
431+
432+
continue;
433+
}
425434
$sections = explode($separator, $maybePath);
426435
$lastKey = array_pop($sections);
427436
$reversedSections = array_reverse($sections);

src/Propel/Generator/Model/Column.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use LogicException;
99
use Propel\Common\Util\SetColumnConverter;
1010
use Propel\Generator\Exception\EngineException;
11+
use Propel\Generator\Exception\LogicException as ExceptionLogicException;
1112
use Propel\Generator\Platform\PlatformInterface;
1213
use function addcslashes;
1314
use function count;
@@ -228,17 +229,20 @@ class Column extends MappingModel
228229
* @param string $name The column's name
229230
* @param string|null $type The column's type
230231
* @param string|int|null $size The column's size
232+
*
233+
* @throws \LogicException
231234
*/
232235
public function __construct(string $name, ?string $type = null, $size = null)
233236
{
234237
$this->setName($name);
235238

236239
if ($type !== null) {
237240
$this->setType($type);
238-
}
239-
240-
if ($size !== null) {
241-
$this->setSize((int)$size);
241+
if ($size !== null) {
242+
$this->setSize((int)$size);
243+
}
244+
} elseif ($size !== null) {
245+
throw new ExceptionLogicException('Cannot set column size without type');
242246
}
243247
}
244248

src/Propel/Generator/Util/VfsTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@ trait VfsTrait
1818
/**
1919
* @var \org\bovigo\vfs\vfsStreamDirectory
2020
*/
21-
private $root;
21+
private vfsStreamDirectory|null $root = null;
2222

2323
/**
2424
* @return \org\bovigo\vfs\vfsStreamDirectory
2525
*/
2626
public function getRoot(): vfsStreamDirectory
2727
{
28-
if ($this->root === null) {
29-
$this->root = vfsStream::setup();
30-
}
28+
$this->root ??= vfsStream::setup();
3129

3230
return $this->root;
3331
}

tests/Propel/Tests/Common/Config/ConfigurationManagerTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Propel\Tests\Common\Config;
1010

1111
use org\bovigo\vfs\vfsStream;
12+
use PHPUnit\Framework\Attributes\DataProvider;
1213
use Propel\Common\Config\ConfigurationManager;
1314
use Propel\Common\Config\Exception\InvalidArgumentException;
1415
use Propel\Tests\TestCase;
@@ -460,10 +461,9 @@ classname: Propel\Runtime\Connection\DebugPDO
460461
}
461462

462463
/**
463-
* @dataProvider providerForInvalidConnections
464-
*
465464
* @return void
466465
*/
466+
#[DataProvider('providerForInvalidConnections')]
467467
public function testRuntimeOrGeneratorConnectionIsNotInConfiguredConnectionsThrowsException($yamlConf, $section)
468468
{
469469
$this->expectException(InvalidConfigurationException::class);
@@ -473,10 +473,9 @@ public function testRuntimeOrGeneratorConnectionIsNotInConfiguredConnectionsThro
473473
}
474474

475475
/**
476-
* @dataProvider providerForInvalidDefaultConnection
477-
*
478476
* @return void
479477
*/
478+
#[DataProvider('providerForInvalidDefaultConnection')]
480479
public function testRuntimeOrGeneratorDefaultConnectionIsNotInConfiguredConnectionsThrowsException($yamlConf, $section)
481480
{
482481
$this->expectException(InvalidConfigurationException::class);
@@ -864,7 +863,7 @@ classname: Propel\Runtime\Connection\DebugPDO
864863
/**
865864
* @return array<array>
866865
*/
867-
public function deflateConfigurationDataProvider(): array
866+
public static function deflateConfigurationDataProvider(): array
868867
{
869868
return [
870869
[['foo' => 42], ['foo' => 42]],
@@ -874,12 +873,12 @@ public function deflateConfigurationDataProvider(): array
874873
}
875874

876875
/**
877-
* @dataProvider deflateConfigurationDataProvider
878-
*
879876
* @param array $flattenedConfig
880877
* @param array $expectedArray
878+
*
881879
* @return void
882880
*/
881+
#[DataProvider('deflateConfigurationDataProvider')]
883882
public function testDeflateConfiguration(array $flattenedConfig, array $expectedArray)
884883
{
885884
$actualArray = ConfigurationManager::deflateConfigurationArray($flattenedConfig);

tests/Propel/Tests/Common/Config/DataProviderTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait DataProviderTrait
1616
/**
1717
* @return string[][]
1818
*/
19-
public function providerForInvalidConnections()
19+
public static function providerForInvalidConnections()
2020
{
2121
return [
2222
["
@@ -113,7 +113,7 @@ classname: Propel\Runtime\Connection\DebugPDO
113113
/**
114114
* @return string[][]
115115
*/
116-
public function providerForInvalidDefaultConnection()
116+
public static function providerForInvalidDefaultConnection()
117117
{
118118
return [
119119
["
@@ -176,7 +176,7 @@ classname: Propel\Runtime\Connection\DebugPDO
176176
/**
177177
* @return array
178178
*/
179-
public function providerForXmlToArrayConverter()
179+
public static function providerForXmlToArrayConverter()
180180
{
181181
$moviesXml = <<<EOF
182182
<?xml version='1.0' standalone='yes'?>
@@ -329,7 +329,7 @@ public function providerForXmlToArrayConverter()
329329
/**
330330
* @return array
331331
*/
332-
public function providerForXmlToArrayConverterXmlInclusions()
332+
public static function providerForXmlToArrayConverterXmlInclusions()
333333
{
334334
$xmlOne = <<<EOF
335335
<?xml version="1.0" encoding="UTF-8"?>

tests/Propel/Tests/Common/Config/Loader/FileLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Propel\Tests\Common\Config\Loader;
1010

11+
use PHPUnit\Framework\Attributes\DataProvider;
1112
use Propel\Common\Config\Exception\InvalidArgumentException;
1213
use Propel\Common\Config\Exception\RuntimeException;
1314
use Propel\Common\Config\Loader\FileLoader as BaseFileLoader;
@@ -26,7 +27,7 @@ public function setUp(): void
2627
$this->loader = new TestableFileLoader();
2728
}
2829

29-
public function resolveParamsProvider()
30+
public static function resolveParamsProvider()
3031
{
3132
return [
3233
[
@@ -164,10 +165,9 @@ public function testResolveParams()
164165
}
165166

166167
/**
167-
* @dataProvider resolveParamsProvider
168-
*
169168
* @return void
170169
*/
170+
#[DataProvider('resolveParamsProvider')]
171171
public function testResolveValues($conf, $expected, $message)
172172
{
173173
$this->assertEquals($expected, $this->loader->resolveParams($conf), $message);

tests/Propel/Tests/Common/Config/XmlToArrayConverterTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ class XmlToArrayConverterTest extends TestCase
2121
use DataProviderTrait;
2222

2323
/**
24-
* @dataProvider providerForXmlToArrayConverter
25-
*
2624
* @return void
2725
*/
26+
#[\PHPUnit\Framework\Attributes\DataProvider('providerForXmlToArrayConverter')]
2827
public function testConvertFromString(string $xml, $expected)
2928
{
3029
$actual = XmlToArrayConverter::convert($xml);
@@ -33,10 +32,9 @@ public function testConvertFromString(string $xml, $expected)
3332
}
3433

3534
/**
36-
* @dataProvider providerForXmlToArrayConverter
37-
*
3835
* @return void
3936
*/
37+
#[\PHPUnit\Framework\Attributes\DataProvider('providerForXmlToArrayConverter')]
4038
public function testConvertFromFile($xml, $expected)
4139
{
4240
$file = $this->newFile('testconvert.xml', $xml);
@@ -46,10 +44,9 @@ public function testConvertFromFile($xml, $expected)
4644
}
4745

4846
/**
49-
* @dataProvider providerForXmlToArrayConverterXmlInclusions
50-
*
5147
* @return void
5248
*/
49+
#[\PHPUnit\Framework\Attributes\DataProvider('providerForXmlToArrayConverterXmlInclusions')]
5350
public function testConvertFromFileWithXmlInclusion($xmlLoad, $xmlInclude, $expected)
5451
{
5552
$this->newFile('testconvert.xml', $xmlLoad);

0 commit comments

Comments
 (0)