3 class MWDebugTest
extends MediaWikiTestCase
{
6 protected function setUp() {
8 // Make sure MWDebug class is enabled
9 static $MWDebugEnabled = false;
10 if ( !$MWDebugEnabled ) {
12 $MWDebugEnabled = true;
14 /** Clear log before each test */
19 protected function tearDown() {
25 * @covers MWDebug::log
27 public function testAddLog() {
28 MWDebug
::log( 'logging a string' );
31 'msg' => 'logging a string',
33 'caller' => __METHOD__
,
40 * @covers MWDebug::warning
42 public function testAddWarning() {
43 MWDebug
::warning( 'Warning message' );
46 'msg' => 'Warning message',
48 'caller' => 'MWDebugTest::testAddWarning',
55 * @covers MWDebug::deprecated
57 public function testAvoidDuplicateDeprecations() {
58 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
59 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
61 // assertCount() not available on WMF integration server
62 $this->assertEquals( 1,
63 count( MWDebug
::getLog() ),
64 "Only one deprecated warning per function should be kept"
69 * @covers MWDebug::deprecated
71 public function testAvoidNonConsecutivesDuplicateDeprecations() {
72 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
73 MWDebug
::warning( 'some warning' );
74 MWDebug
::log( 'we could have logged something too' );
75 // Another deprecation
76 MWDebug
::deprecated( 'wfOldFunction', '1.0', 'component' );
78 // assertCount() not available on WMF integration server
79 $this->assertEquals( 3,
80 count( MWDebug
::getLog() ),
81 "Only one deprecated warning per function should be kept"