3 class MWDebugTest
extends MediaWikiTestCase
{
5 protected function setUp() {
7 // Make sure MWDebug class is enabled
8 static $MWDebugEnabled = false;
9 if ( !$MWDebugEnabled ) {
11 $MWDebugEnabled = true;
13 /** Clear log before each test */
18 protected function tearDown() {
24 * @covers MWDebug::log
26 public function testAddLog() {
27 MWDebug
::log( 'logging a string' );
30 'msg' => 'logging a string',
32 'caller' => __METHOD__
,
39 * @covers MWDebug::warning
41 public function testAddWarning() {
42 MWDebug
::warning( 'Warning message' );
45 'msg' => 'Warning message',
47 'caller' => 'MWDebugTest::testAddWarning',
54 * @covers MWDebug::deprecated
56 public function testAvoidDuplicateDeprecations() {
57 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
58 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
60 // assertCount() not available on WMF integration server
61 $this->assertEquals( 1,
62 count( MWDebug
::getLog() ),
63 "Only one deprecated warning per function should be kept"
68 * @covers MWDebug::deprecated
70 public function testAvoidNonConsecutivesDuplicateDeprecations() {
71 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
72 MWDebug
::warning( 'some warning' );
73 MWDebug
::log( 'we could have logged something too' );
74 // Another deprecation
75 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
77 // assertCount() not available on WMF integration server
78 $this->assertEquals( 3,
79 count( MWDebug
::getLog() ),
80 "Only one deprecated warning per function should be kept"