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);
57 # remove from OAIFieldMappings too 59 DELETE FROM OAIFieldMappings 60 WHERE SPTFieldId = " . addslashes($FieldId));
67 $MyId = self::$TestFieldIds[
'ClassificationTestField'];
72 $this->assertInstanceOf(
73 Classification::class, $TestParent);
75 $TestParent->FieldId(), $MyId);
78 # attempt to create a duplicate w/o setting a parentid 84 "Exception not thrown on creation of duplicate Classification");
90 "Duplicate name specified for new classification " 94 # attempt to create a duplicate top-level class 100 "Exception not thrown on creation of duplicate Classification");
106 "Duplicate name specified for new classification " 110 # attempt to create a child with an invalid parent 114 "TestBadChild", $MyId, -10);
116 "Exception not thrown when creating with invalid ParentId");
120 $this->assertInstanceOf(
121 InvalidArgumentException::class, $e);
124 "Invalid parent ID specified (-10).");
127 # attempt to create a child, specifying the parent 129 "FirstChild", $MyId, $TestParent->Id() );
130 $this->assertInstanceOf(
131 Classification::class, $TestFirstChild);
133 $TestFirstChild->ParentId(),
136 # attempt to create a child, not specifying the parent 138 "TestParent -- SecondChild", $MyId);
139 $this->assertInstanceOf(
140 Classification::class, $TestSecondChild);
144 # test the various ways to retrieve our name 146 $TestSecondChild->Name(),
147 "TestParent -- SecondChild");
150 $TestSecondChild->FullName(),
151 "TestParent -- SecondChild");
154 $TestSecondChild->SegmentName(),
158 $TestSecondChild->VariantName());
161 $IdsUpdated = $TestSecondChild->RecalcResourceCount();
164 $TestSecondChild->Id(),
170 $this->assertEquals($IdsUpdated, $Expected);
172 # Test initial Depth values 174 $TestSecondChild->Depth(), 1);
176 $TestParent->Depth(), 0);
179 # test recalculating depth 180 $TestParent->RecalcDepthAndFullName();
182 # verify that names and depths remain correct after recalc 184 $TestSecondChild->FullName(),
185 "TestParent -- SecondChild");
187 $TestSecondChild->SegmentName(),
191 $TestSecondChild->Depth(), 1);
193 $TestParent->Depth(), 0);
196 $TestSecondChild->FullResourceCount(), 0);
199 # test listing children 200 $ChildIds = $TestParent->ChildList();
202 $TestFirstChild->Id(),
203 $TestSecondChild->Id() );
206 $this->assertEquals($ChildIds, $Expected);
209 $DelCount = $TestSecondChild->Delete();
213 # test deletions that eat our parents 214 $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.