Skip to content

Commit

Permalink
Add non-numeric tests for hierarchy & movement operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepat committed Apr 29, 2014
1 parent 7a51140 commit cbf22b2
Show file tree
Hide file tree
Showing 5 changed files with 807 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<file>tests/suite/QueryBuilderExtensionTest.php</file>
<file>tests/suite/NodeModelExtensionsTest.php</file>
<directory>tests/suite/Category</directory>
<directory>tests/suite/Cluster</directory>
</testsuite>
</testsuites>
</phpunit>
19 changes: 19 additions & 0 deletions tests/seeders/ClusterSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,22 @@ public function run() {
}

}

class OrderedClusterSeeder {

public function run() {
DB::table('clusters')->delete();

OrderedCluster::unguard();

OrderedCluster::create(array('id' => '7461d8f5-2ea9-4788-99c4-9d0244f0bfb1', 'name' => 'Root Z' , 'lft' => 1 , 'rgt' => 10 , 'depth' => 0));
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'));
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'));
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'));
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'));
OrderedCluster::create(array('id' => '3bb62314-9e1e-49c6-a5cb-17a9ab9b1b9a', 'name' => 'Root A' , 'lft' => 11 , 'rgt' => 12 , 'depth' => 0));

OrderedCluster::reguard();
}

}
19 changes: 19 additions & 0 deletions tests/suite/Cluster/ClusterColumnsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

class ClusterColumnsTest extends ClusterTestCase {

public function testKeyIsNonNumeric() {
$root = Cluster::root();

$this->assertTrue(is_string($root->getKey()));
$this->assertFalse(is_numeric($root->getKey()));
}

public function testParentKeyIsNonNumeric() {
$child1 = $this->clusters('Child 1');

$this->assertTrue(is_string($child1->getParentId()));
$this->assertFalse(is_numeric($child1->getParentId()));
}

}
Loading

0 comments on commit cbf22b2

Please sign in to comment.