CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
21 function ListFields(&$Schema)
22 {
23 $Fields = $Schema->GetFields();
24 foreach ($Fields as $Field)
25 {
26 printf("Id: %d<br>\n", $Field->Id());
27 printf("Name: %s<br>\n", $Field->Name());
28 printf("Type: %s<br>\n", $Field->Type());
29 }
30 }
31
35 function UnitTest()
36 {
37 print("<br>Creating schema...<br>");
38 $Schema = new MetadataSchema();
39
40 print("<br>Listing fields...<br>");
41 ListFields($Schema);
42
43 print("<br>Adding field...<br>");
44 $Schema->AddField("TestFieldOne", MetadataSchema::MDFTYPE_NUMBER);
45 $Schema->AddField("TestFieldTwo", MetadataSchema::MDFTYPE_PARAGRAPH);
46
47 print("<br>Listing fields...<br>");
48 ListFields($Schema);
49
50 print("<br>Dropping field...<br>");
51 $Field = $Schema->GetFieldByName("TestFieldOne");
52 $Schema->DropField($Field->Id());
53 $Field = $Schema->GetFieldByName("TestFieldTwo");
54 $Schema->DropField($Field->Id());
55
56 print("<br>Listing fields...<br>");
57 ListFields($Schema);
58 }
59
60
61 # ----- MAIN -----------------------------------------------------------------
62
63 UnitTest();
64
MetadataSchema
Metadata schema (in effect a Factory class for MetadataField).
Definition: MetadataSchema.php:13
ListFields
ListFields(&$Schema)
List fields in specified schema.
Definition: MetadataSchema--Test.php:21
UnitTest
UnitTest()
Perform unit test.
Definition: MetadataSchema--Test.php:35
MetadataSchema\MDFTYPE_NUMBER
const MDFTYPE_NUMBER
Definition: MetadataSchema.php:23
PHP
PHP
Definition: RSSClient--Test.php:12
MetadataSchema\MDFTYPE_PARAGRAPH
const MDFTYPE_PARAGRAPH
Definition: MetadataSchema.php:22