public/phpmyadmin/test/classes/Server/Status/MonitorTest.php
/**
     * Test for Monitor::getJsonForLogDataTypeGeneral
     *
     * @return void
     */
Test for Monitor::getJsonForLogDataTypeGeneral
@return void
Test for Monitor :: getJsonForLogDataTypeGeneral @return void
public function testPMAGetJsonForLogDataTypeGeneral()
    {
        $_POST['limitTypes'] = true;
        $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
            ->disableOriginalConstructor()
            ->getMock();
        $value = array(
            'sql_text' => 'insert sql_text',
            '#' => 10,
            'argument' => 'argument argument2',
        );
        $value2 = array(
            'sql_text' => 'update sql_text',
            '#' => 11,
            'argument' => 'argument3 argument4',
        );
        $dbi->expects($this->at(1))->method('fetchAssoc')
            ->will($this->returnValue($value));
        $dbi->expects($this->at(2))->method('fetchAssoc')
            ->will($this->returnValue($value2));
        $dbi->expects($this->at(3))->method('fetchAssoc')
            ->will($this->returnValue(false));
        $GLOBALS['dbi'] = $dbi;
        $start = 0;
        $end = 10;
        $ret = Monitor::getJsonForLogDataTypeGeneral($start, $end);
        $result_rows = array(
            $value,
            $value2,
        );
        $result_sum = array('argument' =>10, 'TOTAL' =>21, 'argument3' => 11);
        $this->assertEquals(
            2,
            $ret['numRows']
        );
        $this->assertEquals(
            $result_rows,
            $ret['rows']
        );
        $this->assertEquals(
            $result_sum,
            $ret['sum']
        );
    }
public function testPMAGetJsonForLogDataTypeGeneral ( ) { $ _POST [ 'limitTypes' ] = true ; $ dbi = $ this -> getMockBuilder ( 'PhpMyAdmin\DatabaseInterface' ) -> disableOriginalConstructor ( ) -> getMock ( ) ; $ value = array ( 'sql_text' => 'insert sql_text' , '#' => 10 , 'argument' => 'argument argument2' , ) ; $ value2 = array ( 'sql_text' => 'update sql_text' , '#' => 11 , 'argument' => 'argument3 argument4' , ) ; $ dbi -> expects ( $ this -> at ( 1 ) ) -> method ( 'fetchAssoc' ) -> will ( $ this -> returnValue ( $ value ) ) ; $ dbi -> expects ( $ this -> at ( 2 ) ) -> method ( 'fetchAssoc' ) -> will ( $ this -> returnValue ( $ value2 ) ) ; $ dbi -> expects ( $ this -> at ( 3 ) ) -> method ( 'fetchAssoc' ) -> will ( $ this -> returnValue ( false ) ) ; $ GLOBALS [ 'dbi' ] = $ dbi ; $ start = 0 ; $ end = 10 ; $ ret = Monitor :: getJsonForLogDataTypeGeneral ( $ start , $ end ) ; $ result_rows = array ( $ value , $ value2 , ) ; $ result_sum = array ( 'argument' => 10 , 'TOTAL' => 21 , 'argument3' => 11 ) ; $ this -> assertEquals ( 2 , $ ret [ 'numRows' ] ) ; $ this -> assertEquals ( $ result_rows , $ ret [ 'rows' ] ) ; $ this -> assertEquals ( $ result_sum , $ ret [ 'sum' ] ) ; }
Test for Monitor::getJsonForLogDataTypeGeneral
 @return void
Test for Monitor :: getJsonForLogDataTypeGeneral @return void
//Mock DBI //Call the test function