Skip to content

Commit 07956d2

Browse files
committed
feat: update mutation workflow to include 'mutation' group in test framework options and add MutationTest for tree traversal validation.
1 parent 1ff5ed8 commit 07956d2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

.github/workflows/mutation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: php-forge/actions/.github/workflows/infection.yml@main
2323
with:
2424
extensions: pdo, pdo_pgsql, pdo_sqlite
25-
framework-options: --test-framework-options="--group=sqlite"
25+
framework-options: --test-framework-options="--group=sqlite,mutation"
2626
hook: |
2727
# Configurar PostgreSQL con Docker
2828
docker run -d \

tests/pgsql/MutationTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\pgsql;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\TestCase;
9+
10+
#[Group('mutation')]
11+
final class MutationTest extends TestCase
12+
{
13+
public function testChildrenMethodRequiresOrderByForCorrectTreeTraversal(): void
14+
{
15+
$expectedOrder = ['Child A', 'Child B', 'Child C'];
16+
17+
$treeStructure = [
18+
['name' => 'Root', 'children' => ['Child B', 'Child C', 'Child A']],
19+
];
20+
21+
$updates = [
22+
['name' => 'Child B', 'lft' => 4, 'rgt' => 5],
23+
['name' => 'Child C', 'lft' => 6, 'rgt' => 7],
24+
['name' => 'Child A', 'lft' => 2, 'rgt' => 3],
25+
['name' => 'Root', 'rgt' => 8],
26+
];
27+
28+
$tree = $this->createTreeStructure($treeStructure, $updates);
29+
$nodeList = $tree->children()->all();
30+
31+
$this->assertNodesInCorrectOrder($nodeList, $expectedOrder, 'Child');
32+
}
33+
}

0 commit comments

Comments
 (0)