@@ -5,24 +5,24 @@ |
||
| 5 | 5 | |
| 6 | 6 | class PrevNextSiblingExtensionTest extends SapphireTest { |
| 7 | 7 | |
| 8 | - protected static $fixture_file = 'tests/PrevNextSiblingExtensionTest.yml'; |
|
| 8 | + protected static $fixture_file = 'tests/PrevNextSiblingExtensionTest.yml'; |
|
| 9 | 9 | |
| 10 | 10 | public function testNextSibling() { |
| 11 | 11 | $child1 = $this->objFromFixture('Page', 'child01'); |
| 12 | - $child2 = $this->objFromFixture('Page', 'child02'); |
|
| 13 | - $child3 = $this->objFromFixture('Page', 'child03'); |
|
| 14 | - $this->assertNull($child3->NextSibling()); |
|
| 15 | - $this->assertEquals($child2->ID, $child1->NextSibling()->ID); |
|
| 16 | - $this->assertEquals($child3->ID, $child2->NextSibling()->ID); |
|
| 12 | + $child2 = $this->objFromFixture('Page', 'child02'); |
|
| 13 | + $child3 = $this->objFromFixture('Page', 'child03'); |
|
| 14 | + $this->assertNull($child3->NextSibling()); |
|
| 15 | + $this->assertEquals($child2->ID, $child1->NextSibling()->ID); |
|
| 16 | + $this->assertEquals($child3->ID, $child2->NextSibling()->ID); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function testPreviousSibling() { |
| 20 | 20 | $child1 = $this->objFromFixture('Page', 'child01'); |
| 21 | - $this->assertNull($child1->PreviousSibling()); |
|
| 22 | - $child2 = $this->objFromFixture('Page', 'child02'); |
|
| 23 | - $this->assertEquals($child1->ID, $child2->PreviousSibling()->ID); |
|
| 24 | - $child3 = $this->objFromFixture('Page', 'child03'); |
|
| 25 | - $this->assertEquals($child2->ID, $child3->PreviousSibling()->ID); |
|
| 21 | + $this->assertNull($child1->PreviousSibling()); |
|
| 22 | + $child2 = $this->objFromFixture('Page', 'child02'); |
|
| 23 | + $this->assertEquals($child1->ID, $child2->PreviousSibling()->ID); |
|
| 24 | + $child3 = $this->objFromFixture('Page', 'child03'); |
|
| 25 | + $this->assertEquals($child2->ID, $child3->PreviousSibling()->ID); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | } |
@@ -7,16 +7,16 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PrevNextSiblingExtension extends Extension |
| 9 | 9 | { |
| 10 | - public function NextSibling() |
|
| 11 | - { |
|
| 12 | - $where = "\"ParentID\" = {$this->owner->ParentID} AND \"Sort\" > {$this->owner->Sort}"; |
|
| 13 | - $result = SiteTree::get()->where($where)->sort('"Sort"')->First(); |
|
| 14 | - return $result; |
|
| 15 | - } |
|
| 10 | + public function NextSibling() |
|
| 11 | + { |
|
| 12 | + $where = "\"ParentID\" = {$this->owner->ParentID} AND \"Sort\" > {$this->owner->Sort}"; |
|
| 13 | + $result = SiteTree::get()->where($where)->sort('"Sort"')->First(); |
|
| 14 | + return $result; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function PreviousSibling() |
|
| 18 | - { |
|
| 19 | - $where = "\"ParentID\" = {$this->owner->ParentID} AND \"Sort\" < {$this->owner->Sort}"; |
|
| 20 | - return SiteTree::get()->where($where)->sort('"Sort" DESC')->First(); |
|
| 21 | - } |
|
| 17 | + public function PreviousSibling() |
|
| 18 | + { |
|
| 19 | + $where = "\"ParentID\" = {$this->owner->ParentID} AND \"Sort\" < {$this->owner->Sort}"; |
|
| 20 | + return SiteTree::get()->where($where)->sort('"Sort" DESC')->First(); |
|
| 21 | + } |
|
| 22 | 22 | } |