X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22statistiques_visites%22%2C%22%22%29%20.%20%22?a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=d3dd38936f43a498126ff1ba39181d4e4990c659;hb=b6b686c13b1d78525ae16150a201491c8d0b6451;hp=9c06f516d9784f976bb9fca799fdd7358f6a54f3;hpb=855b17cf2dc7ea45bb10d3a5fa799e84a5f3fd14;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 9c06f516d9..d3dd38936f 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -5,6 +5,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { public $regex = ''; public $runDisabled = false; + /** + * @var Array of TestUser + */ + public static $users; + /** * @var DatabaseBase */ @@ -527,4 +532,46 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } } + /** + * Asserts that the provided variable is of the specified + * internal type or equals the $value argument. This is useful + * for testing return types of functions that return a certain + * type or *value* when not set or on error. + * + * @since 1.20 + * + * @param string $type + * @param mixed $actual + * @param mixed $value + * @param string $message + */ + protected function assertTypeOrValue( $type, $actual, $value = false, $message = '' ) { + if ( $actual === $value ) { + $this->assertTrue( true, $message ); + } + else { + $this->assertType( $type, $actual, $message ); + } + } + + /** + * Asserts the type of the provided value. This can be either + * in internal type such as boolean or integer, or a class or + * interface the value extends or implements. + * + * @since 1.20 + * + * @param string $type + * @param mixed $actual + * @param string $message + */ + protected function assertType( $type, $actual, $message = '' ) { + if ( is_object( $actual ) ) { + $this->assertInstanceOf( $type, $actual, $message ); + } + else { + $this->assertInternalType( $type, $actual, $message ); + } + } + }