/** * Tests for getDropdownValueForDbAction() * * Case three: foreign and Drizzle * * @return void * @test */ public function testGetDropdownValueForDbActionThree() { if (!PMA_HAS_RUNKIT) { $this->markTestSkipped("Cannot redefine PMA_DRIZZLE constant"); } runkit_constant_redefine('PMA_DRIZZLE', true); $tableMock = $this->getMockBuilder('PMA_Table')->disableOriginalConstructor()->getMock(); $statusInfo = 'InnoDB'; $tableMock->expects($this->any())->method('getStatusInfo')->will($this->returnValue($statusInfo)); $GLOBALS['dbi']->expects($this->any())->method('getTable')->will($this->returnValue($tableMock)); $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\\Controllers\\Table\\TableRelationController'); $container->alias('TableRelationController', 'PMA\\Controllers\\Table\\TableRelationController'); $ctrl = $container->get('TableRelationController', array('tbl_storage_engine' => 'INNODB')); $_REQUEST['foreign'] = 'true'; $ctrl->getDropdownValueForDbAction(); $json = $this->response->getJSONResult(); $this->assertEquals(array('table'), $json['tables']); }
/** * 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 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\\Controllers\\Table\\TableRelationController'); $container->alias('TableRelationController', 'PMA\\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']); }