Moodle  2.2.1
http://www.collinsharper.com
UnitTestCase Class Reference

Inherited by ajax_test, backup_check_test, backup_controller_test, backup_dbops_test, backup_destinations_test, backup_factories_test, backup_helper_test, backup_plan_test, backup_step_test, backup_task_test, backup_ui_test, backuplib_test, base_atom_test, base_attribute_test, base_final_element_test, base_nested_element_test, base_optigroup_test, code_test, collatorlib_test, componentlib_test, ContainsSelectExpectation_test, ContainsTagWithAttribute_test, ContainsTagWithAttributes_test, ContainsTagWithContents_test, convert_helper_test, courselib_test, custom_menu_test, data_loading_method_test_base, data_preset_test, ddl_test, dml_test, DoesNotContainTagWithAttributes_test, duration_form_element_test, eventslib_test, externallib_test, FakeDBUnitTestCase, filelib_test, filter_manager_test, filter_mediaplugin_test, filter_urltolink_test, formslib_test, global_navigation_test, gradeedittreelib_test, grading_manager_test, html_writer_test, htmlpurifier_test, logger_test, lti_locallib_test, mathsslib_test, mod_quiz_display_options_test, modforumlib_test, moodle1_converter_test, moodle_block_manager_test, moodle_page_editing_test, moodle_page_test, moodlelib_test, moodlesimplepie_test, navbar_test, navigation_cache_test, navigation_node_test, outputlib_methods_test, progressive_parser_test, purifier_test, qbehaviour_missing_test, qbehaviour_walkthrough_test_base, qformat_default_test, qformat_gift_test, qformat_xml_test, qtype_calculated_question_test, qtype_calculated_test, qtype_calculated_variable_substituter_test, qtype_calculatedmulti_question_test, qtype_calculatedsimple_question_test, qtype_description_test, qtype_essay_question_test, qtype_essay_test, qtype_match_question_test, qtype_match_test, qtype_missing_test, qtype_multianswer_question_test, qtype_multianswer_test, qtype_multichoice_multi_question_test, qtype_multichoice_single_question_test, qtype_multichoice_test, qtype_numerical_answer_processor_test, qtype_numerical_answer_test, qtype_numerical_form_test, qtype_numerical_question_test, qtype_numerical_test, qtype_random_test, qtype_shortanswer_question_test, qtype_shortanswer_test, qtype_truefalse_question_test, qtype_truefalse_test, question_attempt_iterator_test, question_attempt_step_iterator_test, question_attempt_step_test, question_attempt_test, question_attempt_upgrader_test_base, question_attempt_with_steps_test, question_bank_test, question_cbm_test, question_engine_test, question_first_matching_answer_grading_strategy_test, question_hint_test, question_reportlib_test, question_state_test, question_type_test, question_usage_by_activity_test, question_utils_test, questionlib_test, quiz_class_test, quiz_editlib_test, quiz_lib_test, quiz_locallib_test, quiz_statistics_question_stats_test, quizaccess_delaybetweenattempts_test, quizaccess_ipaddress_test, quizaccess_numattempts_test, quizaccess_openclosedate_test, quizaccess_password_test, quizaccess_safebrowser_test, quizaccess_securewindow_test, quizaccess_timelimit_test, restore_decode_test, scorm_formatduration_test, setting_test, settings_navigation_test, TestOfTestDoxReporter, textlib_test, UnitTestCaseUsingDatabase, url_lib_test, user_picture_test, web_test, webservice_test, wikiparser_test, workshop_accumulative_strategy_test, workshop_allocation_random_test, workshop_best_evaluation_test, workshop_internal_api_test, workshop_numerrors_strategy_test, workshop_rubric_strategy_test, xhtml_container_stack_test, xml_output_test, and xml_writer_test.

Public Member Functions

 UnitTestCase ($label=false)
 assertTrue ($result, $message=false)
 assertFalse ($result, $message= '%s')
 assertNull ($value, $message= '%s')
 assertNotNull ($value, $message= '%s')
 assertIsA ($object, $type, $message= '%s')
 assertNotA ($object, $type, $message= '%s')
 assertEqual ($first, $second, $message= '%s')
 assertNotEqual ($first, $second, $message= '%s')
 assertWithinMargin ($first, $second, $margin, $message= '%s')
 assertOutsideMargin ($first, $second, $margin, $message= '%s')
 assertIdentical ($first, $second, $message= '%s')
 assertNotIdentical ($first, $second, $message= '%s')
 assertReference (&$first, &$second, $message= '%s')
 assertClone (&$first, &$second, $message= '%s')
 assertCopy (&$first, &$second, $message="%s")
 assertPattern ($pattern, $subject, $message= '%s')
 assertWantedPattern ($pattern, $subject, $message= '%s')
 assertNoPattern ($pattern, $subject, $message= '%s')
 assertNoUnwantedPattern ($pattern, $subject, $message= '%s')
 swallowErrors ()
 assertNoErrors ($message= '%s')
 assertError ($expected=false, $message= '%s')
 expectError ($expected=false, $message= '%s')
 expectException ($expected=false, $message= '%s')
 _coerceExpectation ($expected)
 assertErrorPattern ($pattern, $message= '%s')

Detailed Description

Definition at line 23 of file unit_tester.php.


Member Function Documentation

_coerceExpectation ( expected)

Creates an equality expectation if the object/value is not already some type of expectation.

Parameters:
mixed$expectedExpected value.
Returns:
SimpleExpectation Expectation object. private

Definition at line 402 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

assertClone ( &$  first,
&$  second,
message = '%s' 
)

Will trigger a pass if both parameters refer to different objects. Fail otherwise. The objects have to be identical though.

Parameters:
mixed$firstObject reference to check.
mixed$secondHopefully not the same object.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 259 of file unit_tester.php.

Here is the call graph for this function:

assertCopy ( &$  first,
&$  second,
message = "%s" 
)
Deprecated:

Definition at line 276 of file unit_tester.php.

Here is the call graph for this function:

assertEqual ( first,
second,
message = '%s' 
)

Will trigger a pass if the two parameters have the same value only. Otherwise a fail.

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 139 of file unit_tester.php.

assertError ( expected = false,
message = '%s' 
)
Deprecated:

Definition at line 357 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

assertErrorPattern ( pattern,
message = '%s' 
)
Deprecated:

Definition at line 416 of file unit_tester.php.

Here is the call graph for this function:

assertFalse ( result,
message = '%s' 
)

Will be true on false and vice versa. False is the PHP definition of false, so that null, empty strings, zero and an empty array all count as false.

Parameters:
boolean$resultPass on false.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 62 of file unit_tester.php.

assertIdentical ( first,
second,
message = '%s' 
)

Will trigger a pass if the two parameters have the same value and same type. Otherwise a fail.

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 205 of file unit_tester.php.

assertIsA ( object,
type,
message = '%s' 
)

Type and class test. Will pass if class matches the type name or is a subclass or if not an object, but the type is correct.

Parameters:
mixed$objectObject to test.
string$typeType name as string.
string$messageMessage to display.
Returns:
boolean True on pass. public

Definition at line 106 of file unit_tester.php.

Here is the caller graph for this function:

assertNoErrors ( message = '%s')
Deprecated:

Definition at line 348 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

assertNoPattern ( pattern,
subject,
message = '%s' 
)

Will trigger a pass if the perl regex pattern is not present in subject. Fail if found.

Parameters:
string$patternPerl regex to look for including the regex delimiters.
string$subjectString to search in.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 322 of file unit_tester.php.

Here is the caller graph for this function:

assertNotA ( object,
type,
message = '%s' 
)

Type and class mismatch test. Will pass if class name or underling type does not match the one specified.

Parameters:
mixed$objectObject to test.
string$typeType name as string.
string$messageMessage to display.
Returns:
boolean True on pass. public

Definition at line 123 of file unit_tester.php.

Here is the caller graph for this function:

assertNotEqual ( first,
second,
message = '%s' 
)

Will trigger a pass if the two parameters have a different value. Otherwise a fail.

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 155 of file unit_tester.php.

Here is the caller graph for this function:

assertNotIdentical ( first,
second,
message = '%s' 
)

Will trigger a pass if the two parameters have the different value or different type.

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 221 of file unit_tester.php.

Here is the caller graph for this function:

assertNotNull ( value,
message = '%s' 
)

Will be true if the value is set.

Parameters:
mixed$valueSupposedly set value.
string$messageMessage to display.
Returns:
boolean True on pass. public

Definition at line 88 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

assertNoUnwantedPattern ( pattern,
subject,
message = '%s' 
)
Deprecated:

Definition at line 332 of file unit_tester.php.

Here is the call graph for this function:

assertNull ( value,
message = '%s' 
)

Will be true if the value is null.

Parameters:
null$valueSupposedly null value.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 73 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

assertOutsideMargin ( first,
second,
margin,
message = '%s' 
)

Will trigger a pass if the two parameters differ by more than the margin.

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
mixed$marginFuzziness of match.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 189 of file unit_tester.php.

assertPattern ( pattern,
subject,
message = '%s' 
)

Will trigger a pass if the Perl regex pattern is found in the subject. Fail otherwise.

Parameters:
string$patternPerl regex to look for including the regex delimiters.
string$subjectString to search in.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 298 of file unit_tester.php.

Here is the caller graph for this function:

assertReference ( &$  first,
&$  second,
message = '%s' 
)

Will trigger a pass if both parameters refer to the same object. Fail otherwise.

Parameters:
mixed$firstObject reference to check.
mixed$secondHopefully the same object.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 237 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

assertTrue ( result,
message = false 
)

Called from within the test methods to register passes and failures.

Parameters:
boolean$resultPass on true.
string$messageMessage to display describing the test state.
Returns:
boolean True on pass public

Definition at line 48 of file unit_tester.php.

assertWantedPattern ( pattern,
subject,
message = '%s' 
)
Deprecated:

Definition at line 308 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

assertWithinMargin ( first,
second,
margin,
message = '%s' 
)

Will trigger a pass if the if the first parameter is near enough to the second by the margin.

Parameters:
mixed$firstValue to compare.
mixed$secondValue to compare.
mixed$marginFuzziness of match.
string$messageMessage to display.
Returns:
boolean True on pass public

Definition at line 172 of file unit_tester.php.

Here is the caller graph for this function:

expectError ( expected = false,
message = '%s' 
)

Prepares for an error. If the error mismatches it passes through, otherwise it is swallowed. Any left over errors trigger failures.

Parameters:
SimpleExpectation/string$expected The error to match.
string$messageMessage on failure. public

Definition at line 371 of file unit_tester.php.

Here is the call graph for this function:

Here is the caller graph for this function:

expectException ( expected = false,
message = '%s' 
)

Prepares for an exception. If the error mismatches it passes through, otherwise it is swallowed. Any left over errors trigger failures.

Parameters:
SimpleExpectation/Exception$expected The error to match.
string$messageMessage on failure. public

Definition at line 385 of file unit_tester.php.

Here is the call graph for this function:

Deprecated:

Definition at line 339 of file unit_tester.php.

Here is the call graph for this function:

UnitTestCase ( label = false)

Creates an empty test case. Should be subclassed with test methods for a functional test case.

Parameters:
string$labelName of test case. Will use the class name if none specified. public

Definition at line 32 of file unit_tester.php.

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations