2012-01-13 23:07:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class MWDebugTest extends MediaWikiTestCase {
|
|
|
|
|
|
2012-01-16 13:50:17 +00:00
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
|
// Make sure MWDebug class is enabled
|
|
|
|
|
static $MWDebugEnabled = false;
|
|
|
|
|
if( !$MWDebugEnabled ) {
|
|
|
|
|
MWDebug::init();
|
|
|
|
|
$MWDebugEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 23:07:52 +00:00
|
|
|
function tearDown() {
|
|
|
|
|
/** Clear log before each test */
|
|
|
|
|
MWDebug::clearLog();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 23:26:26 +00:00
|
|
|
/**
|
|
|
|
|
* @group Broken
|
|
|
|
|
*/
|
2012-01-13 23:07:52 +00:00
|
|
|
function testAddLog() {
|
|
|
|
|
MWDebug::log( 'logging a string' );
|
|
|
|
|
$this->assertEquals( array( array(
|
|
|
|
|
'msg' => 'logging a string',
|
|
|
|
|
'type' => 'log',
|
|
|
|
|
'caller' => __METHOD__ ,
|
|
|
|
|
) ),
|
|
|
|
|
MWDebug::getLog()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 23:26:26 +00:00
|
|
|
/**
|
|
|
|
|
* @group Broken
|
|
|
|
|
*/
|
2012-01-13 23:07:52 +00:00
|
|
|
function testAddWarning() {
|
|
|
|
|
MWDebug::warning( 'Warning message' );
|
|
|
|
|
$this->assertEquals( array( array(
|
|
|
|
|
'msg' => 'Warning message',
|
|
|
|
|
'type' => 'warn',
|
|
|
|
|
'caller' => 'MWDebug::warning',
|
|
|
|
|
) ),
|
|
|
|
|
MWDebug::getLog()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 23:26:26 +00:00
|
|
|
/**
|
|
|
|
|
* Broken on gallium which use an old PHPUnit version
|
|
|
|
|
* @group Broken
|
|
|
|
|
*/
|
2012-01-13 23:07:52 +00:00
|
|
|
function testAvoidDuplicateDeprecations() {
|
|
|
|
|
MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
|
|
|
|
|
MWDebug::deprecated( 'wfOldFunction', '1.0', 'component' );
|
|
|
|
|
|
|
|
|
|
$this->assertCount( 1,
|
|
|
|
|
MWDebug::getLog(),
|
|
|
|
|
"Only one deprecated warning per function should be kept"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-13 23:26:26 +00:00
|
|
|
/**
|
|
|
|
|
* Broken on gallium which use an old PHPUnit version
|
|
|
|
|
* @group Broken
|
|
|
|
|
*/
|
2012-01-13 23:07:52 +00:00
|
|
|
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' );
|
|
|
|
|
|
|
|
|
|
$this->assertCount( 3,
|
|
|
|
|
MWDebug::getLog(),
|
|
|
|
|
"Only one deprecated warning per function should be kept"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|