getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $dbi->expects($this->any()) ->method('insertId') ->will($this->returnValue(10)); $databases = array(); $database_name = 'PMA'; $databases[$database_name]['SCHEMA_TABLES'] = 1; $databases[$database_name]['SCHEMA_TABLE_ROWS'] = 3; $databases[$database_name]['SCHEMA_DATA_LENGTH'] = 5; $databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 10; $databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 10; $databases[$database_name]['SCHEMA_LENGTH'] = 10; $databases[$database_name]['ENGINE'] = "InnerDB"; $dbi->expects($this->any())->method('getTablesFull') ->will($this->returnValue($databases)); $GLOBALS['dbi'] = $dbi; $this->object = new PMA_User_Schema(); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @access protected * @return void */ protected function tearDown() { unset($this->object); } /** * Test for setAction & processUserChoice * * @return void * * @group medium */ public function testSetActionAndProcessUserChoice() { //action: selectpage $_REQUEST['chpage'] = 10; $_REQUEST['action_choose'] = '2'; $this->object->setAction("selectpage"); $this->object->processUserChoice(); $this->assertEquals( "selectpage", $this->object->action ); $this->assertEquals( 10, $this->object->chosenPage ); $_REQUEST['action_choose'] = '1'; $this->object->processUserChoice(); //deleteCoordinates successfully $this->assertEquals( 0, $this->object->chosenPage ); //action: createpage $_POST['newpage'] = "3"; $_POST['auto_layout_foreign'] = true; $_POST['auto_layout_internal'] = true; $_POST['delrow'] = array("row1", "row2"); $_POST['chpage'] = "chpage"; $this->object->setAction("delete_old_references"); $this->object->processUserChoice(); $this->object->setAction("createpage"); $this->object->processUserChoice(); $this->assertEquals( 10, $this->object->pageNumber ); $this->assertEquals( "1", $this->object->autoLayoutForeign ); $this->assertEquals( "1", $this->object->autoLayoutInternal ); //action: edcoord $_POST['chpage'] = "3"; $_POST['c_table_rows'] = 1; $_POST['c_table_0'] = array( 'x' => 'x0', 'y' => 'y0', 'name' => 'name0', 'delete' => 'delete0', 'x' => 'x0', ); $this->object->setAction("edcoord"); $this->object->processUserChoice(); $this->assertEquals( '3', $this->object->chosenPage ); $this->assertEquals( 1, $this->object->c_table_rows ); } }