Beispiel #1
0
 /**
  * @covers MWDebug::appendDebugInfoToApiResult
  */
 public function testAppendDebugInfoToApiResultXmlFormat()
 {
     $request = $this->newApiRequest(['action' => 'help', 'format' => 'xml'], '/api.php?action=help&format=xml');
     $context = new RequestContext();
     $context->setRequest($request);
     $apiMain = new ApiMain($context);
     $result = new ApiResult($apiMain);
     MWDebug::appendDebugInfoToApiResult($context, $result);
     $this->assertInstanceOf('ApiResult', $result);
     $data = $result->getResultData();
     $expectedKeys = ['mwVersion', 'phpEngine', 'phpVersion', 'gitRevision', 'gitBranch', 'gitViewUrl', 'time', 'log', 'debugLog', 'queries', 'request', 'memory', 'memoryPeak', 'includes', '_element'];
     foreach ($expectedKeys as $expectedKey) {
         $this->assertArrayHasKey($expectedKey, $data['debuginfo'], "debuginfo has {$expectedKey}");
     }
     $xml = ApiFormatXml::recXmlPrint('help', $data);
     // exception not thrown
     $this->assertInternalType('string', $xml);
 }
Beispiel #2
0
 /**
  * Execute the actual module, without any error handling
  */
 protected function executeAction()
 {
     $params = $this->setupExecuteAction();
     $module = $this->setupModule();
     $this->mModule = $module;
     $this->checkExecutePermissions($module);
     if (!$this->checkMaxLag($module, $params)) {
         return;
     }
     if (!$this->checkConditionalRequestHeaders($module)) {
         return;
     }
     if (!$this->mInternalMode) {
         $this->setupExternalResponse($module, $params);
     }
     $this->checkAsserts($params);
     // Execute
     $module->execute();
     Hooks::run('APIAfterExecute', array(&$module));
     $this->reportUnusedParams();
     if (!$this->mInternalMode) {
         // append Debug information
         MWDebug::appendDebugInfoToApiResult($this->getContext(), $this->getResult());
         // Print result data
         $this->printResult(false);
     }
 }
Beispiel #3
0
 /**
  * Execute the actual module, without any error handling
  */
 protected function executeAction()
 {
     $params = $this->setupExecuteAction();
     $module = $this->setupModule();
     $this->checkExecutePermissions($module);
     if (!$this->checkMaxLag($module, $params)) {
         return;
     }
     if (!$this->mInternalMode) {
         $this->setupExternalResponse($module, $params);
     }
     // Execute
     $module->profileIn();
     $module->execute();
     wfRunHooks('APIAfterExecute', array(&$module));
     $module->profileOut();
     if (!$this->mInternalMode) {
         //append Debug information
         MWDebug::appendDebugInfoToApiResult($this->getContext(), $this->getResult());
         // Print result data
         $this->printResult(false);
     }
 }