[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/core/ -> DokuWikiTest.php (summary)

Helper class to provide basic functionality for tests

File Size: 269 lines (9 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 9 functions

  setExpectedException()
  setUpBeforeClass()
  setUp()
  setupDataDir()
  setupConfDir()
  waitForTick()
  callInaccessibleMethod()
  getInaccessibleProperty()
  setInaccessibleProperty()

Functions
Functions that are not part of a class:

setExpectedException($class, $message=null)   X-Ref
setExpectedException was deprecated in PHPUnit 6

param: string $class
param: null|string $message

setUpBeforeClass()   X-Ref
Setup the data directory

This is ran before each test class

setUp()   X-Ref
Reset the DokuWiki environment before each test run. Makes sure loaded config,
language and plugins are correct.

return: void

setupDataDir()   X-Ref
Reinitialize the data directory for this class run


setupConfDir()   X-Ref
Reinitialize the conf directory for this class run


waitForTick($init = false)   X-Ref
Waits until a new second has passed

This tried to be clever about the passing of time and return early if possible. Unfortunately
this never worked reliably for unknown reasons. To avoid flaky tests, this now always simply
sleeps for a full second on every call.

param: bool $init no longer used
return: int new timestamp

callInaccessibleMethod($obj, $func, array $args)   X-Ref
Allow for testing inaccessible methods (private or protected)

This makes it easier to test protected methods without needing to create intermediate
classes inheriting and changing the access.

link: https://stackoverflow.com/a/8702347/172068
param: object $obj Object in which to call the method
param: string $func The method to call
param: array $args The arguments to call the method with
return: mixed

getInaccessibleProperty($obj, $prop)   X-Ref
Allow for reading inaccessible properties (private or protected)

This makes it easier to check internals of tested objects. This should generally
be avoided.

param: object $obj Object on which to access the property
param: string $prop name of the property to access
return: mixed

setInaccessibleProperty($obj, $prop, $value)   X-Ref
Allow for reading inaccessible properties (private or protected)

This makes it easier to set internals of tested objects. This should generally
be avoided.

param: object $obj Object on which to access the property
param: string $prop name of the property to access
param: mixed $value new value to set the property to
return: void