private function newBrowseBySubject($subject, $asRawMode = false)
 {
     $instance = new BrowseBySubject($this->apiFactory->newApiMain(array('subject' => $subject)), 'browsebysubject');
     if ($asRawMode) {
         $instance->getMain()->getResult()->setRawMode();
     }
     $instance->execute();
     return $instance;
 }
 private function newBrowseBySubject($subject, $asRawMode = false)
 {
     $instance = new BrowseBySubject($this->apiFactory->newApiMain(array('subject' => $subject)), 'browsebysubject');
     // Went away with 1.26/1.27
     if (function_exists('setRawMode') && $asRawMode) {
         $instance->getMain()->getResult()->setRawMode();
     }
     $instance->execute();
     // MW 1.25
     return method_exists($instance, 'getResult') ? $instance->getResult() : $instance;
 }
 public function testRawJsonPrintOutput()
 {
     $parameters = array('subject' => 'Foo', 'subobject' => 'Bar');
     $dataItem = new DIWikiPage('Foo', NS_MAIN, '', 'Bar');
     $semanticData = $this->semanticDataFactory->newEmptySemanticData($dataItem);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->atLeastOnce())->method('getSemanticData')->with($this->equalTo($dataItem))->will($this->returnValue($semanticData));
     $this->applicationFactory->registerObject('Store', $store);
     $instance = new BrowseBySubject($this->apiFactory->newApiMain($parameters), 'browsebysubject');
     $instance->getMain()->getResult()->setRawMode();
     $instance->execute();
     $printer = $instance->getMain()->createPrinterByName('json');
     ob_start();
     $printer->initPrinter(false);
     $printer->execute();
     $printer->closePrinter();
     $out = ob_get_clean();
     $this->stringValidator->assertThatStringContains('"subject":"Foo#0##Bar"', $out);
 }
 public function testHtmlJsonPrintOutput()
 {
     $parameters = array('subject' => 'Foo', 'subobject' => 'Bar', 'type' => 'html');
     $dataItem = new DIWikiPage('Foo', NS_MAIN, '', 'Bar');
     $semanticData = $this->semanticDataFactory->newEmptySemanticData($dataItem);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->atLeastOnce())->method('getSemanticData')->with($this->equalTo($dataItem))->will($this->returnValue($semanticData));
     $this->testEnvironment->registerObject('Store', $store);
     $instance = new BrowseBySubject($this->apiFactory->newApiMain($parameters), 'browsebysubject');
     // Went away with 1.26/1.27
     if (function_exists('setRawMode')) {
         $instance->getMain()->getResult()->setRawMode();
     }
     $instance->execute();
     $printer = $instance->getMain()->createPrinterByName('json');
     ob_start();
     $printer->initPrinter(false);
     $printer->execute();
     $printer->closePrinter();
     $out = ob_get_clean();
     $this->stringValidator->assertThatStringContains('"query":"\\n<table class=\\"smwb-factbox\\" ', $out);
 }