public/phpmyadmin/test/classes/Controllers/Server/ServerDatabasesControllerTest.php
/**
     * Tests for _getHtmlForDatabases
     *
     * @return void
     * @group medium
     */
Tests for _getHtmlForDatabases
@return void
@group medium
Tests for _getHtmlForDatabases @return void @group medium
public function testGetHtmlForDatabase()
    {
        $class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerDatabasesController');
        $method = $class->getMethod('_getHtmlForDatabases');
        $method->setAccessible(true);
        $container = Container::getDefaultContainer();
        $container->factory('PhpMyAdmin\Controllers\Server\ServerDatabasesController');
        $container->alias(
            'ServerDatabasesController', 'PhpMyAdmin\Controllers\Server\ServerDatabasesController'
        );
        $ctrl = $container->get('ServerDatabasesController');
        $databases = array(
            array("SCHEMA_NAME" => "pma_bookmark"),
            array("SCHEMA_NAME" => "information_schema"),
            array("SCHEMA_NAME" => "mysql"),
            array("SCHEMA_NAME" => "performance_schema"),
            array("SCHEMA_NAME" => "phpmyadmin")
        );
        $property = $class->getProperty('_databases');
        $property->setAccessible(true);
        $property->setValue($ctrl, $databases);
        $property = $class->getProperty('_database_count');
        $property->setAccessible(true);
        $property->setValue($ctrl, 5);
        $property = $class->getProperty('_pos');
        $property->setAccessible(true);
        $property->setValue($ctrl, 0);
        $property = $class->getProperty('_dbstats');
        $property->setAccessible(true);
        $property->setValue($ctrl, false);
        $property = $class->getProperty('_sort_by');
        $property->setAccessible(true);
        $property->setValue($ctrl, 'SCHEMA_NAME');
        $property = $class->getProperty('_sort_order');
        $property->setAccessible(true);
        $property->setValue($ctrl, 'asc');
        $replication_types = array("master", "slave");
        $html = $method->invoke($ctrl, $replication_types);
        $this->assertContains(
            '<div id="tableslistcontainer">',
            $html
        );
        $this->assertContains(
            '<form class="ajax" action="server_databases.php" ',
            $html
        );
        $this->assertContains(
            '<table id="tabledatabases" class="data">',
            $html
        );
        $this->assertContains(
            '<a href="server_databases.php',
            $html
        );
        $this->assertContains(
            'sort_by=SCHEMA_NAME',
            $html
        );
        $this->assertRegExp(
            '/title="pma_bookmark"[[:space:]]*value="pma_bookmark"/',
            $html
        );
        $this->assertRegExp(
            '/title="information_schema"[[:space:]]*value="information_schema"/',
            $html
        );
        $this->assertRegExp(
            '/title="performance_schema"[[:space:]]*value="performance_schema"/',
            $html
        );
        $this->assertRegExp(
            '/title="phpmyadmin"[[:space:]]*value="phpmyadmin"/',
            $html
        );
        $this->assertContains(
            'Total: <span id="filter-rows-count">5</span>',
            $html
        );
        $this->assertContains(
            'Check all',
            $html
        );
        $this->assertContains(
            'Note: Enabling the database statistics here might cause heavy traffic',
            $html
        );
        $this->assertContains(
            'Enable statistics',
            $html
        );
    }
public function testGetHtmlForDatabase ( ) { $ class = new ReflectionClass ( '\PhpMyAdmin\Controllers\Server\ServerDatabasesController' ) ; $ method = $ class -> getMethod ( '_getHtmlForDatabases' ) ; $ method -> setAccessible ( true ) ; $ container = Container :: getDefaultContainer ( ) ; $ container -> factory ( 'PhpMyAdmin\Controllers\Server\ServerDatabasesController' ) ; $ container -> alias ( 'ServerDatabasesController' , 'PhpMyAdmin\Controllers\Server\ServerDatabasesController' ) ; $ ctrl = $ container -> get ( 'ServerDatabasesController' ) ; $ databases = array ( array ( " SCHEMA_NAME " => " pma_bookmark " ) , array ( " SCHEMA_NAME " => " information_schema " ) , array ( " SCHEMA_NAME " => " mysql " ) , array ( " SCHEMA_NAME " => " performance_schema " ) , array ( " SCHEMA_NAME " => " phpmyadmin " ) ) ; $ property = $ class -> getProperty ( '_databases' ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ ctrl , $ databases ) ; $ property = $ class -> getProperty ( '_database_count' ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ ctrl , 5 ) ; $ property = $ class -> getProperty ( '_pos' ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ ctrl , 0 ) ; $ property = $ class -> getProperty ( '_dbstats' ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ ctrl , false ) ; $ property = $ class -> getProperty ( '_sort_by' ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ ctrl , 'SCHEMA_NAME' ) ; $ property = $ class -> getProperty ( '_sort_order' ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ ctrl , 'asc' ) ; $ replication_types = array ( " master " , " slave " ) ; $ html = $ method -> invoke ( $ ctrl , $ replication_types ) ; $ this -> assertContains ( '<div id="tableslistcontainer">' , $ html ) ; $ this -> assertContains ( '<form class="ajax" action="server_databases.php" ' , $ html ) ; $ this -> assertContains ( '<table id="tabledatabases" class="data">' , $ html ) ; $ this -> assertContains ( '<a href="server_databases.php' , $ html ) ; $ this -> assertContains ( 'sort_by=SCHEMA_NAME' , $ html ) ; $ this -> assertRegExp ( '/title="pma_bookmark"[[:space:]]*value="pma_bookmark"/' , $ html ) ; $ this -> assertRegExp ( '/title="information_schema"[[:space:]]*value="information_schema"/' , $ html ) ; $ this -> assertRegExp ( '/title="performance_schema"[[:space:]]*value="performance_schema"/' , $ html ) ; $ this -> assertRegExp ( '/title="phpmyadmin"[[:space:]]*value="phpmyadmin"/' , $ html ) ; $ this -> assertContains ( 'Total: <span id="filter-rows-count">5</span>' , $ html ) ; $ this -> assertContains ( 'Check all' , $ html ) ; $ this -> assertContains ( 'Note: Enabling the database statistics here might cause heavy traffic' , $ html ) ; $ this -> assertContains ( 'Enable statistics' , $ html ) ; }
Tests for _getHtmlForDatabases
 @return void
 @group medium
Tests for _getHtmlForDatabases @return void @group medium
//Call the test function //validate 1: General info //validate 2:ajax Form //validate 3: PMA_getHtmlForColumnOrderWithSort //validate 4: PMA_getHtmlAndColumnOrderForDatabaseList //validate 5: table footer //validate 6: footer buttons //validate 7: enable statistics