Skip to content

Commit f5168a7

Browse files
authored
Merge pull request #59 from ingenerator/support-php83
Support PHP 8.3
2 parents 4277373 + dff8e49 commit f5168a7

37 files changed

+674
-782
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ README text eol=lf
2929
*.sqlite binary
3030

3131
# Ignore paths that should not be included in an archive (eg for a distribution version)
32+
/.github export-ignore
33+
/docs export-ignore
3234
/test export-ignore
35+
phpunit.xml export-ignore

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
php_version:
20-
- '8.1'
2120
- '8.2'
21+
- '8.3'
2222
dependencies:
2323
- 'default'
2424
include:
25-
- php_version: '8.1'
26-
dependencies: 'lowest'
2725
- php_version: '8.2'
2826
dependencies: 'lowest'
27+
- php_version: '8.3'
28+
dependencies: 'lowest'
2929
steps:
3030
- name: Setup PHP
3131
uses: shivammathur/setup-php@v2

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
### Unreleased
22

3+
### v2.1.0 (2024-08-02)
4+
5+
* Support PHP 8.3
6+
* Upgrade tests to support PHPUnit 11
7+
* Drop support for PHP 8.1
8+
39
### v2.0.0 (2023-10-27)
410

511
* Support psr/log ^1.1 || ^2.0 || ^3.0

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
],
1717
"require": {
1818
"ext-json": "*",
19-
"ext-mbstring": "~8.1.0 || ~8.2.0",
20-
"ext-pdo": "~8.1.0 || ~8.2.0",
21-
"ext-sodium": "~8.1.0 || ~8.2.0",
22-
"php": "~8.1.0 || ~8.2.0",
19+
"ext-mbstring": "~8.2.0 || ~8.3.0",
20+
"ext-pdo": "~8.2.0 || ~8.3.0",
21+
"ext-sodium": "~8.2.0 || ~8.3.0",
22+
"php": "~8.2.0 || ~8.3.0",
2323
"psr/log": "^1.1 || ^2.0 || ^3.0"
2424
},
2525
"require-dev": {
26-
"johnkary/phpunit-speedtrap": "^3.3",
2726
"mikey179/vfsstream": "^1.6.11",
28-
"phpunit/phpunit": "^9.5.5"
27+
"phpunit/phpunit": "^11.0",
28+
"ergebnis/phpunit-slow-test-detector": "^2.15"
2929
},
3030
"support": {
3131
"source": "https://github.com/ingenerator/php-utils",

phpunit.xml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,31 @@
33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
bootstrap="test/phpunit-bootstrap.php"
55
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
convertDeprecationsToExceptions="true"
10-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
11-
<coverage>
12-
<include>
13-
<directory suffix=".php">src</directory>
14-
</include>
15-
</coverage>
16-
<testsuites>
17-
<testsuite name="unit">
18-
<directory>test/unit</directory>
19-
</testsuite>
20-
</testsuites>
21-
<listeners>
22-
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
23-
<arguments>
24-
<array>
25-
<element key="slowThreshold">
26-
<integer>200</integer>
27-
</element>
28-
<element key="reportLength">
29-
<integer>20</integer>
30-
</element>
31-
</array>
32-
</arguments>
33-
</listener>
34-
</listeners>
6+
failOnDeprecation="true"
7+
failOnNotice="true"
8+
failOnWarning="true"
9+
failOnRisky="true"
10+
displayDetailsOnIncompleteTests="true"
11+
displayDetailsOnSkippedTests="true"
12+
displayDetailsOnTestsThatTriggerDeprecations="true"
13+
displayDetailsOnTestsThatTriggerErrors="true"
14+
displayDetailsOnTestsThatTriggerNotices="true"
15+
displayDetailsOnTestsThatTriggerWarnings="true"
16+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
17+
<source>
18+
<include>
19+
<directory suffix=".php">src</directory>
20+
</include>
21+
</source>
22+
<testsuites>
23+
<testsuite name="unit">
24+
<directory>test/unit</directory>
25+
</testsuite>
26+
</testsuites>
27+
<extensions>
28+
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
29+
<parameter name="maximum-count" value="20"/>
30+
<parameter name="maximum-duration" value="200"/>
31+
</bootstrap>
32+
</extensions>
3533
</phpunit>

test/unit/ArrayHelpers/AssociativeArrayUtilsTest.php

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88

99

1010
use Ingenerator\PHPUtils\ArrayHelpers\AssociativeArrayUtils;
11+
use PHPUnit\Framework\Attributes\DataProvider;
12+
use PHPUnit\Framework\Attributes\TestWith;
13+
use PHPUnit\Framework\TestCase;
1114

12-
class AssociativeArrayUtilsTest extends \PHPUnit\Framework\TestCase
15+
class AssociativeArrayUtilsTest extends TestCase
1316
{
1417

15-
/**
16-
* @testWith [["one", "two", "three"], false]
17-
* [{"1": "mixed indices", "5": "also mixed"}, true]
18-
* [{"one": "o clock", "two": "o clock", "three": "o clock"}, true]
19-
*/
18+
#[TestWith([['one', 'two', 'three'], false])]
19+
#[TestWith([[1 => 'mixed indices', 5 => 'also mixed'], true])]
20+
#[TestWith([['one' => 'o clock', 'two' => 'o clock', 'three' => 'o clock'], true])]
2021
public function test_is_associative(array $array, $expected)
2122
{
2223
$this->assertSame(
@@ -25,7 +26,7 @@ public function test_is_associative(array $array, $expected)
2526
);
2627
}
2728

28-
public function provider_paths_to_nested()
29+
public static function provider_paths_to_nested(): array
2930
{
3031
return [
3132
[
@@ -51,15 +52,13 @@ public function provider_paths_to_nested()
5152
];
5253
}
5354

54-
/**
55-
* @dataProvider provider_paths_to_nested
56-
*/
55+
#[DataProvider('provider_paths_to_nested')]
5756
public function test_it_converts_pathed_hash_to_nested_arrays($input, $expect)
5857
{
5958
$this->assertSame($expect, AssociativeArrayUtils::pathsToNested($input));
6059
}
6160

62-
public function provider_pop_keys()
61+
public static function provider_pop_keys(): array
6362
{
6463
return [
6564
[
@@ -90,9 +89,7 @@ public function provider_pop_keys()
9089
];
9190
}
9291

93-
/**
94-
* @dataProvider provider_pop_keys
95-
*/
92+
#[DataProvider('provider_pop_keys')]
9693
public function test_it_can_pop_keys_from_a_source_array($source, $pop_keys, $expect)
9794
{
9895
$result = AssociativeArrayUtils::popKeys($source, $pop_keys);
@@ -104,7 +101,7 @@ public function test_it_can_pop_keys_from_a_source_array($source, $pop_keys, $ex
104101
*
105102
* @return array
106103
*/
107-
public function provider_set_path()
104+
public static function provider_set_path(): array
108105
{
109106
return [
110107
// Tests returns normal values
@@ -125,9 +122,7 @@ public function provider_set_path()
125122
];
126123
}
127124

128-
/**
129-
* @dataProvider provider_set_path
130-
*/
125+
#[DataProvider('provider_set_path')]
131126
public function test_set_path($expected, $array, ...$args)
132127
{
133128
AssociativeArrayUtils::setPath($array, ...$args);
@@ -136,7 +131,7 @@ public function test_set_path($expected, $array, ...$args)
136131
}
137132

138133

139-
public function provider_merge()
134+
public static function provider_merge(): array
140135
{
141136
return [
142137
// Test how it merges arrays and sub arrays with assoc keys
@@ -266,9 +261,7 @@ public function provider_merge()
266261
];
267262
}
268263

269-
/**
270-
* @dataProvider provider_merge
271-
*/
264+
#[DataProvider('provider_merge')]
272265
public function test_deep_merge($expected, ...$args)
273266
{
274267
$this->assertSame(

test/unit/Assets/StaticAssetUrlProviderTest.php

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
namespace test\unit\Ingenerator\PHPUtils\Assets;
55

66

7+
use InvalidArgumentException;
78
use org\bovigo\vfs\vfsStream;
89
use org\bovigo\vfs\vfsStreamDirectory;
10+
use PHPUnit\Framework\Attributes\TestWith;
911
use PHPUnit\Framework\TestCase;
1012
use Ingenerator\PHPUtils\Assets\StaticAssetUrlProvider;
13+
use RuntimeException;
1114

1215
class StaticAssetUrlProviderTest extends TestCase
1316
{
@@ -31,21 +34,19 @@ public function test_it_is_initialisable()
3134
public function test_it_throws_in_invalid_mode()
3235
{
3336
$this->options['mode'] = 'some-junk';
34-
$this->expectException(\InvalidArgumentException::class);
37+
$this->expectException(InvalidArgumentException::class);
3538
$this->newSubject();
3639
}
3740

3841
public function test_in_local_mode_get_url_throws_if_file_does_not_exist()
3942
{
4043
$subject = $this->newSubject();
41-
$this->expectException(\RuntimeException::class);
44+
$this->expectException(RuntimeException::class);
4245
$subject->getUrl('assets/some-file.css');
4346
}
4447

45-
/**
46-
* @testWith ["assets/my-file.css"]
47-
* ["/assets/my-file.css"]
48-
*/
48+
#[TestWith(['assets/my-file.css'])]
49+
#[TestWith(['/assets/my-file.css'])]
4950
public function test_in_local_mode_get_url_returns_absolute_url_with_mtime_suffix($rel_path)
5051
{
5152
vfsStream::create(
@@ -67,17 +68,15 @@ public function test_in_remote_mode_get_url_throws_if_asset_base_url_file_does_n
6768
{
6869
$this->options['asset_base_url_file'] = $this->vfs->url().'/no-such-file.php';
6970
$this->options['mode'] = StaticAssetUrlProvider::MODE_REMOTE;
70-
$this->expectException(\InvalidArgumentException::class);
71+
$this->expectException(InvalidArgumentException::class);
7172
$this->expectExceptionMessage('no-such-file.php');
7273
$this->newSubject();
7374
}
7475

75-
/**
76-
* @testWith [""]
77-
* ["some content that is not php"]
78-
* ["<?php $a = 1;"]
79-
* ["<?php return '';"]
80-
*/
76+
#[TestWith([''])]
77+
#[TestWith(['some content that is not php'])]
78+
#[TestWith(['<?php $a = 1;'])]
79+
#[TestWith(["<?php return '';"])]
8180
public function test_in_remote_mode_get_url_throws_if_asset_base_url_file_does_not_return_string($file_content)
8281
{
8382
vfsStream::create(
@@ -87,15 +86,13 @@ public function test_in_remote_mode_get_url_throws_if_asset_base_url_file_does_n
8786

8887
$this->options['asset_base_url_file'] = $this->vfs->getChild('asset-base-url.php')->url();
8988
$this->options['mode'] = StaticAssetUrlProvider::MODE_REMOTE;
90-
$this->expectException(\RuntimeException::class);
89+
$this->expectException(RuntimeException::class);
9190
$this->expectExceptionMessage('Invalid content in asset base url');
9291
$this->newSubject();
9392
}
9493

95-
/**
96-
* @testWith ["assets/my-file.css"]
97-
* ["/assets/my-file.css"]
98-
*/
94+
#[TestWith(['assets/my-file.css'])]
95+
#[TestWith(['/assets/my-file.css'])]
9996
public function test_it_remote_mode_get_url_returns_url_prefixed_with_base_url($rel_path)
10097
{
10198
vfsStream::create(

0 commit comments

Comments
 (0)