[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpunit/classes/ -> advanced_testcase.php (summary)

Advanced test case.

Copyright: 2012 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 648 lines (23 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 31 functions

  __construct()
  runBare()
  createFlatXMLDataSet()
  createXMLDataSet()
  createCsvDataSet()
  createArrayDataSet()
  loadDataSet()
  preventResetByRollback()
  resetAfterTest()
  getDebuggingMessages()
  resetDebugging()
  assertDebuggingCalled()
  assertDebuggingCalledCount()
  assertDebuggingNotCalled()
  assertEventLegacyData()
  assertEventLegacyLogData()
  assertEventContextNotUsed()
  setCurrentTimeStart()
  assertTimeCurrent()
  redirectMessages()
  redirectEmails()
  redirectEvents()
  tearDownAfterClass()
  resetAllData()
  setUser()
  setAdminUser()
  setGuestUser()
  setTimezone()
  getDataGenerator()
  getExternalTestFileUrl()
  recurseFolders()

Functions
Functions that are not part of a class:

__construct($name = null, array $data = array()   X-Ref
Constructs a test case with the given name.

Note: use setUp() or setUpBeforeClass() in your test cases.

param: string $name
param: array  $data
param: string $dataName

runBare()   X-Ref
Runs the bare test sequence.

return: void

createFlatXMLDataSet($xmlFile)   X-Ref
Creates a new FlatXmlDataSet with the given $xmlFile. (absolute path.)

param: string $xmlFile
return: PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet

createXMLDataSet($xmlFile)   X-Ref
Creates a new XMLDataSet with the given $xmlFile. (absolute path.)

param: string $xmlFile
return: PHPUnit_Extensions_Database_DataSet_XmlDataSet

createCsvDataSet($files, $delimiter = ',', $enclosure = '"', $escape = '"')   X-Ref
Creates a new CsvDataSet from the given array of csv files. (absolute paths.)

param: array $files array tablename=>cvsfile
param: string $delimiter
param: string $enclosure
param: string $escape
return: PHPUnit_Extensions_Database_DataSet_CsvDataSet

createArrayDataSet(array $data)   X-Ref
Creates new ArrayDataSet from given array

param: array $data array of tables, first row in each table is columns
return: phpunit_ArrayDataSet

loadDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)   X-Ref
Load date into moodle database tables from standard PHPUnit data set.

Note: it is usually better to use data generators

param: PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
return: void

preventResetByRollback()   X-Ref
Call this method from test if you want to make sure that
the resetting of database is done the slow way without transaction
rollback.

This is useful especially when testing stuff that is not compatible with transactions.

return: void

resetAfterTest($reset = true)   X-Ref
Reset everything after current test.

param: bool $reset true means reset state back, false means keep all data for the next test,
return: void

getDebuggingMessages()   X-Ref
Return debugging messages from the current test.

return: array with instances having 'message', 'level' and 'stacktrace' property.

resetDebugging()   X-Ref
Clear all previous debugging messages in current test
and revert to default DEVELOPER_DEBUG level.


assertDebuggingCalled($debugmessage = null, $debuglevel = null, $message = '')   X-Ref
Assert that exactly debugging was just called once.

Discards the debugging message if successful.

param: null|string $debugmessage null means any
param: null|string $debuglevel null means any
param: string $message

assertDebuggingCalledCount($expectedcount, $debugmessages = array()   X-Ref
Asserts how many times debugging has been called.

param: int $expectedcount The expected number of times
param: array $debugmessages Expected debugging messages, one for each expected message.
param: array $debuglevels Expected debugging levels, one for each expected message.
param: string $message
return: void

assertDebuggingNotCalled($message = '')   X-Ref
Call when no debugging() messages expected.

param: string $message

assertEventLegacyData($expected, \core\event\base $event, $message = '')   X-Ref
Assert that an event legacy data is equal to the expected value.

param: mixed $expected expected data.
param: \core\event\base $event the event object.
param: string $message
return: void

assertEventLegacyLogData($expected, \core\event\base $event, $message = '')   X-Ref
Assert that an event legacy log data is equal to the expected value.

param: mixed $expected expected data.
param: \core\event\base $event the event object.
param: string $message
return: void

assertEventContextNotUsed(\core\event\base $event, $message = '')   X-Ref
Assert that an event is not using event->contxet.
While restoring context might not be valid and it should not be used by event url
or description methods.

param: \core\event\base $event the event object.
param: string $message
return: void

setCurrentTimeStart()   X-Ref
Stores current time as the base for assertTimeCurrent().

Note: this is called automatically before calling individual test methods.
return: int current time

assertTimeCurrent($time, $message = '')   X-Ref
Assert that: start < $time < time()

param: int $time
param: string $message
return: void

redirectMessages()   X-Ref
Starts message redirection.

You can verify if messages were sent or not by inspecting the messages
array in the returned messaging sink instance. The redirection
can be stopped by calling $sink->close();

return: phpunit_message_sink

redirectEmails()   X-Ref
Starts email redirection.

You can verify if email were sent or not by inspecting the email
array in the returned phpmailer sink instance. The redirection
can be stopped by calling $sink->close();

return: phpunit_message_sink

redirectEvents()   X-Ref
Starts event redirection.

You can verify if events were triggered or not by inspecting the events
array in the returned event sink instance. The redirection
can be stopped by calling $sink->close();

return: phpunit_event_sink

tearDownAfterClass()   X-Ref
Cleanup after all tests are executed.

Note: do not forget to call this if overridden...

return: void

resetAllData($detectchanges = false)   X-Ref
Reset all database tables, restore global state and clear caches and optionally purge dataroot dir.

param: bool $detectchanges
return: void

setUser($user = null)   X-Ref
Set current $USER, reset access cache.

param: null|int|stdClass $user user record, null or 0 means non-logged-in, positive integer means userid
return: void

setAdminUser()   X-Ref
Set current $USER to admin account, reset access cache.

return: void

setGuestUser()   X-Ref
Set current $USER to guest account, reset access cache.

return: void

setTimezone($servertimezone = 'Australia/Perth', $defaultphptimezone = 'Australia/Perth')   X-Ref
Change server and default php timezones.

param: string $servertimezone timezone to set in $CFG->timezone (not validated)
param: string $defaultphptimezone timezone to fake default php timezone (must be valid)

getDataGenerator()   X-Ref
Get data generator

return: testing_data_generator

getExternalTestFileUrl($path, $https = false)   X-Ref
Returns UTL of the external test file.

The result depends on the value of following constants:
- TEST_EXTERNAL_FILES_HTTP_URL
- TEST_EXTERNAL_FILES_HTTPS_URL

They should point to standard external test files repository,
it defaults to 'http://download.moodle.org/unittest'.

False value means skip tests that require external files.

param: string $path
param: bool $https true if https required
return: string url

recurseFolders($path, $callback, $fileregexp = '/.*/', $exclude = false, $ignorefolders = array()   X-Ref
Recursively visit all the files in the source tree. Calls the callback
function with the pathname of each file found.

param: string $path the folder to start searching from.
param: string $callback the method of this class to call with the name of each file found.
param: string $fileregexp a regexp used to filter the search (optional).
param: bool $exclude If true, pathnames that match the regexp will be ignored. If false,
param: array $ignorefolders will not go into any of these folders (optional).
return: void



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1