Skip to content

Commit cbf22b2

Browse files
committed
Add non-numeric tests for hierarchy & movement operations.
1 parent 7a51140 commit cbf22b2

File tree

5 files changed

+807
-0
lines changed

5 files changed

+807
-0
lines changed

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<file>tests/suite/QueryBuilderExtensionTest.php</file>
1515
<file>tests/suite/NodeModelExtensionsTest.php</file>
1616
<directory>tests/suite/Category</directory>
17+
<directory>tests/suite/Cluster</directory>
1718
</testsuite>
1819
</testsuites>
1920
</phpunit>

tests/seeders/ClusterSeeder.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@ public function run() {
2020
}
2121

2222
}
23+
24+
class OrderedClusterSeeder {
25+
26+
public function run() {
27+
DB::table('clusters')->delete();
28+
29+
OrderedCluster::unguard();
30+
31+
OrderedCluster::create(array('id' => '7461d8f5-2ea9-4788-99c4-9d0244f0bfb1', 'name' => 'Root Z' , 'lft' => 1 , 'rgt' => 10 , 'depth' => 0));
32+
OrderedCluster::create(array('id' => '5d7ce1fd-6151-46d3-a5b3-0ebb9988dc57', 'name' => 'Child C' , 'lft' => 2 , 'rgt' => 3 , 'depth' => 1, 'parent_id' => '7461d8f5-2ea9-4788-99c4-9d0244f0bfb1'));
33+
OrderedCluster::create(array('id' => '07c1fc8c-53b5-4fe7-b9c4-e09f266a455c', 'name' => 'Child G' , 'lft' => 4 , 'rgt' => 7 , 'depth' => 1, 'parent_id' => '7461d8f5-2ea9-4788-99c4-9d0244f0bfb1'));
34+
OrderedCluster::create(array('id' => '3315a297-af87-4ad3-9fa5-19785407573d', 'name' => 'Child G.1', 'lft' => 5 , 'rgt' => 6 , 'depth' => 2, 'parent_id' => '07c1fc8c-53b5-4fe7-b9c4-e09f266a455c'));
35+
OrderedCluster::create(array('id' => '054476d2-6830-4014-a181-4de010ef7114', 'name' => 'Child A' , 'lft' => 8 , 'rgt' => 9 , 'depth' => 1, 'parent_id' => '7461d8f5-2ea9-4788-99c4-9d0244f0bfb1'));
36+
OrderedCluster::create(array('id' => '3bb62314-9e1e-49c6-a5cb-17a9ab9b1b9a', 'name' => 'Root A' , 'lft' => 11 , 'rgt' => 12 , 'depth' => 0));
37+
38+
OrderedCluster::reguard();
39+
}
40+
41+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
class ClusterColumnsTest extends ClusterTestCase {
4+
5+
public function testKeyIsNonNumeric() {
6+
$root = Cluster::root();
7+
8+
$this->assertTrue(is_string($root->getKey()));
9+
$this->assertFalse(is_numeric($root->getKey()));
10+
}
11+
12+
public function testParentKeyIsNonNumeric() {
13+
$child1 = $this->clusters('Child 1');
14+
15+
$this->assertTrue(is_string($child1->getParentId()));
16+
$this->assertFalse(is_numeric($child1->getParentId()));
17+
}
18+
19+
}

0 commit comments

Comments
 (0)