16 # construct the schema object 20 self::$TestFieldIds = array();
22 # outline fields to be created 23 self::$TestFields = array(
28 foreach (self::$TestFields as $FieldName => $FieldType)
30 $TmpField = $Schema->GetItemByName($FieldName);
31 if ($TmpField === NULL)
33 $TmpField = $Schema->AddField($FieldName, $FieldType);
35 $TmpField->IsTempItem(FALSE);
36 self::$TestFieldIds[$FieldName] = $TmpField->Id();
47 # construct the schema object 52 # drop all of the test fields 53 foreach (self::$TestFieldIds as $FieldName => $FieldId)
55 $Schema->DropField($FieldId);
62 $MyId = self::$TestFieldIds[
'ClassificationTestField'];
67 $this->assertInstanceOf(
68 Classification::class, $TestParent);
70 $TestParent->FieldId(), $MyId);
73 # attempt to create a duplicate w/o setting a parentid 79 "Exception not thrown on creation of duplicate Classification");
85 "Duplicate name specified for new classification " 89 # attempt to create a duplicate top-level class 95 "Exception not thrown on creation of duplicate Classification");
101 "Duplicate name specified for new classification " 105 # attempt to create a child with an invalid parent 109 "TestBadChild", $MyId, -10);
111 "Exception not thrown when creating with invalid ParentId");
115 $this->assertInstanceOf(
116 InvalidArgumentException::class, $e);
119 "Invalid parent ID specified (-10).");
122 # attempt to create a child, specifying the parent 124 "FirstChild", $MyId, $TestParent->Id() );
125 $this->assertInstanceOf(
126 Classification::class, $TestFirstChild);
128 $TestFirstChild->ParentId(),
131 # attempt to create a child, not specifying the parent 133 "TestParent -- SecondChild", $MyId);
134 $this->assertInstanceOf(
135 Classification::class, $TestSecondChild);
139 # test the various ways to retrieve our name 141 $TestSecondChild->Name(),
142 "TestParent -- SecondChild");
145 $TestSecondChild->FullName(),
146 "TestParent -- SecondChild");
149 $TestSecondChild->SegmentName(),
153 $TestSecondChild->VariantName());
156 $IdsUpdated = $TestSecondChild->RecalcResourceCount();
159 $TestSecondChild->Id(),
165 $this->assertEquals($IdsUpdated, $Expected);
167 # Test initial Depth values 169 $TestSecondChild->Depth(), 1);
171 $TestParent->Depth(), 0);
174 # test recalculating depth 175 $TestParent->RecalcDepthAndFullName();
177 # verify that names and depths remain correct after recalc 179 $TestSecondChild->FullName(),
180 "TestParent -- SecondChild");
182 $TestSecondChild->SegmentName(),
186 $TestSecondChild->Depth(), 1);
188 $TestParent->Depth(), 0);
191 $TestSecondChild->FullResourceCount(), 0);
194 # test listing children 195 $ChildIds = $TestParent->ChildList();
197 $TestFirstChild->Id(),
198 $TestSecondChild->Id() );
201 $this->assertEquals($ChildIds, $Expected);
204 $DelCount = $TestSecondChild->Delete();
208 # test deletions that eat our parents 209 $DelCount = $TestFirstChild->Delete(TRUE);
static SegmentsCreated()
Get number of new segments (Classifications) generated when creating a new Classification with a full...
SQL database abstraction object with smart query caching.
static Create($Name, $FieldId, $ParentId=NULL)
Add new classification to the hierarchy.
const NOPARENT
Parent value for classifications with no parent.
static tearDownAfterClass()
After to running the tests, this function is run.
static setUpBeforeClass()
Prior to running any of the tests, this function is run.