| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
use bookstore::Peer as PropelPeer; |
|---|
| 4 |
use bookstore::Model as PropelModel; |
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
require_once 'cms/CmsTestBase.php'; |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
class GeneratedNestedSetObjectTest extends CmsTestBase { |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
* Test xxxNestedSet::isRoot() as true |
|---|
| 46 |
*/ |
|---|
| 47 |
public function testObjectIsRootTrue() |
|---|
| 48 |
{ |
|---|
| 49 |
$pp = PropelPeer::PagePeer::retrieveRoot(1); |
|---|
| 50 |
$this->assertTrue($pp->isRoot(), 'Node must be root'); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
* Test xxxNestedSet::isRoot() as false |
|---|
| 55 |
*/ |
|---|
| 56 |
public function testObjectIsRootFalse() |
|---|
| 57 |
{ |
|---|
| 58 |
$c = new ::Criteria(PropelPeer::PagePeer::DATABASE_NAME); |
|---|
| 59 |
$c->add(PropelPeer::PagePeer::TITLE, 'school', ::Criteria::EQUAL); |
|---|
| 60 |
|
|---|
| 61 |
$school = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 62 |
$this->assertFalse($school->isRoot(), 'Node must not be root'); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
* Test xxxNestedSet::retrieveParent() as true. |
|---|
| 67 |
*/ |
|---|
| 68 |
public function testObjectRetrieveParentTrue() |
|---|
| 69 |
{ |
|---|
| 70 |
$c = new ::Criteria(PropelPeer::PagePeer::DATABASE_NAME); |
|---|
| 71 |
$c->add(PropelPeer::PagePeer::TITLE, 'school', ::Criteria::EQUAL); |
|---|
| 72 |
|
|---|
| 73 |
$school = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 74 |
$this->assertNotNull($school->retrieveParent(), 'Parent node must exist'); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
* Test xxxNestedSet::retrieveParent() as false. |
|---|
| 79 |
*/ |
|---|
| 80 |
public function testObjectRetrieveParentFalse() |
|---|
| 81 |
{ |
|---|
| 82 |
$c = new ::Criteria(PropelPeer::PagePeer::DATABASE_NAME); |
|---|
| 83 |
$c->add(PropelPeer::PagePeer::TITLE, 'home', ::Criteria::EQUAL); |
|---|
| 84 |
|
|---|
| 85 |
$home = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 86 |
$this->assertNull($home->retrieveParent(), 'Parent node must not exist and retrieved not be null'); |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
* Test xxxNestedSet::hasParent() as true. |
|---|
| 91 |
*/ |
|---|
| 92 |
public function testObjectHasParentTrue() |
|---|
| 93 |
{ |
|---|
| 94 |
$c = new ::Criteria(); |
|---|
| 95 |
$c->add(PropelPeer::PagePeer::TITLE, 'school', ::Criteria::EQUAL); |
|---|
| 96 |
|
|---|
| 97 |
$school = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 98 |
$this->assertTrue($school->hasParent(), 'Node must have parent node'); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
* Test xxxNestedSet::hasParent() as false |
|---|
| 103 |
*/ |
|---|
| 104 |
public function testObjectHasParentFalse() |
|---|
| 105 |
{ |
|---|
| 106 |
$c = new ::Criteria(); |
|---|
| 107 |
$c->add(PropelPeer::PagePeer::TITLE, 'home', ::Criteria::EQUAL); |
|---|
| 108 |
|
|---|
| 109 |
$home = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 110 |
$this->assertFalse($home->hasParent(), 'Root node must not have parent'); |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
* Test xxxNestedSet::isLeaf() as true. |
|---|
| 115 |
*/ |
|---|
| 116 |
public function testObjectIsLeafTrue() |
|---|
| 117 |
{ |
|---|
| 118 |
$c = new ::Criteria(); |
|---|
| 119 |
$c->add(PropelPeer::PagePeer::TITLE, 'simulator', ::Criteria::EQUAL); |
|---|
| 120 |
|
|---|
| 121 |
$simulator = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 122 |
$this->assertTrue($simulator->isLeaf($simulator), 'Node must be a leaf'); |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
* Test xxxNestedSet::isLeaf() as false |
|---|
| 127 |
*/ |
|---|
| 128 |
public function testObjectIsLeafFalse() |
|---|
| 129 |
{ |
|---|
| 130 |
$c = new ::Criteria(); |
|---|
| 131 |
$c->add(PropelPeer::PagePeer::TITLE, 'contact', ::Criteria::EQUAL); |
|---|
| 132 |
|
|---|
| 133 |
$contact = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 134 |
$this->assertFalse($contact->isLeaf($contact), 'Node must not be a leaf'); |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
* Test xxxNestedSet::makeRoot() |
|---|
| 139 |
*/ |
|---|
| 140 |
public function testObjectMakeRoot() |
|---|
| 141 |
{ |
|---|
| 142 |
$page = new PropelModel::Page(); |
|---|
| 143 |
$page->makeRoot(); |
|---|
| 144 |
$this->assertEquals(1, $page->getLeftValue(), 'Node left value must equal 1'); |
|---|
| 145 |
$this->assertEquals(2, $page->getRightValue(), 'Node right value must equal 2'); |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
* Test xxxNestedSet::makeRoot() exception |
|---|
| 150 |
* @expectedException PropelException |
|---|
| 151 |
*/ |
|---|
| 152 |
public function testObjectMakeRootException() |
|---|
| 153 |
{ |
|---|
| 154 |
$c = new ::Criteria(); |
|---|
| 155 |
$c->add(PropelPeer::PagePeer::TITLE, 'home', ::Criteria::EQUAL); |
|---|
| 156 |
|
|---|
| 157 |
$home = PropelPeer::PagePeer::doSelectOne($c); |
|---|
| 158 |
$home->makeRoot(); |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
} |
|---|
| 162 |
|
|---|
| 163 |
?> |
|---|