/**
  * Tests for handleRealRowCountRequestAction()
  *
  * @return void
  * @test
  */
 public function testHandleRealRowCountRequestAction()
 {
     $_REQUEST['table'] = 'table';
     $ctrl = new DatabaseStructureController(null, null, null, null, null, null, null);
     $ctrl->handleRealRowCountRequestAction();
     $json = $this->_response->getJSONResult();
     $this->assertEquals(6, $json['real_row_count']);
     // Fall into another branch
     $_REQUEST['real_row_count_all'] = 'abc';
     $GLOBALS['tables'] = array(array('TABLE_NAME' => 'table'));
     $ctrl->handleRealRowCountRequestAction();
     $json = $this->_response->getJSONResult();
     $expected_result = array(array('table' => 'table', 'row_count' => 6));
     $this->assertEquals(json_encode($expected_result), $json['real_row_count_all']);
 }
 /**
  * Tests for handleRealRowCountRequestAction()
  *
  * @return void
  * @test
  */
 public function testHandleRealRowCountRequestAction()
 {
     $_REQUEST['table'] = 'table';
     $ctrl = new DatabaseStructureController($GLOBALS['db'], null);
     // Showing statistics
     $class = new ReflectionClass('PMA\\libraries\\controllers\\database\\DatabaseStructureController');
     $property = $class->getProperty('_tables');
     $property->setAccessible(true);
     $ctrl->handleRealRowCountRequestAction();
     $json = $this->_response->getJSONResult();
     $this->assertEquals(6, $json['real_row_count']);
     // Fall into another branch
     $_REQUEST['real_row_count_all'] = 'abc';
     $property->setValue($ctrl, array(array('TABLE_NAME' => 'table')));
     $ctrl->handleRealRowCountRequestAction();
     $json = $this->_response->getJSONResult();
     $expected_result = array(array('table' => 'table', 'row_count' => 6));
     $this->assertEquals(json_encode($expected_result), $json['real_row_count_all']);
 }
 /**
  * Tests for getDropdownValueForDbAction()
  *
  * Case two: not foreign
  *
  * @return void
  * @test
  */
 public function testGetDropdownValueForDbActionTwo()
 {
     $GLOBALS['dbi']->expects($this->any())->method('fetchArray')->will($this->returnCallback(function () {
         static $count = 0;
         if ($count == 0) {
             $count++;
             return array('table');
         }
         return null;
     }));
     $container = Container::getDefaultContainer();
     $container->set('dbi', $GLOBALS['dbi']);
     $container->factory('PMA\\libraries\\controllers\\table\\TableRelationController');
     $container->alias('TableRelationController', 'PMA\\libraries\\controllers\\table\\TableRelationController');
     $ctrl = $container->get('TableRelationController', array('tbl_storage_engine' => 'INNODB'));
     $_REQUEST['foreign'] = 'false';
     $ctrl->getDropdownValueForDbAction();
     $json = $this->_response->getJSONResult();
     $this->assertEquals(array('table'), $json['tables']);
 }