Skip to content

Commit daedee4

Browse files
committed
Upgraded PHPUnit 9 -> 10 and fixed tests.
Removed Travis config in lieu of GHA. Dropped support for PHP < 8.1.
1 parent 4cb4adf commit daedee4

File tree

11 files changed

+80
-57
lines changed

11 files changed

+80
-57
lines changed

Diff for: .github/workflows/Tests.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: 0 6 * * *
9+
10+
jobs:
11+
Test:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php:
18+
- 8.1
19+
- 8.2
20+
- 8.3
21+
dependencies:
22+
- hi
23+
- lo
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Setup PHP ${{ matrix.php }}
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php }}
32+
coverage: xdebug
33+
34+
- name: Validate composer.json
35+
run: composer validate
36+
37+
- name: Cache dependencies
38+
id: composer-cache
39+
uses: actions/cache@v4
40+
with:
41+
path: vendor
42+
key: php-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('composer.json') }}
43+
restore-keys: php-${{ matrix.php }}-${{ matrix.dependencies }}-
44+
45+
- name: Install dependencies ${{ matrix.dependencies == 'lo' && '(lowest)' || '' }}
46+
run: composer update --no-interaction --no-progress
47+
${{ matrix.dependencies == 'lo' && '--prefer-lowest' || '' }}
48+
49+
- name: Run test suite with coverage
50+
run: composer test -- --coverage-clover=build/logs/clover.xml
51+
52+
- name: Upload test coverage
53+
uses: codecov/codecov-action@v4
54+
env:
55+
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.*/
2+
!/.github/
23
/vendor/
34
/composer.lock

Diff for: .travis.yml

-34
This file was deleted.

Diff for: README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ Debug(Strategy|Mapping|array|mixed $expression)
926926
Requirements
927927
------------
928928

929-
- [PHP 5.6](http://php.net/)
929+
- [PHP 8.1](http://php.net/)
930930
- [Composer](https://getcomposer.org/)
931931

932932
Limitations
@@ -947,8 +947,8 @@ in this document can be found in `DocumentationTest`.
947947
[Version image]: https://poser.pugx.org/scriptfusion/mapper/version "Latest version"
948948
[Downloads]: https://packagist.org/packages/scriptfusion/mapper
949949
[Downloads image]: https://poser.pugx.org/scriptfusion/mapper/downloads "Total downloads"
950-
[Build]: http://travis-ci.org/ScriptFUSION/Mapper
951-
[Build image]: https://travis-ci.org/ScriptFUSION/Mapper.svg?branch=master "Build status"
950+
[Build]: https://github.com/ScriptFUSION/Mapper/actions/workflows/Tests.yaml
951+
[Build image]: https://github.com/ScriptFUSION/Mapper/actions/workflows/Tests.yaml/badge.svg "Build status"
952952
[Coverage]: https://coveralls.io/github/ScriptFUSION/Mapper
953953
[Coverage image]: https://coveralls.io/repos/ScriptFUSION/Mapper/badge.svg "Test coverage"
954954
[Style]: https://styleci.io/repos/59734709

Diff for: composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
],
1010
"license": "LGPL-3.0",
1111
"require": {
12-
"php": "^7.2|^8",
12+
"php": "^8.1",
1313
"scriptfusion/array-walker": "^1",
1414
"eloquent/enumeration": "^5|^6"
1515
},
1616
"require-dev": {
1717
"scriptfusion/static-class": "^1",
18-
"phpunit/phpunit": "^8.5|^9",
18+
"phpunit/phpunit": "^10.5",
1919
"mockery/mockery": "^1.3.3"
2020
},
2121
"autoload": {

Diff for: src/Strategy/Copy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __invoke($record, $context = null)
4444
// Resolve the path expression. Path will always be an array after this block.
4545
if (!is_array($path = parent::__invoke($record, $context))) {
4646
// If it's not an array treat it as a delimited string; implicitly casts other scalar types.
47-
$path = explode(self::PATH_SEPARATOR, $path);
47+
$path = explode(self::PATH_SEPARATOR, (string)$path);
4848
}
4949

5050
// Overwrite record with resolved data expression if set and ensure it is an array.

Diff for: src/Strategy/Replace.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Replace extends Delegate
1919
* Any number of searches and replacements can be specified. Searches and replacements are parsed in pairs. If no
2020
* replacements are specified, all matches are removed instead of replaced. If fewer replacements than searches are
2121
* specified, the last replacement will be used for the remaining searches. If more replacements than searches are
22-
* specified, the extra replacements are ignored.
22+
* specified, the extra replacements will be ignored.
2323
*
2424
* @param Strategy|Mapping|array|mixed $expression Expression to search in.
2525
* @param $searches string|Expression|array Search string(s).
@@ -40,7 +40,7 @@ public function __invoke($data, $context = null)
4040
$replace = null;
4141

4242
foreach ($this->searches as $search) {
43-
$replace = count($replacements) ? array_shift($replacements) : $replace;
43+
$replace = count($replacements) ? array_shift($replacements) : (string)$replace;
4444

4545
if ($search instanceof Expression) {
4646
$output = preg_replace($search, $replace, $output);

Diff for: test/Integration/Mapper/MapperTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testMapScalars($scalar)
5353
self::assertSame($scalar, $mapped);
5454
}
5555

56-
public function provideScalars()
56+
public static function provideScalars()
5757
{
5858
return [
5959
'string empty' => [''],

Diff for: test/Unit/Mapper/Strategy/ReplaceTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testReplace($input, $search, $replace, $output)
2121
self::assertSame($output, $replace([]));
2222
}
2323

24-
public function provideReplacements()
24+
public static function provideReplacements()
2525
{
2626
return [
2727
'Single removal' => ['foo', 'o', null, 'f'],

Diff for: test/Unit/Mapper/Strategy/ToListTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testMap()
2626
]
2727
));
2828

29-
self::assertSame([$map], $this->toList($map));
29+
self::assertSame([$map], $this->toList());
3030
}
3131

3232
public function testList()
@@ -38,18 +38,18 @@ public function testList()
3838
]
3939
));
4040

41-
self::assertSame($map, $this->toList($map));
41+
self::assertSame($map, $this->toList());
4242
}
4343

4444
public function testScalar()
4545
{
4646
$this->toList->setMapper(MockFactory::mockMapper('foo'));
4747

48-
$this->toList(['foo']);
48+
self::assertSame(['foo'], $this->toList());
4949
}
5050

5151
private function toList()
5252
{
53-
return call_user_func_array($this->toList, func_get_args());
53+
return ($this->toList)([]);
5454
}
5555
}

Diff for: test/phpunit.xml

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<phpunit
2-
beStrictAboutOutputDuringTests="true"
2+
beStrictAboutOutputDuringTests="true"
33
>
4-
<testsuite>
5-
<directory>.</directory>
6-
</testsuite>
7-
<filter>
8-
<whitelist processUncoveredFilesFromWhitelist="true">
9-
<directory>../src</directory>
10-
</whitelist>
11-
</filter>
4+
<testsuite name="default">
5+
<directory>.</directory>
6+
</testsuite>
7+
8+
<source>
9+
<include>
10+
<directory>../src</directory>
11+
</include>
12+
</source>
1213
</phpunit>

0 commit comments

Comments
 (0)