Skip to content

Commit f1d4290

Browse files
committed
test: Add mutation testing configuration and update composer dev-dependencies
1 parent 46d5597 commit f1d4290

5 files changed

Lines changed: 103 additions & 12 deletions

File tree

.github/workflows/infection.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
3+
name: 🧬 Mutation testing
4+
5+
on: # yamllint disable-line rule:truthy
6+
pull_request:
7+
branches:
8+
- 1.x
9+
paths:
10+
- 'src/**'
11+
- 'tests/**'
12+
- 'infection.json'
13+
- 'testo.php'
14+
- 'composer.json'
15+
- 'composer.lock'
16+
- '.github/workflows/infection.yml'
17+
push:
18+
branches:
19+
- 1.x
20+
paths:
21+
- 'src/**'
22+
- 'tests/**'
23+
- 'infection.json'
24+
- 'testo.php'
25+
- 'composer.json'
26+
- 'composer.lock'
27+
- '.github/workflows/infection.yml'
28+
29+
jobs:
30+
infection:
31+
timeout-minutes: 4
32+
runs-on: ${{ matrix.os }}
33+
concurrency:
34+
cancel-in-progress: true
35+
group: infection-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.php-version }}-${{ matrix.dependencies }}
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
os:
40+
- ubuntu-latest
41+
php-version:
42+
- '8.5'
43+
dependencies:
44+
- highest
45+
name: 🧬 Infection PHP${{ matrix.php-version }}
46+
steps:
47+
- name: 📦 Check out the codebase
48+
uses: actions/checkout@v6
49+
50+
- name: 🛠️ Setup PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: ${{ matrix.php-version }}
54+
coverage: xdebug
55+
ini-values: error_reporting=E_ALL
56+
57+
- name: 📥 Install dependencies with composer
58+
uses: ramsey/composer-install@v3
59+
env:
60+
COMPOSER_ROOT_VERSION: '1.x-dev'
61+
with:
62+
dependency-versions: ${{ matrix.dependencies }}
63+
64+
- name: 🧬 Run Infection
65+
run: composer infect:ci

.gitmodules

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

composer.json

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@
3030
},
3131
"require-dev": {
3232
"buggregator/trap": "^1.15",
33-
"spiral/code-style": "^2.3.1",
33+
"infection/infection": "^0.33.2",
34+
"llm/skills": "^1.7",
3435
"roxblnfk/unpoly": "^1.8.1",
35-
"vimeo/psalm": "^6.13",
36-
"testo/testo": "^0.10.20"
36+
"spiral/code-style": "^2.3.1",
37+
"testo/bridge-infection": "^0.1.6",
38+
"testo/testo": "^0.10.21",
39+
"vimeo/psalm": "^7"
3740
},
3841
"minimum-stability": "dev",
3942
"prefer-stable": true,
@@ -47,16 +50,19 @@
4750
"Internal\\Path\\Tests\\": "tests/"
4851
}
4952
},
53+
"config": {
54+
"sort-packages": true,
55+
"allow-plugins": {
56+
"infection/extension-installer": true,
57+
"llm/skills": true
58+
}
59+
},
5060
"scripts": {
5161
"cs:diff": "php-cs-fixer fix --dry-run -v --diff",
5262
"cs:fix": "php-cs-fixer fix -v",
53-
"infect": [
54-
"@putenv XDEBUG_MODE=coverage",
55-
"roave-infection-static-analysis-plugin --configuration=infection.json.dist"
56-
],
63+
"infect": "infection --configuration=infection.json --threads=max",
5764
"infect:ci": [
58-
"@putenv XDEBUG_MODE=coverage",
59-
"roave-infection-static-analysis-plugin --ansi --configuration=infection.json.dist --logger-github --ignore-msi-with-no-mutations --only-covered"
65+
"infection --ansi --configuration=infection.json --logger-github --threads=max --show-mutations=0"
6066
],
6167
"psalm": "psalm",
6268
"psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",

infection.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "vendor/infection/infection/resources/schema.json",
3+
"source": {
4+
"directories": [
5+
"src"
6+
]
7+
},
8+
"testFramework": "testo"
9+
}

src/Path.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ final class Path implements \Stringable
3838
/**
3939
* @param non-empty-string $path The filesystem path. In never ends with a separator.
4040
* Might be ended with "." or ".." if the path is a directory.
41+
* @psalm-mutation-free
4142
*/
4243
private function __construct(
4344
private readonly string $path,
@@ -46,6 +47,9 @@ private function __construct(
4647

4748
/**
4849
* Create a new path object
50+
*
51+
* @psalm-pure
52+
* @psalm-mutation-free
4953
*/
5054
public static function create(self|string $path = ''): self
5155
{
@@ -58,6 +62,7 @@ public static function create(self|string $path = ''): self
5862
* Join this path with one or more path components
5963
*
6064
* @psalm-immutable
65+
* @psalm-mutation-free
6166
*/
6267
public function join(self|string ...$paths): self
6368
{
@@ -88,6 +93,7 @@ public function join(self|string ...$paths): self
8893
* Return the file or directory name (the final path component)
8994
*
9095
* @return non-empty-string
96+
* @psalm-mutation-free
9197
*/
9298
public function name(): string
9399
{
@@ -101,6 +107,7 @@ public function name(): string
101107
* Return the file stem (the file name without its extension)
102108
*
103109
* @return non-empty-string
110+
* @psalm-mutation-free
104111
*/
105112
public function stem(): string
106113
{
@@ -111,6 +118,8 @@ public function stem(): string
111118

112119
/**
113120
* Return the file suffix (extension) without the leading dot
121+
*
122+
* @psalm-mutation-free
114123
*/
115124
public function extension(): string
116125
{
@@ -123,6 +132,7 @@ public function extension(): string
123132
* Return the parent directory path
124133
*
125134
* @psalm-immutable
135+
* @psalm-mutation-free
126136
*/
127137
public function parent(): self
128138
{
@@ -152,6 +162,8 @@ public function parent(): self
152162

153163
/**
154164
* Return whether this path is absolute
165+
*
166+
* @psalm-mutation-free
155167
*/
156168
public function isAbsolute(): bool
157169
{
@@ -160,6 +172,8 @@ public function isAbsolute(): bool
160172

161173
/**
162174
* Return whether this path is relative
175+
*
176+
* @psalm-mutation-free
163177
*/
164178
public function isRelative(): bool
165179
{

0 commit comments

Comments
 (0)