CWIS Developer Documentation
MetadataSchema--Test.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: MetadataSchema--Test.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2002-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis
8 #
9 
10 PageTitle("Metadata Schema Unit Test");
11 
12 
13 # ----- EXPORTED FUNCTIONS ---------------------------------------------------
14 
15 # ----- LOCAL FUNCTIONS ------------------------------------------------------
16 
17 function ListFields(&$Schema)
18 {
19  $Fields = $Schema->GetFields();
20  foreach ($Fields as $Field)
21  {
22  printf("Id: %d<br>\n", $Field->Id());
23  printf("Name: %s<br>\n", $Field->Name());
24  printf("Type: %s<br>\n", $Field->Type());
25  }
26 }
27 
28 function UnitTest()
29 {
30  print("<br>Creating schema...<br>");
31  $Schema = new MetadataSchema();
32 
33  print("<br>Listing fields...<br>");
34  ListFields($Schema);
35 
36  print("<br>Adding field...<br>");
37  $Schema->AddField("TestFieldOne", MetadataSchema::MDFTYPE_NUMBER);
38  $Schema->AddField("TestFieldTwo", MetadataSchema::MDFTYPE_PARAGRAPH);
39 
40  print("<br>Listing fields...<br>");
41  ListFields($Schema);
42 
43  print("<br>Dropping field...<br>");
44  $Field = $Schema->GetFieldByName("TestFieldOne");
45  $Schema->DropField($Field->Id());
46  $Field = $Schema->GetFieldByName("TestFieldTwo");
47  $Schema->DropField($Field->Id());
48 
49  print("<br>Listing fields...<br>");
50  ListFields($Schema);
51 }
52 
53 
54 # ----- MAIN -----------------------------------------------------------------
55 
56 UnitTest();
57 
Metadata schema (in effect a Factory class for MetadataField).
ListFields(&$Schema)
PHP
Definition: OAIClient.php:39