Skip to content

Commit 90f9057

Browse files
committed
feat: modernise, drop support for php < 7.4, migrate tests and config for phpUnit 9, replace travis with github actions
1 parent 676a643 commit 90f9057

File tree

4 files changed

+65
-34
lines changed

4 files changed

+65
-34
lines changed

.github/workflows/ci.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# .github/workflows/code_checks.yaml
2+
name: Code_Checks
3+
4+
on: ["push", "pull_request"]
5+
6+
jobs:
7+
tests:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: ['7.4']
13+
stability: [ prefer-stable ]
14+
experimental: [false]
15+
include:
16+
- php: '7.4'
17+
stability: prefer-lowest
18+
- php: '8.0'
19+
- php: '8.1'
20+
- php: '8.2'
21+
- php: '8.3'
22+
23+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} tests
24+
steps:
25+
# basically git clone
26+
- uses: actions/checkout@v4
27+
28+
- name: Cache dependencies
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.composer/cache/files
32+
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
33+
34+
# use PHP of specific version
35+
- uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: ${{ matrix.php }}
38+
extensions: pcov
39+
coverage: pcov
40+
41+
- name: Install dependencies
42+
run: |
43+
composer install --verbose --prefer-dist --no-interaction -o
44+
45+
- name: Execute tests
46+
run: vendor/bin/phpunit -c ./tests/phpunit.xml.dist ./tests --verbose
47+
48+
cs:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: shivammathur/setup-php@v2
53+
with:
54+
php-version: 8.2
55+
coverage: none # disable xdebug, pcov
56+
- run: composer install --no-progress
57+
- run: ./vendor/bin/phpcs --encoding=utf-8 --extensions=php --standard=./tests/phpcs.xml -nsp ./
58+

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
"require-dev": {
3434
"phpunit/phpunit": "^9.5",
35-
"squizlabs/php_codesniffer": "^2.8.1"
35+
"squizlabs/php_codesniffer": "^3.7"
3636
},
3737

3838
"replace": {

tests/AbstractPhysicalQuantityTest.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ public function testConvertToUnknownUnitThrowsException(
111111
AbstractPhysicalQuantity $value,
112112
$arbitraryUnit,
113113
$valueInArbitraryUnit
114-
): void
115-
{
114+
): void {
116115
$this->expectException(\PhpUnitsOfMeasure\Exception\UnknownUnitOfMeasure::class);
117116
$value->toUnit('someUnknownUnit');
118117
}
@@ -125,8 +124,7 @@ public function testUnitConvertsToArbitraryUnit(
125124
AbstractPhysicalQuantity $value,
126125
$arbitraryUnit,
127126
$valueInArbitraryUnit
128-
): void
129-
{
127+
): void {
130128
$this->assertSame($valueInArbitraryUnit, $value->toUnit($arbitraryUnit));
131129
}
132130

@@ -146,8 +144,7 @@ public function testSerialize(
146144
AbstractPhysicalQuantity $value,
147145
$arbitraryUnit,
148146
$valueInArbitraryUnit
149-
): void
150-
{
147+
): void {
151148
serialize($value);
152149
}
153150

@@ -158,8 +155,7 @@ public function testUnserialize(
158155
AbstractPhysicalQuantity $value,
159156
$arbitraryUnit,
160157
$valueInArbitraryUnit
161-
): void
162-
{
158+
): void {
163159
$unserializedValue = unserialize(serialize($value));
164160

165161
$this->assertSame($valueInArbitraryUnit, $unserializedValue->toUnit($arbitraryUnit));
@@ -175,8 +171,7 @@ public function testAdd(
175171
AbstractPhysicalQuantity $secondValue,
176172
$sumString,
177173
$diffString
178-
): void
179-
{
174+
): void {
180175
if ($shouldThrowException) {
181176
$this->expectException(PhysicalQuantityMismatch::class);
182177
}
@@ -198,11 +193,9 @@ public function testSubtract(
198193
AbstractPhysicalQuantity $secondValue,
199194
$sumString,
200195
$diffString
201-
): void
202-
{
196+
): void {
203197
if ($shouldThrowException) {
204198
$this->expectException(PhysicalQuantityMismatch::class);
205-
206199
}
207200

208201
$difference = $firstValue->subtract($secondValue);

0 commit comments

Comments
 (0)