wiki.techinc.nl/tests/phpunit/includes/debug/MWDebugTest.php
Antoine Musso 19854b4e28 enable MWDebug tests
The first ones were failing because the test suite ran on gallium without
MWDebug being initialized. This is now the case since r109033.

The second part was failling because PHPUnit on gallium does not have
the assertCount() method. Use a assertEquals() / count() workaround instead.


Tests added by 108873
Reverts r108877
2012-01-16 13:56:18 +00:00

66 lines
1.6 KiB
PHP

<?php
class MWDebugTest extends MediaWikiTestCase {
function setUp() {
// Make sure MWDebug class is enabled
static $MWDebugEnabled = false;
if( !$MWDebugEnabled ) {
MWDebug::init();
$MWDebugEnabled = true;
}
}
function tearDown() {
/** Clear log before each test */
MWDebug::clearLog();
}
function testAddLog() {
MWDebug::log( 'logging a string' );
$this->assertEquals( array( array(
'msg' => 'logging a string',
'type' => 'log',
'caller' => __METHOD__ ,
) ),
MWDebug::getLog()
);
}
function testAddWarning() {
MWDebug::warning( 'Warning message' );
$this->assertEquals( array( array(
'msg' => 'Warning message',
'type' => 'warn',
'caller' => 'MWDebug::warning',
) ),
MWDebug::getLog()
);
}
function testAvoidDuplicateDeprecations() {
MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
// assertCount() not available on WMF integration server
$this->assertEquals( 1,
count( MWDebug::getLog() ),
"Only one deprecated warning per function should be kept"
);
}
function testAvoidNonConsecutivesDuplicateDeprecations() {
MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
MWDebug::warning( 'some warning' );
MWDebug::log( 'we could have logged something too' );
// Another deprecation
MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
// assertCount() not available on WMF integration server
$this->assertEquals( 3,
count( MWDebug::getLog() ),
"Only one deprecated warning per function should be kept"
);
}
}