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[
'ControlledNameTestField'];
66 $this->assertInstanceOf(
67 ControlledName::class, $TestName);
69 $TestName->FieldId(), $MyId);
71 $TestName->Name(),
"TestName");
73 $TestName->InUse(), 0);
75 $TestName->GetAssociatedResources(), array() );
77 $TestName->VariantName(), NULL);
79 $TestName->Qualifier(), NULL);
81 # test setting / updating / clearing variants 83 $TestName->VariantName(
"TestVariant"),
"TestVariant");
85 $TestName->VariantName(),
"TestVariant");
87 $TestName->VariantName(
"ChangedVariant"),
"ChangedVariant");
89 $TestName->VariantName(),
"ChangedVariant");
91 $TestName->VariantName(FALSE), NULL);
93 $TestName->VariantName(), NULL);
95 # test setting / clearing Qualifiers 98 $TestName->Qualifier($MyQual)->Id(), $MyQual->Id());
100 $TestName->Qualifier()->Id(), $MyQual->Id());
103 $TestName->QualifierId(NULL), NULL);
105 $TestName->Qualifier(), NULL);
111 array($TestName->Id()),
115 # Create a duplicate of the name 117 "TestName", $MyId), TRUE);
120 $TestDup->Id(), $TestName->Id() );
122 # load an invalid name 125 $ExpIsThrown = FALSE;
131 $this->assertEquals(get_class($E),
"InvalidArgumentException");
133 $this->assertEquals($ExpIsThrown, TRUE);
136 $TestName->Delete(TRUE);
static ControlledNameExists($Term, $FieldId)
Check if there exists a controlledname with a ControlledName and FieldId same as given.
static SearchForControlledName($ControlledName, $FieldId)
Check if the given controlled name already exists for a given field ID.
static Create($Term, $FieldId)
Create a new empty ControlledName if it's not already present.
SQL database abstraction object with smart query caching.
Metadata type representing non-hierarchical controlled vocabulary values.
static Create()
Initialize a new qualifier.
static tearDownAfterClass()
After to running the tests, this function is run.
static setUpBeforeClass()
Prior to running any of the tests, this function is run.