/**
  * @covers ::wfDebug
  * @covers ::wfDebugMem
  */
 public function testDebugFunctionTest()
 {
     global $wgDebugLogFile, $wgDebugTimestamps;
     $old_log_file = $wgDebugLogFile;
     $wgDebugLogFile = tempnam(wfTempDir(), 'mw-');
     # @todo FIXME: $wgDebugTimestamps should be tested
     $old_wgDebugTimestamps = $wgDebugTimestamps;
     $wgDebugTimestamps = false;
     wfDebug("This is a normal string");
     $this->assertEquals("This is a normal string", file_get_contents($wgDebugLogFile));
     unlink($wgDebugLogFile);
     wfDebug("This is nöt an ASCII string");
     $this->assertEquals("This is nöt an ASCII string", file_get_contents($wgDebugLogFile));
     unlink($wgDebugLogFile);
     wfDebug("05This has böth UTF and control chars");
     $this->assertEquals(" 05This has böth UTF and control chars ", file_get_contents($wgDebugLogFile));
     unlink($wgDebugLogFile);
     wfDebugMem();
     $this->assertGreaterThan(1000, preg_replace('/\\D/', '', file_get_contents($wgDebugLogFile)));
     unlink($wgDebugLogFile);
     wfDebugMem(true);
     $this->assertGreaterThan(1000000, preg_replace('/\\D/', '', file_get_contents($wgDebugLogFile)));
     unlink($wgDebugLogFile);
     $wgDebugLogFile = $old_log_file;
     $wgDebugTimestamps = $old_wgDebugTimestamps;
 }
Example #2
0
 /**
  * @covers ::wfDebug
  * @covers ::wfDebugMem
  */
 public function testDebugFunctionTest()
 {
     $debugLogFile = $this->getNewTempFile();
     $this->setMwGlobals(array('wgDebugLogFile' => $debugLogFile, 'wgDebugTimestamps' => false));
     wfDebug("This is a normal string");
     $this->assertEquals("This is a normal string\n", file_get_contents($debugLogFile));
     unlink($debugLogFile);
     wfDebug("This is nöt an ASCII string");
     $this->assertEquals("This is nöt an ASCII string\n", file_get_contents($debugLogFile));
     unlink($debugLogFile);
     wfDebug("05This has böth UTF and control chars");
     $this->assertEquals(" 05This has böth UTF and control chars \n", file_get_contents($debugLogFile));
     unlink($debugLogFile);
     wfDebugMem();
     $this->assertGreaterThan(1000, preg_replace('/\\D/', '', file_get_contents($debugLogFile)));
     unlink($debugLogFile);
     wfDebugMem(true);
     $this->assertGreaterThan(1000000, preg_replace('/\\D/', '', file_get_contents($debugLogFile)));
     unlink($debugLogFile);
 }
Example #3
0
 function testDebugFunctionTest()
 {
     global $wgDebugLogFile, $wgOut, $wgShowDebug, $wgDebugTimestamps;
     $old_log_file = $wgDebugLogFile;
     $wgDebugLogFile = tempnam(wfTempDir(), 'mw-');
     # @todo FIXME: This setting should be tested
     $wgDebugTimestamps = false;
     wfDebug("This is a normal string");
     $this->assertEquals("This is a normal string", file_get_contents($wgDebugLogFile));
     unlink($wgDebugLogFile);
     wfDebug("This is nöt an ASCII string");
     $this->assertEquals("This is nöt an ASCII string", file_get_contents($wgDebugLogFile));
     unlink($wgDebugLogFile);
     wfDebug("05This has böth UTF and control chars");
     $this->assertEquals(" 05This has böth UTF and control chars ", file_get_contents($wgDebugLogFile));
     unlink($wgDebugLogFile);
     $old_wgOut = $wgOut;
     $old_wgShowDebug = $wgShowDebug;
     $wgOut = new MockOutputPage();
     $wgShowDebug = true;
     $message = "05This has böth UTF and control chars";
     wfDebug($message);
     if ($wgOut->message == "JAJA is a stupid error message. Anyway, here's your message: {$message}") {
         $this->assertTrue(true, 'MockOutputPage called, set the proper message.');
     } else {
         $this->assertTrue(false, 'MockOutputPage was not called.');
     }
     $wgOut = $old_wgOut;
     $wgShowDebug = $old_wgShowDebug;
     unlink($wgDebugLogFile);
     wfDebugMem();
     $this->assertGreaterThan(5000, preg_replace('/\\D/', '', file_get_contents($wgDebugLogFile)));
     unlink($wgDebugLogFile);
     wfDebugMem(true);
     $this->assertGreaterThan(5000000, preg_replace('/\\D/', '', file_get_contents($wgDebugLogFile)));
     unlink($wgDebugLogFile);
     $wgDebugLogFile = $old_log_file;
 }