Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9c8520e
chore: Add `mutation` testing workflow and configuration files.
terabytesoftw Jun 29, 2025
2a16fcd
chore: Add `infection` plugin configuration and mutation testing scri…
terabytesoftw Jun 29, 2025
bf0831f
chore: Add `infection` dependency to `require-dev` in `composer.json`.
terabytesoftw Jun 29, 2025
3a34701
test: Add `null` coalescing operator test in `NestedSetsBehaviorTest`…
terabytesoftw Jun 29, 2025
de3b750
refactor: Update `beforeInsertNode` method to throw exception for `nu…
terabytesoftw Jun 29, 2025
3c19ebc
Merge branch 'main' into feat-mini-1.
terabytesoftw Jun 29, 2025
3b07b86
test: Add transaction rollback test for delete operation with childre…
terabytesoftw Jun 29, 2025
429c795
test: Add validation tests for `appendTo` method in `NestedSetsBehavi…
terabytesoftw Jun 30, 2025
339f7b0
test: Add strict validation for `Tree` model and update tests for `ap…
terabytesoftw Jun 30, 2025
8f744de
test: Enhance validation checks in `appendTo` method for `TreeWithStr…
terabytesoftw Jun 30, 2025
8630ec4
Apply fixes from StyleCI
StyleCIBot Jun 30, 2025
a09095b
test: Remove redundant parameter from `appendTo` method call in `Nest…
terabytesoftw Jun 30, 2025
4380651
Merge branch 'main' into feat-mini-1.
terabytesoftw Jun 30, 2025
f60111d
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
372f9c6
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
5c3b8e8
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
e3eeb8d
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
0fa313d
feat: Update validation scenarios in `prependTo` method tests to ensu…
terabytesoftw Jun 30, 2025
5e6f8a0
fix: Remove unnecessary validation parameter from `prependTo` method …
terabytesoftw Jun 30, 2025
cb2d003
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
a3cff2e
feat: Add `ExtendableMultipleTree` and `ExtendableMultipleTreeQuery` …
terabytesoftw Jun 30, 2025
758a92b
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
dd48f77
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
b02cb06
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
a5e88bc
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
182da72
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
9542071
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
92a47da
test: Add verification for correct order of children by `left` attrib…
terabytesoftw Jun 30, 2025
d0e7eee
test: Add verification for correct order of parents by 'left' attribu…
terabytesoftw Jun 30, 2025
30c00b8
test: Refactor children and parents order verification methods for cl…
terabytesoftw Jun 30, 2025
6f90737
test: Update children method to require order by for correct tree tra…
terabytesoftw Jun 30, 2025
32d923a
Apply fixes from StyleCI
StyleCIBot Jun 30, 2025
31d7cc0
test: Refactor child existence assertions for improved clarity and sa…
terabytesoftw Jun 30, 2025
461f51c
test: Simplify child order assertions for clarity and maintainability.
terabytesoftw Jun 30, 2025
bf01e28
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
c04b85b
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
73b9407
test: Refactor roots method test to use database inserts for tree nod…
terabytesoftw Jun 30, 2025
674e9de
Apply fixes from StyleCI
StyleCIBot Jun 30, 2025
e816235
refactor: Update roots method to order by left attribute and tree att…
terabytesoftw Jun 30, 2025
ed763f9
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
b75f9a2
test: Add verification for leaves method ordering based on left attri…
terabytesoftw Jun 30, 2025
03fd99e
Merge branch 'main' into feat-mini-1
terabytesoftw Jun 30, 2025
b0944dc
test: Remove redundant leaves method ordering verification in `Nested…
terabytesoftw Jun 30, 2025
2e6f83c
test: Add verification for roots method ordering in `NestedSetsQueryB…
terabytesoftw Jun 30, 2025
fa9883f
test: Refactor leaves method test to maintain left attribute ordering…
terabytesoftw Jun 30, 2025
812e954
test: Remove redundant leaves method ordering verification when tree …
terabytesoftw Jun 30, 2025
bddddfa
test: Add verification for roots method ordering when tree attribute …
terabytesoftw Jul 1, 2025
d6ec8e4
Merge branch 'main' into feat-mini-1
terabytesoftw Jul 1, 2025
89e8d37
Merge branch 'main' into feat-mini-1
terabytesoftw Jul 1, 2025
7a0c607
fix: Update left attribute shifting logic in `NestedSetsBehavior` to …
terabytesoftw Jul 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'

name: mutation test

jobs:
mutation:
uses: php-forge/actions/.github/workflows/infection.yml@main
with:
phpstan: true
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"require-dev": {
"ext-simplexml": "*",
"infection/infection": "^0.27|^0.29",
"maglnet/composer-require-checker": "^4.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-strict-rules": "^2.0.3",
Expand All @@ -41,13 +42,15 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"phpstan/extension-installer": true,
"yiisoft/yii2-composer": true
}
},
"scripts": {
"check-dependencies": "./vendor/bin/composer-require-checker check",
"ecs": "./vendor/bin/ecs --fix",
"mutation": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --only-covered --min-msi=100 --min-covered-msi=100",
"rector": "./vendor/bin/rector process src",
"static": "./vendor/bin/phpstan --memory-limit=512M",
"tests": "./vendor/bin/phpunit"
Expand Down
17 changes: 9 additions & 8 deletions infection.json.dist → infection.json5
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"source": {
"directories": [
"src"
]
},
"$schema": "vendor/infection/infection/resources/schema.json",
"logs": {
"text": "php:\/\/stderr",
"stryker": {
"report": "main"
}
},
"mutators": {
"@default": true
}
"source": {
"directories": [
"src"
]
},
"phpStan": {
"configDir": "."
},
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="tests/bootstrap.php"
cacheDirectory="runtime/.phpunit.cache"
colors="true"
Expand Down
2 changes: 1 addition & 1 deletion src/NestedSetsBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,21 +527,21 @@
{
$this->operation = self::OPERATION_DELETE_WITH_CHILDREN;

if ($this->getOwner()->isTransactional(ActiveRecord::OP_DELETE) !== false) {

Check warning on line 530 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "NotIdentical": @@ @@ public function deleteWithChildren(): bool|int { $this->operation = self::OPERATION_DELETE_WITH_CHILDREN; - if ($this->getOwner()->isTransactional(ActiveRecord::OP_DELETE) !== false) { + if ($this->getOwner()->isTransactional(ActiveRecord::OP_DELETE) === false) { return $this->deleteWithChildrenInternal(); } $transaction = $this->getOwner()::getDb()->beginTransaction();

Check warning on line 530 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "NotIdentical": @@ @@ public function deleteWithChildren(): bool|int { $this->operation = self::OPERATION_DELETE_WITH_CHILDREN; - if ($this->getOwner()->isTransactional(ActiveRecord::OP_DELETE) !== false) { + if ($this->getOwner()->isTransactional(ActiveRecord::OP_DELETE) === false) { return $this->deleteWithChildrenInternal(); } $transaction = $this->getOwner()::getDb()->beginTransaction();
return $this->deleteWithChildrenInternal();
}

$transaction = $this->getOwner()::getDb()->beginTransaction();

try {
match ($result = $this->deleteWithChildrenInternal()) {

Check warning on line 537 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MatchArmRemoval": @@ @@ $transaction = $this->getOwner()::getDb()->beginTransaction(); try { match ($result = $this->deleteWithChildrenInternal()) { - false => $transaction->rollBack(), default => $transaction->commit(), }; return $result;

Check warning on line 537 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MatchArmRemoval": @@ @@ $transaction = $this->getOwner()::getDb()->beginTransaction(); try { match ($result = $this->deleteWithChildrenInternal()) { - false => $transaction->rollBack(), default => $transaction->commit(), }; return $result;
false => $transaction->rollBack(),
default => $transaction->commit(),
};

return $result;
} catch (Exception $e) {
$transaction->rollBack();

Check warning on line 544 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ }; return $result; } catch (Exception $e) { - $transaction->rollBack(); + throw $e; } }

Check warning on line 544 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ }; return $result; } catch (Exception $e) { - $transaction->rollBack(); + throw $e; } }

throw $e;
}
Expand Down Expand Up @@ -691,7 +691,7 @@
$nodeLeft = $node->getAttribute($this->leftAttribute);
$nodeRight = $node->getAttribute($this->rightAttribute);

if ($currentLeft <= $nodeLeft || $currentRight >= $nodeRight) {

Check warning on line 694 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "GreaterThanOrEqualTo": @@ @@ $currentRight = $owner->getAttribute($this->rightAttribute); $nodeLeft = $node->getAttribute($this->leftAttribute); $nodeRight = $node->getAttribute($this->rightAttribute); - if ($currentLeft <= $nodeLeft || $currentRight >= $nodeRight) { + if ($currentLeft <= $nodeLeft || $currentRight > $nodeRight) { return false; } if ($this->treeAttribute !== false) {

Check warning on line 694 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LessThanOrEqualTo": @@ @@ $currentRight = $owner->getAttribute($this->rightAttribute); $nodeLeft = $node->getAttribute($this->leftAttribute); $nodeRight = $node->getAttribute($this->rightAttribute); - if ($currentLeft <= $nodeLeft || $currentRight >= $nodeRight) { + if ($currentLeft < $nodeLeft || $currentRight >= $nodeRight) { return false; } if ($this->treeAttribute !== false) {

Check warning on line 694 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "GreaterThanOrEqualTo": @@ @@ $currentRight = $owner->getAttribute($this->rightAttribute); $nodeLeft = $node->getAttribute($this->leftAttribute); $nodeRight = $node->getAttribute($this->rightAttribute); - if ($currentLeft <= $nodeLeft || $currentRight >= $nodeRight) { + if ($currentLeft <= $nodeLeft || $currentRight > $nodeRight) { return false; } if ($this->treeAttribute !== false) {

Check warning on line 694 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LessThanOrEqualTo": @@ @@ $currentRight = $owner->getAttribute($this->rightAttribute); $nodeLeft = $node->getAttribute($this->leftAttribute); $nodeRight = $node->getAttribute($this->rightAttribute); - if ($currentLeft <= $nodeLeft || $currentRight >= $nodeRight) { + if ($currentLeft < $nodeLeft || $currentRight >= $nodeRight) { return false; } if ($this->treeAttribute !== false) {
return false;
}

Expand Down Expand Up @@ -800,7 +800,7 @@

$this->applyTreeAttributeCondition($condition);

return $this->getOwner()::find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);

Check warning on line 803 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ { $condition = ['and', ['>', $this->leftAttribute, $this->getOwner()->getAttribute($this->leftAttribute)], ['<', $this->rightAttribute, $this->getOwner()->getAttribute($this->rightAttribute)], [$this->rightAttribute => new Expression($this->getOwner()::getDb()->quoteColumnName($this->leftAttribute) . '+ 1')]]; $this->applyTreeAttributeCondition($condition); - return $this->getOwner()::find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); + return $this->getOwner()::find()->andWhere($condition)->addOrderBy([]); } /** * Creates the root node if the active record is new, or moves it as the root node in the nested set tree.

Check warning on line 803 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ { $condition = ['and', ['>', $this->leftAttribute, $this->getOwner()->getAttribute($this->leftAttribute)], ['<', $this->rightAttribute, $this->getOwner()->getAttribute($this->rightAttribute)], [$this->rightAttribute => new Expression($this->getOwner()::getDb()->quoteColumnName($this->leftAttribute) . '+ 1')]]; $this->applyTreeAttributeCondition($condition); - return $this->getOwner()::find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); + return $this->getOwner()::find()->andWhere($condition)->addOrderBy([]); } /** * Creates the root node if the active record is new, or moves it as the root node in the nested set tree.
}

/**
Expand Down Expand Up @@ -943,7 +943,7 @@

$this->applyTreeAttributeCondition($condition);

return $this->getOwner()::find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]);

Check warning on line 946 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ $condition[] = ['>=', $this->depthAttribute, $this->getOwner()->getAttribute($this->depthAttribute) - $depth]; } $this->applyTreeAttributeCondition($condition); - return $this->getOwner()::find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); + return $this->getOwner()::find()->andWhere($condition)->addOrderBy([]); } /** * Inserts the current node as the first child of the specified target node or moves it if it already exists.

Check warning on line 946 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "ArrayItemRemoval": @@ @@ $condition[] = ['>=', $this->depthAttribute, $this->getOwner()->getAttribute($this->depthAttribute) - $depth]; } $this->applyTreeAttributeCondition($condition); - return $this->getOwner()::find()->andWhere($condition)->addOrderBy([$this->leftAttribute => SORT_ASC]); + return $this->getOwner()::find()->andWhere($condition)->addOrderBy([]); } /** * Inserts the current node as the first child of the specified target node or moves it if it already exists.
}

/**
Expand Down Expand Up @@ -1152,7 +1152,7 @@

$this->applyTreeAttributeCondition($condition);
$result = $this->getOwner()::deleteAll($condition);
$this->getOwner()->setOldAttributes(null);

Check warning on line 1155 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ $condition = ['and', ['>=', $this->leftAttribute, $this->owner?->getAttribute($this->leftAttribute)], ['<=', $this->rightAttribute, $this->owner?->getAttribute($this->rightAttribute)]]; $this->applyTreeAttributeCondition($condition); $result = $this->getOwner()::deleteAll($condition); - $this->getOwner()->setOldAttributes(null); + $this->getOwner()->afterDelete(); return $result; }

Check warning on line 1155 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ $condition = ['and', ['>=', $this->leftAttribute, $this->owner?->getAttribute($this->leftAttribute)], ['<=', $this->rightAttribute, $this->owner?->getAttribute($this->rightAttribute)]]; $this->applyTreeAttributeCondition($condition); $result = $this->getOwner()::deleteAll($condition); - $this->getOwner()->setOldAttributes(null); + $this->getOwner()->afterDelete(); return $result; }
$this->getOwner()->afterDelete();

return $result;
Expand Down Expand Up @@ -1199,7 +1199,7 @@

$this->shiftLeftRightAttribute($value, $delta);

if ($leftValue >= $value) {
if ($leftValue > $value) {

Check warning on line 1202 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "GreaterThan": @@ @@ if ($this->treeAttribute === false || $this->getOwner()->getAttribute($this->treeAttribute) === $node->getAttribute($this->treeAttribute)) { $delta = $rightValue - $leftValue + 1; $this->shiftLeftRightAttribute($value, $delta); - if ($leftValue > $value) { + if ($leftValue >= $value) { $leftValue += $delta; $rightValue += $delta; }

Check warning on line 1202 in src/NestedSetsBehavior.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "GreaterThan": @@ @@ if ($this->treeAttribute === false || $this->getOwner()->getAttribute($this->treeAttribute) === $node->getAttribute($this->treeAttribute)) { $delta = $rightValue - $leftValue + 1; $this->shiftLeftRightAttribute($value, $delta); - if ($leftValue > $value) { + if ($leftValue >= $value) { $leftValue += $delta; $rightValue += $delta; }
$leftValue += $delta;
$rightValue += $delta;
}
Expand Down