Skip to content

Commit 10d1d11

Browse files
CI and Code Quality Tools Setup (#1)
1 parent dd4356f commit 10d1d11

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main, develop ]
5+
branches: [ master, main, develop ]
66
pull_request:
7-
branches: [ main, develop ]
7+
branches: [ master, main, develop ]
88

99
jobs:
1010
test:
@@ -56,7 +56,7 @@ jobs:
5656
composer install --no-interaction --prefer-dist
5757
5858
- name: Run PHPUnit
59-
run: vendor/bin/phpunit
59+
run: composer test
6060

6161
code-quality:
6262
name: Code Quality
@@ -89,8 +89,7 @@ jobs:
8989
run: composer install --no-interaction --prefer-dist
9090

9191
- name: Run PHPStan
92-
run: vendor/bin/phpstan analyse --level=8 src
92+
run: composer analyse
9393

9494
- name: Run PHPCS
95-
run: vendor/bin/phpcs
96-
95+
run: composer cs-check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/bin/
12
/vendor/
23
/.phpunit.cache/
34
composer.lock

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,3 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
111111
## Copyright
112112

113113
Copyright (c) Florian Krämer (https://florian-kraemer.net)
114-

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@
3737
},
3838
"config": {
3939
"sort-packages": true,
40+
"bin-dir": "./bin",
4041
"allow-plugins": {
4142
"phpstan/extension-installer": true
4243
}
4344
},
4445
"scripts": {
45-
"cs-check": "phpcs --standard=PSR12 src tests",
46-
"cs-fix": "phpcbf --standard=PSR12 src tests",
47-
"test": "phpunit",
48-
"analyse": "phpstan analyse --level=8 src",
46+
"cs-check": "./bin/phpcs",
47+
"cs-fix": "./bin/phpcbf",
48+
"test": "./bin/phpunit",
49+
"analyse": "./bin/phpstan analyse",
4950
"quality": [
5051
"@cs-check",
5152
"@analyse",

phpstan.neon.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
- tests

tests/Unit/ExecutionTimeReportPrinterTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testPrintWithEmptyTestTimes(): void
2727

2828
ob_start();
2929
$printer->print();
30-
$output = ob_get_clean();
30+
$output = ob_get_clean() ?: '';
3131

3232
$this->assertEmpty($output);
3333
}
@@ -41,7 +41,7 @@ public function testPrintWithZeroTopN(): void
4141

4242
ob_start();
4343
$printer->print();
44-
$output = ob_get_clean();
44+
$output = ob_get_clean() ?: '';
4545

4646
$this->assertEmpty($output);
4747
}
@@ -55,7 +55,7 @@ public function testPrintWithSingleTest(): void
5555

5656
ob_start();
5757
$printer->print();
58-
$output = ob_get_clean();
58+
$output = ob_get_clean() ?: '';
5959

6060
$this->assertStringContainsString('Top 1 slowest tests:', $output);
6161
$this->assertStringContainsString('Test1', $output);
@@ -74,7 +74,7 @@ public function testPrintSortsTestsByTimeDescending(): void
7474

7575
ob_start();
7676
$printer->print();
77-
$output = ob_get_clean();
77+
$output = ob_get_clean() ?: '';
7878

7979
$slowPos = strpos($output, 'SlowTest');
8080
$mediumPos = strpos($output, 'MediumTest');
@@ -98,7 +98,7 @@ public function testPrintRespectsTopNParameter(): void
9898

9999
ob_start();
100100
$printer->print();
101-
$output = ob_get_clean();
101+
$output = ob_get_clean() ?: '';
102102

103103
$this->assertStringContainsString('Top 2 slowest tests:', $output);
104104
$this->assertStringContainsString('Test1', $output);
@@ -116,7 +116,7 @@ public function testPrintAlignsColumns(): void
116116

117117
ob_start();
118118
$printer->print();
119-
$output = ob_get_clean();
119+
$output = ob_get_clean() ?: '';
120120

121121
$lines = explode("\n", $output);
122122
$testLines = array_filter($lines, static fn(string $line): bool => str_contains($line, '.'));
@@ -146,7 +146,7 @@ public function testPrintFormatsTimeCorrectly(): void
146146

147147
ob_start();
148148
$printer->print();
149-
$output = ob_get_clean();
149+
$output = ob_get_clean() ?: '';
150150

151151
$this->assertStringContainsString('123.00 ms', $output);
152152
$this->assertStringContainsString('0.123 s', $output);

0 commit comments

Comments
 (0)