Extension:MWUnit/Extending MWUnit

This page has information about MWUnit's code. It is intended for developers that want to modify it or write code that ties into it. It is not intended for site administrators or end users.

Defining new assertions
MWUnit provides a mechanism to define new assertions via another extensions. To define a new assertion, an extension must register the MWUnitGetAssertionClasses hook. Place the following code in your extension's  file:

In the class, you must then define the method. This function gets called when MWUnit retrieves the list of valid assertion classes. This allows your extension to add or remove assertions from the list. We will add a new assertion by adding the name of it's class to the given array:

Any assertion class must implement the  interface. This interface has the following three methods:


 * getName: Returns the name of this assertion as used in the parser function magic word, without the `assert_` prefix.
 * shouldRegister: Returns true if and only if this assertion should be registered with the Parser. Allows extensions to define conditional assertions.
 * getRequiredArgumentCount: Returns the number of arguments required by the assertion.

Additionally, the  method MUST be defined.