コード例 #1
0
 /**
  * Execute the controller.
  *
  * @return  boolean
  *
  * @since   1.0
  */
 public function execute()
 {
     // Check if we are allowed to receive the raw data
     $authorizedRaw = $this->getInput()->server->getString('HTTP_JOOMLA_RAW', 'fail') === $this->getApplication()->get('stats.rawdata', false);
     // Check if a single data source is requested
     $source = $this->getInput()->getString('source');
     $this->view->isAuthorizedRaw($authorizedRaw);
     $this->view->setSource($source);
     $this->getApplication()->setBody($this->view->render());
     return true;
 }
コード例 #2
0
 /**
  * @testdox The raw statistics data is returned
  *
  * @covers  Stats\Views\Stats\StatsJsonView::render
  */
 public function testTheRawStatisticsDataIsReturned()
 {
     $mockModel = $this->getMockBuilder('Stats\\Models\\StatsModel')->disableOriginalConstructor()->getMock();
     $mockModel->expects($this->once())->method('getItems')->willReturn([(object) ['unique_id' => '1a', 'php_version' => PHP_VERSION, 'cms_version' => '3.5.0', 'db_type' => 'mysql', 'db_version' => '5.6.25', 'server_os' => 'Darwin 14.1.0'], (object) ['unique_id' => '2b', 'php_version' => PHP_VERSION, 'cms_version' => '3.5.0', 'db_type' => 'postgresql', 'db_version' => '9.4.0', 'server_os' => 'Darwin 14.1.0']]);
     $returnData = ['data' => ['php_version' => [['name' => PHP_VERSION, 'count' => 2]], 'db_type' => [['name' => 'mysql', 'count' => 1], ['name' => 'postgresql', 'count' => 1]], 'db_version' => [['name' => '5.6.25', 'count' => 1], ['name' => '9.4.0', 'count' => 1]], 'cms_version' => [['name' => '3.5.0', 'count' => 2]], 'server_os' => [['name' => 'Darwin 14.1.0', 'count' => 2]], 'total' => 2]];
     $view = new StatsJsonView($mockModel);
     $view->isAuthorizedRaw(true);
     $this->assertSame($returnData, json_decode($view->render(), true));
 }