Schema |
![]() |
Schema - class to represent and manipulate test suite schemas
Shane P. McCarron <shane@aptest.com>
Copyright 1999-2006 Applied Testing and Technology, Inc. All Rights Reserved.
use Schema;
# create a schema object
my $schema = new Schema(suiteName);
# get a handle to the hash of a schema field
$field = $schema->field(name);
# get a handle to a hash of all fields
$fieldHash = $schema->field();
# structure a value in a schema instance
$output = $schema->print(fieldName, value, edit);
The Schema object is a tool to instantiate the schema for a test suite.
$schema = new Schema(suite, edit);
Creates a new schema object.
returns a reference to the schema object.
Returns a reference to an account DB open in read mode.
$schema->delRow(testCase, fieldName, row);
testCase is a handle to a test case.
fieldName is the name of the field.
row is the row number to delete. If row is greater than the number of rows defined in a table, the command is silently ignored.
$state = $schema->edit();
$state = $schema->edit(boolean);
$mode = $schema->mode();
$mode = $schema->mode( string );
The mode is one of 'view', 'edit', 'run', 'report'.
$ref = $schema->field();
$ref = $schema->field(name);
@list = $schema->flist() ;
Returns the list of fields defined in the schema.
$output = $schema->fieldEntryWrap(testcase, test, field, value, fn);
testcase - reference to a TestCase object
test - a handle to the test case instance
field - the field we are using
value - the value the field has in the test case
fn - pointer to a function to call to wrap each value. The arguments passed to the function are the field name and the value (which may be special in the case of an menu).
$output = $schema->fieldEntryVar(test, field, value, suffix, fn);
test - a handle to the test case instance
field - the field we are using
value - the value the field has in the test case
suffix - a suffix to attach to HTML form variable names
fn - the name of a javascript function to call on change
$output = $schema->fieldEntry(test, field, value [, row]);
testcase - reference to a TestCase object
test - a handle to the test case instance
name - the field we are using
value - the value the field has in the test case
row - the row in an inset table. If defined, is used as a suffix for the CGI variable name.
$table = $schema->buildSelectorTable( currentSelection, allowNonSelectable, showSpecials );
The arguments are passed through to fieldSelection().
$output = $schema->fieldSelection( field, currentSelection, allowNonSelectable, showSpecials );
field is the field to present
currentSelection is a reference to an array of existing selections or a comma-separated string of current selections.
allowNonSelectable is a boolean that indicates whether even non-selectable fields should be presented (for use in report and edit selectors).
showSpecials is a boolean that indicates whether the special isCS and isRE selectors should also be shown on items that support those flags.
returns an input field appropriate for the field. If $field is empty, returns an empty string. If the field doesn't exist, returns undef. if field is not selectable, returns an empty string.
$output = $schema->fieldPrint(fname, ref, useLabels) ;
fname is the name of the field
ref is a reference to a selector-style hash (pat, isCS, isRE).
useLabels is true if the label should be emitted as well.
Returns the output formatted appropriately for the field. Note that this does not work with field type "table", since that is necessarily only emitted in the context of a test case.
$status = $schema->hRules(field, pattern [, isCaseSensitive [, isRE]]) ;
field is the field to set up rules for.
pattern is the pattern to highlight.
isCaseSensitive indicates the pattern is case sensitive (defaults to no).
isRE indicates the pattern is a regular expression (defaults to no).
Returns 1 if successful, 0 if it failed for some reason, and undef if the field does not exist.
@list = $schema->flist();
$schema->insRow(testHandle, fieldName, rowNumber);
testHandle - a Framework handle to an active test case
fieldName - the name of the field in the schema
rowNumber - the row to insert before. If not defined, then just add a row to the end.
looks up fieldName in the current schema, finds the associated fields, and performs the operation on those fields
$newval = $schema->makeValid($field, $value);
returns a valid value, which may have been reordered if it is a list field.
$num = $schema->numFields();
returns the number of fields defined in a schema
$schema->print();
$schema->print(field);
returns the string-ified version of the entire database, or just the contents of field
Really a no-op, since this object does not have a database.
$desc = $schema->selDesc(field, selRef) ;
field is the name of the field.
selRef is a hash reference to a selector.
Returns a string that is a description of the selection in the context of the field type.
Gets/sets a handle to a test session from which variables can be extracted and interpolated into field values during formatting.
$val = $schema->sessVars(vname) ;
Returns the value of the session variable, or undef if the variale is not defined for the session. Also returns undef if the schema object does not have a sessionVarHandle.
$dir = $schema->suiteDir();
$schema->suiteDir(suite);
Gets/sets the path to the test suite data root.
$type = $schema->typeOf(name);
searches the schema for a field with the given name. Returns the type of that field as a string.
Returns a reference to a hash of fullnames by user id.
@values = $schema->valuesOf(name);
searches the schema for a field with the given name. Returns an array of legal values for that field.
@list = $schema->visibleList() ;
$schema->inHistory(name);
searches the schema for a field with the given name. Returns true if that field is in a history table.
$schema->inTable(name);
searches the schema for a field with the given name. Returns true if that field is in a table.
$schema->isHidden(name);
searches the schema for a field with the given name. Returns true if that field should be not displayed.
$schema->isList(name);
searches the schema for a field with the given name. Returns true if that field is a list type field.
$schema->styleOf(name);
searches the schema for a field with the given name. Returns the style of that field as a string.
$schema->labelOf(name);
searches the schema for a field with the given name. Returns the label of that field as a string.
$schema->isSelectable(name);
searches the schema for a field with the given name. Returns true if the field is selectable, or false if it is not.
$schema->isVisible(name);
searches the schema for a field with the given name. Returns true if the field is visible in reports.
$schema->getFieldsByType(type[,style]);
searches the schema for fields of a given type, and optionally a given style. Returns a list of field names.
Returns JavaScript code that defines the dependencies among schema fields for use in the schema editor and also in selector pages.
Copyright © 2000-2006 Applied Testing and Technology, Inc. All rights reserved.