|
@@ 121-140 (lines=20) @@
|
| 118 |
|
$this->assertEquals($parent->primaryKey,2); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
public function testPrev() |
| 122 |
|
{ |
| 123 |
|
// single root |
| 124 |
|
$nestedSet=NestedSet::model()->findByPk(7); |
| 125 |
|
$this->assertTrue($nestedSet instanceof NestedSet); |
| 126 |
|
$sibling=$nestedSet->prev()->find(); |
| 127 |
|
$this->assertTrue($sibling instanceof NestedSet); |
| 128 |
|
$this->assertEquals($sibling->primaryKey,6); |
| 129 |
|
$sibling=$sibling->prev()->find(); |
| 130 |
|
$this->assertNull($sibling); |
| 131 |
|
|
| 132 |
|
// many roots |
| 133 |
|
$nestedSet=NestedSetWithManyRoots::model()->findByPk(7); |
| 134 |
|
$this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
| 135 |
|
$sibling=$nestedSet->prev()->find(); |
| 136 |
|
$this->assertTrue($sibling instanceof NestedSetWithManyRoots); |
| 137 |
|
$this->assertEquals($sibling->primaryKey,6); |
| 138 |
|
$sibling=$sibling->prev()->find(); |
| 139 |
|
$this->assertNull($sibling); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
public function testNext() |
| 143 |
|
{ |
|
@@ 142-161 (lines=20) @@
|
| 139 |
|
$this->assertNull($sibling); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
public function testNext() |
| 143 |
|
{ |
| 144 |
|
// single root |
| 145 |
|
$nestedSet=NestedSet::model()->findByPk(6); |
| 146 |
|
$this->assertTrue($nestedSet instanceof NestedSet); |
| 147 |
|
$sibling=$nestedSet->next()->find(); |
| 148 |
|
$this->assertTrue($sibling instanceof NestedSet); |
| 149 |
|
$this->assertEquals($sibling->primaryKey,7); |
| 150 |
|
$sibling=$sibling->next()->find(); |
| 151 |
|
$this->assertNull($sibling); |
| 152 |
|
|
| 153 |
|
// many roots |
| 154 |
|
$nestedSet=NestedSetWithManyRoots::model()->findByPk(6); |
| 155 |
|
$this->assertTrue($nestedSet instanceof NestedSetWithManyRoots); |
| 156 |
|
$sibling=$nestedSet->next()->find(); |
| 157 |
|
$this->assertTrue($sibling instanceof NestedSetWithManyRoots); |
| 158 |
|
$this->assertEquals($sibling->primaryKey,7); |
| 159 |
|
$sibling=$sibling->next()->find(); |
| 160 |
|
$this->assertNull($sibling); |
| 161 |
|
} |
| 162 |
|
|
| 163 |
|
/** |
| 164 |
|
* @depends testDescendants |