diff options
author | Maurício Meneghini Fauth <mauriciofauth@gmail.com> | 2018-05-30 07:42:21 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauriciofauth@gmail.com> | 2018-05-30 07:42:21 +0300 |
commit | b9c0463d960494cbfe0f04b3159c5ff4a467c446 (patch) | |
tree | 9fe17f2cc230558fbff7a76b9386600ac37d0e8e /test | |
parent | 93bf3d0d1739ec3b15d0e0317ee18b222c58c462 (diff) |
Use short array syntax instead of long array syntax
Replaces array() with [].
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
Diffstat (limited to 'test')
147 files changed, 5738 insertions, 5738 deletions
diff --git a/test/bootstrap-dist.php b/test/bootstrap-dist.php index b22ddaf5eb..47979a26d5 100644 --- a/test/bootstrap-dist.php +++ b/test/bootstrap-dist.php @@ -30,7 +30,7 @@ define('PHPMYADMIN', 1); define('TESTSUITE', 1); // Selenium tests setup -$test_defaults = array( +$test_defaults = [ 'TESTSUITE_SERVER' => 'localhost', 'TESTSUITE_USER' => 'root', 'TESTSUITE_PASSWORD' => '', @@ -44,7 +44,7 @@ $test_defaults = array( 'TESTSUITE_BROWSERSTACK_KEY' => '', 'TESTSUITE_FULL' => '', 'CI_MODE' => '' -); +]; if (PHP_SAPI == 'cli') { foreach ($test_defaults as $varname => $defvalue) { $envvar = getenv($varname); diff --git a/test/classes/AdvisorTest.php b/test/classes/AdvisorTest.php index fae6e2dd35..69c2e8b465 100644 --- a/test/classes/AdvisorTest.php +++ b/test/classes/AdvisorTest.php @@ -56,12 +56,12 @@ class AdvisorTest extends PmaTestCase */ public function escapeStrings() { - return array( - array('80%', '80%%'), - array('%s%', '%s%%'), - array('80% foo', '80%% foo'), - array('%s% foo', '%s%% foo'), - ); + return [ + ['80%', '80%%'], + ['%s%', '%s%%'], + ['80% foo', '80%% foo'], + ['%s% foo', '%s%% foo'], + ]; } /** @@ -73,7 +73,7 @@ class AdvisorTest extends PmaTestCase { $advisor = new Advisor($GLOBALS['dbi'], new ExpressionLanguage()); $parseResult = $advisor->parseRulesFile(); - $this->assertEquals($parseResult['errors'], array()); + $this->assertEquals($parseResult['errors'], []); } /** @@ -97,13 +97,13 @@ class AdvisorTest extends PmaTestCase */ public function advisorTimes() { - return array( - array(10, "10 per second"), - array(0.02, "1.2 per minute"), - array(0.003, "10.8 per hour"), - array(0.00003, "2.59 per day"), - array(0.0000000003, "<0.01 per day"), - ); + return [ + [10, "10 per second"], + [0.02, "1.2 per minute"], + [0.003, "10.8 per hour"], + [0.00003, "2.59 per day"], + [0.0000000003, "<0.01 per day"], + ]; } /** @@ -136,15 +136,15 @@ class AdvisorTest extends PmaTestCase { $advisor = new Advisor($GLOBALS['dbi'], new ExpressionLanguage()); $parseResult = $advisor->parseRulesFile(); - $this->assertEquals($parseResult['errors'], array()); + $this->assertEquals($parseResult['errors'], []); $advisor->setVariable('value', 0); $advisor->addRule('fired', $rule); $runResult = $advisor->getRunResult(); if (isset($runResult['errors']) || !is_null($error)) { - $this->assertEquals(array($error), $runResult['errors']); + $this->assertEquals([$error], $runResult['errors']); } - if (isset($runResult['fired']) || $expected != array()) { - $this->assertEquals(array($expected), $runResult['fired']); + if (isset($runResult['fired']) || $expected != []) { + $this->assertEquals([$expected], $runResult['fired']); } } @@ -155,186 +155,186 @@ class AdvisorTest extends PmaTestCase */ public function rulesProvider() { - return array( - array( - array( + return [ + [ + [ 'justification' => 'foo', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), - array( + ], + [ 'justification' => 'foo', 'id' => 'Basic', 'name' => 'Basic', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => 'foo', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend {status_var}' - ), - array( + ], + [ 'justification' => 'foo', 'id' => 'Variable', 'name' => 'Variable', 'issue' => 'issue', 'recommendation' => 'Recommend <a href="server_variables.php?' . 'filter=status_var&lang=en">status_var</a>' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => '%s foo | value', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), - array( + ], + [ 'justification' => '0 foo', 'id' => 'Format', 'name' => 'Format', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => '%s% foo | value', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), - array( + ], + [ 'justification' => '0% foo', 'id' => 'Percent', 'name' => 'Percent', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => '%s% %d foo | value, value', 'name' => 'Double', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), - array( + ], + [ 'justification' => '0% 0 foo', 'id' => 'Double', 'name' => 'Double', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => '"\'foo', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\'' - ), - array( + ], + [ 'justification' => '"\'foo', 'id' => 'Quotes', 'name' => 'Quotes', 'issue' => 'issue', 'recommendation' => 'Recommend"\'' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => 'foo | fsafdsa', 'name' => 'Failure', 'issue' => 'issue', 'recommendation' => 'Recommend' - ), - array(), + ], + [], 'Failed formatting string for rule \'Failure\'. ' . 'Error when evaluating: Variable "fsafdsa" is not ' . 'valid around position 2 for expression `[fsafdsa]`.' - ), - array( - array( + ], + [ + [ 'justification' => 'Version string (%s) | value', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="https://example.com/">web</a>', - ), - array( + ], + [ 'justification' => 'Version string (0)', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="./url.php?url=https%3A%2F%2F' . 'example.com%2F" target="_blank" rel="noopener noreferrer">web</a>', 'id' => 'Distribution' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => 'Timestamp (%s) | ADVISOR_timespanFormat(1377027)', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="https://example.com/">web</a>', - ), - array( + ], + [ 'justification' => 'Timestamp (15 days, 22 hours, 30 minutes and 27 seconds)', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="./url.php?url=https%3A%2F%2F' . 'example.com%2F" target="_blank" rel="noopener noreferrer">web</a>', 'id' => 'Distribution' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => 'Memory: %s | ADVISOR_formatByteDown(1000000, 2, 2)', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="https://example.com/">web</a>', - ), - array( + ], + [ 'justification' => 'Memory: 0.95 MiB', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="./url.php?url=https%3A%2F%2F' . 'example.com%2F" target="_blank" rel="noopener noreferrer">web</a>', 'id' => 'Distribution' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => 'Time: %s | ADVISOR_bytime(0.02, 2)', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="https://example.com/">web</a>', - ), - array( + ], + [ 'justification' => 'Time: 1.2 per minute', 'name' => 'Distribution', 'issue' => 'official MySQL binaries.', 'recommendation' => 'See <a href="./url.php?url=https%3A%2F%2F' . 'example.com%2F" target="_blank" rel="noopener noreferrer">web</a>', 'id' => 'Distribution' - ), + ], null, - ), - array( - array( + ], + [ + [ 'justification' => 'Current version: %s | value', 'name' => 'Minor Version', 'precondition' => '! fired(\'Release Series\')', @@ -342,8 +342,8 @@ class AdvisorTest extends PmaTestCase 'recommendation' => 'You should upgrade', 'formula' => 'version', 'test' => "substr(value,0,2) <= '5.' && substr(value,2,1) <= 1 && substr(value,4,2) < 30", - ), - array( + ], + [ 'justification' => 'Current version: 0', 'name' => 'Minor Version', 'issue' => 'Version less than 5.1.30', @@ -352,9 +352,9 @@ class AdvisorTest extends PmaTestCase 'precondition' => '! fired(\'Release Series\')', 'formula' => 'version', 'test' => "substr(value,0,2) <= '5.' && substr(value,2,1) <= 1 && substr(value,4,2) < 30", - ), + ], null, - ), - ); + ], + ]; } } diff --git a/test/classes/BookmarkTest.php b/test/classes/BookmarkTest.php index ac4a11ff8f..3817728b16 100644 --- a/test/classes/BookmarkTest.php +++ b/test/classes/BookmarkTest.php @@ -55,7 +55,7 @@ class BookmarkTest extends TestCase public function testGetList() { $this->assertEquals( - array(), + [], Bookmark::getList( $GLOBALS['dbi'], $GLOBALS['cfg']['Server']['user'], @@ -88,12 +88,12 @@ class BookmarkTest extends TestCase */ public function testSave() { - $bookmarkData = array( + $bookmarkData = [ 'bkm_database' => 'phpmyadmin', 'bkm_user' => 'root', 'bkm_sql_query' => 'SELECT "phpmyadmin"', 'bkm_label' => 'bookmark1', - ); + ]; $bookmark = Bookmark::createBookmark( $GLOBALS['dbi'], diff --git a/test/classes/BrowseForeignersTest.php b/test/classes/BrowseForeignersTest.php index 231546b5bc..ba84ddc9c1 100644 --- a/test/classes/BrowseForeignersTest.php +++ b/test/classes/BrowseForeignersTest.php @@ -110,8 +110,8 @@ class BrowseForeignersTest extends TestCase ); $_REQUEST['pos'] = 15; - $foreignData = array(); - $foreignData['disp_row'] = array(); + $foreignData = []; + $foreignData['disp_row'] = []; $foreignData['the_total'] = 5; $this->assertEquals( @@ -165,7 +165,7 @@ class BrowseForeignersTest extends TestCase $desc = 'foobar<baz'; $this->assertEquals( - array('foobar<baz', ''), + ['foobar<baz', ''], $this->callProtectedMethod( 'getDescriptionAndTitle', [$desc] @@ -175,7 +175,7 @@ class BrowseForeignersTest extends TestCase $browseForeigners = new BrowseForeigners(5, 25, 100, false, ''); $this->assertEquals( - array('fooba...', 'foobar<baz'), + ['fooba...', 'foobar<baz'], $this->callProtectedMethod( 'getDescriptionAndTitle', [$desc], @@ -194,7 +194,7 @@ class BrowseForeignersTest extends TestCase $db = ''; $table = ''; $field = 'foo'; - $foreignData = array(); + $foreignData = []; $foreignData['disp_row'] = ''; $fieldkey = 'bar'; $current_value = ''; @@ -269,7 +269,7 @@ class BrowseForeignersTest extends TestCase $result ); - $foreignData['disp_row'] = array(); + $foreignData['disp_row'] = []; $foreignData['the_total'] = 5; $result = $this->browseForeigners->getHtmlForRelationalFieldSelection( $db, diff --git a/test/classes/CentralColumnsTest.php b/test/classes/CentralColumnsTest.php index eeb0286600..16816e76ea 100644 --- a/test/classes/CentralColumnsTest.php +++ b/test/classes/CentralColumnsTest.php @@ -29,42 +29,42 @@ class CentralColumnsTest extends TestCase { private $centralColumns; - private $columnData = array( - array( + private $columnData = [ + [ 'col_name' => "id", "col_type" => 'integer', 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => 'UNSIGNED,auto_increment', 'col_default' => 1, 'col_collation' => '' - ), - array('col_name' => "col1", 'col_type' => 'varchar', + ], + ['col_name' => "col1", 'col_type' => 'varchar', 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => 'BINARY', 'col_default' => 1, 'col_collation' => '' - ), - array( + ], + [ 'col_name' => "col2", 'col_type' => 'DATETIME', 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => 'on update CURRENT_TIMESTAMP', 'col_default' => 'CURRENT_TIMESTAMP', 'col_collation' => '' - ) - ); + ] + ]; - private $modifiedColumnData = array( - array( + private $modifiedColumnData = [ + [ 'col_name' => "id", "col_type" => 'integer', 'col_length' => 0, 'col_isNull' => 0, 'col_extra' => 'auto_increment', 'col_default' => 1, 'col_collation' => '', 'col_attribute' => 'UNSIGNED' - ), - array('col_name' => "col1", 'col_type' => 'varchar', + ], + ['col_name' => "col1", 'col_type' => 'varchar', 'col_length' => 100, 'col_isNull' => 1, 'col_extra' => '', 'col_default' => 1, 'col_collation' => '', 'col_attribute' => 'BINARY' - ), - array( + ], + [ 'col_name' => "col2", 'col_type' => 'DATETIME', 'col_length' => 0, 'col_isNull' => 1, 'col_extra' => '', 'col_default' => 'CURRENT_TIMESTAMP', 'col_collation' => '', 'col_attribute' => 'on update CURRENT_TIMESTAMP' - ) - ); + ] + ]; /** * prepares environment for tests @@ -86,14 +86,14 @@ class CentralColumnsTest extends TestCase //$_SESSION $GLOBALS['server'] = 1; - $_SESSION['relation'][1] = array( + $_SESSION['relation'][1] = [ 'PMA_VERSION' => PMA_VERSION, 'centralcolumnswork' => true, 'relwork' => 1, 'db' => 'phpmyadmin', 'relation' => 'relation', 'central_columns' => 'pma_central_columns' - ); + ]; // mock DBI $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') @@ -110,23 +110,23 @@ class CentralColumnsTest extends TestCase ->method('getColumns') ->will( $this->returnValue( - array( - "id"=>array("Type"=>"integer", "Null"=>"NO"), - "col1"=>array("Type"=>'varchar(100)', "Null"=>"YES"), - "col2"=>array("Type"=>'DATETIME', "Null"=>"NO") - ) + [ + "id"=>["Type"=>"integer", "Null"=>"NO"], + "col1"=>["Type"=>'varchar(100)', "Null"=>"YES"], + "col2"=>["Type"=>'DATETIME', "Null"=>"NO"] + ] ) ); $dbi->expects($this->any()) ->method('getColumnNames') - ->will($this->returnValue(array("id", "col1", "col2"))); + ->will($this->returnValue(["id", "col1", "col2"])); $dbi->expects($this->any()) ->method('tryQuery') ->will($this->returnValue(true)); $dbi->expects($this->any()) ->method('getTables') ->will( - $this->returnValue(array("PMA_table", "PMA_table1", "PMA_table2")) + $this->returnValue(["PMA_table", "PMA_table1", "PMA_table2"]) ); $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); @@ -165,11 +165,11 @@ class CentralColumnsTest extends TestCase public function testGetParams() { $this->assertSame( - array( + [ 'user' => 'pma_user', 'db' => 'phpmyadmin', 'table' => 'pma_central_columns' - ), + ], $this->centralColumns->getParams() ); } @@ -213,7 +213,7 @@ class CentralColumnsTest extends TestCase null, null, DatabaseInterface::CONNECT_CONTROL ) ->will( - $this->returnValue(array(3)) + $this->returnValue([3]) ); $this->assertEquals( @@ -234,7 +234,7 @@ class CentralColumnsTest extends TestCase $this->assertTrue( $this->centralColumns->syncUniqueColumns( - array('PMA_table') + ['PMA_table'] ) ); } @@ -258,7 +258,7 @@ class CentralColumnsTest extends TestCase null, null, DatabaseInterface::CONNECT_CONTROL ) ->will( - $this->returnValue(array('col1')) + $this->returnValue(['col1']) ); $GLOBALS['dbi']->expects($this->at(7)) @@ -269,12 +269,12 @@ class CentralColumnsTest extends TestCase DatabaseInterface::CONNECT_CONTROL ) ->will( - $this->returnValue(array('col1')) + $this->returnValue(['col1']) ); $this->assertTrue( $this->centralColumns->deleteColumnsFromList( - array("col1"), + ["col1"], false ) ); @@ -282,14 +282,14 @@ class CentralColumnsTest extends TestCase // when column does not exist in the central column list $this->assertInstanceOf( 'PhpMyAdmin\Message', $this->centralColumns->deleteColumnsFromList( - array('column1'), + ['column1'], false ) ); $this->assertInstanceOf( 'PhpMyAdmin\Message', $this->centralColumns->deleteColumnsFromList( - array('PMA_table') + ['PMA_table'] ) ); } @@ -314,7 +314,7 @@ class CentralColumnsTest extends TestCase $this->assertTrue( $this->centralColumns->makeConsistentWithList( "phpmyadmin", - array('PMA_table') + ['PMA_table'] ) ); } @@ -337,10 +337,10 @@ class CentralColumnsTest extends TestCase null, null, DatabaseInterface::CONNECT_CONTROL ) ->will( - $this->returnValue(array('id','col1')) + $this->returnValue(['id','col1']) ); $this->assertEquals( - array("id", "col1"), + ["id", "col1"], $this->centralColumns->getFromTable( $db, $table @@ -405,14 +405,14 @@ class CentralColumnsTest extends TestCase public function testUpdateMultipleColumn() { $_POST['db'] = 'phpmyadmin'; - $_POST['orig_col_name'] = array("col1","col2"); - $_POST['field_name'] = array("col1","col2"); - $_POST['field_default_type'] = array("",""); - $_POST['col_extra'] = array("",""); - $_POST['field_length'] = array("",""); - $_POST['field_attribute'] = array("",""); - $_POST['field_type'] = array("",""); - $_POST['field_collation'] = array("",""); + $_POST['orig_col_name'] = ["col1","col2"]; + $_POST['field_name'] = ["col1","col2"]; + $_POST['field_default_type'] = ["",""]; + $_POST['col_extra'] = ["",""]; + $_POST['field_length'] = ["",""]; + $_POST['field_attribute'] = ["",""]; + $_POST['field_type'] = ["",""]; + $_POST['field_collation'] = ["",""]; $this->assertTrue( $this->centralColumns->updateMultipleColumn() ); @@ -437,17 +437,17 @@ class CentralColumnsTest extends TestCase $this->returnValue($this->columnData) ); $result = $this->centralColumns->getHtmlForEditingPage( - array("col1", "col2"), + ["col1", "col2"], 'phpmyadmin' ); $this->assertContains( '<form', $result ); - $header_cells = array( + $header_cells = [ __('Name'), __('Type'), __('Length/Values'), __('Default'), __('Collation'), __('Attributes'), __('Null'), __('A_I') - ); + ]; $this->assertContains( $this->callProtectedMethod( 'getEditTableHeader', diff --git a/test/classes/CharsetsTest.php b/test/classes/CharsetsTest.php index 4e19be3d2d..e119a24163 100644 --- a/test/classes/CharsetsTest.php +++ b/test/classes/CharsetsTest.php @@ -53,97 +53,97 @@ class CharsetsTest extends TestCase */ public function collationDescr() { - return array( - array('binary', 'Binary'), - array('foo_bulgarian_bar', 'Bulgarian'), - array('gb2312_chinese', 'Simplified Chinese'), - array('gbk_chinese', 'Simplified Chinese'), - array('big5_chinese_ci', 'Traditional Chinese, case-insensitive'), - array('big5_chinese', 'Traditional Chinese'), - array('foo_ci_bar', 'Unknown, case-insensitive'), - array('foo_croatian_bar', 'Croatian'), - array('foo_czech_bar', 'Czech'), - array('foo_danish_bar', 'Danish'), - array('foo_english_bar', 'English'), - array('foo_esperanto_bar', 'Esperanto'), - array('foo_estonian_bar', 'Estonian'), - array('foo_german1_bar', 'German (dictionary order)'), - array('foo_german2_bar', 'German (phone book order)'), - array('foo_hungarian_bar', 'Hungarian'), - array('foo_icelandic_bar', 'Icelandic'), - array('foo_japanese_bar', 'Japanese'), - array('foo_latvian_bar', 'Latvian'), - array('foo_lithuanian_bar', 'Lithuanian'), - array('foo_korean_bar', 'Korean'), - array('foo_persian_bar', 'Persian'), - array('foo_polish_bar', 'Polish'), - array('foo_roman_bar', 'West European'), - array('foo_romanian_bar', 'Romanian'), - array('foo_slovak_bar', 'Slovak'), - array('foo_slovenian_bar', 'Slovenian'), - array('foo_spanish_bar', 'Spanish (modern)'), - array('foo_spanish2_bar', 'Spanish (traditional)'), - array('foo_swedish_bar', 'Swedish'), - array('foo_thai_bar', 'Thai'), - array('foo_turkish_bar', 'Turkish'), - array('foo_ukrainian_bar', 'Ukrainian'), - array('foo_unicode_bar', 'Unicode'), - array('ucs2', 'Unicode'), - array('utf8', 'Unicode'), - array('ascii', 'West European'), - array('cp850', 'West European'), - array('dec8', 'West European'), - array('hp8', 'West European'), - array('latin1', 'West European'), - array('cp1250', 'Central European'), - array('cp852', 'Central European'), - array('latin2', 'Central European'), - array('macce', 'Central European'), - array('cp866', 'Russian'), - array('koi8r', 'Russian'), - array('gb2312', 'Simplified Chinese'), - array('gbk', 'Simplified Chinese'), - array('sjis', 'Japanese'), - array('ujis', 'Japanese'), - array('cp932', 'Japanese'), - array('eucjpms', 'Japanese'), - array('cp1257', 'Baltic'), - array('latin7', 'Baltic'), - array('armscii8', 'Armenian'), - array('armscii', 'Armenian'), - array('big5', 'Traditional Chinese'), - array('cp1251', 'Cyrillic'), - array('cp1256', 'Arabic'), - array('euckr', 'Korean'), - array('hebrew', 'Hebrew'), - array('geostd8', 'Georgian'), - array('greek', 'Greek'), - array('keybcs2', 'Czech-Slovak'), - array('koi8u', 'Ukrainian'), - array('latin5', 'Turkish'), - array('swe7', 'Swedish'), - array('tis620', 'Thai'), - array('foobar', 'Unknown'), - array('foo_test_bar', 'Unknown'), - array('foo_bin_bar', 'Unknown, binary'), - array('utf8mb4_0900_ai_ci', 'Unicode (UCA 9.0.0), accent-insensitive, case-insensitive'), - array('utf8mb4_unicode_520_ci', 'Unicode (UCA 5.2.0), case-insensitive'), - array('utf8mb4_unicode_ci', 'Unicode (UCA 4.0.0), case-insensitive'), - array('utf8mb4_tr_0900_ai_ci', 'Turkish (UCA 9.0.0), accent-insensitive, case-insensitive'), - array('utf8mb4_turkish_ci', 'Turkish (UCA 4.0.0), case-insensitive'), - array('utf32_thai_520_w2', 'Thai (UCA 5.2.0), multi-level'), - array('utf8mb4_czech_ci', 'Czech (UCA 4.0.0), case-insensitive'), - array('cp1250_czech_cs', 'Czech, case-sensitive'), - array('latin1_general_ci', 'West European, case-insensitive'), - array('utf8mb4_bin', 'Unicode (UCA 4.0.0), binary'), - array('utf8mb4_croatian_mysql561_ci', 'Croatian (MySQL 5.6.1), case-insensitive'), - array('ucs2_general_mysql500_ci', 'Unicode (MySQL 5.0.0), case-insensitive'), - array('utf32_general_ci', 'Unicode, case-insensitive'), - array('utf8mb4_es_trad_0900_ai_ci', 'Spanish (traditional) (UCA 9.0.0), accent-insensitive, case-insensitive'), - array('utf8mb4_es_0900_ai_ci', 'Spanish (modern) (UCA 9.0.0), accent-insensitive, case-insensitive'), - array('utf8mb4_de_pb_0900_ai_ci', 'German (phone book order) (UCA 9.0.0), accent-insensitive, case-insensitive'), - array('utf8mb4_de_0900_ai_ci', 'German (dictionary order) (UCA 9.0.0), accent-insensitive, case-insensitive'), - ); + return [ + ['binary', 'Binary'], + ['foo_bulgarian_bar', 'Bulgarian'], + ['gb2312_chinese', 'Simplified Chinese'], + ['gbk_chinese', 'Simplified Chinese'], + ['big5_chinese_ci', 'Traditional Chinese, case-insensitive'], + ['big5_chinese', 'Traditional Chinese'], + ['foo_ci_bar', 'Unknown, case-insensitive'], + ['foo_croatian_bar', 'Croatian'], + ['foo_czech_bar', 'Czech'], + ['foo_danish_bar', 'Danish'], + ['foo_english_bar', 'English'], + ['foo_esperanto_bar', 'Esperanto'], + ['foo_estonian_bar', 'Estonian'], + ['foo_german1_bar', 'German (dictionary order)'], + ['foo_german2_bar', 'German (phone book order)'], + ['foo_hungarian_bar', 'Hungarian'], + ['foo_icelandic_bar', 'Icelandic'], + ['foo_japanese_bar', 'Japanese'], + ['foo_latvian_bar', 'Latvian'], + ['foo_lithuanian_bar', 'Lithuanian'], + ['foo_korean_bar', 'Korean'], + ['foo_persian_bar', 'Persian'], + ['foo_polish_bar', 'Polish'], + ['foo_roman_bar', 'West European'], + ['foo_romanian_bar', 'Romanian'], + ['foo_slovak_bar', 'Slovak'], + ['foo_slovenian_bar', 'Slovenian'], + ['foo_spanish_bar', 'Spanish (modern)'], + ['foo_spanish2_bar', 'Spanish (traditional)'], + ['foo_swedish_bar', 'Swedish'], + ['foo_thai_bar', 'Thai'], + ['foo_turkish_bar', 'Turkish'], + ['foo_ukrainian_bar', 'Ukrainian'], + ['foo_unicode_bar', 'Unicode'], + ['ucs2', 'Unicode'], + ['utf8', 'Unicode'], + ['ascii', 'West European'], + ['cp850', 'West European'], + ['dec8', 'West European'], + ['hp8', 'West European'], + ['latin1', 'West European'], + ['cp1250', 'Central European'], + ['cp852', 'Central European'], + ['latin2', 'Central European'], + ['macce', 'Central European'], + ['cp866', 'Russian'], + ['koi8r', 'Russian'], + ['gb2312', 'Simplified Chinese'], + ['gbk', 'Simplified Chinese'], + ['sjis', 'Japanese'], + ['ujis', 'Japanese'], + ['cp932', 'Japanese'], + ['eucjpms', 'Japanese'], + ['cp1257', 'Baltic'], + ['latin7', 'Baltic'], + ['armscii8', 'Armenian'], + ['armscii', 'Armenian'], + ['big5', 'Traditional Chinese'], + ['cp1251', 'Cyrillic'], + ['cp1256', 'Arabic'], + ['euckr', 'Korean'], + ['hebrew', 'Hebrew'], + ['geostd8', 'Georgian'], + ['greek', 'Greek'], + ['keybcs2', 'Czech-Slovak'], + ['koi8u', 'Ukrainian'], + ['latin5', 'Turkish'], + ['swe7', 'Swedish'], + ['tis620', 'Thai'], + ['foobar', 'Unknown'], + ['foo_test_bar', 'Unknown'], + ['foo_bin_bar', 'Unknown, binary'], + ['utf8mb4_0900_ai_ci', 'Unicode (UCA 9.0.0), accent-insensitive, case-insensitive'], + ['utf8mb4_unicode_520_ci', 'Unicode (UCA 5.2.0), case-insensitive'], + ['utf8mb4_unicode_ci', 'Unicode (UCA 4.0.0), case-insensitive'], + ['utf8mb4_tr_0900_ai_ci', 'Turkish (UCA 9.0.0), accent-insensitive, case-insensitive'], + ['utf8mb4_turkish_ci', 'Turkish (UCA 4.0.0), case-insensitive'], + ['utf32_thai_520_w2', 'Thai (UCA 5.2.0), multi-level'], + ['utf8mb4_czech_ci', 'Czech (UCA 4.0.0), case-insensitive'], + ['cp1250_czech_cs', 'Czech, case-sensitive'], + ['latin1_general_ci', 'West European, case-insensitive'], + ['utf8mb4_bin', 'Unicode (UCA 4.0.0), binary'], + ['utf8mb4_croatian_mysql561_ci', 'Croatian (MySQL 5.6.1), case-insensitive'], + ['ucs2_general_mysql500_ci', 'Unicode (MySQL 5.0.0), case-insensitive'], + ['utf32_general_ci', 'Unicode, case-insensitive'], + ['utf8mb4_es_trad_0900_ai_ci', 'Spanish (traditional) (UCA 9.0.0), accent-insensitive, case-insensitive'], + ['utf8mb4_es_0900_ai_ci', 'Spanish (modern) (UCA 9.0.0), accent-insensitive, case-insensitive'], + ['utf8mb4_de_pb_0900_ai_ci', 'German (phone book order) (UCA 9.0.0), accent-insensitive, case-insensitive'], + ['utf8mb4_de_0900_ai_ci', 'German (dictionary order) (UCA 9.0.0), accent-insensitive, case-insensitive'], + ]; } /** diff --git a/test/classes/Config/ConfigFileTest.php b/test/classes/Config/ConfigFileTest.php index 52cfd8de05..3b2eb5fc5d 100644 --- a/test/classes/Config/ConfigFileTest.php +++ b/test/classes/Config/ConfigFileTest.php @@ -65,13 +65,13 @@ class ConfigFileTest extends PmaTestCase { // Check default dynamic values $this->assertEquals( - array(), + [], $this->object->getConfig() ); // Check environment state $this->assertEquals( - array(), + [], $_SESSION["ConfigFile1"] ); @@ -94,10 +94,10 @@ class ConfigFileTest extends PmaTestCase self::SIMPLE_KEY_WITH_DEFAULT_VALUE ); $default_host = $this->object->getDefault('Servers/1/host'); - $default_config = array( + $default_config = [ self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $default_simple_value, 'Servers/1/host' => $default_host, - 'Servers/2/host' => $default_host); + 'Servers/2/host' => $default_host]; /** * Case 1: set default value, key should not be persisted @@ -127,7 +127,7 @@ class ConfigFileTest extends PmaTestCase */ $this->object->set('Servers/2/host', $default_host); $this->assertEquals( - array('Servers' => array(2 => array('host' => $default_host))), + ['Servers' => [2 => ['host' => $default_host]]], $this->object->getConfig() ); } @@ -143,13 +143,13 @@ class ConfigFileTest extends PmaTestCase /** * Case 1: filter should not allow to set b */ - $this->object->setAllowedKeys(array('a', 'c')); + $this->object->setAllowedKeys(['a', 'c']); $this->object->set('a', 1); $this->object->set('b', 2); $this->object->set('c', 3); $this->assertEquals( - array('a' => 1, 'c' => 3), + ['a' => 1, 'c' => 3], $this->object->getConfig() ); @@ -160,7 +160,7 @@ class ConfigFileTest extends PmaTestCase $this->object->set('b', 2); $this->assertEquals( - array('a' => 1, 'b' => 2, 'c' => 3), + ['a' => 1, 'b' => 2, 'c' => 3], $this->object->getConfig() ); } @@ -174,21 +174,21 @@ class ConfigFileTest extends PmaTestCase public function testConfigReadMapping() { $this->object->setCfgUpdateReadMapping( - array( + [ 'Servers/value1' => 'Servers/1/value1', 'Servers/value2' => 'Servers/1/value2' - ) + ] ); $this->object->set('Servers/1/passthrough1', 1); $this->object->set('Servers/1/passthrough2', 2); - $this->object->updateWithGlobalConfig(array('Servers/value1' => 3)); + $this->object->updateWithGlobalConfig(['Servers/value1' => 3]); $this->assertEquals( - array('Servers' => array( - 1 => array( + ['Servers' => [ + 1 => [ 'passthrough1' => 1, 'passthrough2' => 2, - 'value1' => 3))), + 'value1' => 3]]], $this->object->getConfig() ); $this->assertEquals( @@ -222,14 +222,14 @@ class ConfigFileTest extends PmaTestCase public function testSetConfigData() { $this->object->set('abc', 'should be deleted by setConfigData'); - $this->object->setConfigData(array('a' => 'b')); + $this->object->setConfigData(['a' => 'b']); $this->assertEquals( - array('a' => 'b'), + ['a' => 'b'], $this->object->getConfig() ); $this->assertEquals( - array('a' => 'b'), + ['a' => 'b'], $this->object->getConfigArray() ); } @@ -266,8 +266,8 @@ class ConfigFileTest extends PmaTestCase $this->object->get('key not excist') ); $this->assertEquals( - array(1), - $this->object->get('key not excist', array(1)) + [1], + $this->object->get('key not excist', [1]) ); $default = new stdClass(); $this->assertInstanceOf( @@ -307,7 +307,7 @@ class ConfigFileTest extends PmaTestCase // values are not written when they are the same as in config.inc.php $this->object = new ConfigFile( - array(self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $default_value) + [self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $default_value] ); $this->object->set(self::SIMPLE_KEY_WITH_DEFAULT_VALUE, $default_value); $this->assertEmpty($this->object->getConfig()); @@ -316,11 +316,11 @@ class ConfigFileTest extends PmaTestCase // allow to overwrite with value from config.default.php $config_inc_php_value = $default_value . 'suffix'; $this->object = new ConfigFile( - array(self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $config_inc_php_value) + [self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $config_inc_php_value] ); $this->object->set(self::SIMPLE_KEY_WITH_DEFAULT_VALUE, $default_value); $this->assertEquals( - array(self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $default_value), + [self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $default_value], $this->object->getConfig() ); } @@ -348,7 +348,7 @@ class ConfigFileTest extends PmaTestCase $localhost_value, $flat_default_config['Servers/1/host'] ); - $cfg = array(); + $cfg = []; include './libraries/config.default.php'; // verify that $cfg read from config.default.php is valid $this->assertGreaterThanOrEqual(100, count($cfg)); @@ -365,10 +365,10 @@ class ConfigFileTest extends PmaTestCase { $this->object->set('key', 'value'); $this->object->set('key2', 'value'); - $this->object->updateWithGlobalConfig(array('key' => 'ABC')); + $this->object->updateWithGlobalConfig(['key' => 'ABC']); $this->assertEquals( - array('key' => 'ABC', 'key2' => 'value'), + ['key' => 'ABC', 'key2' => 'value'], $this->object->getConfig() ); } @@ -400,7 +400,7 @@ class ConfigFileTest extends PmaTestCase */ public function testGetDbEntry() { - $cfg_db = array(); + $cfg_db = []; include './libraries/config.values.php'; // verify that $cfg_db read from config.values.php is valid $this->assertGreaterThanOrEqual(20, count($cfg_db)); @@ -411,8 +411,8 @@ class ConfigFileTest extends PmaTestCase ); $this->assertNull($this->object->getDbEntry('no such key')); $this->assertEquals( - array(1), - $this->object->getDbEntry('no such key', array(1)) + [1], + $this->object->getDbEntry('no such key', [1]) ); } @@ -448,11 +448,11 @@ class ConfigFileTest extends PmaTestCase $this->object->get('ServerDefault') ); $this->assertEquals( - array('Servers' => array(1 => array('x' => 1), 2 => array('x' => 4))), + ['Servers' => [1 => ['x' => 1], 2 => ['x' => 4]]], $this->object->getConfig() ); $this->assertEquals( - array('Servers/1/x' => 1, 'Servers/2/x' => 4), + ['Servers/1/x' => 1, 'Servers/2/x' => 4], $this->object->getConfigArray() ); } @@ -469,7 +469,7 @@ class ConfigFileTest extends PmaTestCase $this->object->set('Servers/2/x', 'b'); $this->assertEquals( - array(1 => array('x' => 'a'), 2 => array('x' => 'b')), + [1 => ['x' => 'a'], 2 => ['x' => 'b']], $this->object->getServers() ); } @@ -488,16 +488,16 @@ class ConfigFileTest extends PmaTestCase ); $this->object->updateWithGlobalConfig( - array( - 'Servers' => array( - 1 => array( + [ + 'Servers' => [ + 1 => [ "auth_type" => "config", "user" => "testUser", "host" => "example.com", "port" => "21" - ) - ) - ) + ] + ] + ] ); $this->assertEquals( "mysqli://testUser@example.com:21", @@ -505,18 +505,18 @@ class ConfigFileTest extends PmaTestCase ); $this->object->updateWithGlobalConfig( - array( - 'Servers' => array( - 1 => array( + [ + 'Servers' => [ + 1 => [ "auth_type" => "config", "user" => "testUser", "host" => "localhost", "port" => "21", "socket" => "123", "password" => "", - ) - ) - ) + ] + ] + ] ); $this->assertEquals( "mysqli://testUser@123", @@ -524,17 +524,17 @@ class ConfigFileTest extends PmaTestCase ); $this->object->updateWithGlobalConfig( - array( - 'Servers' => array( - 1 => array( + [ + 'Servers' => [ + 1 => [ "auth_type" => "config", "user" => "testUser", "host" => "example.com", "port" => "21", "password" => "testPass" - ) - ) - ) + ] + ] + ] ); $this->assertEquals( "mysqli://testUser:***@example.com:21", @@ -576,17 +576,17 @@ class ConfigFileTest extends PmaTestCase */ public function testGetConfigArray() { - $this->object->setPersistKeys(array(self::SIMPLE_KEY_WITH_DEFAULT_VALUE)); - $this->object->set('Array/test', array('x', 'y')); + $this->object->setPersistKeys([self::SIMPLE_KEY_WITH_DEFAULT_VALUE]); + $this->object->set('Array/test', ['x', 'y']); $default_value = $this->object->getDefault( self::SIMPLE_KEY_WITH_DEFAULT_VALUE ); $this->assertEquals( - array( + [ self::SIMPLE_KEY_WITH_DEFAULT_VALUE => $default_value, - 'Array/test' => array('x', 'y') - ), + 'Array/test' => ['x', 'y'] + ], $this->object->getConfigArray() ); } diff --git a/test/classes/Config/DescriptionTest.php b/test/classes/Config/DescriptionTest.php index 9f85886ce6..c1cd399f0e 100644 --- a/test/classes/Config/DescriptionTest.php +++ b/test/classes/Config/DescriptionTest.php @@ -49,23 +49,23 @@ class DescriptionTest extends PmaTestCase */ public function getValues() { - return array( - array( + return [ + [ 'AllowArbitraryServer', 'name', 'Allow login to any MySQL server', - ), - array( + ], + [ 'UnknownSetting', 'name', 'UnknownSetting', - ), - array( + ], + [ 'UnknownSetting', 'desc', '', - ), - ); + ], + ]; } /** @@ -89,16 +89,16 @@ class DescriptionTest extends PmaTestCase */ public function testAll() { - $nested = array( + $nested = [ 'Export', 'Import', 'Schema', 'DBG', 'DefaultTransformations', 'SQLQuery', - ); + ]; - $cfg = array(); + $cfg = []; include './libraries/config.default.php'; foreach ($cfg as $key => $value) { $this->assertGet($key); diff --git a/test/classes/Config/FormDisplayTemplateTest.php b/test/classes/Config/FormDisplayTemplateTest.php index 7b10969792..8be1271802 100644 --- a/test/classes/Config/FormDisplayTemplateTest.php +++ b/test/classes/Config/FormDisplayTemplateTest.php @@ -40,7 +40,7 @@ class FormDisplayTemplateTest extends TestCase { $_SERVER['REQUEST_URI'] = 'https://www.phpmyadmin.net'; $GLOBALS['cfg']['ServerDefault'] = ''; - $result = FormDisplayTemplate::displayFormTop(null, 'posted', array(1)); + $result = FormDisplayTemplate::displayFormTop(null, 'posted', [1]); $this->assertContains( '<form method="get" action="https://www.phpmyadmin.net" ' . @@ -76,7 +76,7 @@ class FormDisplayTemplateTest extends TestCase */ public function testDisplayTabsTop() { - $result = FormDisplayTemplate::displayTabsTop(array('one', 'two')); + $result = FormDisplayTemplate::displayTabsTop(['one', 'two']); $this->assertContains( '<ul class="tabs responsivetable"', @@ -106,8 +106,8 @@ class FormDisplayTemplateTest extends TestCase */ public function testDisplayFieldsetTop() { - $attributes = array('name' => 'attrname'); - $errors = array('e1', 'e2'); + $attributes = ['name' => 'attrname']; + $errors = ['e1', 'e2']; $result = FormDisplayTemplate::displayFieldsetTop("TitleTest", "DescTest", $errors, $attributes); @@ -150,8 +150,8 @@ class FormDisplayTemplateTest extends TestCase public function testDisplayInput() { $GLOBALS['_FormDislayGroup'] = 1; - $opts = array(); - $opts['errors'] = array('e1'); + $opts = []; + $opts['errors'] = ['e1']; $opts['userprefs_allow'] = false; $opts['setvalue'] = ':group'; $opts['doc'] = "https://example.com/"; @@ -220,8 +220,8 @@ class FormDisplayTemplateTest extends TestCase $GLOBALS['PMA_Config']->set('is_setup', true); $GLOBALS['_FormDislayGroup'] = 0; - $opts = array(); - $opts['errors'] = array(); + $opts = []; + $opts['errors'] = []; $opts['setvalue'] = 'setVal'; $opts['comment'] = "testComment"; $opts['show_restore_default'] = true; @@ -263,8 +263,8 @@ class FormDisplayTemplateTest extends TestCase // short_text $GLOBALS['_FormDislayGroup'] = 0; - $opts = array(); - $opts['errors'] = array(); + $opts = []; + $opts['errors'] = []; $result = FormDisplayTemplate::displayInput( 'test/path', 'testName', 'short_text', 'val', @@ -291,12 +291,12 @@ class FormDisplayTemplateTest extends TestCase // select case 1 $opts['values_escaped'] = true; - $opts['values_disabled'] = array(1, 2); - $opts['values'] = array( + $opts['values_disabled'] = [1, 2]; + $opts['values'] = [ 1 => 'test', 'key1' => true, 'key2' => false, - ); + ]; $result = FormDisplayTemplate::displayInput( 'test/path', 'testName', 'select', true, '', true, $opts @@ -323,12 +323,12 @@ class FormDisplayTemplateTest extends TestCase // select case 2 $opts['values_escaped'] = false; - $opts['values_disabled'] = array(1, 2); - $opts['values'] = array( + $opts['values_disabled'] = [1, 2]; + $opts['values'] = [ 'a<b' => 'c&d', 'key1' => true, 'key2' => false, - ); + ]; $result = FormDisplayTemplate::displayInput( 'test/path', 'testName', 'select', false, '', true, $opts @@ -347,7 +347,7 @@ class FormDisplayTemplateTest extends TestCase // list $result = FormDisplayTemplate::displayInput( - 'test/path', 'testName', 'list', array('foo', 'bar'), + 'test/path', 'testName', 'list', ['foo', 'bar'], '', true, $opts ); @@ -486,22 +486,22 @@ class FormDisplayTemplateTest extends TestCase */ public function testAddJsValidate() { - $validators = array( - 'one' => array('\\\';', '\r\n\\\'<scrIpt></\' + \'script>'), - 'two' => array() - ); + $validators = [ + 'one' => ['\\\';', '\r\n\\\'<scrIpt></\' + \'script>'], + 'two' => [] + ]; - $js = array(); + $js = []; FormDisplayTemplate::addJsValidate('testID', $validators, $js); $this->assertEquals( - array( + [ 'validateField(\'testID\', \'PMA_\\\';\', true, ' . '[\'\\\\r\\\\n\\\\\\\'' . '<scrIpt></\\\' + \\\'script>\'])', 'validateField(\'testID\', \'PMA_\', true)' - ), + ], $js ); } @@ -514,10 +514,10 @@ class FormDisplayTemplateTest extends TestCase public function testDisplayJavascript() { $this->assertNull( - FormDisplayTemplate::displayJavascript(array()) + FormDisplayTemplate::displayJavascript([]) ); - $result = FormDisplayTemplate::displayJavascript(array('var i = 1', 'i++')); + $result = FormDisplayTemplate::displayJavascript(['var i = 1', 'i++']); $this->assertEquals( '<script type="text/javascript">' . "\n" @@ -542,7 +542,7 @@ class FormDisplayTemplateTest extends TestCase */ public function testDisplayErrors() { - $errors = array('<err1>', '&err2'); + $errors = ['<err1>', '&err2']; $result = FormDisplayTemplate::displayErrors('err"Name1"', $errors); diff --git a/test/classes/Config/FormDisplayTest.php b/test/classes/Config/FormDisplayTest.php index 37e5cb03a8..a6837395b9 100644 --- a/test/classes/Config/FormDisplayTest.php +++ b/test/classes/Config/FormDisplayTest.php @@ -79,14 +79,14 @@ class FormDisplayTest extends PmaTestCase $attrForms = $reflection->getProperty('_forms'); $attrForms->setAccessible(true); - $array = array( - "Servers" => array( - "1" => array( + $array = [ + "Servers" => [ + "1" => [ 'test' => 1, 1 => ':group:end' - ) - ) - ); + ] + ] + ]; $this->object->registerForm('pma_testform', $array, 2); $_forms = $attrForms->getValue($this->object); @@ -96,18 +96,18 @@ class FormDisplayTest extends PmaTestCase ); $this->assertEquals( - array( + [ "Servers/2/test" => "Servers/1/test", "Servers/2/:group:end:0" => "Servers/1/:group:end:0" - ), + ], $this->readAttribute($this->object, '_systemPaths') ); $this->assertEquals( - array( + [ "Servers/2/test" => "Servers-2-test", "Servers/2/:group:end:0" => "Servers-2-:group:end:0" - ), + ], $this->readAttribute($this->object, '_translatedPaths') ); } @@ -126,23 +126,23 @@ class FormDisplayTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Config\FormDisplay') ->disableOriginalConstructor() - ->setMethods(array('save')) + ->setMethods(['save']) ->getMock(); $attrForms = new ReflectionProperty('PhpMyAdmin\Config\FormDisplay', '_forms'); $attrForms->setAccessible(true); - $attrForms->setValue($this->object, array(1, 2, 3)); + $attrForms->setValue($this->object, [1, 2, 3]); $this->object->expects($this->once()) ->method('save') - ->with(array(0, 1, 2), false) + ->with([0, 1, 2], false) ->will($this->returnValue(true)); $this->assertTrue( $this->object->process(false, false) ); - $attrForms->setValue($this->object, array()); + $attrForms->setValue($this->object, []); $this->assertFalse( $this->object->process(false, false) @@ -164,20 +164,20 @@ class FormDisplayTest extends PmaTestCase $attrIsValidated = $reflection->getProperty('_errors'); $attrIsValidated->setAccessible(true); - $attrIsValidated->setValue($this->object, array()); + $attrIsValidated->setValue($this->object, []); $this->assertNull( $this->object->displayErrors() ); - $arr = array( - "Servers/1/test" => array('e1'), - "foobar" => array('e2', 'e3') - ); + $arr = [ + "Servers/1/test" => ['e1'], + "foobar" => ['e2', 'e3'] + ]; - $sysArr = array( + $sysArr = [ "Servers/1/test" => "Servers/1/test2" - ); + ]; $attrSystemPaths = $reflection->getProperty('_systemPaths'); $attrSystemPaths->setAccessible(true); @@ -209,21 +209,21 @@ class FormDisplayTest extends PmaTestCase $attrIsValidated = $reflection->getProperty('_errors'); $attrIsValidated->setAccessible(true); - $attrIsValidated->setValue($this->object, array()); + $attrIsValidated->setValue($this->object, []); $this->assertNull( $this->object->fixErrors() ); - $arr = array( - "Servers/1/test" => array('e1'), - "Servers/2/test" => array('e2', 'e3'), - "Servers/3/test" => array() - ); + $arr = [ + "Servers/1/test" => ['e1'], + "Servers/2/test" => ['e2', 'e3'], + "Servers/3/test" => [] + ]; - $sysArr = array( + $sysArr = [ "Servers/1/test" => "Servers/1/host" - ); + ]; $attrSystemPaths = $reflection->getProperty('_systemPaths'); $attrSystemPaths->setAccessible(true); @@ -234,13 +234,13 @@ class FormDisplayTest extends PmaTestCase $this->object->fixErrors(); $this->assertEquals( - array( - 'Servers' => array( - '1' => array( + [ + 'Servers' => [ + '1' => [ 'test' => 'localhost' - ) - ) - ), + ] + ] + ], $_SESSION['ConfigFile0'] ); } @@ -258,21 +258,21 @@ class FormDisplayTest extends PmaTestCase ); $attrValidateSelect->setAccessible(true); - $arr = array('foo' => 'var'); + $arr = ['foo' => 'var']; $value = 'foo'; $this->assertTrue( $attrValidateSelect->invokeArgs( $this->object, - array(&$value, $arr) + [&$value, $arr] ) ); - $arr = array('' => 'foobar'); + $arr = ['' => 'foobar']; $value = null; $this->assertTrue( $attrValidateSelect->invokeArgs( $this->object, - array(&$value, $arr) + [&$value, $arr] ) ); $this->assertEquals( @@ -280,21 +280,21 @@ class FormDisplayTest extends PmaTestCase gettype($value) ); - $arr = array(0 => 'foobar'); + $arr = [0 => 'foobar']; $value = 0; $this->assertTrue( $attrValidateSelect->invokeArgs( $this->object, - array(&$value, $arr) + [&$value, $arr] ) ); - $arr = array('1' => 'foobar'); + $arr = ['1' => 'foobar']; $value = 0; $this->assertFalse( $attrValidateSelect->invokeArgs( $this->object, - array(&$value, $arr) + [&$value, $arr] ) ); } @@ -315,7 +315,7 @@ class FormDisplayTest extends PmaTestCase $attrErrors->setValue( $this->object, - array(1, 2) + [1, 2] ); $this->assertTrue( @@ -386,7 +386,7 @@ class FormDisplayTest extends PmaTestCase $attrUserprefs->setAccessible(true); $method->invoke($this->object, null); $this->assertEquals( - array(), + [], $attrUserprefs->getValue($this->object) ); } @@ -402,7 +402,7 @@ class FormDisplayTest extends PmaTestCase $method->setAccessible(true); // recoding - $opts = array('values' => array()); + $opts = ['values' => []]; $opts['values']['iconv'] = 'testIconv'; $opts['values']['recode'] = 'testRecode'; $opts['values']['mb'] = 'testMB'; @@ -411,7 +411,7 @@ class FormDisplayTest extends PmaTestCase $method->invokeArgs( $this->object, - array('RecodingEngine', &$opts) + ['RecodingEngine', &$opts] ); $expect['comment'] = ''; @@ -434,7 +434,7 @@ class FormDisplayTest extends PmaTestCase // ZipDump, GZipDump, BZipDump $method->invokeArgs( $this->object, - array('ZipDump', &$opts) + ['ZipDump', &$opts] ); $comment = ''; @@ -458,7 +458,7 @@ class FormDisplayTest extends PmaTestCase $method->invokeArgs( $this->object, - array('GZipDump', &$opts) + ['GZipDump', &$opts] ); $comment = ''; @@ -482,7 +482,7 @@ class FormDisplayTest extends PmaTestCase $method->invokeArgs( $this->object, - array('BZipDump', &$opts) + ['BZipDump', &$opts] ); $comment = ''; @@ -512,7 +512,7 @@ class FormDisplayTest extends PmaTestCase $method->invokeArgs( $this->object, - array('MaxDbList', &$opts) + ['MaxDbList', &$opts] ); $this->assertEquals( @@ -522,7 +522,7 @@ class FormDisplayTest extends PmaTestCase $method->invokeArgs( $this->object, - array('MaxTableList', &$opts) + ['MaxTableList', &$opts] ); $this->assertEquals( @@ -532,7 +532,7 @@ class FormDisplayTest extends PmaTestCase $method->invokeArgs( $this->object, - array('QueryHistoryMax', &$opts) + ['QueryHistoryMax', &$opts] ); $this->assertEquals( diff --git a/test/classes/Config/FormTest.php b/test/classes/Config/FormTest.php index 89760a9874..f1bff27f55 100644 --- a/test/classes/Config/FormTest.php +++ b/test/classes/Config/FormTest.php @@ -39,7 +39,7 @@ class FormTest extends PmaTestCase $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['server'] = 0; $this->object = new Form( - 'pma_form_name', array('pma_form1','pma_form2'), new ConfigFile(), 1 + 'pma_form_name', ['pma_form1','pma_form2'], new ConfigFile(), 1 ); } @@ -86,7 +86,7 @@ class FormTest extends PmaTestCase $attrFieldsTypes->setAccessible(true); $attrFieldsTypes->setValue( $this->object, - array("7" => "Seven") + ["7" => "Seven"] ); $this->assertNull( @@ -107,26 +107,26 @@ class FormTest extends PmaTestCase public function testGetOptionValueList() { $this->assertEquals( - array('NHibernate C# DO', 'NHibernate XML'), + ['NHibernate C# DO', 'NHibernate XML'], $this->object->getOptionValueList("Export/codegen_format") ); $this->assertEquals( - array( + [ 'auto' => 'auto', '1' => 1, '0' => 0 - ), + ], $this->object->getOptionValueList("OBGzip") ); $this->assertEquals( - array( + [ 'none' => 'Nowhere', 'left' => 'Left', 'right' => 'Right', 'both' => "Both" - ), + ], $this->object->getOptionValueList("RowActionLinks") ); } @@ -142,14 +142,14 @@ class FormTest extends PmaTestCase $method = $reflection->getMethod('_readFormPathsCallback'); $method->setAccessible(true); - $array = array( - "foo" => array( - "bar" => array( + $array = [ + "foo" => [ + "bar" => [ 'test' => 1, 1 => ':group:end' - ) - ) - ); + ] + ] + ]; $method->invoke($this->object, $array, 'foo', 'pref'); @@ -194,14 +194,14 @@ class FormTest extends PmaTestCase $method = $reflection->getMethod('readFormPaths'); $method->setAccessible(true); - $array = array( - "foo" => array( - "bar" => array( + $array = [ + "foo" => [ + "bar" => [ 'test' => 1, 1 => ':group:end' - ) - ) - ); + ] + ] + ]; $method->invoke($this->object, $array); @@ -249,12 +249,12 @@ class FormTest extends PmaTestCase $method = $reflection->getMethod('readTypes'); $method->setAccessible(true); - $this->object->fields = array( + $this->object->fields = [ "pma_form1" => "Servers/1/port", "pma_form2" => "Servers/1/auth_type", ":group:end:0" => "preffoo/foo/bar/test", "1" => "preffoo/foo/bar/:group:end:0" - ); + ]; $attrFieldsTypes = $reflection->getProperty('_fieldsTypes'); $attrFieldsTypes->setAccessible(true); @@ -262,12 +262,12 @@ class FormTest extends PmaTestCase $method->invoke($this->object, null); $this->assertEquals( - array( + [ "pma_form1" => "integer", "pma_form2" => "select", ":group:end:0" => "group", "1" => "NULL" - ), + ], $attrFieldsTypes->getValue($this->object) ); } @@ -281,7 +281,7 @@ class FormTest extends PmaTestCase { $this->object = $this->getMockBuilder('PhpMyAdmin\Config\Form') ->disableOriginalConstructor() - ->setMethods(array('readFormPaths', 'readTypes')) + ->setMethods(['readFormPaths', 'readTypes']) ->getMock(); $this->object->expects($this->exactly(1)) diff --git a/test/classes/Config/Forms/FormListTest.php b/test/classes/Config/Forms/FormListTest.php index 8eb9b546f9..c94e46efe2 100644 --- a/test/classes/Config/Forms/FormListTest.php +++ b/test/classes/Config/Forms/FormListTest.php @@ -75,19 +75,19 @@ class FormListTest extends PmaTestCase */ public function formObjects() { - return array( - array( + return [ + [ '\\PhpMyAdmin\\Config\\Forms\\User\\UserFormList', '\\PhpMyAdmin\\Config\\Forms\\User\\', - ), - array( + ], + [ '\\PhpMyAdmin\\Config\\Forms\\Page\\PageFormList', '\\PhpMyAdmin\\Config\\Forms\\Page\\', - ), - array( + ], + [ '\\PhpMyAdmin\\Config\\Forms\\Setup\\SetupFormList', '\\PhpMyAdmin\\Config\\Forms\\Setup\\', - ), - ); + ], + ]; } } diff --git a/test/classes/Config/ServerConfigChecksTest.php b/test/classes/Config/ServerConfigChecksTest.php index 833e61b5c4..e7f3264de9 100644 --- a/test/classes/Config/ServerConfigChecksTest.php +++ b/test/classes/Config/ServerConfigChecksTest.php @@ -35,7 +35,7 @@ class ServeConfigChecksTest extends PmaTestCase public function setUp() { $GLOBALS['PMA_Config'] = new Config(); - $GLOBALS['cfg']['AvailableCharsets'] = array(); + $GLOBALS['cfg']['AvailableCharsets'] = []; $GLOBALS['cfg']['ServerDefault'] = 0; $GLOBALS['server'] = 0; @@ -55,8 +55,8 @@ class ServeConfigChecksTest extends PmaTestCase */ public function testManyErrors() { - $_SESSION[$this->sessionID]['Servers'] = array( - '1' => array( + $_SESSION[$this->sessionID]['Servers'] = [ + '1' => [ 'host' => 'localhost', 'ssl' => false, 'auth_type' => 'config', @@ -64,8 +64,8 @@ class ServeConfigChecksTest extends PmaTestCase 'password' => 'password', 'AllowRoot' => true, 'AllowNoPassword' => true, - ) - ); + ] + ]; $_SESSION[$this->sessionID]['AllowArbitraryServer'] = true; $_SESSION[$this->sessionID]['LoginCookieValidity'] = 5000; @@ -87,7 +87,7 @@ class ServeConfigChecksTest extends PmaTestCase $configChecker->performConfigChecks(); $this->assertEquals( - array( + [ 'Servers/1/ssl', 'Servers/1/auth_type', 'Servers/1/AllowNoPassword', @@ -95,18 +95,18 @@ class ServeConfigChecksTest extends PmaTestCase 'LoginCookieValidity', 'SaveDir', 'TempDir', - ), + ], array_keys($_SESSION['messages']['notice']) ); $this->assertEquals( - array( + [ 'LoginCookieValidity', 'GZipDump', 'BZipDump', 'ZipDump_import', 'ZipDump_export', - ), + ], array_keys($_SESSION['messages']['error']) ); } @@ -116,14 +116,14 @@ class ServeConfigChecksTest extends PmaTestCase */ public function testBlowfishCreate() { - $_SESSION[$this->sessionID]['Servers'] = array( - '1' => array( + $_SESSION[$this->sessionID]['Servers'] = [ + '1' => [ 'host' => 'localhost', 'ssl' => true, 'auth_type' => 'cookie', 'AllowRoot' => false - ) - ); + ] + ]; $_SESSION[$this->sessionID]['AllowArbitraryServer'] = false; $_SESSION[$this->sessionID]['LoginCookieValidity'] = -1; @@ -138,7 +138,7 @@ class ServeConfigChecksTest extends PmaTestCase $configChecker->performConfigChecks(); $this->assertEquals( - array('blowfish_secret_created'), + ['blowfish_secret_created'], array_keys($_SESSION['messages']['notice']) ); @@ -155,12 +155,12 @@ class ServeConfigChecksTest extends PmaTestCase { $_SESSION[$this->sessionID]['blowfish_secret'] = 'sec'; - $_SESSION[$this->sessionID]['Servers'] = array( - '1' => array( + $_SESSION[$this->sessionID]['Servers'] = [ + '1' => [ 'host' => 'localhost', 'auth_type' => 'cookie' - ) - ); + ] + ]; $configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']); $configChecker->performConfigChecks(); diff --git a/test/classes/ConfigTest.php b/test/classes/ConfigTest.php index d2649fbf6c..6c50333a5e 100644 --- a/test/classes/ConfigTest.php +++ b/test/classes/ConfigTest.php @@ -143,104 +143,104 @@ class ConfigTest extends PmaTestCase */ public function userAgentProvider() { - return array( - array( + return [ + [ 'Opera/9.80 (X11; Linux x86_64; U; pl) Presto/2.7.62 Version/11.00', 'Linux', 'OPERA', '9.80', - ), - array( + ], + [ 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US) AppleWebKit/' . '528.16 OmniWeb/622.8.0.112941', 'Mac', 'OMNIWEB', '622', - ), - array( + ], + [ 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1)', 'Win', 'IE', '8.0', - ), - array( + ], + [ 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)', 'Win', 'IE', '9.0', - ), - array( + ], + [ 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; ' . 'Trident/6.0)', 'Win', 'IE', '10.0', - ), - array( + ], + [ 'Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; ' . '.NET4.0C; rv:11.0) like Gecko', 'Win', 'IE', '11.0', - ), - array( + ], + [ 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; ' . '.NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; ' . '.NET CLR 3.0.30729; InfoPath.3; rv:11.0) like Gecko', 'Win', 'IE', '11.0', - ), - array( + ], + [ 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, ' . 'like Gecko) Chrome/25.0.1364.172 Safari/537.22', 'Win', 'CHROME', '25.0.1364.172', - ), - array( + ], + [ 'Mozilla/5.0 (Unknown; U; Unix BSD/SYSV system; C -) ' . 'AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.10.2', 'Unix', 'SAFARI', '5.0.419', - ), - array( + ], + [ 'Mozilla/5.0 (Windows; U; Win95; en-US; rv:1.9b) Gecko/20031208', 'Win', 'GECKO', '1.9', - ), - array( + ], + [ 'Mozilla/5.0 (compatible; Konqueror/4.5; NetBSD 5.0.2; X11; ' . 'amd64; en_US) KHTML/4.5.4 (like Gecko)', 'Other', 'KONQUEROR', - ), - array( + ], + [ 'Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0', 'Linux', 'FIREFOX', '5.0', - ), - array( + ], + [ 'Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 ' . 'Firefox/12.0', 'Linux', 'FIREFOX', '12.0', - ), + ], /** * @todo Is this version really expected? */ - array( + [ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.4+ (KHTML, like G' . 'ecko) Version/5.0 Safari/535.4+ SUSE/12.1 (3.2.1) Epiphany/3.2.1', 'Linux', 'SAFARI', '5.0', - ), - ); + ], + ]; } @@ -340,16 +340,16 @@ class ConfigTest extends PmaTestCase */ public function serverNames() { - return array( - array( + return [ + [ "Microsoft-IIS 7.0", 1, - ), - array( + ], + [ "Apache/2.2.17", 0, - ), - ); + ], + ]; } @@ -520,17 +520,17 @@ class ConfigTest extends PmaTestCase */ public function httpsParams() { - return array( - array('http', '', '', '', '', 'http', 80, false), - array('http', '', 'http://', '', '', 'http', 80, false), - array('http', '', '', '', '', 'http', 443, true), - array('http', '', '', '', '', 'https', 80, true), - array('http', '', '', '', 'on', 'http', 80, true), - array('http', '', '', 'on', '', 'http', 80, true), - array('http', '', 'https://', '', '', 'http', 80, true), - array('http', 'on', '', '', '', 'http', 80, true), - array('https', '', '', '', '', 'http', 80, true), - ); + return [ + ['http', '', '', '', '', 'http', 80, false], + ['http', '', 'http://', '', '', 'http', 80, false], + ['http', '', '', '', '', 'http', 443, true], + ['http', '', '', '', '', 'https', 80, true], + ['http', '', '', '', 'on', 'http', 80, true], + ['http', '', '', 'on', '', 'http', 80, true], + ['http', '', 'https://', '', '', 'http', 80, true], + ['http', 'on', '', '', '', 'http', 80, true], + ['https', '', '', '', '', 'http', 80, true], + ]; } /** @@ -548,7 +548,7 @@ class ConfigTest extends PmaTestCase { $this->object->enableBc(); - $defines = array( + $defines = [ 'PMA_VERSION', 'PMA_MAJOR_VERSION', 'PMA_IS_WINDOWS', @@ -556,7 +556,7 @@ class ConfigTest extends PmaTestCase 'PMA_USR_OS', 'PMA_USR_BROWSER_VER', 'PMA_USR_BROWSER_AGENT' - ); + ]; foreach ($defines as $define) { $this->assertTrue(defined($define)); @@ -589,88 +589,88 @@ class ConfigTest extends PmaTestCase */ public function rootUris() { - return array( - array( + return [ + [ '', '', '/', - ), - array( + ], + [ '/', '', '/', - ), - array( + ], + [ '/index.php', '', '/', - ), - array( + ], + [ '\\index.php', '', '/', - ), - array( + ], + [ '\\', '', '/', - ), - array( + ], + [ '\\path\\to\\index.php', '', '/path/to/', - ), - array( + ], + [ '/foo/bar/phpmyadmin/index.php', '', '/foo/bar/phpmyadmin/', - ), - array( + ], + [ '/foo/bar/phpmyadmin/', '', '/foo/bar/phpmyadmin/', - ), - array( + ], + [ 'https://example.net/baz/phpmyadmin/', '', '/baz/phpmyadmin/', - ), - array( + ], + [ 'http://example.net/baz/phpmyadmin/', '', '/baz/phpmyadmin/', - ), - array( + ], + [ 'http://example.net/phpmyadmin/', '', '/phpmyadmin/', - ), - array( + ], + [ 'http://example.net/', '', '/', - ), - array( + ], + [ 'http://example.net/', 'http://example.net/phpmyadmin/', '/phpmyadmin/', - ), - array( + ], + [ 'http://example.net/', 'http://example.net/phpmyadmin', '/phpmyadmin/', - ), - array( + ], + [ 'http://example.net/', '/phpmyadmin2', '/phpmyadmin2/', - ), - array( + ], + [ 'http://example.net/', '/phpmyadmin3/', '/phpmyadmin3/', - ), - ); + ], + ]; } /** @@ -699,20 +699,20 @@ class ConfigTest extends PmaTestCase */ public function configPaths() { - return array( - array( + return [ + [ './test/test_data/config.inc.php', true, - ), - array( + ], + [ './test/test_data/config-nonexisting.inc.php', false, - ), - array( + ], + [ './libraries/config.default.php', true, - ), - ); + ], + ]; } /** diff --git a/test/classes/Controllers/Database/DatabaseStructureControllerTest.php b/test/classes/Controllers/Database/DatabaseStructureControllerTest.php index 41a6b17177..2768e17de0 100644 --- a/test/classes/Controllers/Database/DatabaseStructureControllerTest.php +++ b/test/classes/Controllers/Database/DatabaseStructureControllerTest.php @@ -112,15 +112,15 @@ class DatabaseStructureControllerTest extends PmaTestCase $property->setValue($ctrl, true); $GLOBALS['cfg']['MaxExactCount'] = 10; - $current_table = array( + $current_table = [ 'ENGINE' => 'InnoDB', 'TABLE_ROWS' => 5, 'Data_length' => 16384, 'Index_length' => 0, 'TABLE_NAME' => 'table' - ); + ]; list($current_table,,, $sum_size) - = $method->invokeArgs($ctrl, array($current_table, 10)); + = $method->invokeArgs($ctrl, [$current_table, 10]); $this->assertEquals( true, @@ -137,7 +137,7 @@ class DatabaseStructureControllerTest extends PmaTestCase $current_table['ENGINE'] = 'MYISAM'; list($current_table,,, $sum_size) - = $method->invokeArgs($ctrl, array($current_table, 10)); + = $method->invokeArgs($ctrl, [$current_table, 10]); $this->assertEquals( false, @@ -157,7 +157,7 @@ class DatabaseStructureControllerTest extends PmaTestCase $current_table['ENGINE'] = 'InnoDB'; list($current_table,,, $sum_size) - = $method->invokeArgs($ctrl, array($current_table, 10)); + = $method->invokeArgs($ctrl, [$current_table, 10]); $this->assertEquals( true, $current_table['COUNTED'] @@ -169,7 +169,7 @@ class DatabaseStructureControllerTest extends PmaTestCase $current_table['ENGINE'] = 'MYISAM'; list($current_table,,, $sum_size) - = $method->invokeArgs($ctrl, array($current_table, 10)); + = $method->invokeArgs($ctrl, [$current_table, 10]); $this->assertEquals( false, $current_table['COUNTED'] @@ -206,14 +206,14 @@ class DatabaseStructureControllerTest extends PmaTestCase $property->setAccessible(true); $property->setValue($ctrl, true); - $current_table = array( + $current_table = [ 'Data_length' => 16384, 'Index_length' => 0, 'Name' => 'table', 'Data_free' => 300, - ); + ]; list($current_table,,,,, $overhead_size, $sum_size) - = $method->invokeArgs($ctrl, array($current_table, 0, 0, 0, 0, 0, 0,)); + = $method->invokeArgs($ctrl, [$current_table, 0, 0, 0, 0, 0, 0,]); $this->assertEquals( 6, $current_table['Rows'] @@ -229,7 +229,7 @@ class DatabaseStructureControllerTest extends PmaTestCase unset($current_table['Data_free']); list($current_table,,,,, $overhead_size,) - = $method->invokeArgs($ctrl, array($current_table, 0, 0, 0, 0, 0, 0,)); + = $method->invokeArgs($ctrl, [$current_table, 0, 0, 0, 0, 0, 0,]); $this->assertEquals(0, $overhead_size); $is_show_stats = false; @@ -239,7 +239,7 @@ class DatabaseStructureControllerTest extends PmaTestCase $container->get('db') ); list($current_table,,,,,, $sum_size) - = $method->invokeArgs($ctrl, array($current_table, 0, 0, 0, 0, 0, 0)); + = $method->invokeArgs($ctrl, [$current_table, 0, 0, 0, 0, 0, 0]); $this->assertEquals(0, $sum_size); $db_is_system_schema = false; @@ -249,7 +249,7 @@ class DatabaseStructureControllerTest extends PmaTestCase $container->get('db') ); list($current_table,,,,,,) - = $method->invokeArgs($ctrl, array($current_table, 0, 0, 0, 0, 0, 0,)); + = $method->invokeArgs($ctrl, [$current_table, 0, 0, 0, 0, 0, 0,]); $this->assertArrayNotHasKey('Row', $current_table); } @@ -275,25 +275,25 @@ class DatabaseStructureControllerTest extends PmaTestCase // When parameter $db is empty $this->assertEquals( false, - $method->invokeArgs($ctrl, array(array(), 'table')) + $method->invokeArgs($ctrl, [[], 'table']) ); // Correct parameter - $tables = array( + $tables = [ 'db.table' - ); + ]; $this->assertEquals( true, - $method->invokeArgs($ctrl, array($tables, 'table')) + $method->invokeArgs($ctrl, [$tables, 'table']) ); // Table not in database - $tables = array( + $tables = [ 'db.tab1e' - ); + ]; $this->assertEquals( false, - $method->invokeArgs($ctrl, array($tables, 'table')) + $method->invokeArgs($ctrl, [$tables, 'table']) ); } @@ -316,18 +316,18 @@ class DatabaseStructureControllerTest extends PmaTestCase $container->get('db') ); - $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = array( - array('db' => 'db', 'table' => 'table') - ); + $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = [ + ['db' => 'db', 'table' => 'table'] + ]; $this->assertEquals( false, - $method->invokeArgs($ctrl, array('')) + $method->invokeArgs($ctrl, ['']) ); $this->assertEquals( true, - $method->invokeArgs($ctrl, array('table')) + $method->invokeArgs($ctrl, ['table']) ); } @@ -344,14 +344,14 @@ class DatabaseStructureControllerTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); $fav_instance->expects($this->at(1))->method('getTables') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $fav_instance->expects($this->at(2)) ->method('getTables') ->will( $this->returnValue( - array( - array('db' => 'db', 'table' => 'table'), - ) + [ + ['db' => 'db', 'table' => 'table'], + ] ) ); @@ -367,13 +367,13 @@ class DatabaseStructureControllerTest extends PmaTestCase // The user hash for test $user = 'abcdefg'; - $favorite_table = array( - $user => array( - array('db' => 'db', 'table' => 'table') - ), - ); + $favorite_table = [ + $user => [ + ['db' => 'db', 'table' => 'table'] + ], + ]; - $method->invokeArgs($ctrl, array($fav_instance, $user, $favorite_table)); + $method->invokeArgs($ctrl, [$fav_instance, $user, $favorite_table]); $json = $this->_response->getJSONResult(); $this->assertEquals(json_encode($favorite_table), $json['favorite_tables']); @@ -412,21 +412,21 @@ class DatabaseStructureControllerTest extends PmaTestCase $_REQUEST['real_row_count_all'] = 'abc'; $property->setValue( $ctrl, - array( - array( + [ + [ 'TABLE_NAME' => 'table' - ) - ) + ] + ] ); $ctrl->handleRealRowCountRequestAction(); $json = $this->_response->getJSONResult(); - $expected_result = array( - array( + $expected_result = [ + [ 'table' => 'table', 'row_count' => 6 - ) - ); + ] + ]; $this->assertEquals( json_encode($expected_result), $json['real_row_count_all'] diff --git a/test/classes/Controllers/Server/ServerBinlogControllerTest.php b/test/classes/Controllers/Server/ServerBinlogControllerTest.php index e0aa025a8c..ff49199bed 100644 --- a/test/classes/Controllers/Server/ServerBinlogControllerTest.php +++ b/test/classes/Controllers/Server/ServerBinlogControllerTest.php @@ -40,7 +40,7 @@ class ServerBinlogControllerTest extends PmaTestCase $GLOBALS['server'] = 1; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; @@ -55,9 +55,9 @@ class ServerBinlogControllerTest extends PmaTestCase Util::cacheSet('profiling_supported', true); - $binary_log_file_names = array(); - $binary_log_file_names[] = array("Log_name"=>"index1", "File_size"=>100); - $binary_log_file_names[] = array("Log_name"=>"index2", "File_size"=>200); + $binary_log_file_names = []; + $binary_log_file_names[] = ["Log_name"=>"index1", "File_size"=>100]; + $binary_log_file_names[] = ["Log_name"=>"index2", "File_size"=>200]; //Mock DBI $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') @@ -81,7 +81,7 @@ class ServerBinlogControllerTest extends PmaTestCase { $container = Container::getDefaultContainer(); - $url_params = array(); + $url_params = []; $url_params['log'] = "log"; $url_params['dontlimitchars'] = 1; @@ -132,30 +132,30 @@ class ServerBinlogControllerTest extends PmaTestCase ); //expects return value - $result = array( - array( + $result = [ + [ "SHOW BINLOG EVENTS IN 'index1' LIMIT 3, 10", null, 1, true, - array("log1"=>"logd") - ), - array( - array("log2"=>"logb"), + ["log1"=>"logd"] + ], + [ + ["log2"=>"logb"], null, 0, false, 'executed' - ) - ); - $value = array( + ] + ]; + $value = [ 'Info' => "index1_Info", 'Log_name' => "index1_Log_name", 'Pos' => "index1_Pos", 'Event_type' => "index1_Event_type", 'End_log_pos' => "index1_End_log_pos", 'Server_id' => "index1_Server_id", - ); + ]; $count = 3; //expects functions @@ -174,7 +174,7 @@ class ServerBinlogControllerTest extends PmaTestCase $container->set('dbi', $dbi); //Call the test function - $url_params = array(); + $url_params = []; $url_params['log'] = "log"; $url_params['dontlimitchars'] = 1; $html = $method->invoke($ctrl, $url_params); @@ -246,7 +246,7 @@ class ServerBinlogControllerTest extends PmaTestCase $dbi ); - $fetchAssoc = array( + $fetchAssoc = [ 'Info' => 'Info', 'Log_name' => 'Log_name', 'Pos' => 'Pos', @@ -254,7 +254,7 @@ class ServerBinlogControllerTest extends PmaTestCase 'Server_id' => 'Server_id', 'Orig_log_pos' => 'Orig_log_pos', 'End_log_pos' => 'End_log_pos', - ); + ]; $dbi->expects($this->at(0))->method('fetchAssoc') ->will($this->returnValue($fetchAssoc)); $dbi->expects($this->at(1))->method('fetchAssoc') @@ -263,7 +263,7 @@ class ServerBinlogControllerTest extends PmaTestCase $GLOBALS['cfg']['LimitChars'] = 2; - $result = array(); + $result = []; $dontlimitchars = ";"; $html = $method->invoke($ctrl, $result, $dontlimitchars); diff --git a/test/classes/Controllers/Server/ServerCollationsControllerTest.php b/test/classes/Controllers/Server/ServerCollationsControllerTest.php index 8621c8b370..e4a8e4aa2c 100644 --- a/test/classes/Controllers/Server/ServerCollationsControllerTest.php +++ b/test/classes/Controllers/Server/ServerCollationsControllerTest.php @@ -49,31 +49,31 @@ class ServerCollationsControllerTest extends PmaTestCase */ public function testPMAGetHtmlForCharsets() { - $mysql_charsets = array("armscii8", "ascii", "big5", "binary"); - $mysql_collations = array( - "armscii8" => array("armscii8"), - "ascii" => array("ascii"), - "big5" => array("big5"), - "binary" => array("binary"), - ); - $mysql_charsets_descriptions = array( + $mysql_charsets = ["armscii8", "ascii", "big5", "binary"]; + $mysql_collations = [ + "armscii8" => ["armscii8"], + "ascii" => ["ascii"], + "big5" => ["big5"], + "binary" => ["binary"], + ]; + $mysql_charsets_descriptions = [ "armscii8" => "PMA_armscii8_general_ci", "ascii" => "PMA_ascii_general_ci", "big5" => "PMA_big5_general_ci", "binary" => "PMA_binary_general_ci", - ); - $mysql_default_collations = array( + ]; + $mysql_default_collations = [ "armscii8" => "armscii8", "ascii" => "ascii", "big5" => "big5", "binary" => "binary", - ); - $mysql_collations_available = array( + ]; + $mysql_collations_available = [ "armscii8" => true, "ascii" => true, "big5" => true, "binary" => true, - ); + ]; $container = Container::getDefaultContainer(); $container->set('PhpMyAdmin\Response', new ResponseStub()); diff --git a/test/classes/Controllers/Server/ServerDatabasesControllerTest.php b/test/classes/Controllers/Server/ServerDatabasesControllerTest.php index 18bd6fb25b..ec0eb6af49 100644 --- a/test/classes/Controllers/Server/ServerDatabasesControllerTest.php +++ b/test/classes/Controllers/Server/ServerDatabasesControllerTest.php @@ -77,13 +77,13 @@ class ServerDatabasesControllerTest extends PmaTestCase $ctrl = $container->get('ServerDatabasesController'); //Call the test function - $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") - ); + $databases = [ + ["SCHEMA_NAME" => "pma_bookmark"], + ["SCHEMA_NAME" => "information_schema"], + ["SCHEMA_NAME" => "mysql"], + ["SCHEMA_NAME" => "performance_schema"], + ["SCHEMA_NAME" => "phpmyadmin"] + ]; $property = $class->getProperty('_databases'); $property->setAccessible(true); $property->setValue($ctrl, $databases); @@ -108,7 +108,7 @@ class ServerDatabasesControllerTest extends PmaTestCase $property->setAccessible(true); $property->setValue($ctrl, 'asc'); - $replication_types = array("master", "slave"); + $replication_types = ["master", "slave"]; $html = $method->invoke($ctrl, $replication_types); @@ -203,7 +203,7 @@ class ServerDatabasesControllerTest extends PmaTestCase $ctrl = $container->get('ServerDatabasesController'); //$_REQUEST['sort_by'] and $_REQUEST['sort_order'] are empty - $method->invoke($ctrl, array("master", "slave")); + $method->invoke($ctrl, ["master", "slave"]); $this->assertEquals( 'SCHEMA_NAME', $propertySortBy->getValue($ctrl) @@ -275,47 +275,47 @@ class ServerDatabasesControllerTest extends PmaTestCase $ctrl = $container->get('ServerDatabasesController'); $this->assertEquals( - array( - 'DEFAULT_COLLATION_NAME' => array( + [ + 'DEFAULT_COLLATION_NAME' => [ 'disp_name' => __('Collation'), - 'description_function' => array( + 'description_function' => [ Charsets::class, 'getCollationDescr' - ), + ], 'format' => 'string', 'footer' => 'utf8_general_ci' - ), - 'SCHEMA_TABLES' => array( + ], + 'SCHEMA_TABLES' => [ 'disp_name' => __('Tables'), 'format' => 'number', 'footer' => 0 - ), - 'SCHEMA_TABLE_ROWS' => array( + ], + 'SCHEMA_TABLE_ROWS' => [ 'disp_name' => __('Rows'), 'format' => 'number', 'footer' => 0 - ), - 'SCHEMA_DATA_LENGTH' => array( + ], + 'SCHEMA_DATA_LENGTH' => [ 'disp_name' => __('Data'), 'format' => 'byte', 'footer' => 0 - ), - 'SCHEMA_INDEX_LENGTH' => array( + ], + 'SCHEMA_INDEX_LENGTH' => [ 'disp_name' => __('Indexes'), 'format' => 'byte', 'footer' => 0 - ), - 'SCHEMA_LENGTH' => array( + ], + 'SCHEMA_LENGTH' => [ 'disp_name' => __('Total'), 'format' => 'byte', 'footer' => 0 - ), - 'SCHEMA_DATA_FREE' => array( + ], + 'SCHEMA_DATA_FREE' => [ 'disp_name' => __('Overhead'), 'format' => 'byte', 'footer' => 0 - ) - ), + ] + ], $method->invoke($ctrl) ); } diff --git a/test/classes/Controllers/Server/ServerEnginesControllerTest.php b/test/classes/Controllers/Server/ServerEnginesControllerTest.php index fd0e48a0da..57cbb3d17c 100644 --- a/test/classes/Controllers/Server/ServerEnginesControllerTest.php +++ b/test/classes/Controllers/Server/ServerEnginesControllerTest.php @@ -160,14 +160,14 @@ class ServerEnginesControllerTest extends PmaTestCase ); $this->assertContains( Url::getCommon( - array('engine' => $_REQUEST['engine'], 'page' => "Documentation") + ['engine' => $_REQUEST['engine'], 'page' => "Documentation"] ), $html ); //validate 5: other items $this->assertContains( - Url::getCommon(array('engine' => $_REQUEST['engine'])), + Url::getCommon(['engine' => $_REQUEST['engine']]), $html ); $this->assertContains( diff --git a/test/classes/Controllers/Server/ServerPluginsControllerTest.php b/test/classes/Controllers/Server/ServerPluginsControllerTest.php index 8c4869ad85..cfe0b2f83c 100644 --- a/test/classes/Controllers/Server/ServerPluginsControllerTest.php +++ b/test/classes/Controllers/Server/ServerPluginsControllerTest.php @@ -51,7 +51,7 @@ class ServerPluginsControllerTest extends PmaTestCase /** * Prepare plugin list */ - $row = array(); + $row = []; $row["plugin_name"] = "plugin_name1"; $row["plugin_type"] = "plugin_type1"; $row["plugin_type_version"] = "plugin_version1"; diff --git a/test/classes/Controllers/Server/ServerVariablesControllerTest.php b/test/classes/Controllers/Server/ServerVariablesControllerTest.php index 9c280a22ba..3591fd986a 100644 --- a/test/classes/Controllers/Server/ServerVariablesControllerTest.php +++ b/test/classes/Controllers/Server/ServerVariablesControllerTest.php @@ -55,37 +55,37 @@ class ServerVariablesControllerTest extends PmaTestCase ->getMock(); //this data is needed when PhpMyAdmin\Server\Status\Data constructs - $server_session_variable = array( + $server_session_variable = [ "auto_increment_increment" => "1", "auto_increment_offset" => "13", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", - ); + ]; - $server_global_variables = array( + $server_global_variables = [ "auto_increment_increment" => "0", "auto_increment_offset" => "12" - ); + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW SESSION VARIABLES;", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_session_variable - ), - array( + ], + [ "SHOW GLOBAL VARIABLES;", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_global_variables - ) - ); + ] + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); @@ -128,7 +128,7 @@ class ServerVariablesControllerTest extends PmaTestCase $name_for_value_not_num = "PMA_key"; //name is_numeric and the value type is byte - $args = array($name_for_value_byte, "3"); + $args = [$name_for_value_byte, "3"]; list($formattedValue, $isHtmlFormatted) = $method->invokeArgs($ctrl, $args); $this->assertEquals( '<abbr title="3">3 B</abbr>', @@ -137,7 +137,7 @@ class ServerVariablesControllerTest extends PmaTestCase $this->assertEquals(true, $isHtmlFormatted); //name is_numeric and the value type is not byte - $args = array($name_for_value_not_byte, "3"); + $args = [$name_for_value_not_byte, "3"]; list($formattedValue, $isHtmlFormatted) = $method->invokeArgs($ctrl, $args); $this->assertEquals( '3', @@ -146,7 +146,7 @@ class ServerVariablesControllerTest extends PmaTestCase $this->assertEquals(false, $isHtmlFormatted); //value is not a number - $args = array($name_for_value_not_byte, "value"); + $args = [$name_for_value_not_byte, "value"]; list($formattedValue, $isHtmlFormatted) = $method->invokeArgs($ctrl, $args); $this->assertEquals( 'value', @@ -306,7 +306,7 @@ class ServerVariablesControllerTest extends PmaTestCase $formatVariable = $class->getMethod('_formatVariable'); $formatVariable->setAccessible(true); - $args = array($name, "12"); + $args = [$name, "12"]; list($value, $isHtmlFormatted) = $formatVariable->invokeArgs($ctrl, $args); $this->assertContains( $value, @@ -319,7 +319,7 @@ class ServerVariablesControllerTest extends PmaTestCase $html ); - $args = array($name, "13"); + $args = [$name, "13"]; list($value, $isHtmlFormatted) = $formatVariable->invokeArgs($ctrl, $args); $this->assertContains( $value, diff --git a/test/classes/Controllers/Table/TableIndexesControllerTest.php b/test/classes/Controllers/Table/TableIndexesControllerTest.php index e098710c75..ade697d6bc 100644 --- a/test/classes/Controllers/Table/TableIndexesControllerTest.php +++ b/test/classes/Controllers/Table/TableIndexesControllerTest.php @@ -42,32 +42,32 @@ class TableIndexesControllerTest extends PmaTestCase $GLOBALS['table'] = 'table'; $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $GLOBALS['cfg']['Server']['pmadb'] = ''; - $GLOBALS['url_params'] = array( + $GLOBALS['url_params'] = [ 'db' => 'db', 'server' => 1 - ); + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $indexs = array( - array( + $indexs = [ + [ "Schema" => "Schema1", "Key_name"=>"Key_name1", "Column_name"=>"Column_name1" - ), - array( + ], + [ "Schema" => "Schema2", "Key_name"=>"Key_name2", "Column_name"=>"Column_name2" - ), - array( + ], + [ "Schema" => "Schema3", "Key_name"=>"Key_name3", "Column_name"=>"Column_name3" - ), - ); + ], + ]; $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($indexs)); @@ -149,7 +149,7 @@ class TableIndexesControllerTest extends PmaTestCase $table->expects($this->any())->method('isView') ->will($this->returnValue(false)); $table->expects($this->any())->method('getNameAndTypeOfTheColumns') - ->will($this->returnValue(array("field_name" => "field_type"))); + ->will($this->returnValue(["field_name" => "field_type"])); $GLOBALS['dbi']->expects($this->any())->method('getTable') ->will($this->returnValue($table)); @@ -179,11 +179,11 @@ class TableIndexesControllerTest extends PmaTestCase //Url::getHiddenInputs $this->assertContains( Url::getHiddenInputs( - array( + [ 'db' => 'db', 'table' => 'table', 'create_index' => 1, - ) + ] ), $html ); diff --git a/test/classes/Controllers/Table/TableRelationControllerTest.php b/test/classes/Controllers/Table/TableRelationControllerTest.php index fea73928c2..fd8ce669fd 100644 --- a/test/classes/Controllers/Table/TableRelationControllerTest.php +++ b/test/classes/Controllers/Table/TableRelationControllerTest.php @@ -54,23 +54,23 @@ class TableRelationControllerTest extends PmaTestCase } }; - $indexes = array( - array( + $indexes = [ + [ 'Schema' => 'Schema1', 'Key_name' => 'Key_name1', 'Column_name' => 'Column_name1', - ), - array( + ], + [ 'Schema' => 'Schema2', 'Key_name' => 'Key_name2', 'Column_name' => 'Column_name2', - ), - array( + ], + [ 'Schema' => 'Schema3', 'Key_name' => 'Key_name3', 'Column_name' => 'Column_name3', - ), - ); + ], + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); @@ -99,9 +99,9 @@ class TableRelationControllerTest extends PmaTestCase */ public function testGetDropdownValueForTableActionIsView() { - $viewColumns = array( + $viewColumns = [ 'viewCol', 'viewCol2', 'viewCol3' - ); + ]; $tableMock = $this->getMockBuilder('PhpMyAdmin\Table') ->disableOriginalConstructor() ->getMock(); @@ -145,9 +145,9 @@ class TableRelationControllerTest extends PmaTestCase */ public function testGetDropdownValueForTableActionNotView() { - $indexedColumns = array( + $indexedColumns = [ 'primaryTableCol' - ); + ]; $tableMock = $this->getMockBuilder('PhpMyAdmin\Table') ->disableOriginalConstructor() ->getMock(); @@ -195,7 +195,7 @@ class TableRelationControllerTest extends PmaTestCase static $count = 0; if ($count == 0) { $count++; - return array('Engine' => 'InnoDB', 'Name' => 'table',); + return ['Engine' => 'InnoDB', 'Name' => 'table',]; } return null; } @@ -211,14 +211,14 @@ class TableRelationControllerTest extends PmaTestCase ); $ctrl = $container->get( 'TableRelationController', - array('tbl_storage_engine' => 'INNODB') + ['tbl_storage_engine' => 'INNODB'] ); $_REQUEST['foreign'] = 'true'; $ctrl->getDropdownValueForDbAction(); $json = $this->_response->getJSONResult(); $this->assertEquals( - array('table'), + ['table'], $json['tables'] ); } @@ -241,7 +241,7 @@ class TableRelationControllerTest extends PmaTestCase static $count = 0; if ($count == 0) { $count++; - return array('table'); + return ['table']; } return null; } @@ -257,14 +257,14 @@ class TableRelationControllerTest extends PmaTestCase ); $ctrl = $container->get( 'TableRelationController', - array('tbl_storage_engine' => 'INNODB',) + ['tbl_storage_engine' => 'INNODB',] ); $_REQUEST['foreign'] = 'false'; $ctrl->getDropdownValueForDbAction(); $json = $this->_response->getJSONResult(); $this->assertEquals( - array('table'), + ['table'], $json['tables'] ); } diff --git a/test/classes/Controllers/Table/TableSearchControllerTest.php b/test/classes/Controllers/Table/TableSearchControllerTest.php index f9db5ee44e..fc7b4eada6 100644 --- a/test/classes/Controllers/Table/TableSearchControllerTest.php +++ b/test/classes/Controllers/Table/TableSearchControllerTest.php @@ -56,20 +56,20 @@ class TableSearchControllerTest extends PmaTestCase ->getMock(); $dbi->types = new Types($dbi); - $columns =array( - array( + $columns =[ + [ 'Field' => 'Field1', 'Type' => 'Type1', 'Null' => 'Null1', 'Collation' => 'Collation1', - ), - array( + ], + [ 'Field' => 'Field2', 'Type' => 'Type2', 'Null' => 'Null2', 'Collation' => 'Collation2', - ) - ); + ] + ]; $dbi->expects($this->any())->method('getColumns') ->will($this->returnValue($columns)); @@ -193,7 +193,7 @@ class TableSearchControllerTest extends PmaTestCase $sql ); - $_POST['criteriaValues'] = array( + $_POST['criteriaValues'] = [ 'value1', 'value2', 'value3', @@ -201,8 +201,8 @@ class TableSearchControllerTest extends PmaTestCase 'value5', 'value6', 'value7,value8' - ); - $_POST['criteriaColumnNames'] = array( + ]; + $_POST['criteriaColumnNames'] = [ 'name', 'id', 'index', @@ -210,8 +210,8 @@ class TableSearchControllerTest extends PmaTestCase 'index3', 'index4', 'index5', - ); - $_POST['criteriaColumnTypes'] = array( + ]; + $_POST['criteriaColumnTypes'] = [ 'varchar', 'int', 'enum', @@ -219,8 +219,8 @@ class TableSearchControllerTest extends PmaTestCase 'type2', 'type3', 'type4' - ); - $_POST['criteriaColumnCollations'] = array( + ]; + $_POST['criteriaColumnCollations'] = [ "char1", "char2", "char3", @@ -228,8 +228,8 @@ class TableSearchControllerTest extends PmaTestCase "char5", "char6", "char7", - ); - $_POST['criteriaColumnOperators'] = array( + ]; + $_POST['criteriaColumnOperators'] = [ "!=", ">", "IS NULL", @@ -237,7 +237,7 @@ class TableSearchControllerTest extends PmaTestCase "REGEXP ^...$", "IN (...)", "BETWEEN" - ); + ]; $sql = $method->invoke($tableSearch); $result = "SELECT DISTINCT * FROM `PMA` WHERE `name` != 'value1'" @@ -317,18 +317,18 @@ class TableSearchControllerTest extends PmaTestCase $method->invoke($ctrl) ); - $_POST['criteriaColumnNames'] = array( + $_POST['criteriaColumnNames'] = [ 'b', 'a', 'c', 'd' - ); - $_POST['criteriaColumnOperators'] = array( + ]; + $_POST['criteriaColumnOperators'] = [ '<=', '=', 'IS NULL', 'IS NOT NULL' - ); - $_POST['criteriaValues'] = array( + ]; + $_POST['criteriaValues'] = [ '10', '2', '', '' - ); - $_POST['criteriaColumnTypes'] = array( + ]; + $_POST['criteriaColumnTypes'] = [ 'int(11)', 'int(11)', 'int(11)', 'int(11)' - ); + ]; $result = $method->invoke($ctrl); $this->assertEquals( ' WHERE `b` <= 10 AND `a` = 2 AND `c` IS NULL AND `d` IS NOT NULL', @@ -350,9 +350,9 @@ class TableSearchControllerTest extends PmaTestCase $meta_two = new stdClass(); $meta_two->length = 11; $meta_two->type = 'int'; - $fields_meta = array( + $fields_meta = [ $meta_one, $meta_two - ); + ]; $GLOBALS['dbi']->expects($this->any())->method('getFieldsMeta') ->will($this->returnValue($fields_meta)); @@ -364,10 +364,10 @@ class TableSearchControllerTest extends PmaTestCase if ($count == 0) { $count++; - return array( + return [ 'col1' => 1, 'col2' => 2, - ); + ]; } else { return null; } @@ -386,10 +386,10 @@ class TableSearchControllerTest extends PmaTestCase $_REQUEST['db'] = 'PMA'; $_REQUEST['table'] = 'PMA_BookMark'; $_REQUEST['where_clause'] = '`col1` = 1'; - $expected = array( + $expected = [ 'col1' => 1, 'col2' => 2 - ); + ]; $ctrl->getDataRowAction(); $json = $this->_response->getJSONResult(); diff --git a/test/classes/Controllers/Table/TableStructureControllerTest.php b/test/classes/Controllers/Table/TableStructureControllerTest.php index 658d6363c4..3177d364d4 100644 --- a/test/classes/Controllers/Table/TableStructureControllerTest.php +++ b/test/classes/Controllers/Table/TableStructureControllerTest.php @@ -121,10 +121,10 @@ class TableStructureControllerTest extends PmaTestCase if ($callCount == 0) { $callCount++; - return array( + return [ 'Key_name' => 'PRIMARY', 'Column_name' => 'column', - ); + ]; } else { return null; } @@ -221,7 +221,7 @@ class TableStructureControllerTest extends PmaTestCase $method->invoke($ctrl) ); - $_REQUEST['selected'] = array('a', 'b'); + $_REQUEST['selected'] = ['a', 'b']; $method->invoke($ctrl); $this->assertEquals( $_REQUEST['selected'], @@ -259,15 +259,15 @@ class TableStructureControllerTest extends PmaTestCase $submit_mult = "index"; $db = "PMA_db"; $table = "PMA_table"; - $selected = array( + $selected = [ "table1", "table2" - ); + ]; $action = 'db_delete_row'; list($what, $query_type, $is_unset_submit_mult, $mult_btn, $centralColsError) = $method->invokeArgs( $ctrl, - array($submit_mult, $db, $table, $selected, $action) + [$submit_mult, $db, $table, $selected, $action] ); //validate 1: $what @@ -305,7 +305,7 @@ class TableStructureControllerTest extends PmaTestCase list($what, $query_type, $is_unset_submit_mult, $mult_btn, $centralColsError) = $method->invokeArgs( $ctrl, - array($submit_mult, $db, $table, $selected, $action) + [$submit_mult, $db, $table, $selected, $action] ); //validate 1: $what diff --git a/test/classes/CoreTest.php b/test/classes/CoreTest.php index 5826cfb5d8..8d8f44f85e 100644 --- a/test/classes/CoreTest.php +++ b/test/classes/CoreTest.php @@ -22,7 +22,7 @@ use stdClass; */ class CoreTest extends PmaTestCase { - protected $goto_whitelist = array( + protected $goto_whitelist = [ 'db_datadict.php', 'db_sql.php', 'db_export.php', @@ -39,7 +39,7 @@ class CoreTest extends PmaTestCase 'transformation_overview.php', 'transformation_wrapper.php', 'user_password.php', - ); + ]; /** * Setup for test cases @@ -61,15 +61,15 @@ class CoreTest extends PmaTestCase */ function testArrayRead() { - $arr = array( + $arr = [ "int" => 1, "str" => "str_val", - "arr" => array('val1', 'val2', 'val3'), - "sarr" => array( - 'arr1' => array(1, 2, 3), - array(3, array('a', 'b', 'c'), 4) - ) - ); + "arr" => ['val1', 'val2', 'val3'], + "sarr" => [ + 'arr1' => [1, 2, 3], + [3, ['a', 'b', 'c'], 4] + ] + ]; $this->assertEquals( Core::arrayRead('int', $arr), @@ -149,15 +149,15 @@ class CoreTest extends PmaTestCase */ function testArrayWrite() { - $arr = array( + $arr = [ "int" => 1, "str" => "str_val", - "arr" => array('val1', 'val2', 'val3'), - "sarr" => array( - 'arr1' => array(1, 2, 3), - array(3, array('a', 'b', 'c'), 4) - ) - ); + "arr" => ['val1', 'val2', 'val3'], + "sarr" => [ + 'arr1' => [1, 2, 3], + [3, ['a', 'b', 'c'], 4] + ] + ]; Core::arrayWrite('int', $arr, 5); $this->assertEquals($arr['int'], 5); @@ -203,15 +203,15 @@ class CoreTest extends PmaTestCase */ function testArrayRemove() { - $arr = array( + $arr = [ "int" => 1, "str" => "str_val", - "arr" => array('val1', 'val2', 'val3'), - "sarr" => array( - 'arr1' => array(1, 2, 3), - array(3, array('a', 'b', 'c'), 4) - ) - ); + "arr" => ['val1', 'val2', 'val3'], + "sarr" => [ + 'arr1' => [1, 2, 3], + [3, ['a', 'b', 'c'], 4] + ] + ]; Core::arrayRemove('int', $arr); $this->assertArrayNotHasKey('int', $arr); @@ -281,15 +281,15 @@ class CoreTest extends PmaTestCase */ public function providerTestGotoNowhere() { - return array( - array('', [], false), - array('', [''], false), - array('export.php', [], true), - array('export.php', $this->goto_whitelist, true), - array('shell.php', $this->goto_whitelist, false), - array('index.php?sql.php&test=true', $this->goto_whitelist, true), - array('index.php%3Fsql.php%26test%3Dtrue', $this->goto_whitelist, true), - ); + return [ + ['', [], false], + ['', [''], false], + ['export.php', [], true], + ['export.php', $this->goto_whitelist, true], + ['shell.php', $this->goto_whitelist, false], + ['index.php?sql.php&test=true', $this->goto_whitelist, true], + ['index.php%3Fsql.php%26test%3Dtrue', $this->goto_whitelist, true], + ]; } /** @@ -323,56 +323,56 @@ class CoreTest extends PmaTestCase */ public function providerTestPathInfo() { - return array( - array( + return [ + [ '/phpmyadmin/index.php/; cookieinj=value/', '/phpmyadmin/index.php/;%20cookieinj=value///', '/; cookieinj=value/', '/phpmyadmin/index.php' - ), - array( + ], + [ '', '/phpmyadmin/index.php/;%20cookieinj=value///', '/; cookieinj=value/', '/phpmyadmin/index.php' - ), - array( + ], + [ '', '//example.com/../phpmyadmin/index.php', '', '/phpmyadmin/index.php' - ), - array( + ], + [ '', '//example.com/../../.././phpmyadmin/index.php', '', '/phpmyadmin/index.php' - ), - array( + ], + [ '', '/page.php/malicouspathinfo?malicouspathinfo', 'malicouspathinfo', '/page.php' - ), - array( + ], + [ '/phpmyadmin/./index.php', '/phpmyadmin/./index.php', '', '/phpmyadmin/index.php' - ), - array( + ], + [ '/phpmyadmin/index.php', '/phpmyadmin/index.php', '', '/phpmyadmin/index.php' - ), - array( + ], + [ '', '/phpmyadmin/index.php', '', '/phpmyadmin/index.php' - ), - ); + ], + ]; } /** @@ -394,7 +394,7 @@ class CoreTest extends PmaTestCase public function testFatalErrorMessageWithArgs() { $message = "Fatal error #%d in file %s."; - $params = array(1, 'error_file.php'); + $params = [1, 'error_file.php']; $this->expectOutputRegex("/Fatal error #1 in file error_file.php./"); Core::fatalError($message, $params); @@ -428,14 +428,14 @@ class CoreTest extends PmaTestCase */ public function providerTestGetRealSize() { - return array( - array('0', 0), - array('1kb', 1024), - array('1024k', 1024 * 1024), - array('8m', 8 * 1024 * 1024), - array('12gb', 12 * 1024 * 1024 * 1024), - array('1024', 1024), - ); + return [ + ['0', 0], + ['1kb', 1024], + ['1024k', 1024 * 1024], + ['8m', 8 * 1024 * 1024], + ['12gb', 12 * 1024 * 1024 * 1024], + ['1024', 1024], + ]; } /** @@ -475,14 +475,14 @@ class CoreTest extends PmaTestCase */ public function providerTestLinkURL() { - return array( - array('https://wiki.phpmyadmin.net', - './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net'), - array('https://wiki.phpmyadmin.net', - './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net'), - array('wiki.phpmyadmin.net', 'wiki.phpmyadmin.net'), - array('index.php?db=phpmyadmin', 'index.php?db=phpmyadmin') - ); + return [ + ['https://wiki.phpmyadmin.net', + './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net'], + ['https://wiki.phpmyadmin.net', + './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net'], + ['wiki.phpmyadmin.net', 'wiki.phpmyadmin.net'], + ['index.php?db=phpmyadmin', 'index.php?db=phpmyadmin'] + ]; } /** @@ -650,16 +650,16 @@ class CoreTest extends PmaTestCase */ function provideTestIsAllowedDomain() { - return array( - array('https://www.phpmyadmin.net/', true), - array('http://duckduckgo.com\\@github.com', false), - array('https://github.com/', true), - array('https://github.com:123/', false), - array('https://user:pass@github.com:123/', false), - array('https://user:pass@github.com/', false), - array('https://server.local/', true), - array('./relative/', false), - ); + return [ + ['https://www.phpmyadmin.net/', true], + ['http://duckduckgo.com\\@github.com', false], + ['https://github.com/', true], + ['https://github.com:123/', false], + ['https://user:pass@github.com:123/', false], + ['https://user:pass@github.com/', false], + ['https://server.local/', true], + ['./relative/', false], + ]; } /** @@ -685,19 +685,19 @@ class CoreTest extends PmaTestCase */ public static function providerTestNoVarType() { - return array( - array(0, false, 0), - array(0, false, 1), - array(1, false, null), - array(1.1, false, null), - array('', false, null), - array(' ', false, null), - array('0', false, null), - array('string', false, null), - array(array(), false, null), - array(array(1, 2, 3), false, null), - array(true, false, null), - array(false, false, null)); + return [ + [0, false, 0], + [0, false, 1], + [1, false, null], + [1.1, false, null], + ['', false, null], + [' ', false, null], + ['0', false, null], + ['string', false, null], + [[], false, null], + [[1, 2, 3], false, null], + [true, false, null], + [false, false, null]]; } /** @@ -838,7 +838,7 @@ class CoreTest extends PmaTestCase */ public function testNotScalarArray() { - $var = array('test'); + $var = ['test']; $this->assertFalse(Core::isValid($var, 'scalar')); } @@ -905,7 +905,7 @@ class CoreTest extends PmaTestCase public function testValueInArray() { $var = 'a'; - $this->assertTrue(Core::isValid($var, array('a', 'b',))); + $this->assertTrue(Core::isValid($var, ['a', 'b',])); } /** @@ -916,7 +916,7 @@ class CoreTest extends PmaTestCase public function testValueNotInArray() { $var = 'c'; - $this->assertFalse(Core::isValid($var, array('a', 'b',))); + $this->assertFalse(Core::isValid($var, ['a', 'b',])); } /** @@ -965,14 +965,14 @@ class CoreTest extends PmaTestCase */ public function provideTestSimilarType() { - return array( - array(1, 1), - array(1.5, 1.5), - array(true, true), - array('string', "string"), - array(array(1, 2, 3.4), array(1, 2, 3.4)), - array(array(1, '2', '3.4', 5, 'text'), array('1', '2', 3.4,'5')) - ); + return [ + [1, 1], + [1.5, 1.5], + [true, true], + ['string', "string"], + [[1, 2, 3.4], [1, 2, 3.4]], + [[1, '2', '3.4', 5, 'text'], ['1', '2', 3.4,'5']] + ]; } /** @@ -1011,18 +1011,18 @@ class CoreTest extends PmaTestCase */ function provideTestSafeUnserialize() { - return array( - array('s:6:"foobar";', 'foobar'), - array('foobar', null), - array('b:0;', false), - array('O:1:"a":1:{s:5:"value";s:3:"100";}', null), - array('O:8:"stdClass":1:{s:5:"field";O:8:"stdClass":0:{}}', null), - array('a:2:{i:0;s:90:"1234567890;a345678901234567890123456789012345678901234567890123456789012345678901234567890";i:1;O:8:"stdClass":0:{}}', null), - array(serialize(array(1, 2, 3)), array(1, 2, 3)), - array(serialize('string""'), 'string""'), - array(serialize(array('foo' => 'bar')), array('foo' => 'bar')), - array(serialize(array('1', new stdClass(), '2')), null), - ); + return [ + ['s:6:"foobar";', 'foobar'], + ['foobar', null], + ['b:0;', false], + ['O:1:"a":1:{s:5:"value";s:3:"100";}', null], + ['O:8:"stdClass":1:{s:5:"field";O:8:"stdClass":0:{}}', null], + ['a:2:{i:0;s:90:"1234567890;a345678901234567890123456789012345678901234567890123456789012345678901234567890";i:1;O:8:"stdClass":0:{}}', null], + [serialize([1, 2, 3]), [1, 2, 3]], + [serialize('string""'), 'string""'], + [serialize(['foo' => 'bar']), ['foo' => 'bar']], + [serialize(['1', new stdClass(), '2']), null], + ]; } /** @@ -1050,12 +1050,12 @@ class CoreTest extends PmaTestCase */ function provideTestSanitizeMySQLHost() { - return array( - array('p:foo.bar', 'foo.bar'), - array('p:p:foo.bar', 'foo.bar'), - array('bar.baz', 'bar.baz'), - array('P:example.com', 'example.com'), - ); + return [ + ['p:foo.bar', 'foo.bar'], + ['p:p:foo.bar', 'foo.bar'], + ['bar.baz', 'bar.baz'], + ['P:example.com', 'example.com'], + ]; } /** diff --git a/test/classes/Database/Designer/CommonTest.php b/test/classes/Database/Designer/CommonTest.php index bf802a62e6..72fe47baf4 100644 --- a/test/classes/Database/Designer/CommonTest.php +++ b/test/classes/Database/Designer/CommonTest.php @@ -33,17 +33,17 @@ class CommonTest extends TestCase protected function setUp() { $GLOBALS['server'] = 1; - $_SESSION = array( - 'relation' => array( - '1' => array( + $_SESSION = [ + 'relation' => [ + '1' => [ 'PMA_VERSION' => PMA_VERSION, 'db' => 'pmadb', 'pdf_pages' => 'pdf_pages', 'pdfwork' => true, 'table_coords' => 'table_coords' - ) - ) - ); + ] + ] + ]; } /** @@ -110,7 +110,7 @@ class CommonTest extends TestCase DatabaseInterface::CONNECT_CONTROL, DatabaseInterface::QUERY_STORE ) - ->will($this->returnValue(array($pageName))); + ->will($this->returnValue([$pageName])); $GLOBALS['dbi'] = $dbi; $this->designerCommon = new Common($GLOBALS['dbi']); @@ -175,7 +175,7 @@ class CommonTest extends TestCase DatabaseInterface::CONNECT_CONTROL, DatabaseInterface::QUERY_STORE ) - ->will($this->returnValue(array($default_pg))); + ->will($this->returnValue([$default_pg])); $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); @@ -210,7 +210,7 @@ class CommonTest extends TestCase DatabaseInterface::CONNECT_CONTROL, DatabaseInterface::QUERY_STORE ) - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); @@ -246,7 +246,7 @@ class CommonTest extends TestCase DatabaseInterface::CONNECT_CONTROL, DatabaseInterface::QUERY_STORE ) - ->will($this->returnValue(array($default_pg))); + ->will($this->returnValue([$default_pg])); $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); @@ -274,8 +274,8 @@ class CommonTest extends TestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array(), - array(array($first_pg)) + [], + [[$first_pg]] ); $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); diff --git a/test/classes/Database/QbeTest.php b/test/classes/Database/QbeTest.php index 12aad29d5c..003d923efb 100644 --- a/test/classes/Database/QbeTest.php +++ b/test/classes/Database/QbeTest.php @@ -56,7 +56,7 @@ class QbeTest extends PmaTestCase $dbi->expects($this->any()) ->method('getTableIndexes') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $GLOBALS['dbi'] = $dbi; $this->object->dbi = $dbi; @@ -102,21 +102,21 @@ class QbeTest extends PmaTestCase 'style="width:12ex" name="criteriaSort[1]"', $this->_callProtectedFunction( '_getSortSelectCell', - array(1) + [1] ) ); $this->assertNotContains( 'selected="selected"', $this->_callProtectedFunction( '_getSortSelectCell', - array(1) + [1] ) ); $this->assertContains( 'value="ASC" selected="selected">', $this->_callProtectedFunction( '_getSortSelectCell', - array(1, 'ASC') + [1, 'ASC'] ) ); } @@ -132,28 +132,28 @@ class QbeTest extends PmaTestCase '<th>Sort:</th>', $this->_callProtectedFunction( '_getSortRow', - array() + [] ) ); $this->assertContains( 'name="criteriaSort[0]"', $this->_callProtectedFunction( '_getSortRow', - array() + [] ) ); $this->assertContains( 'name="criteriaSort[1]"', $this->_callProtectedFunction( '_getSortRow', - array() + [] ) ); $this->assertContains( 'name="criteriaSort[2]"', $this->_callProtectedFunction( '_getSortRow', - array() + [] ) ); } @@ -173,7 +173,7 @@ class QbeTest extends PmaTestCase . '</td></tr>', $this->_callProtectedFunction( '_getShowRow', - array() + [] ) ); } @@ -198,7 +198,7 @@ class QbeTest extends PmaTestCase . 'style="width: 12ex" size="20" /></td></tr>', $this->_callProtectedFunction( '_getCriteriaInputboxRow', - array() + [] ) ); } @@ -214,21 +214,21 @@ class QbeTest extends PmaTestCase 'Add/Delete criteria rows', $this->_callProtectedFunction( '_getFootersOptions', - array('row') + ['row'] ) ); $this->assertContains( 'name="criteriaRowAdd"', $this->_callProtectedFunction( '_getFootersOptions', - array('row') + ['row'] ) ); $this->assertContains( '<option value="0" selected="selected">0</option>', $this->_callProtectedFunction( '_getFootersOptions', - array('row') + ['row'] ) ); } @@ -244,21 +244,21 @@ class QbeTest extends PmaTestCase 'name="criteriaRowAdd"', $this->_callProtectedFunction( '_getTableFooters', - array() + [] ) ); $this->assertContains( 'name="criteriaColumnAdd"', $this->_callProtectedFunction( '_getTableFooters', - array() + [] ) ); $this->assertContains( '<input type="submit" name="modify" value="Update Query" />', $this->_callProtectedFunction( '_getTableFooters', - array() + [] ) ); } @@ -279,7 +279,7 @@ class QbeTest extends PmaTestCase . 'name="criteriaColumnDelete[1]" /></td>', $this->_callProtectedFunction( '_getAndOrColCell', - array(1) + [1] ) ); } @@ -309,7 +309,7 @@ class QbeTest extends PmaTestCase . '</tr>', $this->_callProtectedFunction( '_getModifyColumnsRow', - array() + [] ) ); } @@ -333,7 +333,7 @@ class QbeTest extends PmaTestCase . 'value="or" checked="checked" /></td></tr></table></td>', $this->_callProtectedFunction( '_getInsDelAndOrCell', - array(3, array('and' => '', 'or' => ' checked="checked"')) + [3, ['and' => '', 'or' => ' checked="checked"']] ) ); } @@ -354,7 +354,7 @@ class QbeTest extends PmaTestCase . '12ex" size="20" /></td>', $this->_callProtectedFunction( '_getInputboxRow', - array(2) + [2] ) ); } @@ -384,7 +384,7 @@ class QbeTest extends PmaTestCase . '"textfield" style="width: 12ex" size="20" /></td></tr>', $this->_callProtectedFunction( '_getInsDelAndOrCriteriaRows', - array(2,3) + [2,3] ) ); } @@ -400,7 +400,7 @@ class QbeTest extends PmaTestCase '', $this->_callProtectedFunction( '_getSelectClause', - array() + [] ) ); } @@ -416,7 +416,7 @@ class QbeTest extends PmaTestCase '', $this->_callProtectedFunction( '_getWhereClause', - array() + [] ) ); } @@ -432,7 +432,7 @@ class QbeTest extends PmaTestCase '', $this->_callProtectedFunction( '_getOrderByClause', - array() + [] ) ); } @@ -445,17 +445,17 @@ class QbeTest extends PmaTestCase public function testGetIndexes() { $this->assertEquals( - array( - 'unique' => array(), - 'index' => array() - ), + [ + 'unique' => [], + 'index' => [] + ], $this->_callProtectedFunction( '_getIndexes', - array( - array('`table1`','table2'), - array('column1', 'column2', 'column3'), - array('column2') - ) + [ + ['`table1`','table2'], + ['column1', 'column2', 'column3'], + ['column2'] + ] ) ); } @@ -468,16 +468,16 @@ class QbeTest extends PmaTestCase public function testGetLeftJoinColumnCandidates() { $this->assertEquals( - array( + [ 0 => 'column2' - ), + ], $this->_callProtectedFunction( '_getLeftJoinColumnCandidates', - array( - array('`table1`','table2'), - array('column1', 'column2', 'column3'), - array('column2') - ) + [ + ['`table1`','table2'], + ['column1', 'column2', 'column3'], + ['column2'] + ] ) ); } @@ -493,12 +493,12 @@ class QbeTest extends PmaTestCase 0, $this->_callProtectedFunction( '_getMasterTable', - array( - array('table1','table2'), - array('column1', 'column2', 'column3'), - array('column2'), - array('qbe_test') - ) + [ + ['table1','table2'], + ['column1', 'column2', 'column3'], + ['column2'], + ['qbe_test'] + ] ) ); } @@ -510,20 +510,20 @@ class QbeTest extends PmaTestCase */ public function testGetWhereClauseTablesAndColumns() { - $_POST['criteriaColumn'] = array( + $_POST['criteriaColumn'] = [ 'table1.id', 'table1.value', 'table1.name', 'table1.deleted' - ); + ]; $this->assertEquals( - array( - 'where_clause_tables' => array(), - 'where_clause_columns' => array() - ), + [ + 'where_clause_tables' => [], + 'where_clause_columns' => [] + ], $this->_callProtectedFunction( '_getWhereClauseTablesAndColumns', - array() + [] ) ); } @@ -535,17 +535,17 @@ class QbeTest extends PmaTestCase */ public function testGetFromClause() { - $_POST['criteriaColumn'] = array( + $_POST['criteriaColumn'] = [ 'table1.id', 'table1.value', 'table1.name', 'table1.deleted' - ); + ]; $this->assertEquals( '`table1`', $this->_callProtectedFunction( '_getFromClause', - array(array('`table1`.`id`')) + [['`table1`.`id`']] ) ); } @@ -557,18 +557,18 @@ class QbeTest extends PmaTestCase */ public function testGetSQLQuery() { - $_POST['criteriaColumn'] = array( + $_POST['criteriaColumn'] = [ 'table1.id', 'table1.value', 'table1.name', 'table1.deleted' - ); + ]; $this->assertEquals( 'FROM `table1` ', $this->_callProtectedFunction( '_getSQLQuery', - array(array('`table1`.`id`')) + [['`table1`.`id`']] ) ); } diff --git a/test/classes/Database/SearchTest.php b/test/classes/Database/SearchTest.php index 0b11e15e0b..f9efb044de 100644 --- a/test/classes/Database/SearchTest.php +++ b/test/classes/Database/SearchTest.php @@ -45,10 +45,10 @@ class SearchTest extends PmaTestCase $dbi->expects($this->any()) ->method('getColumns') ->with('pma', 'table1') - ->will($this->returnValue(array( - array('Field' => 'column1'), - array('Field' => 'column2'), - ))); + ->will($this->returnValue([ + ['Field' => 'column1'], + ['Field' => 'column2'], + ])); $dbi->expects($this->any()) ->method('escapeString') @@ -106,7 +106,7 @@ class SearchTest extends PmaTestCase $expected, $this->callProtectedFunction( 'getWhereClause', - array('table1') + ['table1'] ) ); } @@ -118,28 +118,28 @@ class SearchTest extends PmaTestCase */ public function searchTypes() { - return array( - array( + return [ + [ '1', " WHERE (CONVERT(`column1` USING utf8) LIKE '%search%' OR CONVERT(`column2` USING utf8) LIKE '%search%') OR (CONVERT(`column1` USING utf8) LIKE '%string%' OR CONVERT(`column2` USING utf8) LIKE '%string%')" - ), - array( + ], + [ '2', " WHERE (CONVERT(`column1` USING utf8) LIKE '%search%' OR CONVERT(`column2` USING utf8) LIKE '%search%') AND (CONVERT(`column1` USING utf8) LIKE '%string%' OR CONVERT(`column2` USING utf8) LIKE '%string%')" - ), - array( + ], + [ '3', " WHERE (CONVERT(`column1` USING utf8) LIKE '%search string%' OR CONVERT(`column2` USING utf8) LIKE '%search string%')" - ), - array( + ], + [ '4', " WHERE (CONVERT(`column1` USING utf8) LIKE 'search string' OR CONVERT(`column2` USING utf8) LIKE 'search string')" - ), - array( + ], + [ '5', " WHERE (CONVERT(`column1` USING utf8) REGEXP 'search string' OR CONVERT(`column2` USING utf8) REGEXP 'search string')" - ), - ); + ], + ]; } /** @@ -150,15 +150,15 @@ class SearchTest extends PmaTestCase public function testGetSearchSqls() { $this->assertEquals( - array ( + [ 'select_columns' => 'SELECT * FROM `pma`.`table1` WHERE FALSE', 'select_count' => 'SELECT COUNT(*) AS `count` FROM `pma`.`table1` ' . 'WHERE FALSE', 'delete' => 'DELETE FROM `pma`.`table1` WHERE FALSE' - ), + ], $this->callProtectedFunction( 'getSearchSqls', - array('table1') + ['table1'] ) ); } @@ -198,7 +198,7 @@ class SearchTest extends PmaTestCase { $actual = $this->callProtectedFunction( 'getResultDivs', - array() + [] ); $this->assertContains( '<div id="table-info"', diff --git a/test/classes/DatabaseInterfaceTest.php b/test/classes/DatabaseInterfaceTest.php index e9fadc73f5..de0f347b1c 100644 --- a/test/classes/DatabaseInterfaceTest.php +++ b/test/classes/DatabaseInterfaceTest.php @@ -76,11 +76,11 @@ class DatabaseInterfaceTest extends PmaTestCase */ public function currentUserData() { - return array( - array(array(array('pma@localhost')), 'pma@localhost', array('pma', 'localhost')), - array(array(array('@localhost')), '@localhost', array('', 'localhost')), - array(false, '@', array('', '')), - ); + return [ + [[['pma@localhost']], 'pma@localhost', ['pma', 'localhost']], + [[['@localhost']], '@localhost', ['', 'localhost']], + [false, '@', ['', '']], + ]; } /** @@ -111,37 +111,37 @@ class DatabaseInterfaceTest extends PmaTestCase ->method('getFieldsMeta') ->will( $this->returnValue( - array( + [ $meta1, $meta2 - ) + ] ) ); $dbi = new DatabaseInterface($extension); $sql_query = "PMA_sql_query"; - $view_columns = array( + $view_columns = [ "view_columns1", "view_columns2" - ); + ]; $column_map = $dbi->getColumnMapFromSql( $sql_query, $view_columns ); $this->assertEquals( - array( + [ 'table_name' => 'meta1_table', 'refering_column' => 'meta1_name', 'real_column' => 'view_columns1' - ), + ], $column_map[0] ); $this->assertEquals( - array( + [ 'table_name' => 'meta2_table', 'refering_column' => 'meta2_name', 'real_column' => 'view_columns2' - ), + ], $column_map[1] ); } @@ -167,7 +167,7 @@ class DatabaseInterfaceTest extends PmaTestCase public function testPostConnectControl() { $GLOBALS['db'] = ''; - $GLOBALS['cfg']['Server']['only_db'] = array(); + $GLOBALS['cfg']['Server']['only_db'] = []; $this->_dbi->postConnectControl(); $this->assertInstanceOf('PhpMyAdmin\Database\DatabaseList', $GLOBALS['dblist']); } @@ -235,38 +235,38 @@ class DatabaseInterfaceTest extends PmaTestCase */ public function connectionParams() { - $cfg_basic = array( + $cfg_basic = [ 'user' => 'u', 'password' => 'pass', 'host' => '', 'controluser' => 'u2', 'controlpass' => 'p2', - ); - $cfg_ssl = array( + ]; + $cfg_ssl = [ 'user' => 'u', 'password' => 'pass', 'host' => '', 'ssl' => true, 'controluser' => 'u2', 'controlpass' => 'p2', - ); - $cfg_control_ssl = array( + ]; + $cfg_control_ssl = [ 'user' => 'u', 'password' => 'pass', 'host' => '', 'control_ssl' => true, 'controluser' => 'u2', 'controlpass' => 'p2', - ); - return array( - array( + ]; + return [ + [ $cfg_basic, DatabaseInterface::CONNECT_USER, null, - array( + [ 'u', 'pass', - array( + [ 'user' => 'u', 'password' => 'pass', 'host' => 'localhost', @@ -276,33 +276,33 @@ class DatabaseInterfaceTest extends PmaTestCase 'compress' => false, 'controluser' => 'u2', 'controlpass' => 'p2', - ) - ), - ), - array( + ] + ], + ], + [ $cfg_basic, DatabaseInterface::CONNECT_CONTROL, null, - array( + [ 'u2', 'p2', - array( + [ 'host' => 'localhost', 'socket' => null, 'port' => 0, 'ssl' => false, 'compress' => false, - ) - ), - ), - array( + ] + ], + ], + [ $cfg_ssl, DatabaseInterface::CONNECT_USER, null, - array( + [ 'u', 'pass', - array( + [ 'user' => 'u', 'password' => 'pass', 'host' => 'localhost', @@ -312,33 +312,33 @@ class DatabaseInterfaceTest extends PmaTestCase 'compress' => false, 'controluser' => 'u2', 'controlpass' => 'p2', - ) - ), - ), - array( + ] + ], + ], + [ $cfg_ssl, DatabaseInterface::CONNECT_CONTROL, null, - array( + [ 'u2', 'p2', - array( + [ 'host' => 'localhost', 'socket' => null, 'port' => 0, 'ssl' => true, 'compress' => false, - ) - ), - ), - array( + ] + ], + ], + [ $cfg_control_ssl, DatabaseInterface::CONNECT_USER, null, - array( + [ 'u', 'pass', - array( + [ 'user' => 'u', 'password' => 'pass', 'host' => 'localhost', @@ -349,26 +349,26 @@ class DatabaseInterfaceTest extends PmaTestCase 'controluser' => 'u2', 'controlpass' => 'p2', 'control_ssl' => true, - ) - ), - ), - array( + ] + ], + ], + [ $cfg_control_ssl, DatabaseInterface::CONNECT_CONTROL, null, - array( + [ 'u2', 'p2', - array( + [ 'host' => 'localhost', 'socket' => null, 'port' => 0, 'ssl' => true, 'compress' => false, - ) - ), - ), - ); + ] + ], + ], + ]; } /** @@ -395,14 +395,14 @@ class DatabaseInterfaceTest extends PmaTestCase */ public function errorData() { - return array( - array(2002, 'msg', 'The server is not responding'), - array(2003, 'msg', 'The server is not responding'), - array(1698, 'msg', 'logout.php'), - array(1005, 'msg', 'server_engines.php'), - array(1005, 'errno: 13', 'Please check privileges'), - array(-1, 'error message', 'error message'), - ); + return [ + [2002, 'msg', 'The server is not responding'], + [2003, 'msg', 'The server is not responding'], + [1698, 'msg', 'logout.php'], + [1005, 'msg', 'server_engines.php'], + [1005, 'errno: 13', 'Please check privileges'], + [-1, 'error message', 'error message'], + ]; } /** @@ -437,12 +437,12 @@ class DatabaseInterfaceTest extends PmaTestCase */ public function isAmazonRdsData() { - return array( - array(array(array('/usr')), false), - array(array(array('E:/mysql')), false), - array(array(array('/rdsdbbin/mysql/')), true), - array(array(array('/rdsdbbin/mysql-5.7.18/')), true), - ); + return [ + [[['/usr']], false], + [[['E:/mysql']], false], + [[['/rdsdbbin/mysql/']], true], + [[['/rdsdbbin/mysql-5.7.18/']], true], + ]; } /** @@ -470,12 +470,12 @@ class DatabaseInterfaceTest extends PmaTestCase */ public function versionData() { - return array( - array('5.0.5', 50005, 5, true), - array('5.05.01', 50501, 5, false), - array('5.6.35', 50635, 5, false), - array('10.1.22-MariaDB-', 100122, 10, false), - ); + return [ + ['5.0.5', 50005, 5, true], + ['5.05.01', 50501, 5, false], + ['5.6.35', 50635, 5, false], + ['10.1.22-MariaDB-', 100122, 10, false], + ]; } /** @@ -495,10 +495,10 @@ class DatabaseInterfaceTest extends PmaTestCase $extension->expects($this->exactly(4)) ->method('realQuery') ->withConsecutive( - array("SET collation_connection = 'utf8_czech_ci';"), - array("SET collation_connection = 'utf8mb4_bin_ci';"), - array("SET collation_connection = 'utf8_czech_ci';"), - array("SET collation_connection = 'utf8_bin_ci';") + ["SET collation_connection = 'utf8_czech_ci';"], + ["SET collation_connection = 'utf8mb4_bin_ci';"], + ["SET collation_connection = 'utf8_czech_ci';"], + ["SET collation_connection = 'utf8_bin_ci';"] ) ->willReturnOnConsecutiveCalls( true, diff --git a/test/classes/Dbi/DbiDummyTest.php b/test/classes/Dbi/DbiDummyTest.php index f81b655333..2f2e009e69 100644 --- a/test/classes/Dbi/DbiDummyTest.php +++ b/test/classes/Dbi/DbiDummyTest.php @@ -52,7 +52,7 @@ class DbiDummyTest extends TestCase public function testFetch() { $result = $GLOBALS['dbi']->tryQuery('SELECT 1'); - $this->assertEquals(array('1'), $GLOBALS['dbi']->fetchArray($result)); + $this->assertEquals(['1'], $GLOBALS['dbi']->fetchArray($result)); } /** @@ -77,10 +77,10 @@ class DbiDummyTest extends TestCase */ public function schemaData() { - return array( - array('information_schema', true), - array('pma_test', false), - ); + return [ + ['information_schema', true], + ['pma_test', false], + ]; } /** @@ -110,14 +110,14 @@ class DbiDummyTest extends TestCase */ public function errorData() { - return array( - array(1234, '', '#1234 - '), - array(1234, 'foobar', '#1234 - foobar'), - array( + return [ + [1234, '', '#1234 - '], + [1234, 'foobar', '#1234 - foobar'], + [ 2002, 'foobar', '#2002 - foobar — The server is not responding (or the local ' . 'server\'s socket is not correctly configured).' - ), - ); + ], + ]; } } diff --git a/test/classes/Display/ExportTest.php b/test/classes/Display/ExportTest.php index 817b461680..8c2ee1a238 100644 --- a/test/classes/Display/ExportTest.php +++ b/test/classes/Display/ExportTest.php @@ -133,16 +133,16 @@ class ExportTest extends TestCase $num_tables_str = "10"; $unlim_num_rows_str = "unlim_num_rows_str"; $single_table = "single_table"; - $GLOBALS['dbi']->cacheTableContent(array($db, $table, 'ENGINE'), 'MERGE'); + $GLOBALS['dbi']->cacheTableContent([$db, $table, 'ENGINE'], 'MERGE'); - $columns_info = array( - 'test_column1' => array( + $columns_info = [ + 'test_column1' => [ 'COLUMN_NAME' => 'test_column1' - ), - 'test_column2' => array( + ], + 'test_column2' => [ 'COLUMN_NAME' => 'test_column2' - ) - ); + ] + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); @@ -150,7 +150,7 @@ class ExportTest extends TestCase $dbi->expects($this->any())->method('getColumnsFull') ->will($this->returnValue($columns_info)); $dbi->expects($this->any())->method('getCompatibilities') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $GLOBALS['dbi'] = $dbi; @@ -158,10 +158,10 @@ class ExportTest extends TestCase $export_list = Plugins::getPlugins( "export", 'libraries/classes/Plugins/Export/', - array( + [ 'export_type' => $export_type, 'single_table' => isset($single_table) - ) + ] ); //Call the test function @@ -269,18 +269,18 @@ class ExportTest extends TestCase */ public function testGetHtmlForAliasModalDialog() { - $columns_info = array( - 'test\'_db' => array( - 'test_<b>table' => array( - 'co"l1' => array( + $columns_info = [ + 'test\'_db' => [ + 'test_<b>table' => [ + 'co"l1' => [ 'COLUMN_NAME' => 'co"l1' - ), - 'col<2' => array( + ], + 'col<2' => [ 'COLUMN_NAME' => 'col<2' - ) - ) - ) - ); + ] + ] + ] + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index ce490fabf8..43060d0839 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -98,12 +98,12 @@ class ResultsTest extends PmaTestCase $this->assertTrue( $this->_callPrivateFunction( '_isSelect', - array( - array( + [ + [ 'statement' => $parser->statements[0], 'select_from' => true, - ), - ) + ], + ] ) ); } @@ -128,7 +128,7 @@ class ResultsTest extends PmaTestCase $actual = $this->_callPrivateFunction( '_getTableNavigationButton', - array(&$caption, $title, $pos, $html_sql_query, true) + [&$caption, $title, $pos, $html_sql_query, true] ); $this->assertContains( @@ -156,14 +156,14 @@ class ResultsTest extends PmaTestCase */ public function providerForTestGetTableNavigationButton() { - return array( - array( + return [ + [ 'btn', 'Submit', 1, 'SELECT * FROM `pma_bookmark` WHERE 1', - ) - ); + ] + ]; } /** @@ -173,14 +173,14 @@ class ResultsTest extends PmaTestCase */ public function providerForTestGetTableNavigation() { - return array( - array( + return [ + [ 21, 41, false, '310' - ) - ); + ] + ]; } /** @@ -190,16 +190,16 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForTestGetClassesForColumn() { - return array( - array( + return [ + [ 'grid_edit', 'not_null', '', '', '', 'data grid_edit not_null ' - ) - ); + ] + ]; } /** @@ -227,10 +227,10 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getClassesForColumn', - array( + [ $grid_edit_class, $not_null_class, $relation_class, $hide_class, $field_type_class - ) + ] ) ); } @@ -246,7 +246,7 @@ class ResultsTest extends PmaTestCase 'datetimefield', $this->_callPrivateFunction( '_getClassForDateTimeRelatedFields', - array(DisplayResults::DATETIME_FIELD) + [DisplayResults::DATETIME_FIELD] ) ); } @@ -262,7 +262,7 @@ class ResultsTest extends PmaTestCase 'datefield', $this->_callPrivateFunction( '_getClassForDateTimeRelatedFields', - array(DisplayResults::DATE_FIELD) + [DisplayResults::DATE_FIELD] ) ); } @@ -278,7 +278,7 @@ class ResultsTest extends PmaTestCase 'text', $this->_callPrivateFunction( '_getClassForDateTimeRelatedFields', - array(DisplayResults::STRING_FIELD) + [DisplayResults::STRING_FIELD] ) ); } @@ -292,8 +292,8 @@ class ResultsTest extends PmaTestCase { $_SESSION['tmpval']['max_rows'] = DisplayResults::ALL_ROWS; $this->assertEquals( - array(0, 0), - $this->_callPrivateFunction('_getOffsets', array()) + [0, 0], + $this->_callPrivateFunction('_getOffsets', []) ); } @@ -307,8 +307,8 @@ class ResultsTest extends PmaTestCase $_SESSION['tmpval']['max_rows'] = 5; $_SESSION['tmpval']['pos'] = 4; $this->assertEquals( - array(9, 0), - $this->_callPrivateFunction('_getOffsets', array()) + [9, 0], + $this->_callPrivateFunction('_getOffsets', []) ); } @@ -319,15 +319,15 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForGetCheckboxForMultiRowSubmissions() { - return array( - array( + return [ + [ 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60' . '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=' . 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D' . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message' . '_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_' . 'structure.php', - array( + [ 'edit_lnk' => 'ur', 'del_lnk' => 'dr', 'sort_lnk' => '0', @@ -335,10 +335,10 @@ class ResultsTest extends PmaTestCase 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1' - ), + ], 0, '%60new%60.%60id%60+%3D+1', - array('`new`.`id`' => '= 1'), + ['`new`.`id`' => '= 1'], '[%_PMA_CHECKBOX_DIR_%]', 'klass', '<td class="klass" class="center print_ignore"><input type' @@ -347,8 +347,8 @@ class ResultsTest extends PmaTestCase . 'new%60.%60id%60+%3D+1" /><input type="hidden" class="condition_' . 'array" value="{"`new`.`id`":"= 1"}" /> ' . '</td>' - ) - ); + ] + ]; } /** @@ -376,10 +376,10 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getCheckboxForMultiRowSubmissions', - array( + [ $del_url, $displayParts, $row_no, $where_clause_html, $condition_array, $id_suffix, $class - ) + ] ) ); } @@ -391,8 +391,8 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForGetEditLink() { - return array( - array( + return [ + [ 'tbl_change.php?db=Data&table=customer&where_clause=%60' . 'customer%60.%60id%60+%3D+1&clause_is_unique=1&sql_query=' . 'SELECT+%2A+FROM+%60customer%60&goto=sql.php&default_' @@ -412,8 +412,8 @@ class ResultsTest extends PmaTestCase . 'alt="Edit" class="icon ic_b_edit" /> Edit</span></a>' . '<input type="hidden" class="where_clause" value ="%60customer' . '%60.%60id%60+%3D+1" /></span></td>' - ) - ); + ] + ]; } /** @@ -440,9 +440,9 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getEditLink', - array( + [ $edit_url, $class, $edit_str, $where_clause, $where_clause_html - ) + ] ) ); } @@ -454,8 +454,8 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForGetCopyLink() { - return array( - array( + return [ + [ 'tbl_change.php?db=Data&table=customer&where_clause=%60cust' . 'omer%60.%60id%60+%3D+1&clause_is_unique=1&sql_query=' . 'SELECT+%2A+FROM+%60customer%60&goto=sql.php&default_' @@ -475,8 +475,8 @@ class ResultsTest extends PmaTestCase . 'alt="Copy" class="icon ic_b_insrow" /> Copy</span></a>' . '<input type="hidden" class="where_clause" value="%60customer%60' . '.%60id%60+%3D+1" /></span></td>' - ) - ); + ] + ]; } /** @@ -503,9 +503,9 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getCopyLink', - array( + [ $copy_url, $copy_str, $where_clause, $where_clause_html, $class - ) + ] ) ); } @@ -517,8 +517,8 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForGetDeleteLink() { - return array( - array( + return [ + [ 'sql.php?db=Data&table=customer&sql_query=DELETE+FROM+%60' . 'Data%60.%60customer%60+WHERE+%60customer%60.%60id%60+%3D+1&' . 'message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb' @@ -541,8 +541,8 @@ class ResultsTest extends PmaTestCase . 'Delete</span></a>' . '<div class="hide">DELETE FROM `Data`.`customer` WHERE ' . '`customer`.`id` = 1</div></td>' - ) - ); + ] + ]; } /** @@ -568,9 +568,9 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getDeleteLink', - array( + [ $del_url, $del_str, $js_conf, $class - ) + ] ) ); } @@ -582,8 +582,8 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForGetCheckboxAndLinks() { - return array( - array( + return [ + [ DisplayResults::POSITION_LEFT, 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data' . '%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=' @@ -591,7 +591,7 @@ class ResultsTest extends PmaTestCase . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26' . 'message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3D' . 'tbl_structure.php', - array( + [ 'edit_lnk' => 'ur', 'del_lnk' => 'dr', 'sort_lnk' => '0', @@ -599,13 +599,13 @@ class ResultsTest extends PmaTestCase 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1' - ), + ], 0, '`new`.`id` = 1', '%60new%60.%60id%60+%3D+1', - array( + [ '`new`.`id`' => '= 1', - ), + ], 'tbl_change.php?db=data&table=new&where_clause=%60new%60.' . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+' . 'FROM+%60new%60&goto=sql.php&default_action=update', @@ -654,8 +654,8 @@ class ResultsTest extends PmaTestCase . 'Delete</span></a>' . '<div class="hide">DELETE FROM `data`.`new` WHERE `new`.`id` = 1' . '</div></td>' - ), - array( + ], + [ DisplayResults::POSITION_RIGHT, 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60' . '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=' @@ -663,7 +663,7 @@ class ResultsTest extends PmaTestCase . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message' . '_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_' . 'structure.php', - array( + [ 'edit_lnk' => 'ur', 'del_lnk' => 'dr', 'sort_lnk' => '0', @@ -671,13 +671,13 @@ class ResultsTest extends PmaTestCase 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1' - ), + ], 0, '`new`.`id` = 1', '%60new%60.%60id%60+%3D+1', - array( + [ '`new`.`id`' => '= 1', - ), + ], 'tbl_change.php?db=data&table=new&where_clause=%60new%60.' . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+' . 'FROM+%60new%60&goto=sql.php&default_action=update', @@ -724,8 +724,8 @@ class ResultsTest extends PmaTestCase . '[0]" class="multi_checkbox checkall" value="%60new%60.%60id%60' . '+%3D+1" /><input type="hidden" class="condition_array" value="' . '{"`new`.`id`":"= 1"}" /> </td>' - ), - array( + ], + [ DisplayResults::POSITION_NONE, 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.' . '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+' @@ -733,7 +733,7 @@ class ResultsTest extends PmaTestCase . '%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_' . 'to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure' . '.php', - array( + [ 'edit_lnk' => 'ur', 'del_lnk' => 'dr', 'sort_lnk' => '0', @@ -741,13 +741,13 @@ class ResultsTest extends PmaTestCase 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1' - ), + ], 0, '`new`.`id` = 1', '%60new%60.%60id%60+%3D+1', - array( + [ '`new`.`id`' => '= 1', - ), + ], 'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60' . 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+' . '%60new%60&goto=sql.php&default_action=update', @@ -767,8 +767,8 @@ class ResultsTest extends PmaTestCase . 'checkall" value="%60new%60.%60id%60+%3D+1" /><input type=' . '"hidden" class="condition_array" value="{"`new`.`id`":' . '"= 1"}" /> </td>' - ), - ); + ], + ]; } /** @@ -804,12 +804,12 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getCheckboxAndLinks', - array( + [ $position, $del_url, $displayParts, $row_no, $where_clause, $where_clause_html, $condition_array, $edit_url, $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf - ) + ] ) ); } @@ -821,8 +821,8 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForGetPlacedLinks() { - return array( - array( + return [ + [ DisplayResults::POSITION_NONE, 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.' . '%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+' @@ -830,7 +830,7 @@ class ResultsTest extends PmaTestCase . '%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_' . 'to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure' . '.php', - array( + [ 'edit_lnk' => 'ur', 'del_lnk' => 'dr', 'sort_lnk' => '0', @@ -838,13 +838,13 @@ class ResultsTest extends PmaTestCase 'bkm_form' => '1', 'text_btn' => '1', 'pview_lnk' => '1' - ), + ], 0, '`new`.`id` = 1', '%60new%60.%60id%60+%3D+1', - array( + [ '`new`.`id`' => '= 1', - ), + ], 'tbl_change.php?db=data&table=new&where_clause=%60new%60.%60' . 'id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+FROM+' . '%60new%60&goto=sql.php&default_action=update', @@ -864,8 +864,8 @@ class ResultsTest extends PmaTestCase . 'checkall" value="%60new%60.%60id%60+%3D+1" /><input type=' . '"hidden" class="condition_array" value="{"`new`.`id`":' . '"= 1"}" /> </td>' - ) - ); + ] + ]; } /** @@ -900,12 +900,12 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getPlacedLinks', - array( + [ $dir, $del_url, $displayParts, $row_no, $where_clause, $where_clause_html, $condition_array, $edit_url, $copy_url, $edit_anchor_class, $edit_str, $copy_str, $del_str, $js_conf - ) + ] ) ); } @@ -918,47 +918,47 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForTestGetSpecialLinkUrl() { - return array( - array( + return [ + [ 'information_schema', 'routines', 'circumference', - array( + [ 'routine_name' => 'circumference', 'routine_schema' => 'data', 'routine_type' => 'FUNCTION' - ), + ], 'routine_name', 'db_routines.php?item_name=circumference&db=data' . '&item_type=FUNCTION&server=0&lang=en' - ), - array( + ], + [ 'information_schema', 'routines', 'area', - array( + [ 'routine_name' => 'area', 'routine_schema' => 'data', 'routine_type' => 'PROCEDURE' - ), + ], 'routine_name', 'db_routines.php?item_name=area&db=data' . '&item_type=PROCEDURE&server=0&lang=en' - ), - array( + ], + [ 'information_schema', 'columns', 'CHARACTER_SET_NAME', - array( + [ 'table_schema' => 'information_schema', 'table_name' => 'CHARACTER_SETS' - ), + ], 'column_name', 'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60info' . 'rmation_schema%60.%60CHARACTER_SETS%60&db=information_schema' . '&test_name=value&server=0&lang=en' - ) - ); + ] + ]; } @@ -979,45 +979,45 @@ class ResultsTest extends PmaTestCase public function testGetSpecialLinkUrl( $db, $table, $column_value, $row_info, $field_name, $output ) { - $GLOBALS['special_schema_links'] = array( - 'information_schema' => array( - 'routines' => array( - 'routine_name' => array( + $GLOBALS['special_schema_links'] = [ + 'information_schema' => [ + 'routines' => [ + 'routine_name' => [ 'link_param' => 'item_name', - 'link_dependancy_params' => array( - 0 => array( + 'link_dependancy_params' => [ + 0 => [ 'param_info' => 'db', 'column_name' => 'routine_schema' - ), - 1 => array( + ], + 1 => [ 'param_info' => 'item_type', 'column_name' => 'routine_type' - ) - ), + ] + ], 'default_page' => 'db_routines.php' - ) - ), - 'columns' => array( - 'column_name' => array( - 'link_param' => array( + ] + ], + 'columns' => [ + 'column_name' => [ + 'link_param' => [ 'sql_query', 'table_schema', 'table_name' - ), - 'link_dependancy_params' => array( - 0 => array( + ], + 'link_dependancy_params' => [ + 0 => [ 'param_info' => 'db', 'column_name' => 'table_schema' - ), - 1 => array( - 'param_info' => array('test_name', 'value') - ) - ), + ], + 1 => [ + 'param_info' => ['test_name', 'value'] + ] + ], 'default_page' => 'index.php' - ) - ) - ) - ); + ] + ] + ] + ]; $this->object->__set('db', $db); $this->object->__set('table', $table); @@ -1026,7 +1026,7 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getSpecialLinkUrl', - array($column_value, $row_info, $field_name) + [$column_value, $row_info, $field_name] ) ); } @@ -1039,8 +1039,8 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForTestGetRowInfoForSpecialLinks() { - $column_names = array('host', 'db', 'user', 'select_privilages'); - $fields_mata = array(); + $column_names = ['host', 'db', 'user', 'select_privilages']; + $fields_mata = []; foreach ($column_names as $column_name) { $field_meta = new stdClass(); @@ -1048,30 +1048,30 @@ class ResultsTest extends PmaTestCase $fields_mata[] = $field_meta; } - return array( - array( + return [ + [ $fields_mata, count($fields_mata), - array( + [ 0 => 'localhost', 1 => 'phpmyadmin', 2 => 'pmauser', 3 => 'Y' - ), - array( + ], + [ 0 => '0', 1 => '3', 2 => '1', 3 => '2' - ), - array( + ], + [ 'host' => 'localhost', 'select_privilages' => 'Y', 'db' => 'phpmyadmin', 'user' => 'pmauser' - ) - ) - ); + ] + ] + ]; } @@ -1098,7 +1098,7 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getRowInfoForSpecialLinks', - array($row, $col_order) + [$row, $col_order] ) ); } @@ -1111,8 +1111,8 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForTestGetShowAllCheckboxForTableNavigation() { - return array( - array( + return [ + [ 'mysql', 'user', 'tbl_structure.php', @@ -1132,8 +1132,8 @@ class ResultsTest extends PmaTestCase . '<input type="checkbox" name="navig" id="showAll_0"' . ' class="showAllRows" value="all" />' . '<label for="showAll_0">Show all</label></form></td>' - ) - ); + ] + ]; } @@ -1161,7 +1161,7 @@ class ResultsTest extends PmaTestCase $result = $this->_callPrivateFunction( '_getShowAllCheckboxForTableNavigation', - array(false, $html_sql_query) + [false, $html_sql_query] ); $this->assertContains( @@ -1197,16 +1197,16 @@ class ResultsTest extends PmaTestCase $parser = new Parser( 'SELECT * FROM db_name WHERE `db_name`.`tbl`.id > 0 AND `id` < 10' ); - return array( - array( - array('statement' => $parser->statements[0]), - array( + return [ + [ + ['statement' => $parser->statements[0]], + [ 'db_name' => 'true', 'tbl' => 'true', 'id' => 'true', - ), - ), - ); + ], + ], + ]; } @@ -1224,7 +1224,7 @@ class ResultsTest extends PmaTestCase { $this->_callPrivateFunction( '_setHighlightedColumnGlobalField', - array($analyzed_sql) + [$analyzed_sql] ); $this->assertEquals( @@ -1241,12 +1241,12 @@ class ResultsTest extends PmaTestCase */ public function dataProviderForTestGetPartialText() { - return array( - array('P', 10, 'foo', array(false, 'foo', 3)), - array('P', 1, 'foo', array(true, 'f...', 3)), - array('F', 10, 'foo', array(false, 'foo', 3)), - array('F', 1, 'foo', array(false, 'foo', 3)) - ); + return [ + ['P', 10, 'foo', [false, 'foo', 3]], + ['P', 1, 'foo', [true, 'f...', 3]], + ['F', 10, 'foo', [false, 'foo', 3]], + ['F', 1, 'foo', [false, 'foo', 3]] + ]; } @@ -1270,7 +1270,7 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getPartialText', - array($str) + [$str] ) ); } @@ -1287,10 +1287,10 @@ class ResultsTest extends PmaTestCase $meta = new stdClass(); $meta->type = 'BLOB'; $meta->orgtable = 'bar'; - $url_params = array('db' => 'foo', 'table' => 'bar'); + $url_params = ['db' => 'foo', 'table' => 'bar']; - return array( - array( + return [ + [ true, true, 'BLOB', @@ -1304,8 +1304,8 @@ class ResultsTest extends PmaTestCase '<a href="tbl_get_field.php?db=foo&table=bar&server=0' . '&lang=en' . '" class="disableAjax">1001</a>' - ), - array( + ], + [ true, true, 'BLOB', @@ -1319,8 +1319,8 @@ class ResultsTest extends PmaTestCase '<a href="tbl_get_field.php?db=foo&table=bar&server=0' . '&lang=en' . '" class="disableAjax">0x123456</a>' - ), - array( + ], + [ true, false, 'BLOB', @@ -1334,8 +1334,8 @@ class ResultsTest extends PmaTestCase '<a href="tbl_get_field.php?db=foo&table=bar&server=0' . '&lang=en' . '" class="disableAjax">[BLOB - 4 B]</a>' - ), - array( + ], + [ false, false, 'BINARY', @@ -1347,8 +1347,8 @@ class ResultsTest extends PmaTestCase $url_params, null, '1001' - ), - array( + ], + [ false, true, 'GEOMETRY', @@ -1360,8 +1360,8 @@ class ResultsTest extends PmaTestCase $url_params, null, '[GEOMETRY - NULL]' - ) - ); + ] + ]; } @@ -1399,11 +1399,11 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_handleNonPrintableContents', - array( + [ $category, $content, $transformation_plugin, $transform_options, $default_function, $meta, $url_params, &$is_truncated - ) + ] ) ); } @@ -1435,22 +1435,22 @@ class ResultsTest extends PmaTestCase $meta2->decimals = 0; $meta2->name = 'varchar'; $meta2->orgname = 'varchar'; - $url_params = array('db' => 'foo', 'table' => 'tbl'); + $url_params = ['db' => 'foo', 'table' => 'tbl']; - return array( - array( + return [ + [ 'all', '1001', 'grid_edit', $meta, - array(), + [], $url_params, false, [Core::class, 'mimeDefaultFunction'], [Core::class, 'mimeDefaultFunction'], - array('https://www.example.com/'), + ['https://www.example.com/'], false, - array(), + [], 0, 'binary', '<td class="left hex">' . PHP_EOL @@ -1459,39 +1459,39 @@ class ResultsTest extends PmaTestCase . '" ' . 'class="disableAjax">[BLOB - 4 B]</a>' . PHP_EOL . '</td>' . PHP_EOL - ), - array( + ], + [ 'noblob', '1001', 'grid_edit', $meta, - array(), + [], $url_params, false, $transformation_plugin, [Core::class, 'mimeDefaultFunction'], [], false, - array(), + [], 0, 'binary', '<td class="left grid_edit transformed hex">' . PHP_EOL . ' 1001' . PHP_EOL . '</td>' . PHP_EOL - ), - array( + ], + [ 'noblob', null, 'grid_edit', $meta2, - array(), + [], $url_params, false, $transformation_plugin, [Core::class, 'mimeDefaultFunction'], [], false, - array(), + [], 0, 0, '<td ' . PHP_EOL @@ -1500,27 +1500,27 @@ class ResultsTest extends PmaTestCase . ' class="grid_edit null">' . PHP_EOL . ' <em>NULL</em>' . PHP_EOL . '</td>' . PHP_EOL - ), - array( + ], + [ 'all', 'foo bar baz', 'grid_edit', $meta2, - array(), + [], $url_params, false, [Core::class, 'mimeDefaultFunction'], [Core::class, 'mimeDefaultFunction'], [], false, - array(), + [], 0, 0, '<td data-decimals="0" data-type="string" ' . 'data-originallength="11" ' . 'class="grid_edit ">foo bar baz</td>' . "\n" - ) - ); + ] + ]; } @@ -1564,11 +1564,11 @@ class ResultsTest extends PmaTestCase $output, $this->_callPrivateFunction( '_getDataCellForNonNumericColumns', - array( + [ $column, $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql_results, &$dt_result, $col_index - ) + ] ) ); } @@ -1621,23 +1621,23 @@ class ResultsTest extends PmaTestCase $meta2->numeric = true; $meta2->primary_key = false; $meta2->unique_key = false; - $fields_meta = array($meta, $meta2); + $fields_meta = [$meta, $meta2]; $this->object->__set('fields_meta', $fields_meta); // MIME transformations $GLOBALS['dbi']->expects($this->exactly(1)) ->method('fetchResult') ->willReturn( - array( - 'db.table.1' => array( + [ + 'db.table.1' => [ 'mimetype' => '', 'transformation' => 'output/text_plain_dateformat.php', - ), - 'db.table.2' => array( + ], + 'db.table.2' => [ 'mimetype' => '', 'transformation' => 'output/text_plain_bool2text.php', - ), - ) + ], + ] ); $transformations = new Transformations(); @@ -1649,11 +1649,11 @@ class ResultsTest extends PmaTestCase // Actually invoke tested method $output = $this->_callPrivateFunction( '_getRowValues', - array( - &$result, array(3600, true), 0, false, array(), + [ + &$result, [3600, true], 0, false, [], '', false, $query, Query::getAll($query) - ) + ] ); // Dateformat diff --git a/test/classes/Engines/BdbTest.php b/test/classes/Engines/BdbTest.php index f3e19bfb24..9221367aa6 100644 --- a/test/classes/Engines/BdbTest.php +++ b/test/classes/Engines/BdbTest.php @@ -57,42 +57,42 @@ class BdbTest extends PmaTestCase { $this->assertEquals( $this->object->getVariables(), - array( - 'version_bdb' => array( + [ + 'version_bdb' => [ 'title' => __('Version information'), - ), - 'bdb_cache_size' => array( + ], + 'bdb_cache_size' => [ 'type' => 1, - ), - 'bdb_home' => array( - ), - 'bdb_log_buffer_size' => array( + ], + 'bdb_home' => [ + ], + 'bdb_log_buffer_size' => [ 'type' => 1, - ), - 'bdb_logdir' => array( - ), - 'bdb_max_lock' => array( + ], + 'bdb_logdir' => [ + ], + 'bdb_max_lock' => [ 'type' => 2, - ), - 'bdb_shared_data' => array( - ), - 'bdb_tmpdir' => array( - ), - 'bdb_data_direct' => array( - ), - 'bdb_lock_detect' => array( - ), - 'bdb_log_direct' => array( - ), - 'bdb_no_recover' => array( - ), - 'bdb_no_sync' => array( - ), - 'skip_sync_bdb_logs' => array( - ), - 'sync_bdb_logs' => array( - ), - ) + ], + 'bdb_shared_data' => [ + ], + 'bdb_tmpdir' => [ + ], + 'bdb_data_direct' => [ + ], + 'bdb_lock_detect' => [ + ], + 'bdb_log_direct' => [ + ], + 'bdb_no_recover' => [ + ], + 'bdb_no_sync' => [ + ], + 'skip_sync_bdb_logs' => [ + ], + 'sync_bdb_logs' => [ + ], + ] ); } diff --git a/test/classes/Engines/InnodbTest.php b/test/classes/Engines/InnodbTest.php index 5eb9ad5399..5e7fa2f801 100644 --- a/test/classes/Engines/InnodbTest.php +++ b/test/classes/Engines/InnodbTest.php @@ -56,99 +56,99 @@ class InnodbTest extends PmaTestCase public function testGetVariables() { $this->assertEquals( - array( - 'innodb_data_home_dir' => array( + [ + 'innodb_data_home_dir' => [ 'title' => __('Data home directory'), 'desc' => __('The common part of the directory path for all InnoDB data files.'), - ), - 'innodb_data_file_path' => array( + ], + 'innodb_data_file_path' => [ 'title' => __('Data files'), - ), - 'innodb_autoextend_increment' => array( + ], + 'innodb_autoextend_increment' => [ 'title' => __('Autoextend increment'), 'desc' => __('The increment size for extending the size of an autoextending tablespace when it becomes full.'), 'type' => 2, - ), - 'innodb_buffer_pool_size' => array( + ], + 'innodb_buffer_pool_size' => [ 'title' => __('Buffer pool size'), 'desc' => __('The size of the memory buffer InnoDB uses to cache data and indexes of its tables.'), 'type' => 1, - ), - 'innodb_additional_mem_pool_size' => array( + ], + 'innodb_additional_mem_pool_size' => [ 'title' => 'innodb_additional_mem_pool_size', 'type' => 1, - ), - 'innodb_buffer_pool_awe_mem_mb' => array( + ], + 'innodb_buffer_pool_awe_mem_mb' => [ 'type' => 1, - ), - 'innodb_checksums' => array( - ), - 'innodb_commit_concurrency' => array( - ), - 'innodb_concurrency_tickets' => array( + ], + 'innodb_checksums' => [ + ], + 'innodb_commit_concurrency' => [ + ], + 'innodb_concurrency_tickets' => [ 'type' => 2, - ), - 'innodb_doublewrite' => array( - ), - 'innodb_fast_shutdown' => array( - ), - 'innodb_file_io_threads' => array( + ], + 'innodb_doublewrite' => [ + ], + 'innodb_fast_shutdown' => [ + ], + 'innodb_file_io_threads' => [ 'type' => 2, - ), - 'innodb_file_per_table' => array( - ), - 'innodb_flush_log_at_trx_commit' => array( - ), - 'innodb_flush_method' => array( - ), - 'innodb_force_recovery' => array( - ), - 'innodb_lock_wait_timeout' => array( + ], + 'innodb_file_per_table' => [ + ], + 'innodb_flush_log_at_trx_commit' => [ + ], + 'innodb_flush_method' => [ + ], + 'innodb_force_recovery' => [ + ], + 'innodb_lock_wait_timeout' => [ 'type' => 2, - ), - 'innodb_locks_unsafe_for_binlog' => array( - ), - 'innodb_log_arch_dir' => array( - ), - 'innodb_log_archive' => array( - ), - 'innodb_log_buffer_size' => array( + ], + 'innodb_locks_unsafe_for_binlog' => [ + ], + 'innodb_log_arch_dir' => [ + ], + 'innodb_log_archive' => [ + ], + 'innodb_log_buffer_size' => [ 'type' => 1, - ), - 'innodb_log_file_size' => array( + ], + 'innodb_log_file_size' => [ 'type' => 1, - ), - 'innodb_log_files_in_group' => array( + ], + 'innodb_log_files_in_group' => [ 'type' => 2, - ), - 'innodb_log_group_home_dir' => array( - ), - 'innodb_max_dirty_pages_pct' => array( + ], + 'innodb_log_group_home_dir' => [ + ], + 'innodb_max_dirty_pages_pct' => [ 'type' => 2, - ), - 'innodb_max_purge_lag' => array( - ), - 'innodb_mirrored_log_groups' => array( + ], + 'innodb_max_purge_lag' => [ + ], + 'innodb_mirrored_log_groups' => [ 'type' => 2, - ), - 'innodb_open_files' => array( + ], + 'innodb_open_files' => [ 'type' => 2, - ), - 'innodb_support_xa' => array( - ), - 'innodb_sync_spin_loops' => array( + ], + 'innodb_support_xa' => [ + ], + 'innodb_sync_spin_loops' => [ 'type' => 2, - ), - 'innodb_table_locks' => array( + ], + 'innodb_table_locks' => [ 'type' => 3, - ), - 'innodb_thread_concurrency' => array( + ], + 'innodb_thread_concurrency' => [ 'type' => 2, - ), - 'innodb_thread_sleep_delay' => array( + ], + 'innodb_thread_sleep_delay' => [ 'type' => 2, - ), - ), + ], + ], $this->object->getVariables() ); } @@ -174,15 +174,15 @@ class InnodbTest extends PmaTestCase public function testGetInfoPages() { $this->assertEquals( - array(), + [], $this->object->getInfoPages() ); $this->object->support = 2; $this->assertEquals( - array ( + [ 'Bufferpool' => 'Buffer Pool', 'Status' => 'InnoDB Status' - ), + ], $this->object->getInfoPages() ); } diff --git a/test/classes/Engines/MemoryTest.php b/test/classes/Engines/MemoryTest.php index f87dee0fea..d0fc5f6dff 100644 --- a/test/classes/Engines/MemoryTest.php +++ b/test/classes/Engines/MemoryTest.php @@ -57,11 +57,11 @@ class MemoryTest extends PmaTestCase { $this->assertEquals( $this->object->getVariables(), - array( - 'max_heap_table_size' => array( + [ + 'max_heap_table_size' => [ 'type' => 1, - ) - ) + ] + ] ); } } diff --git a/test/classes/Engines/MyisamTest.php b/test/classes/Engines/MyisamTest.php index 06a6105b5e..b601e91b1a 100644 --- a/test/classes/Engines/MyisamTest.php +++ b/test/classes/Engines/MyisamTest.php @@ -57,46 +57,46 @@ class MyisamTest extends PmaTestCase { $this->assertEquals( $this->object->getVariables(), - array( - 'myisam_data_pointer_size' => array( + [ + 'myisam_data_pointer_size' => [ 'title' => __('Data pointer size'), 'desc' => __('The default pointer size in bytes, to be used by CREATE TABLE for MyISAM tables when no MAX_ROWS option is specified.'), 'type' => 1, - ), - 'myisam_recover_options' => array( + ], + 'myisam_recover_options' => [ 'title' => __('Automatic recovery mode'), 'desc' => __('The mode for automatic recovery of crashed MyISAM tables, as set via the --myisam-recover server startup option.'), - ), - 'myisam_max_sort_file_size' => array( + ], + 'myisam_max_sort_file_size' => [ 'title' => __('Maximum size for temporary sort files'), 'desc' => __('The maximum size of the temporary file MySQL is allowed to use while re-creating a MyISAM index (during REPAIR TABLE, ALTER TABLE, or LOAD DATA INFILE).'), 'type' => 1, - ), - 'myisam_max_extra_sort_file_size' => array( + ], + 'myisam_max_extra_sort_file_size' => [ 'title' => __('Maximum size for temporary files on index creation'), 'desc' => __('If the temporary file used for fast MyISAM index creation would be larger than using the key cache by the amount specified here, prefer the key cache method.'), 'type' => 1, - ), - 'myisam_repair_threads' => array( + ], + 'myisam_repair_threads' => [ 'title' => __('Repair threads'), 'desc' => __('If this value is greater than 1, MyISAM table indexes are created in parallel (each index in its own thread) during the repair by sorting process.'), 'type' => 2, - ), - 'myisam_sort_buffer_size' => array( + ], + 'myisam_sort_buffer_size' => [ 'title' => __('Sort buffer size'), 'desc' => __('The buffer that is allocated when sorting MyISAM indexes during a REPAIR TABLE or when creating indexes with CREATE INDEX or ALTER TABLE.'), 'type' => 1, - ), - 'myisam_stats_method' => array( - ), - 'delay_key_write' => array( - ), - 'bulk_insert_buffer_size' => array( + ], + 'myisam_stats_method' => [ + ], + 'delay_key_write' => [ + ], + 'bulk_insert_buffer_size' => [ 'type' => 1, - ), - 'skip_external_locking' => array( - ), - ) + ], + 'skip_external_locking' => [ + ], + ] ); } diff --git a/test/classes/Engines/NdbclusterTest.php b/test/classes/Engines/NdbclusterTest.php index 22ea71f805..92bf39ff42 100644 --- a/test/classes/Engines/NdbclusterTest.php +++ b/test/classes/Engines/NdbclusterTest.php @@ -57,10 +57,10 @@ class NdbclusterTest extends PmaTestCase { $this->assertEquals( $this->object->getVariables(), - array( - 'ndb_connectstring' => array( - ), - ) + [ + 'ndb_connectstring' => [ + ], + ] ); } diff --git a/test/classes/Engines/PbxtTest.php b/test/classes/Engines/PbxtTest.php index 8532266103..8b6a89f80a 100644 --- a/test/classes/Engines/PbxtTest.php +++ b/test/classes/Engines/PbxtTest.php @@ -59,8 +59,8 @@ class PbxtTest extends PmaTestCase { $this->assertEquals( $this->object->getVariables(), - array( - 'pbxt_index_cache_size' => array( + [ + 'pbxt_index_cache_size' => [ 'title' => __('Index cache size'), 'desc' => __( 'This is the amount of memory allocated to the' @@ -68,8 +68,8 @@ class PbxtTest extends PmaTestCase . ' allocated here is used only for caching index pages.' ), 'type' => 1 - ), - 'pbxt_record_cache_size' => array( + ], + 'pbxt_record_cache_size' => [ 'title' => __('Record cache size'), 'desc' => __( 'This is the amount of memory allocated to the' @@ -78,8 +78,8 @@ class PbxtTest extends PmaTestCase . ' the handle data (.xtd) and row pointer (.xtr) files.' ), 'type' => 1 - ), - 'pbxt_log_cache_size' => array( + ], + 'pbxt_log_cache_size' => [ 'title' => __('Log cache size'), 'desc' => __( 'The amount of memory allocated to the' @@ -87,16 +87,16 @@ class PbxtTest extends PmaTestCase . ' data. The default is 16MB.' ), 'type' => 1 - ), - 'pbxt_log_file_threshold' => array( + ], + 'pbxt_log_file_threshold' => [ 'title' => __('Log file threshold'), 'desc' => __( 'The size of a transaction log before rollover,' . ' and a new log is created. The default value is 16MB.' ), 'type' => 1 - ), - 'pbxt_transaction_buffer_size' => array( + ], + 'pbxt_transaction_buffer_size' => [ 'title' => __('Transaction buffer size'), 'desc' => __( 'The size of the global transaction log buffer' @@ -104,8 +104,8 @@ class PbxtTest extends PmaTestCase . ' The default is 1MB.' ), 'type' => 1 - ), - 'pbxt_checkpoint_frequency' => array( + ], + 'pbxt_checkpoint_frequency' => [ 'title' => __('Checkpoint frequency'), 'desc' => __( 'The amount of data written to the transaction' @@ -113,8 +113,8 @@ class PbxtTest extends PmaTestCase . ' The default value is 24MB.' ), 'type' => 1 - ), - 'pbxt_data_log_threshold' => array( + ], + 'pbxt_data_log_threshold' => [ 'title' => __('Data log threshold'), 'desc' => __( 'The maximum size of a data log file. The default' @@ -124,8 +124,8 @@ class PbxtTest extends PmaTestCase . ' amount of data that can be stored in the database.' ), 'type' => 1 - ), - 'pbxt_garbage_threshold' => array( + ], + 'pbxt_garbage_threshold' => [ 'title' => __('Garbage threshold'), 'desc' => __( 'The percentage of garbage in a data log file' @@ -133,8 +133,8 @@ class PbxtTest extends PmaTestCase . ' 99. The default is 50.' ), 'type' => 2 - ), - 'pbxt_log_buffer_size' => array( + ], + 'pbxt_log_buffer_size' => [ 'title' => __('Log buffer size'), 'desc' => __( 'The size of the buffer used when writing a data' @@ -143,18 +143,18 @@ class PbxtTest extends PmaTestCase . ' to write a data log.' ), 'type' => 1 - ), - 'pbxt_data_file_grow_size' => array( + ], + 'pbxt_data_file_grow_size' => [ 'title' => __('Data file grow size'), 'desc' => __('The grow size of the handle data (.xtd) files.'), 'type' => 1 - ), - 'pbxt_row_file_grow_size' => array( + ], + 'pbxt_row_file_grow_size' => [ 'title' => __('Row file grow size'), 'desc' => __('The grow size of the row pointer (.xtr) files.'), 'type' => 1 - ), - 'pbxt_log_file_count' => array( + ], + 'pbxt_log_file_count' => [ 'title' => __('Log file count'), 'desc' => __( 'This is the number of transaction log files' @@ -164,8 +164,8 @@ class PbxtTest extends PmaTestCase . ' highest number.' ), 'type' => 2 - ), - ) + ], + ] ); } @@ -194,29 +194,29 @@ class PbxtTest extends PmaTestCase */ public function providerFortTestResolveTypeSize() { - return array( - array( + return [ + [ '8MB', - array ( + [ 0 => '8,192', 1 => 'KiB' - ) - ), - array( + ] + ], + [ '10mb', - array ( + [ 0 => '-1', 1 => 'B' - ) - ), - array( + ] + ], + [ 'A4', - array ( + [ 0 => '0', 1 => 'B' - ) - ) - ); + ] + ] + ]; } /** @@ -228,9 +228,9 @@ class PbxtTest extends PmaTestCase { $this->assertEquals( $this->object->getInfoPages(), - array( + [ 'Documentation' => 'Documentation' - ) + ] ); } diff --git a/test/classes/ErrorHandlerTest.php b/test/classes/ErrorHandlerTest.php index e369113002..cb227d6ec5 100644 --- a/test/classes/ErrorHandlerTest.php +++ b/test/classes/ErrorHandlerTest.php @@ -71,24 +71,24 @@ class ErrorHandlerTest extends PmaTestCase */ public function providerForTestHandleError() { - return array( - array( + return [ + [ E_RECOVERABLE_ERROR, 'Compile Error', 'error.txt', 12, 'Compile Error', '', - ), - array( + ], + [ E_USER_NOTICE, 'User notice', 'error.txt', 12, 'User notice', 'User notice', - ) - ); + ] + ]; } /** @@ -160,11 +160,11 @@ class ErrorHandlerTest extends PmaTestCase public function testCheckSavedErrors() { - $_SESSION['errors'] = array(); + $_SESSION['errors'] = []; $this->_callProtectedFunction( 'checkSavedErrors', - array() + [] ); $this->assertArrayNotHasKey('errors', $_SESSION); } @@ -204,7 +204,7 @@ class ErrorHandlerTest extends PmaTestCase $this->object->countErrors() ); $this->assertEquals( - array(), + [], $this->object->sliceErrors(1) ); $this->assertEquals( diff --git a/test/classes/ErrorTest.php b/test/classes/ErrorTest.php index 6ea6c31e90..2761eaa962 100644 --- a/test/classes/ErrorTest.php +++ b/test/classes/ErrorTest.php @@ -57,7 +57,7 @@ class ErrorTest extends PmaTestCase */ public function testSetBacktrace() { - $bt = array(array('file'=>'bt1','line'=>2, 'function'=>'bar', 'args'=>array('foo'=>$this))); + $bt = [['file'=>'bt1','line'=>2, 'function'=>'bar', 'args'=>['foo'=>$this]]]; $this->object->setBacktrace($bt); $bt[0]['args']['foo'] = '<Class:PhpMyAdmin\Tests\ErrorTest>'; $this->assertEquals($bt, $this->object->getBacktrace()); @@ -97,11 +97,11 @@ class ErrorTest extends PmaTestCase */ public function filePathProvider() { - return array( - array('./ChangeLog', './ChangeLog'), - array(__FILE__, './test/classes/ErrorTest.php'), - array('./NONEXISTING', 'NONEXISTING'), - ); + return [ + ['./ChangeLog', './ChangeLog'], + [__FILE__, './test/classes/ErrorTest.php'], + ['./NONEXISTING', 'NONEXISTING'], + ]; } /** @@ -170,12 +170,12 @@ class ErrorTest extends PmaTestCase */ public function testGetBacktrace() { - $bt = array( - array('file'=>'bt1','line'=>2, 'function'=>'bar', 'args'=>array('foo'=>1)), - array('file'=>'bt2','line'=>2, 'function'=>'bar', 'args'=>array('foo'=>2)), - array('file'=>'bt3','line'=>2, 'function'=>'bar', 'args'=>array('foo'=>3)), - array('file'=>'bt4','line'=>2, 'function'=>'bar', 'args'=>array('foo'=>4)), - ); + $bt = [ + ['file'=>'bt1','line'=>2, 'function'=>'bar', 'args'=>['foo'=>1]], + ['file'=>'bt2','line'=>2, 'function'=>'bar', 'args'=>['foo'=>2]], + ['file'=>'bt3','line'=>2, 'function'=>'bar', 'args'=>['foo'=>3]], + ['file'=>'bt4','line'=>2, 'function'=>'bar', 'args'=>['foo'=>4]], + ]; $this->object->setBacktrace($bt); diff --git a/test/classes/ExportTest.php b/test/classes/ExportTest.php index 4e9131229f..c72d7668fa 100644 --- a/test/classes/ExportTest.php +++ b/test/classes/ExportTest.php @@ -44,70 +44,70 @@ class ExportTest extends TestCase */ public function testMergeAliases() { - $aliases1 = array( - 'test_db' => array( + $aliases1 = [ + 'test_db' => [ 'alias' => 'aliastest', - 'tables' => array( - 'foo' => array( + 'tables' => [ + 'foo' => [ 'alias' => 'foobar', - 'columns' => array( + 'columns' => [ 'bar' => 'foo', 'baz' => 'barbaz' - ) - ), - 'bar' => array( + ] + ], + 'bar' => [ 'alias' => 'foobaz', - 'columns' => array( + 'columns' => [ 'a' => 'a_alias', 'b' => 'b' - ) - ) - ) - ) - ); - $aliases2 = array( - 'test_db' => array( + ] + ] + ] + ] + ]; + $aliases2 = [ + 'test_db' => [ 'alias' => 'test', - 'tables' => array( - 'foo' => array( - 'columns' => array( + 'tables' => [ + 'foo' => [ + 'columns' => [ 'bar' => 'foobar' - ) - ), - 'baz' => array( - 'columns' => array( + ] + ], + 'baz' => [ + 'columns' => [ 'a' => 'x' - ) - ) - ) - ) - ); - $expected = array( - 'test_db' => array( + ] + ] + ] + ] + ]; + $expected = [ + 'test_db' => [ 'alias' => 'test', - 'tables' => array( - 'foo' => array( + 'tables' => [ + 'foo' => [ 'alias' => 'foobar', - 'columns' => array( + 'columns' => [ 'bar' => 'foobar', 'baz' => 'barbaz' - ) - ), - 'bar' => array( + ] + ], + 'bar' => [ 'alias' => 'foobaz', - 'columns' => array( + 'columns' => [ 'a' => 'a_alias', 'b' => 'b' - ) - ), - 'baz' => array( - 'columns' => array( + ] + ], + 'baz' => [ + 'columns' => [ 'a' => 'x' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $actual = $this->export->mergeAliases($aliases1, $aliases2); $this->assertEquals($expected, $actual); } diff --git a/test/classes/FileTest.php b/test/classes/FileTest.php index bd57e0b2d6..f966da9976 100644 --- a/test/classes/FileTest.php +++ b/test/classes/FileTest.php @@ -83,10 +83,10 @@ class FileTest extends PmaTestCase */ public function compressedFiles() { - return array( - array('./test/test_data/test.gz', 'application/gzip'), - array('./test/test_data/test.bz2', 'application/bzip2'), - array('./test/test_data/test.zip', 'application/zip'), - ); + return [ + ['./test/test_data/test.gz', 'application/gzip'], + ['./test/test_data/test.bz2', 'application/bzip2'], + ['./test/test_data/test.zip', 'application/zip'], + ]; } } diff --git a/test/classes/FontTest.php b/test/classes/FontTest.php index 69fa2eeb8d..c4db328d0f 100644 --- a/test/classes/FontTest.php +++ b/test/classes/FontTest.php @@ -230,7 +230,7 @@ class FontTest extends PmaTestCase // string "a", with invalid charlist (= array without proper structure) $this->assertEquals( 6, - $this->font->getStringWidth("a", "arial", 10, array("list")) + $this->font->getStringWidth("a", "arial", 10, ["list"]) ); // string "a", with invalid charlist (= array without proper structure : @@ -239,7 +239,7 @@ class FontTest extends PmaTestCase 6, $this->font->getStringWidth( "a", "arial", 10, - array(array("chars" => "a")) + [["chars" => "a"]] ) ); @@ -249,7 +249,7 @@ class FontTest extends PmaTestCase 6, $this->font->getStringWidth( "a", "arial", 10, - array(array("modifier" => 0.61)) + [["modifier" => 0.61]] ) ); @@ -259,7 +259,7 @@ class FontTest extends PmaTestCase 6, $this->font->getStringWidth( "a", "arial", 10, - array(array("chars" => "a", "modifier" => 0.61)) + [["chars" => "a", "modifier" => 0.61]] ) ); @@ -268,7 +268,7 @@ class FontTest extends PmaTestCase 7, $this->font->getStringWidth( "a", "arial", 10, - array(array("chars" => array("a"), "modifier" => 0.61)) + [["chars" => ["a"], "modifier" => 0.61]] ) ); } diff --git a/test/classes/FooterTest.php b/test/classes/FooterTest.php index 2e4f0ad51a..510916113a 100644 --- a/test/classes/FooterTest.php +++ b/test/classes/FooterTest.php @@ -26,7 +26,7 @@ class FooterTest extends PmaTestCase /** * @var array store private attributes of PhpMyAdmin\Footer */ - public $privates = array(); + public $privates = []; /** * @access protected @@ -99,18 +99,18 @@ class FooterTest extends PmaTestCase public function testGetDebugMessage() { $GLOBALS['cfg']['DBG']['sql'] = true; - $_SESSION['debug']['queries'] = array( - array( + $_SESSION['debug']['queries'] = [ + [ 'count' => 1, 'time' => 0.2, 'query' => 'SELECT * FROM `pma_bookmark` WHERE 1', - ), - array( + ], + [ 'count' => 1, 'time' => 2.5, 'query' => 'SELECT * FROM `db` WHERE 1', - ), - ); + ], + ]; $this->assertEquals( '{"queries":[{"count":1,"time":0.2,"query":"SELECT * FROM `pma_bookmark` WHERE 1"},' @@ -126,15 +126,15 @@ class FooterTest extends PmaTestCase */ public function testRemoveRecursion() { - $object = (object) array(); - $object->child = (object) array(); + $object = (object) []; + $object->child = (object) []; $object->child->parent = $object; $this->_callPrivateFunction( '_removeRecursion', - array( + [ &$object - ) + ] ); $this->assertEquals( @@ -161,9 +161,9 @@ class FooterTest extends PmaTestCase . 'target="_blank" rel="noopener noreferrer">Open new phpMyAdmin window</a></div>', $this->_callPrivateFunction( '_getSelfLink', - array( + [ $this->object->getSelfUrl() - ) + ] ) ); } @@ -188,9 +188,9 @@ class FooterTest extends PmaTestCase . 'class="icon ic_window-new" /></a></div>', $this->_callPrivateFunction( '_getSelfLink', - array( + [ $this->object->getSelfUrl() - ) + ] ) ); } diff --git a/test/classes/Gis/GisFactoryTest.php b/test/classes/Gis/GisFactoryTest.php index 9d6bf7bf6e..1e3ab9ce58 100644 --- a/test/classes/Gis/GisFactoryTest.php +++ b/test/classes/Gis/GisFactoryTest.php @@ -41,35 +41,35 @@ class GisFactoryTest extends TestCase */ public function providerForTestFactory() { - return array( - array( + return [ + [ 'MULTIPOLYGON', 'PhpMyAdmin\Gis\GisMultiPolygon' - ), - array( + ], + [ 'POLYGON', 'PhpMyAdmin\Gis\GisPolygon' - ), - array( + ], + [ 'MULTILINESTRING', 'PhpMyAdmin\Gis\GisMultiLineString' - ), - array( + ], + [ 'LINESTRING', 'PhpMyAdmin\Gis\GisLineString' - ), - array( + ], + [ 'MULTIPOINT', 'PhpMyAdmin\Gis\GisMultiPoint' - ), - array( + ], + [ 'POINT', 'PhpMyAdmin\Gis\GisPoint' - ), - array( + ], + [ 'GEOMETRYCOLLECTION', 'PhpMyAdmin\Gis\GisGeometryCollection' - ), - ); + ], + ]; } } diff --git a/test/classes/Gis/GisGeometryCollectionTest.php b/test/classes/Gis/GisGeometryCollectionTest.php index 824cc9f750..71cb71b99a 100644 --- a/test/classes/Gis/GisGeometryCollectionTest.php +++ b/test/classes/Gis/GisGeometryCollectionTest.php @@ -71,18 +71,18 @@ class GisGeometryCollectionTest extends TestCase */ public function providerForScaleRow() { - return array( - array( + return [ + [ 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),' . '(20 30,35 32,30 20,20 30)))', - array( + [ 'maxX' => 45.0, 'minX' => 10.0, 'maxY' => 45.0, 'minY' => 10.0 - ) - ) - ); + ] + ] + ]; } /** @@ -112,25 +112,25 @@ class GisGeometryCollectionTest extends TestCase */ public function providerForGenerateWkt() { - $temp1 = array( - 0 => array( + $temp1 = [ + 0 => [ 'gis_type' => 'LINESTRING', - 'LINESTRING' => array( + 'LINESTRING' => [ 'no_of_points' => 2, - 0 => array('x' => 5.02, 'y' => 8.45), - 1 => array('x' => 6.14, 'y' => 0.15) - ) - ) - ); + 0 => ['x' => 5.02, 'y' => 8.45], + 1 => ['x' => 6.14, 'y' => 0.15] + ] + ] + ]; - return array( - array( + return [ + [ $temp1, 0, null, 'GEOMETRYCOLLECTION(LINESTRING(5.02 8.45,6.14 0.15))' - ) - ); + ] + ]; } /** @@ -155,29 +155,29 @@ class GisGeometryCollectionTest extends TestCase */ public function providerForGenerateParams() { - return array( - array( + return [ + [ 'GEOMETRYCOLLECTION(LINESTRING(5.02 8.45,6.14 0.15))', - array( + [ 'srid' => 0, - 'GEOMETRYCOLLECTION' => array('geom_count' => 1), - '0' => array( + 'GEOMETRYCOLLECTION' => ['geom_count' => 1], + '0' => [ 'gis_type' => 'LINESTRING', - 'LINESTRING' => array( + 'LINESTRING' => [ 'no_of_points' => 2, - '0' => array( + '0' => [ 'x' => 5.02, 'y' => 8.45 - ), - '1' => array( + ], + '1' => [ 'x' => 6.14, 'y' => 0.15 - ) - ) - ) - ), - ), - ); + ] + ] + ] + ], + ], + ]; } /** @@ -213,21 +213,21 @@ class GisGeometryCollectionTest extends TestCase if (! function_exists('imagecreatetruecolor')) { $this->markTestSkipped('GD extension missing!'); } - return array( - array( + return [ + [ 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),' . '(20 30,35 32,30 20,20 30)))', 'image', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], imagecreatetruecolor(120, 150) - ) - ); + ] + ]; } /** @@ -259,21 +259,21 @@ class GisGeometryCollectionTest extends TestCase */ public function providerForPrepareRowAsPdf() { - return array( - array( + return [ + [ 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),' . '(20 30,35 32,30 20,20 30)))', 'pdf', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], new TCPDF(), - ) - ); + ] + ]; } /** @@ -311,24 +311,24 @@ class GisGeometryCollectionTest extends TestCase */ public function providerForPrepareRowAsSvg() { - return array( - array( + return [ + [ 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),' . '(20 30,35 32,30 20,20 30)))', 'svg', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], '/^(<path d=" M 46, 268 L -4, 248 L 6, 208 L 66, 198 Z M 16,' . ' 228 L 46, 224 L 36, 248 Z " name="svg" id="svg)(\d+)' . '(" class="polygon vector" stroke="black" stroke-width="0.5"' . ' fill="#B02EE0" fill-rule="evenodd" fill-opacity="0.8"\/>)$/' - ) - ); + ] + ]; } /** @@ -363,19 +363,19 @@ class GisGeometryCollectionTest extends TestCase */ public function providerForPrepareRowAsOl() { - return array( - array( + return [ + [ 'GEOMETRYCOLLECTION(POLYGON((35 10,10 20,15 40,45 45,35 10),' . '(20 30,35 32,30 20,20 30)))', 4326, 'Ol', '#B02EE0', - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.' . 'LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326' . '"), map.getProjectionObject())); bound.extend(new OpenLayer' @@ -404,7 +404,7 @@ class GisGeometryCollectionTest extends TestCase . '26"), map.getProjectionObject()))))), null, {"strokeColor":' . '"#000000","strokeWidth":0.5,"fillColor":"#B02EE0","fillOpac' . 'ity":0.8,"label":"Ol","fontSize":10}));' - ) - ); + ] + ]; } } diff --git a/test/classes/Gis/GisGeometryTest.php b/test/classes/Gis/GisGeometryTest.php index 11e487646a..94a3aa3f31 100644 --- a/test/classes/Gis/GisGeometryTest.php +++ b/test/classes/Gis/GisGeometryTest.php @@ -80,7 +80,7 @@ class GisGeometryTest extends TestCase $output, $this->_callProtectedFunction( 'setMinMax', - array($point_set, $min_max) + [$point_set, $min_max] ) ); } @@ -92,33 +92,33 @@ class GisGeometryTest extends TestCase */ public function providerForTestSetMinMax() { - return array( - array( + return [ + [ '12 35,48 75,69 23,25 45,14 53,35 78', - array(), - array( + [], + [ 'minX' => 12, 'maxX' => 69, 'minY' => 23, 'maxY' => 78 - ) - ), - array( + ] + ], + [ '12 35,48 75,69 23,25 45,14 53,35 78', - array( + [ 'minX' => 2, 'maxX' => 29, 'minY' => 23, 'maxY' => 128 - ), - array( + ], + [ 'minX' => 2, 'maxX' => 69, 'minY' => 23, 'maxY' => 128 - ) - ) - ); + ] + ] + ]; } /** @@ -136,7 +136,7 @@ class GisGeometryTest extends TestCase $output, $this->_callProtectedFunction( 'generateParams', - array($value) + [$value] ) ); } @@ -148,29 +148,29 @@ class GisGeometryTest extends TestCase */ public function providerForTestGenerateParams() { - return array( - array( + return [ + [ "'MULTIPOINT(125 50,156 25,178 43,175 80)',125", - array( + [ 'srid' => '125', 'wkt' => 'MULTIPOINT(125 50,156 25,178 43,175 80)', - ), - ), - array( + ], + ], + [ 'MULTIPOINT(125 50,156 25,178 43,175 80)', - array( + [ 'srid' => '0', 'wkt' => 'MULTIPOINT(125 50,156 25,178 43,175 80)', - ), - ), - array( + ], + ], + [ "foo", - array( + [ 'srid' => '0', 'wkt' => '', - ), - ), - ); + ], + ], + ]; } /** @@ -190,7 +190,7 @@ class GisGeometryTest extends TestCase $output, $this->_callProtectedFunction( 'extractPoints', - array($point_set, $scale_data, $linear) + [$point_set, $scale_data, $linear] ) ); } @@ -202,53 +202,53 @@ class GisGeometryTest extends TestCase */ public function providerForTestExtractPoints() { - return array( + return [ // with no scale data - array( + [ '12 35,48 75,69 23', null, false, - array( - 0 => array(12, 35), - 1 => array(48, 75), - 2 => array(69, 23), - ), - ), + [ + 0 => [12, 35], + 1 => [48, 75], + 2 => [69, 23], + ], + ], // with scale data - array( + [ '12 35,48 75,69 23', - array( + [ 'x' => 5, 'y' => 5, 'scale' => 2, 'height' => 200, - ), + ], false, - array( - 0 => array(14, 140), - 1 => array(86, 60), - 2 => array(128, 164), - ), - ), + [ + 0 => [14, 140], + 1 => [86, 60], + 2 => [128, 164], + ], + ], // linear output - array( + [ '12 35,48 75,69 23', null, true, - array(12, 35, 48, 75, 69, 23), - ), + [12, 35, 48, 75, 69, 23], + ], // if a single part of a coordinate is empty - array( + [ '12 35,48 75,69 ', null, false, - array( - 0 => array(12, 35), - 1 => array(48, 75), - 2 => array(0, 0), - ), - ), - ); + [ + 0 => [12, 35], + 1 => [48, 75], + 2 => [0, 0], + ], + ], + ]; } /** @@ -267,7 +267,7 @@ class GisGeometryTest extends TestCase $output, $this->_callProtectedFunction( 'getBoundsForOl', - array($srid, $scale_data) + [$srid, $scale_data] ) ); } @@ -279,15 +279,15 @@ class GisGeometryTest extends TestCase */ public function providerForTestGetBoundsForOl() { - return array( - array( + return [ + [ 4326, - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); ' . 'bound.extend(new OpenLayers.LonLat(0, 0).transform(' . 'new OpenLayers.Projection("EPSG:4326"), ' @@ -295,9 +295,9 @@ class GisGeometryTest extends TestCase . 'bound.extend(new OpenLayers.LonLat(1, 1).transform(' . 'new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject()));' - ) + ] - ); + ]; } /** @@ -316,7 +316,7 @@ class GisGeometryTest extends TestCase $output, $this->_callProtectedFunction( 'getPolygonArrayForOpenLayers', - array($polygons, $srid) + [$polygons, $srid] ) ); } @@ -328,9 +328,9 @@ class GisGeometryTest extends TestCase */ public function providerForTestGetPolygonArrayForOpenLayers() { - return array( - array( - array('Triangle'), + return [ + [ + ['Triangle'], 4326, 'new Array(' . 'new OpenLayers.Geometry.Polygon(' @@ -340,7 +340,7 @@ class GisGeometryTest extends TestCase . '(new OpenLayers.Geometry.Point(0,0)).transform(' . 'new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject()))))))' - ) - ); + ] + ]; } } diff --git a/test/classes/Gis/GisLineStringTest.php b/test/classes/Gis/GisLineStringTest.php index a97a2ccc5a..f23eb334cc 100644 --- a/test/classes/Gis/GisLineStringTest.php +++ b/test/classes/Gis/GisLineStringTest.php @@ -57,19 +57,19 @@ class GisLineStringTest extends GisGeomTestCase */ public function providerForTestGenerateWkt() { - $temp1 = array( - 0 => array( - 'LINESTRING' => array( + $temp1 = [ + 0 => [ + 'LINESTRING' => [ 'no_of_points' => 2, - 0 => array('x' => 5.02, 'y' => 8.45), - 1 => array('x' => 6.14, 'y' => 0.15) - ) - ) - ); + 0 => ['x' => 5.02, 'y' => 8.45], + 1 => ['x' => 6.14, 'y' => 0.15] + ] + ] + ]; $temp2 = $temp1; $temp2[0]['LINESTRING']['no_of_points'] = 3; - $temp2[0]['LINESTRING'][2] = array('x' => 1.56); + $temp2[0]['LINESTRING'][2] = ['x' => 1.56]; $temp3 = $temp2; $temp3[0]['LINESTRING']['no_of_points'] = -1; @@ -78,35 +78,35 @@ class GisLineStringTest extends GisGeomTestCase $temp4[0]['LINESTRING']['no_of_points'] = 3; unset($temp4[0]['LINESTRING'][2]['x']); - return array( - array( + return [ + [ $temp1, 0, null, 'LINESTRING(5.02 8.45,6.14 0.15)' - ), + ], // if a coordinate is missing, default is empty string - array( + [ $temp2, 0, null, 'LINESTRING(5.02 8.45,6.14 0.15,1.56 )' - ), + ], // if no_of_points is not valid, it is considered as 2 - array( + [ $temp3, 0, null, 'LINESTRING(5.02 8.45,6.14 0.15)' - ), + ], // missing coordinates are replaced with provided values (3rd parameter) - array( + [ $temp4, 0, '0', 'LINESTRING(5.02 8.45,6.14 0.15,0 0)' - ) - ); + ] + ]; } /** @@ -116,33 +116,33 @@ class GisLineStringTest extends GisGeomTestCase */ public function providerForTestGenerateParams() { - $temp = array( - 'LINESTRING' => array( + $temp = [ + 'LINESTRING' => [ 'no_of_points' => 2, - 0 => array('x' => '5.02', 'y' => '8.45'), - 1 => array('x' => '6.14', 'y' => '0.15') - ) - ); + 0 => ['x' => '5.02', 'y' => '8.45'], + 1 => ['x' => '6.14', 'y' => '0.15'] + ] + ]; $temp1 = $temp; $temp1['gis_type'] = 'LINESTRING'; - return array( - array( + return [ + [ "'LINESTRING(5.02 8.45,6.14 0.15)',124", null, - array( + [ 'srid' => '124', 0 => $temp - ) - ), - array( + ] + ], + [ 'LINESTRING(5.02 8.45,6.14 0.15)', 2, - array( + [ 2 => $temp1 - ) - ) - ); + ] + ] + ]; } /** @@ -152,17 +152,17 @@ class GisLineStringTest extends GisGeomTestCase */ public function providerForTestScaleRow() { - return array( - array( + return [ + [ 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', - array( + [ 'minX' => 12, 'maxX' => 69, 'minY' => 23, 'maxY' => 78 - ) - ) - ); + ] + ] + ]; } /** @@ -197,20 +197,20 @@ class GisLineStringTest extends GisGeomTestCase if (! function_exists('imagecreatetruecolor')) { $this->markTestSkipped('GD extension missing!'); } - return array( - array( + return [ + [ 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', 'image', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], imagecreatetruecolor(120, 150) - ) - ); + ] + ]; } /** @@ -241,20 +241,20 @@ class GisLineStringTest extends GisGeomTestCase */ public function providerForPrepareRowAsPdf() { - return array( - array( + return [ + [ 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', 'pdf', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], new TCPDF(), - ) - ); + ] + ]; } /** @@ -285,22 +285,22 @@ class GisLineStringTest extends GisGeomTestCase */ public function providerForPrepareRowAsSvg() { - return array( - array( + return [ + [ 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', 'svg', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], '/^(<polyline points="0,218 72,138 114,242 26,198 4,182 46,132 " ' . 'name="svg" id="svg)(\d+)(" class="linestring vector" fill="none" ' . 'stroke="#B02EE0" stroke-width="2"\/>)$/' - ) - ); + ] + ]; } /** @@ -334,18 +334,18 @@ class GisLineStringTest extends GisGeomTestCase */ public function providerForPrepareRowAsOl() { - return array( - array( + return [ + [ 'LINESTRING(12 35,48 75,69 23,25 45,14 53,35 78)', 4326, 'Ol', '#B02EE0', - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.' . 'LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject())); bound.extend(new OpenLayers.LonLat' @@ -365,7 +365,7 @@ class GisLineStringTest extends GisGeomTestCase . 'transform(new OpenLayers.Projection("EPSG:4326"), map.' . 'getProjectionObject()))), null, {"strokeColor":"#B02EE0",' . '"strokeWidth":2,"label":"Ol","fontSize":10}));' - ) - ); + ] + ]; } } diff --git a/test/classes/Gis/GisMultiLineStringTest.php b/test/classes/Gis/GisMultiLineStringTest.php index ce63dea1a6..555791e4af 100644 --- a/test/classes/Gis/GisMultiLineStringTest.php +++ b/test/classes/Gis/GisMultiLineStringTest.php @@ -57,23 +57,23 @@ class GisMultiLineStringTest extends GisGeomTestCase */ public function providerForTestGenerateWkt() { - $temp = array( - 0 => array( - 'MULTILINESTRING' => array( + $temp = [ + 0 => [ + 'MULTILINESTRING' => [ 'no_of_lines' => 2, - 0 => array( + 0 => [ 'no_of_points' => 2, - 0 => array('x' => 5.02, 'y' => 8.45), - 1 => array('x' => 6.14, 'y' => 0.15) - ), - 1 => array( + 0 => ['x' => 5.02, 'y' => 8.45], + 1 => ['x' => 6.14, 'y' => 0.15] + ], + 1 => [ 'no_of_points' => 2, - 0 => array('x' => 1.23, 'y' => 4.25), - 1 => array('x' => 9.15, 'y' => 0.47) - ) - ) - ) - ); + 0 => ['x' => 1.23, 'y' => 4.25], + 1 => ['x' => 9.15, 'y' => 0.47] + ] + ] + ] + ]; $temp1 = $temp; unset($temp1[0]['MULTILINESTRING'][1][1]['y']); @@ -84,49 +84,49 @@ class GisMultiLineStringTest extends GisGeomTestCase $temp3 = $temp; $temp3[0]['MULTILINESTRING'][1]['no_of_points'] = 1; - return array( - array( + return [ + [ $temp, 0, null, 'MULTILINESTRING((5.02 8.45,6.14 0.15),(1.23 4.25,9.15 0.47))' - ), + ], // values at undefined index - array( + [ $temp, 1, null, 'MULTILINESTRING(( , ))' - ), + ], // if a coordinate is missing, default is empty string - array( + [ $temp1, 0, null, 'MULTILINESTRING((5.02 8.45,6.14 0.15),(1.23 4.25,9.15 ))' - ), + ], // missing coordinates are replaced with provided values (3rd parameter) - array( + [ $temp1, 0, '0', 'MULTILINESTRING((5.02 8.45,6.14 0.15),(1.23 4.25,9.15 0))' - ), + ], // at least one line should be there - array( + [ $temp2, 0, null, 'MULTILINESTRING((5.02 8.45,6.14 0.15))' - ), + ], // a line should have at least two points - array( + [ $temp3, 0, '0', 'MULTILINESTRING((5.02 8.45,6.14 0.15),(1.23 4.25,9.15 0.47))' - ), - ); + ], + ]; } /** @@ -136,23 +136,23 @@ class GisMultiLineStringTest extends GisGeomTestCase */ public function testGetShape() { - $row_data = array( + $row_data = [ 'numparts' => 2, - 'parts' => array( - 0 => array( - 'points' => array( - 0 => array('x' => 5.02, 'y' => 8.45), - 1 => array('x' => 6.14, 'y' => 0.15), - ), - ), - 1 => array( - 'points' => array( - 0 => array('x' => 1.23, 'y' => 4.25), - 1 => array('x' => 9.15, 'y' => 0.47), - ), - ), - ), - ); + 'parts' => [ + 0 => [ + 'points' => [ + 0 => ['x' => 5.02, 'y' => 8.45], + 1 => ['x' => 6.14, 'y' => 0.15], + ], + ], + 1 => [ + 'points' => [ + 0 => ['x' => 1.23, 'y' => 4.25], + 1 => ['x' => 9.15, 'y' => 0.47], + ], + ], + ], + ]; $this->assertEquals( $this->object->getShape($row_data), @@ -167,42 +167,42 @@ class GisMultiLineStringTest extends GisGeomTestCase */ public function providerForTestGenerateParams() { - $temp = array( - 'MULTILINESTRING' => array( + $temp = [ + 'MULTILINESTRING' => [ 'no_of_lines' => 2, - 0 => array( + 0 => [ 'no_of_points' => 2, - 0 => array('x' => 5.02, 'y' => 8.45), - 1 => array('x' => 6.14, 'y' => 0.15), - ), - 1 => array( + 0 => ['x' => 5.02, 'y' => 8.45], + 1 => ['x' => 6.14, 'y' => 0.15], + ], + 1 => [ 'no_of_points' => 2, - 0 => array('x' => 1.23, 'y' => 4.25), - 1 => array('x' => 9.15, 'y' => 0.47), - ) - ) - ); + 0 => ['x' => 1.23, 'y' => 4.25], + 1 => ['x' => 9.15, 'y' => 0.47], + ] + ] + ]; $temp1 = $temp; $temp1['gis_type'] = 'MULTILINESTRING'; - return array( - array( + return [ + [ "'MULTILINESTRING((5.02 8.45,6.14 0.15),(1.23 4.25,9.15 0.47))',124", null, - array( + [ 'srid' => '124', 0 => $temp - ) - ), - array( + ] + ], + [ 'MULTILINESTRING((5.02 8.45,6.14 0.15),(1.23 4.25,9.15 0.47))', 2, - array( + [ 2 => $temp1 - ) - ) - ); + ] + ] + ]; } /** @@ -212,17 +212,17 @@ class GisMultiLineStringTest extends GisGeomTestCase */ public function providerForTestScaleRow() { - return array( - array( + return [ + [ 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', - array( + [ 'minX' => 17, 'maxX' => 178, 'minY' => 10, 'maxY' => 75 - ) - ) - ); + ] + ] + ]; } @@ -258,20 +258,20 @@ class GisMultiLineStringTest extends GisGeomTestCase if (! function_exists('imagecreatetruecolor')) { $this->markTestSkipped('GD extension missing!'); } - return array( - array( + return [ + [ 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', 'image', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], imagecreatetruecolor(120, 150) - ) - ); + ] + ]; } /** @@ -302,20 +302,20 @@ class GisMultiLineStringTest extends GisGeomTestCase */ public function providerForPrepareRowAsPdf() { - return array( - array( + return [ + [ 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', 'pdf', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], new TCPDF(), - ) - ); + ] + ]; } /** @@ -346,24 +346,24 @@ class GisMultiLineStringTest extends GisGeomTestCase */ public function providerForPrepareRowAsSvg() { - return array( - array( + return [ + [ 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', 'svg', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], '/^(<polyline points="48,260 70,242 100,138 " name="svg" ' . 'class="linestring vector" fill="none" stroke="#B02EE0" ' . 'stroke-width="2" id="svg)(\d+)("\/><polyline points="48,268 10,' . '242 332,182 " name="svg" class="linestring vector" fill="none" ' . 'stroke="#B02EE0" stroke-width="2" id="svg)(\d+)("\/>)$/' - ) - ); + ] + ]; } /** @@ -397,18 +397,18 @@ class GisMultiLineStringTest extends GisGeomTestCase */ public function providerForPrepareRowAsOl() { - return array( - array( + return [ + [ 'MULTILINESTRING((36 14,47 23,62 75),(36 10,17 23,178 53))', 4326, 'Ol', '#B02EE0', - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.' . 'LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject())); bound.extend(new OpenLayers.LonLat' @@ -429,7 +429,7 @@ class GisMultiLineStringTest extends GisGeomTestCase . 'metry.Point(178,53)).transform(new OpenLayers.Projection("EPSG:' . '4326"), map.getProjectionObject()))))), null, {"strokeColor":"' . '#B02EE0","strokeWidth":2,"label":"Ol","fontSize":10}));' - ) - ); + ] + ]; } } diff --git a/test/classes/Gis/GisMultiPointTest.php b/test/classes/Gis/GisMultiPointTest.php index 582107b99a..b976895b58 100644 --- a/test/classes/Gis/GisMultiPointTest.php +++ b/test/classes/Gis/GisMultiPointTest.php @@ -57,39 +57,39 @@ class GisMultiPointTest extends GisGeomTestCase */ public function providerForTestGenerateWkt() { - $gis_data1 = array( - 0 => array( - 'MULTIPOINT' => array( + $gis_data1 = [ + 0 => [ + 'MULTIPOINT' => [ 'no_of_points' => 2, - 0 => array( + 0 => [ 'x' => 5.02, 'y' => 8.45 - ), - 1 => array( + ], + 1 => [ 'x' => 1.56, 'y' => 4.36 - ) - ) - ) - ); + ] + ] + ] + ]; $gis_data2 = $gis_data1; $gis_data2[0]['MULTIPOINT']['no_of_points'] = -1; - return array( - array( + return [ + [ $gis_data1, 0, null, 'MULTIPOINT(5.02 8.45,1.56 4.36)' - ), - array( + ], + [ $gis_data2, 0, null, 'MULTIPOINT(5.02 8.45)' - ) - ); + ] + ]; } /** @@ -99,13 +99,13 @@ class GisMultiPointTest extends GisGeomTestCase */ public function testGetShape() { - $gis_data = array( + $gis_data = [ 'numpoints' => 2, - 'points' => array( - 0 => array('x' => 5.02, 'y' => 8.45), - 1 => array('x' => 6.14, 'y' => 0.15) - ) - ); + 'points' => [ + 0 => ['x' => 5.02, 'y' => 8.45], + 1 => ['x' => 6.14, 'y' => 0.15] + ] + ]; $this->assertEquals( $this->object->getShape($gis_data), @@ -120,33 +120,33 @@ class GisMultiPointTest extends GisGeomTestCase */ public function providerForTestGenerateParams() { - $temp1 = array( - 'MULTIPOINT' => array( + $temp1 = [ + 'MULTIPOINT' => [ 'no_of_points' => 2, - 0 => array('x' => '5.02', 'y' => '8.45'), - 1 => array('x' => '6.14', 'y' => '0.15') - ) - ); + 0 => ['x' => '5.02', 'y' => '8.45'], + 1 => ['x' => '6.14', 'y' => '0.15'] + ] + ]; $temp2 = $temp1; $temp2['gis_type'] = 'MULTIPOINT'; - return array( - array( + return [ + [ "'MULTIPOINT(5.02 8.45,6.14 0.15)',124", null, - array( + [ 'srid' => '124', 0 => $temp1 - ) - ), - array( + ] + ], + [ 'MULTIPOINT(5.02 8.45,6.14 0.15)', 2, - array( + [ 2 => $temp2 - ) - ) - ); + ] + ] + ]; } /** @@ -156,17 +156,17 @@ class GisMultiPointTest extends GisGeomTestCase */ public function providerForTestScaleRow() { - return array( - array( + return [ + [ 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', - array( + [ 'minX' => 12, 'maxX' => 69, 'minY' => 23, 'maxY' => 78 - ) - ) - ); + ] + ] + ]; } @@ -201,20 +201,20 @@ class GisMultiPointTest extends GisGeomTestCase if (! function_exists('imagecreatetruecolor')) { $this->markTestSkipped('GD extension missing!'); } - return array( - array( + return [ + [ 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', 'image', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], imagecreatetruecolor(120, 150), - ) - ); + ] + ]; } /** @@ -245,20 +245,20 @@ class GisMultiPointTest extends GisGeomTestCase */ public function providerForPrepareRowAsPdf() { - return array( - array( + return [ + [ 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', 'pdf', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], new TCPDF(), - ) - ); + ] + ]; } /** @@ -289,17 +289,17 @@ class GisMultiPointTest extends GisGeomTestCase */ public function providerForPrepareRowAsSvg() { - return array( - array( + return [ + [ 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', 'svg', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], '/^(<circle cx="72" cy="138" r="3" name="svg" class="multipoint ' . 'vector" fill="white" stroke="#B02EE0" stroke-width="2" id="svg)' . '(\d+)("\/><circle cx="114" cy="242" r="3" name="svg" class="mult' @@ -311,8 +311,8 @@ class GisMultiPointTest extends GisGeomTestCase . 'width="2" id="svg)(\d+)("\/><circle cx="46" cy="132" r="3" name=' . '"svg" class="multipoint vector" fill="white" stroke="#B02EE0" ' . 'stroke-width="2" id="svg)(\d+)("\/>)$/' - ) - ); + ] + ]; } /** @@ -346,18 +346,18 @@ class GisMultiPointTest extends GisGeomTestCase */ public function providerForPrepareRowAsOl() { - return array( - array( + return [ + [ 'MULTIPOINT(12 35,48 75,69 23,25 45,14 53,35 78)', 4326, 'Ol', '#B02EE0', - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.Lon' . 'Lat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject())); bound.extend(new OpenLayers.LonLat' @@ -378,7 +378,7 @@ class GisMultiPointTest extends GisGeomTestCase . ')))), null, {"pointRadius":3,"fillColor":"#ffffff","strokeColor"' . ':"#B02EE0","strokeWidth":2,"label":"Ol","labelYOffset":-8,' . '"fontSize":10}));' - ) - ); + ] + ]; } } diff --git a/test/classes/Gis/GisMultiPolygonTest.php b/test/classes/Gis/GisMultiPolygonTest.php index 9de3defe33..0e613adc1d 100644 --- a/test/classes/Gis/GisMultiPolygonTest.php +++ b/test/classes/Gis/GisMultiPolygonTest.php @@ -57,39 +57,39 @@ class GisMultiPolygonTest extends GisGeomTestCase */ private function _getData() { - return array( - 'MULTIPOLYGON' => array( + return [ + 'MULTIPOLYGON' => [ 'no_of_polygons' => 2, - 0 => array( + 0 => [ 'no_of_lines' => 2, - 0 => array( + 0 => [ 'no_of_points' => 5, - 0 => array('x' => 35, 'y' => 10), - 1 => array('x' => 10, 'y' => 20), - 2 => array('x' => 15, 'y' => 40), - 3 => array('x' => 45, 'y' => 45), - 4 => array('x' => 35, 'y' => 10), - ), - 1 => array( + 0 => ['x' => 35, 'y' => 10], + 1 => ['x' => 10, 'y' => 20], + 2 => ['x' => 15, 'y' => 40], + 3 => ['x' => 45, 'y' => 45], + 4 => ['x' => 35, 'y' => 10], + ], + 1 => [ 'no_of_points' => 4, - 0 => array('x' => 20, 'y' => 30), - 1 => array('x' => 35, 'y' => 32), - 2 => array('x' => 30, 'y' => 20), - 3 => array('x' => 20, 'y' => 30), - ) - ), - 1 => array( + 0 => ['x' => 20, 'y' => 30], + 1 => ['x' => 35, 'y' => 32], + 2 => ['x' => 30, 'y' => 20], + 3 => ['x' => 20, 'y' => 30], + ] + ], + 1 => [ 'no_of_lines' => 1, - 0 => array( + 0 => [ 'no_of_points' => 4, - 0 => array('x' => 123, 'y' => 0), - 1 => array('x' => 23, 'y' => 30), - 2 => array('x' => 17, 'y' => 63), - 3 => array('x' => 123, 'y' => 0), - ) - ) - ) - ); + 0 => ['x' => 123, 'y' => 0], + 1 => ['x' => 23, 'y' => 30], + 2 => ['x' => 17, 'y' => 63], + 3 => ['x' => 123, 'y' => 0], + ] + ] + ] + ]; } /** @@ -99,9 +99,9 @@ class GisMultiPolygonTest extends GisGeomTestCase */ public function providerForTestGenerateWkt() { - $temp = array( + $temp = [ 0 => $this->_getData() - ); + ]; $temp1 = $temp; $temp1[0]['MULTIPOLYGON']['no_of_polygons'] = 0; @@ -112,39 +112,39 @@ class GisMultiPolygonTest extends GisGeomTestCase $temp3 = $temp; $temp3[0]['MULTIPOLYGON'][1][0]['no_of_points'] = 3; - return array( - array( + return [ + [ $temp, 0, null, 'MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10)' . ',(20 30,35 32,30 20,20 30)),((123 0,23 30,17 63,123 0)))' - ), + ], // at lease one polygon should be there - array( + [ $temp1, 0, null, 'MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10)' . ',(20 30,35 32,30 20,20 30)))' - ), + ], // a polygon should have at least one ring - array( + [ $temp2, 0, null, 'MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10)' . ',(20 30,35 32,30 20,20 30)),((123 0,23 30,17 63,123 0)))' - ), + ], // a ring should have at least four points - array( + [ $temp3, 0, '0', 'MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10)' . ',(20 30,35 32,30 20,20 30)),((123 0,23 30,17 63,123 0)))' - ), - ); + ], + ]; } /** @@ -159,25 +159,25 @@ class GisMultiPolygonTest extends GisGeomTestCase $temp1 = $this->_getData(); $temp1['gis_type'] = 'MULTIPOLYGON'; - return array( - array( + return [ + [ "'MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10)," . "(20 30,35 32,30 20,20 30)),((123 0,23 30,17 63,123 0)))',124", null, - array( + [ 'srid' => '124', 0 => $temp - ) - ), - array( + ] + ], + [ 'MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10)' . ',(20 30,35 32,30 20,20 30)),((123 0,23 30,17 63,123 0)))', 2, - array( + [ 2 => $temp1 - ) - ) - ); + ] + ] + ]; } /** @@ -201,41 +201,41 @@ class GisMultiPolygonTest extends GisGeomTestCase */ public function providerForTestGetShape() { - return array( - array( - array( - 'parts' => array( - 0 => array( - 'points' => array( - 0 => array('x' => 10, 'y' => 10), - 1 => array('x' => 10, 'y' => 40), - 2 => array('x' => 50, 'y' => 40), - 3 => array('x' => 50, 'y' => 10), - 4 => array('x' => 10, 'y' => 10), - ), - ), - 1 => array( - 'points' => array( - 0 => array('x' => 60, 'y' => 40), - 1 => array('x' => 75, 'y' => 65), - 2 => array('x' => 90, 'y' => 40), - 3 => array('x' => 60, 'y' => 40), - ), - ), - 2 => array( - 'points' => array( - 0 => array('x' => 20, 'y' => 20), - 1 => array('x' => 40, 'y' => 20), - 2 => array('x' => 25, 'y' => 30), - 3 => array('x' => 20, 'y' => 20), - ), - ), - ), - ), + return [ + [ + [ + 'parts' => [ + 0 => [ + 'points' => [ + 0 => ['x' => 10, 'y' => 10], + 1 => ['x' => 10, 'y' => 40], + 2 => ['x' => 50, 'y' => 40], + 3 => ['x' => 50, 'y' => 10], + 4 => ['x' => 10, 'y' => 10], + ], + ], + 1 => [ + 'points' => [ + 0 => ['x' => 60, 'y' => 40], + 1 => ['x' => 75, 'y' => 65], + 2 => ['x' => 90, 'y' => 40], + 3 => ['x' => 60, 'y' => 40], + ], + ], + 2 => [ + 'points' => [ + 0 => ['x' => 20, 'y' => 20], + 1 => ['x' => 40, 'y' => 20], + 2 => ['x' => 25, 'y' => 30], + 3 => ['x' => 20, 'y' => 20], + ], + ], + ], + ], 'MULTIPOLYGON(((10 10,10 40,50 40,50 10,10 10),(20 20,40 20,25 30' . ',20 20)),((60 40,75 65,90 40,60 40)))' - ) - ); + ] + ]; } /** @@ -245,28 +245,28 @@ class GisMultiPolygonTest extends GisGeomTestCase */ public function providerForTestScaleRow() { - return array( - array( + return [ + [ 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),' . '((105 0,56 20,78 73,105 0)))', - array( + [ 'minX' => 16, 'maxX' => 147, 'minY' => 0, 'maxY' => 83 - ) - ), - array( + ] + ], + [ 'MULTIPOLYGON(((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20' . ',20 30)),((105 0,56 20,78 73,105 0)))', - array( + [ 'minX' => 10, 'maxX' => 105, 'minY' => 0, 'maxY' => 73 - ) - ) - ); + ] + ] + ]; } @@ -301,22 +301,22 @@ class GisMultiPolygonTest extends GisGeomTestCase if (! function_exists('imagecreatetruecolor')) { $this->markTestSkipped('GD extension missing!'); } - return array( - array( + return [ + [ 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),' . '((105 0,56 20,78 73,105 0)))', 'image', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], imagecreatetruecolor(120, 150), - ) + ] - ); + ]; } /** @@ -347,21 +347,21 @@ class GisMultiPolygonTest extends GisGeomTestCase */ public function providerForPrepareRowAsPdf() { - return array( - array( + return [ + [ 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),' . '((105 0,56 20,78 73,105 0)))', 'pdf', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], new TCPDF(), - ) - ); + ] + ]; } /** @@ -392,18 +392,18 @@ class GisMultiPolygonTest extends GisGeomTestCase */ public function providerForPrepareRowAsSvg() { - return array( - array( + return [ + [ 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),' . '((105 0,56 20,78 73,105 0)))', 'svg', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], '/^(<path d=" M 248, 208 L 270, 122 L 8, 138 Z " name="svg" class="' . 'multipolygon vector" stroke="black" stroke-width="0.5" fill="' . '#B02EE0" fill-rule="evenodd" fill-opacity="0.8" id="svg)(\d+)' @@ -411,8 +411,8 @@ class GisMultiPolygonTest extends GisGeomTestCase . 'class="multipolygon vector" stroke="black" stroke-width="0.5" ' . 'fill="#B02EE0" fill-rule="evenodd" fill-opacity="0.8" id="svg)' . '(\d+)("\/>)$/' - ) - ); + ] + ]; } /** @@ -446,19 +446,19 @@ class GisMultiPolygonTest extends GisGeomTestCase */ public function providerForPrepareRowAsOl() { - return array( - array( + return [ + [ 'MULTIPOLYGON(((136 40,147 83,16 75,136 40)),' . '((105 0,56 20,78 73,105 0)))', 4326, 'Ol', '#B02EE0', - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.' . 'LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject())); bound.extend(new OpenLayers.LonLat' @@ -485,7 +485,7 @@ class GisMultiPolygonTest extends GisGeomTestCase . 'Layers.Projection("EPSG:4326"), map.getProjectionObject()))))))' . '), null, {"strokeColor":"#000000","strokeWidth":0.5,"fillColor":' . '"#B02EE0","fillOpacity":0.8,"label":"Ol","fontSize":10}));' - ) - ); + ] + ]; } } diff --git a/test/classes/Gis/GisPointTest.php b/test/classes/Gis/GisPointTest.php index 17155aac39..73a22561d7 100644 --- a/test/classes/Gis/GisPointTest.php +++ b/test/classes/Gis/GisPointTest.php @@ -57,38 +57,38 @@ class GisPointTest extends GisGeomTestCase */ public function providerForTestGenerateWkt() { - return array( - array( - array(0 => array('POINT' => array('x' => 5.02, 'y' => 8.45))), + return [ + [ + [0 => ['POINT' => ['x' => 5.02, 'y' => 8.45]]], 0, null, 'POINT(5.02 8.45)' - ), - array( - array(0 => array('POINT' => array('x' => 5.02, 'y' => 8.45))), + ], + [ + [0 => ['POINT' => ['x' => 5.02, 'y' => 8.45]]], 1, null, 'POINT( )' - ), - array( - array(0 => array('POINT' => array('x' => 5.02))), + ], + [ + [0 => ['POINT' => ['x' => 5.02]]], 0, null, 'POINT(5.02 )' - ), - array( - array(0 => array('POINT' => array('y' => 8.45))), + ], + [ + [0 => ['POINT' => ['y' => 8.45]]], 0, null, 'POINT( 8.45)' - ), - array( - array(0 => array('POINT' => array())), + ], + [ + [0 => ['POINT' => []]], 0, null, 'POINT( )' - ), - ); + ], + ]; } /** @@ -112,12 +112,12 @@ class GisPointTest extends GisGeomTestCase */ public function providerForTestGetShape() { - return array( - array( - array('x' => 5.02, 'y' => 8.45), + return [ + [ + ['x' => 5.02, 'y' => 8.45], 'POINT(5.02 8.45)' - ) - ); + ] + ]; } /** @@ -127,28 +127,28 @@ class GisPointTest extends GisGeomTestCase */ public function providerForTestGenerateParams() { - return array( - array( + return [ + [ "'POINT(5.02 8.45)',124", null, - array( + [ 'srid' => '124', - 0 => array( - 'POINT' => array('x' => '5.02', 'y' => '8.45') - ), - ) - ), - array( + 0 => [ + 'POINT' => ['x' => '5.02', 'y' => '8.45'] + ], + ] + ], + [ 'POINT(5.02 8.45)', 2, - array( - 2 => array( + [ + 2 => [ 'gis_type' => 'POINT', - 'POINT' => array('x' => '5.02', 'y' => '8.45') - ), - ) - ) - ); + 'POINT' => ['x' => '5.02', 'y' => '8.45'] + ], + ] + ] + ]; } /** @@ -158,17 +158,17 @@ class GisPointTest extends GisGeomTestCase */ public function providerForTestScaleRow() { - return array( - array( + return [ + [ 'POINT(12 35)', - array( + [ 'minX' => 12, 'maxX' => 12, 'minY' => 35, 'maxY' => 35, - ) - ) - ); + ] + ] + ]; } /** @@ -202,20 +202,20 @@ class GisPointTest extends GisGeomTestCase if (! function_exists('imagecreatetruecolor')) { $this->markTestSkipped('GD extension missing!'); } - return array( - array( + return [ + [ 'POINT(12 35)', 'image', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], imagecreatetruecolor(120, 150) - ) - ); + ] + ]; } /** @@ -246,20 +246,20 @@ class GisPointTest extends GisGeomTestCase */ public function providerForPrepareRowAsPdf() { - return array( - array( + return [ + [ 'POINT(12 35)', 'pdf', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], new TCPDF(), - ) - ); + ] + ]; } /** @@ -292,20 +292,20 @@ class GisPointTest extends GisGeomTestCase */ public function providerForPrepareRowAsSvg() { - return array( - array( + return [ + [ 'POINT(12 35)', 'svg', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], '' - ) - ); + ] + ]; } /** @@ -339,18 +339,18 @@ class GisPointTest extends GisGeomTestCase */ public function providerForPrepareRowAsOl() { - return array( - array( + return [ + [ 'POINT(12 35)', 4326, 'Ol', '#B02EE0', - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.' . 'LonLat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject())); bound.extend(new OpenLayers.LonLat' @@ -361,7 +361,7 @@ class GisPointTest extends GisGeomTestCase . 'ProjectionObject()), null, {"pointRadius":3,"fillColor":"#ffffff"' . ',"strokeColor":"#B02EE0","strokeWidth":2,"label":"Ol","labelY' . 'Offset":-8,"fontSize":10}));' - ) - ); + ] + ]; } } diff --git a/test/classes/Gis/GisPolygonTest.php b/test/classes/Gis/GisPolygonTest.php index 4645f75bd1..e75a9cbed8 100644 --- a/test/classes/Gis/GisPolygonTest.php +++ b/test/classes/Gis/GisPolygonTest.php @@ -57,26 +57,26 @@ class GisPolygonTest extends GisGeomTestCase */ private function _getData() { - return array( - 'POLYGON' => array( + return [ + 'POLYGON' => [ 'no_of_lines' => 2, - 0 => array( + 0 => [ 'no_of_points' => 5, - 0 => array('x' => 35, 'y' => 10), - 1 => array('x' => 10, 'y' => 20), - 2 => array('x' => 15, 'y' => 40), - 3 => array('x' => 45, 'y' => 45), - 4 => array('x' => 35, 'y' => 10), - ), - 1 => array( + 0 => ['x' => 35, 'y' => 10], + 1 => ['x' => 10, 'y' => 20], + 2 => ['x' => 15, 'y' => 40], + 3 => ['x' => 45, 'y' => 45], + 4 => ['x' => 35, 'y' => 10], + ], + 1 => [ 'no_of_points' => 4, - 0 => array('x' => 20, 'y' => 30), - 1 => array('x' => 35, 'y' => 32), - 2 => array('x' => 30, 'y' => 20), - 3 => array('x' => 20, 'y' => 30), - ) - ) - ); + 0 => ['x' => 20, 'y' => 30], + 1 => ['x' => 35, 'y' => 32], + 2 => ['x' => 30, 'y' => 20], + 3 => ['x' => 20, 'y' => 30], + ] + ] + ]; } /** @@ -86,9 +86,9 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForTestGenerateWkt() { - $temp = array( + $temp = [ 0 => $this->_getData() - ); + ]; $temp1 = $temp; unset($temp1[0]['POLYGON'][1][3]['y']); @@ -99,49 +99,49 @@ class GisPolygonTest extends GisGeomTestCase $temp3 = $temp; $temp3[0]['POLYGON'][1]['no_of_points'] = 3; - return array( - array( + return [ + [ $temp, 0, null, 'POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30))' - ), + ], // values at undefined index - array( + [ $temp, 1, null, 'POLYGON(( , , , ))' - ), + ], // if a coordinate is missing, default is empty string - array( + [ $temp1, 0, null, 'POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 ))' - ), + ], // missing coordinates are replaced with provided values (3rd parameter) - array( + [ $temp1, 0, '0', 'POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 0))' - ), + ], // should have at least one ring - array( + [ $temp2, 0, '0', 'POLYGON((35 10,10 20,15 40,45 45,35 10))' - ), + ], // a ring should have at least four points - array( + [ $temp3, 0, '0', 'POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30))' - ), - ); + ], + ]; } /** @@ -156,24 +156,24 @@ class GisPolygonTest extends GisGeomTestCase $temp1 = $temp; $temp1['gis_type'] = 'POLYGON'; - return array( - array( + return [ + [ "'POLYGON((35 10,10 20,15 40,45 45,35 10)," . "(20 30,35 32,30 20,20 30))',124", null, - array( + [ 'srid' => '124', 0 => $temp - ) - ), - array( + ] + ], + [ 'POLYGON((35 10,10 20,15 40,45 45,35 10),(20 30,35 32,30 20,20 30))', 2, - array( + [ 2 => $temp1 - ) - ) - ); + ] + ] + ]; } /** @@ -197,35 +197,35 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForTestArea() { - return array( - array( - array( - 0 => array('x' => 35, 'y' => 10), - 1 => array('x' => 10, 'y' => 10), - 2 => array('x' => 15, 'y' => 40) - ), + return [ + [ + [ + 0 => ['x' => 35, 'y' => 10], + 1 => ['x' => 10, 'y' => 10], + 2 => ['x' => 15, 'y' => 40] + ], -375.00 - ), + ], // first point of the ring repeated as the last point - array( - array( - 0 => array('x' => 35, 'y' => 10), - 1 => array('x' => 10, 'y' => 10), - 2 => array('x' => 15, 'y' => 40), - 3 => array('x' => 35, 'y' => 10) - ), + [ + [ + 0 => ['x' => 35, 'y' => 10], + 1 => ['x' => 10, 'y' => 10], + 2 => ['x' => 15, 'y' => 40], + 3 => ['x' => 35, 'y' => 10] + ], -375.00 - ), + ], // anticlockwise gives positive area - array( - array( - 0 => array('x' => 15, 'y' => 40), - 1 => array('x' => 10, 'y' => 10), - 2 => array('x' => 35, 'y' => 10) - ), + [ + [ + 0 => ['x' => 15, 'y' => 40], + 1 => ['x' => 10, 'y' => 10], + 2 => ['x' => 35, 'y' => 10] + ], 375.00 - ) - ); + ] + ]; } /** @@ -253,39 +253,39 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForTestIsPointInsidePolygon() { - $ring = array( - 0 => array('x' => 35, 'y' => 10), - 1 => array('x' => 10, 'y' => 10), - 2 => array('x' => 15, 'y' => 40), - 3 => array('x' => 35, 'y' => 10) - ); - - return array( + $ring = [ + 0 => ['x' => 35, 'y' => 10], + 1 => ['x' => 10, 'y' => 10], + 2 => ['x' => 15, 'y' => 40], + 3 => ['x' => 35, 'y' => 10] + ]; + + return [ // point inside the ring - array( - array('x' => 20, 'y' => 15), + [ + ['x' => 20, 'y' => 15], $ring, true - ), + ], // point on an edge of the ring - array( - array('x' => 20, 'y' => 10), + [ + ['x' => 20, 'y' => 10], $ring, false - ), + ], // point on a vertex of the ring - array( - array('x' => 10, 'y' => 10), + [ + ['x' => 10, 'y' => 10], $ring, false - ), + ], // point outside the ring - array( - array('x' => 5, 'y' => 10), + [ + ['x' => 5, 'y' => 10], $ring, false - ), - ); + ], + ]; } /** @@ -318,14 +318,14 @@ class GisPolygonTest extends GisGeomTestCase unset($temp['POLYGON'][0]['no_of_points']); unset($temp['POLYGON'][1]['no_of_points']); - return array( - array( + return [ + [ $temp['POLYGON'][0] - ), - array( + ], + [ $temp['POLYGON'][1] - ) - ); + ] + ]; } /** @@ -335,27 +335,27 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForTestScaleRow() { - return array( - array( + return [ + [ 'POLYGON((123 0,23 30,17 63,123 0))', - array( + [ 'minX' => 17, 'maxX' => 123, 'minY' => 0, 'maxY' => 63, - ) - ), - array( + ] + ], + [ 'POLYGON((35 10,10 20,15 40,45 45,35 10),' . '(20 30,35 32,30 20,20 30)))', - array( + [ 'minX' => 10, 'maxX' => 45, 'minY' => 10, 'maxY' => 45 - ) - ), - ); + ] + ], + ]; } /** @@ -389,20 +389,20 @@ class GisPolygonTest extends GisGeomTestCase if (! function_exists('imagecreatetruecolor')) { $this->markTestSkipped('GD extension missing!'); } - return array( - array( + return [ + [ 'POLYGON((123 0,23 30,17 63,123 0))', 'image', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], imagecreatetruecolor(120, 150) - ) - ); + ] + ]; } /** @@ -433,20 +433,20 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForPrepareRowAsPdf() { - return array( - array( + return [ + [ 'POLYGON((123 0,23 30,17 63,123 0))', 'pdf', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], new TCPDF(), - ) - ); + ] + ]; } /** @@ -477,23 +477,23 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForPrepareRowAsSvg() { - return array( - array( + return [ + [ 'POLYGON((123 0,23 30,17 63,123 0))', 'svg', '#B02EE0', - array( + [ 'x' => 12, 'y' => 69, 'scale' => 2, 'height' => 150 - ), + ], '/^(<path d=" M 222, 288 L 22, 228 L 10, 162 Z " name="svg" ' . 'id="svg)(\d+)(" class="polygon vector" stroke="black" ' . 'stroke-width="0.5" fill="#B02EE0" fill-rule="evenodd" ' . 'fill-opacity="0.8"\/>)$/' - ) - ); + ] + ]; } /** @@ -527,18 +527,18 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForPrepareRowAsOl() { - return array( - array( + return [ + [ 'POLYGON((123 0,23 30,17 63,123 0))', 4326, 'Ol', '#B02EE0', - array( + [ 'minX' => '0', 'minY' => '0', 'maxX' => '1', 'maxY' => '1', - ), + ], 'bound = new OpenLayers.Bounds(); bound.extend(new OpenLayers.Lon' . 'Lat(0, 0).transform(new OpenLayers.Projection("EPSG:4326"), ' . 'map.getProjectionObject())); bound.extend(new OpenLayers.' @@ -556,8 +556,8 @@ class GisPolygonTest extends GisGeomTestCase . '("EPSG:4326"), map.getProjectionObject()))))), null, {"stroke' . 'Color":"#000000","strokeWidth":0.5,"fillColor":"#B02EE0",' . '"fillOpacity":0.8,"label":"Ol","fontSize":10}));' - ) - ); + ] + ]; } /** @@ -580,15 +580,15 @@ class GisPolygonTest extends GisGeomTestCase */ public function providerForIsOuterRing() { - return array( - array( - array( - array('x' => 0, 'y' => 0), - array('x' => 0, 'y' => 1), - array('x' => 1, 'y' => 1), - array('x' => 1, 'y' => 0) - ), - ) - ); + return [ + [ + [ + ['x' => 0, 'y' => 0], + ['x' => 0, 'y' => 1], + ['x' => 1, 'y' => 1], + ['x' => 1, 'y' => 0] + ], + ] + ]; } } diff --git a/test/classes/ImportTest.php b/test/classes/ImportTest.php index 10d3090e89..31277c7a24 100644 --- a/test/classes/ImportTest.php +++ b/test/classes/ImportTest.php @@ -92,37 +92,37 @@ class ImportTest extends TestCase function testLookForUse() { $this->assertEquals( - array(null, null), + [null, null], $this->import->lookForUse(null, null, null) ); $this->assertEquals( - array('myDb', null), + ['myDb', null], $this->import->lookForUse(null, 'myDb', null) ); $this->assertEquals( - array('myDb', true), + ['myDb', true], $this->import->lookForUse(null, 'myDb', true) ); $this->assertEquals( - array('myDb', true), + ['myDb', true], $this->import->lookForUse('select 1 from myTable', 'myDb', true) ); $this->assertEquals( - array('anotherDb', true), + ['anotherDb', true], $this->import->lookForUse('use anotherDb', 'myDb', false) ); $this->assertEquals( - array('anotherDb', true), + ['anotherDb', true], $this->import->lookForUse('use anotherDb', 'myDb', true) ); $this->assertEquals( - array('anotherDb', true), + ['anotherDb', true], $this->import->lookForUse('use `anotherDb`;', 'myDb', true) ); } @@ -149,14 +149,14 @@ class ImportTest extends TestCase */ function provGetColumnAlphaName() { - return array( - array('A', 1), - array('Z', 0), - array('AA', 27), - array('AZ', 52), - array('BA', 53), - array('BB', 54), - ); + return [ + ['A', 1], + ['Z', 0], + ['AA', 27], + ['AZ', 52], + ['BA', 53], + ['BB', 54], + ]; } /** @@ -181,14 +181,14 @@ class ImportTest extends TestCase */ function provGetColumnNumberFromName() { - return array( - array(1, 'A'), - array(26, 'Z'), - array(27, 'AA'), - array(52, 'AZ'), - array(53, 'BA'), - array(54, 'BB'), - ); + return [ + [1, 'A'], + [26, 'Z'], + [27, 'AA'], + [52, 'AZ'], + [53, 'BA'], + [54, 'BB'], + ]; } /** @@ -213,12 +213,12 @@ class ImportTest extends TestCase */ function provGetDecimalPrecision() { - return array( - array(2, '2,1'), - array(6, '6,2'), - array(6, '6,0'), - array(16, '16,2'), - ); + return [ + [2, '2,1'], + [6, '6,2'], + [6, '6,0'], + [16, '16,2'], + ]; } /** @@ -243,12 +243,12 @@ class ImportTest extends TestCase */ function provGetDecimalScale() { - return array( - array(1, '2,1'), - array(2, '6,2'), - array(0, '6,0'), - array(20, '30,20'), - ); + return [ + [1, '2,1'], + [2, '6,2'], + [0, '6,0'], + [20, '30,20'], + ]; } /** @@ -273,12 +273,12 @@ class ImportTest extends TestCase */ function provGetDecimalSize() { - return array( - array(array(2, 1, '2,1'), '2.1'), - array(array(2, 1, '2,1'), '6.2'), - array(array(3, 1, '3,1'), '10.0'), - array(array(4, 2, '4,2'), '30.20'), - ); + return [ + [[2, 1, '2,1'], '2.1'], + [[2, 1, '2,1'], '6.2'], + [[3, 1, '3,1'], '10.0'], + [[4, 2, '4,2'], '30.20'], + ]; } /** @@ -306,21 +306,21 @@ class ImportTest extends TestCase */ function provDetectType() { - return array( - array(Import::NONE, null, 'NULL'), - array(Import::NONE, Import::NONE, 'NULL'), - array(Import::INT, Import::INT, 'NULL'), - array(Import::VARCHAR, Import::VARCHAR, 'NULL'), - array(Import::VARCHAR, null, null), - array(Import::VARCHAR, Import::INT, null), - array(Import::INT, Import::INT, '10'), - array(Import::DECIMAL, Import::DECIMAL, '10.2'), - array(Import::DECIMAL, Import::INT, '10.2'), - array(Import::BIGINT, Import::BIGINT, '2147483648'), - array(Import::BIGINT, Import::INT, '2147483648'), - array(Import::VARCHAR, Import::VARCHAR, 'test'), - array(Import::VARCHAR, Import::INT, 'test'), - ); + return [ + [Import::NONE, null, 'NULL'], + [Import::NONE, Import::NONE, 'NULL'], + [Import::INT, Import::INT, 'NULL'], + [Import::VARCHAR, Import::VARCHAR, 'NULL'], + [Import::VARCHAR, null, null], + [Import::VARCHAR, Import::INT, null], + [Import::INT, Import::INT, '10'], + [Import::DECIMAL, Import::DECIMAL, '10.2'], + [Import::DECIMAL, Import::INT, '10.2'], + [Import::BIGINT, Import::BIGINT, '2147483648'], + [Import::BIGINT, Import::INT, '2147483648'], + [Import::VARCHAR, Import::VARCHAR, 'test'], + [Import::VARCHAR, Import::INT, 'test'], + ]; } /** @@ -347,7 +347,7 @@ class ImportTest extends TestCase $dbi->expects($this->any()) ->method('numRows') - ->with(array()) + ->with([]) ->will($this->returnValue(2)); $dbi->expects($this->any()) @@ -358,12 +358,12 @@ class ImportTest extends TestCase $dbi->expects($this->at(1)) ->method('tryQuery') ->with($simulated_update_query) - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $dbi->expects($this->at(4)) ->method('tryQuery') ->with($simulated_delete_query) - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $GLOBALS['dbi'] = $dbi; @@ -382,29 +382,29 @@ class ImportTest extends TestCase function simulatedQueryTest($sql_query, $simulated_query) { $parser = new Parser($sql_query); - $analyzed_sql_results = array( + $analyzed_sql_results = [ 'query' => $sql_query, 'parser' => $parser, 'statement' => $parser->statements[0], - ); + ]; $simulated_data = $this->import->getMatchedRows($analyzed_sql_results); // URL to matched rows. - $_url_params = array( + $_url_params = [ 'db' => 'PMA', 'sql_query' => $simulated_query - ); + ]; $matched_rows_url = 'sql.php' . Url::getCommon($_url_params); $this->assertEquals( - array( + [ 'sql_query' => Util::formatSql( $analyzed_sql_results['query'] ), 'matched_rows' => 2, 'matched_rows_url' => $matched_rows_url - ), + ], $simulated_data ); } @@ -423,7 +423,7 @@ class ImportTest extends TestCase ->getMock(); // List of Transactional Engines. - $transactional_engines = array( + $transactional_engines = [ 'INNODB', 'FALCON', 'NDB', @@ -432,7 +432,7 @@ class ImportTest extends TestCase 'XTRADB', 'SEQUENCE', 'BDB' - ); + ]; $check_query = 'SELECT `ENGINE` FROM `information_schema`.`tables` ' . 'WHERE `table_name` = "%s" ' @@ -447,7 +447,7 @@ class ImportTest extends TestCase $dbi->expects($this->at(0)) ->method('tryQuery') ->with(sprintf($check_table_query, 'PMA', 'table_1')) - ->will($this->returnValue(array('table'))); + ->will($this->returnValue(['table'])); $dbi->expects($this->at(1)) ->method('tryQuery') @@ -461,7 +461,7 @@ class ImportTest extends TestCase $dbi->expects($this->at(3)) ->method('tryQuery') ->with(sprintf($check_table_query, 'PMA', 'table_2')) - ->will($this->returnValue(array('table'))); + ->will($this->returnValue(['table'])); $dbi->expects($this->at(4)) ->method('tryQuery') diff --git a/test/classes/IndexTest.php b/test/classes/IndexTest.php index 139455dc80..d3ac4e2400 100644 --- a/test/classes/IndexTest.php +++ b/test/classes/IndexTest.php @@ -19,7 +19,7 @@ use PhpMyAdmin\Tests\PmaTestCase; */ class IndexTest extends PmaTestCase { - private $_params = array(); + private $_params = []; /** * Configures parameters. @@ -38,18 +38,18 @@ class IndexTest extends PmaTestCase $this->_params['Packed'] = "PMA_Packed"; //test add columns - $column1 = array("Column_name"=>"column1","Seq_in_index"=>"index1", + $column1 = ["Column_name"=>"column1","Seq_in_index"=>"index1", "Collation"=>"Collation1","Cardinality"=>"Cardinality1", "Null"=>"null1" - ); - $column2 = array("Column_name"=>"column2","Seq_in_index"=>"index2", + ]; + $column2 = ["Column_name"=>"column2","Seq_in_index"=>"index2", "Collation"=>"Collation2","Cardinality"=>"Cardinality2", "Null"=>"null2" - ); - $column3 = array("Column_name"=>"column3","Seq_in_index"=>"index3", + ]; + $column3 = ["Column_name"=>"column3","Seq_in_index"=>"index3", "Collation"=>"Collation3","Cardinality"=>"Cardinality3", "Null"=>"null3" - ); + ]; $this->_params['columns'][] = $column1; $this->_params['columns'][] = $column2; $this->_params['columns'][] = $column3; diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php index 2f40cbd79e..9a6b881aac 100644 --- a/test/classes/InsertEditTest.php +++ b/test/classes/InsertEditTest.php @@ -97,17 +97,17 @@ class InsertEditTest extends TestCase */ public function testGetFormParametersForInsertForm() { - $where_clause = array('foo' => 'bar ', '1' => ' test'); + $where_clause = ['foo' => 'bar ', '1' => ' test']; $_REQUEST['clause_is_unique'] = false; $_POST['sql_query'] = 'SELECT a'; $GLOBALS['goto'] = 'index.php'; $result = $this->insertEdit->getFormParametersForInsertForm( - 'dbname', 'tablename', array(), $where_clause, 'localhost' + 'dbname', 'tablename', [], $where_clause, 'localhost' ); $this->assertEquals( - array( + [ 'db' => 'dbname', 'table' => 'tablename', 'goto' => 'index.php', @@ -116,7 +116,7 @@ class InsertEditTest extends TestCase 'where_clause[foo]' => 'bar', 'where_clause[1]' => 'test', 'clause_is_unique' => false - ), + ], $result ); } @@ -129,17 +129,17 @@ class InsertEditTest extends TestCase public function testGetWhereClauseArray() { $this->assertEquals( - array(), + [], $this->callProtectedMethod('getWhereClauseArray', [null]) ); $this->assertEquals( - array(1, 2, 3), + [1, 2, 3], $this->callProtectedMethod('getWhereClauseArray', [[1, 2, 3]]) ); $this->assertEquals( - array('clause'), + ['clause'], $this->callProtectedMethod('getWhereClauseArray', ['clause']) ); } @@ -151,7 +151,7 @@ class InsertEditTest extends TestCase */ public function testAnalyzeWhereClause() { - $clauses = array('a=1', 'b="fo\o"'); + $clauses = ['a=1', 'b="fo\o"']; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -167,15 +167,15 @@ class InsertEditTest extends TestCase $dbi->expects($this->exactly(2)) ->method('fetchAssoc') ->willReturnOnConsecutiveCalls( - array('assoc1'), - array('assoc2') + ['assoc1'], + ['assoc2'] ); $dbi->expects($this->exactly(2)) ->method('getFieldsMeta') ->willReturnOnConsecutiveCalls( - array(), - array() + [], + [] ); $GLOBALS['dbi'] = $dbi; @@ -187,15 +187,15 @@ class InsertEditTest extends TestCase ]); $this->assertEquals( - array( - array('a=1', 'b="fo\\\\o"'), - array('result1', 'result2'), - array( - array('assoc1'), - array('assoc2') - ), + [ + ['a=1', 'b="fo\\\\o"'], + ['result1', 'result2'], + [ + ['assoc1'], + ['assoc2'] + ], '' - ), + ], $result ); } @@ -212,7 +212,7 @@ class InsertEditTest extends TestCase $temp->table = 'table'; $temp->type = 'real'; $temp->primary_key = 1; - $meta_arr = array($temp); + $meta_arr = [$temp]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -227,8 +227,8 @@ class InsertEditTest extends TestCase $this->insertEdit = new InsertEdit($GLOBALS['dbi']); $result = $this->callProtectedMethod('showEmptyResultMessageOrSetUniqueCondition', [ - array('1' => array('1' => 1)), 1, array(), - 'SELECT', array('1' => 'result1') + ['1' => ['1' => 1]], 1, [], + 'SELECT', ['1' => 'result1'] ]); $this->assertTrue($result); @@ -238,7 +238,7 @@ class InsertEditTest extends TestCase $responseMock = $this->getMockBuilder('PhpMyAdmin\Response') ->disableOriginalConstructor() - ->setMethods(array('addHtml')) + ->setMethods(['addHtml']) ->getMock(); $restoreInstance = Response::getInstance(); @@ -247,7 +247,7 @@ class InsertEditTest extends TestCase $response->setValue($responseMock); $result = $this->callProtectedMethod('showEmptyResultMessageOrSetUniqueCondition', [ - array(false), 0, array('1'), 'SELECT', array('1' => 'result1') + [false], 0, ['1'], 'SELECT', ['1' => 'result1'] ]); $response->setValue($restoreInstance); @@ -283,7 +283,7 @@ class InsertEditTest extends TestCase $result = $this->callProtectedMethod('loadFirstRow', ['table', 'db']); $this->assertEquals( - array('result1', array(false, false)), + ['result1', [false, false]], $result ); } @@ -295,17 +295,17 @@ class InsertEditTest extends TestCase */ public function testUrlParamsInEditMode() { - $where_clause_array = array('foo=1', 'bar=2'); + $where_clause_array = ['foo=1', 'bar=2']; $_POST['sql_query'] = 'SELECT 1'; - $result = $this->insertEdit->urlParamsInEditMode(array(1), $where_clause_array, ''); + $result = $this->insertEdit->urlParamsInEditMode([1], $where_clause_array, ''); $this->assertEquals( - array( + [ '0' => 1, 'where_clause' => 'bar=2', 'sql_query' => 'SELECT 1' - ), + ], $result ); } @@ -319,7 +319,7 @@ class InsertEditTest extends TestCase { $GLOBALS['cfg']['ShowFieldTypesInDataEditView'] = true; $GLOBALS['cfg']['ServerDefault'] = 1; - $url_params = array('ShowFunctionFields' => 2); + $url_params = ['ShowFunctionFields' => 2]; $result = $this->insertEdit->showTypeOrFunction('function', $url_params, false); @@ -368,14 +368,14 @@ class InsertEditTest extends TestCase */ public function testAnalyzeTableColumnsArray() { - $column = array( + $column = [ 'Field' => '1<2', 'Field_md5' => 'pswd', 'Type' => 'float(10, 1)' - ); + ]; $result = $this->callProtectedMethod('analyzeTableColumnsArray', [ - $column, array(), false + $column, [], false ]); $this->assertEquals( @@ -441,18 +441,18 @@ class InsertEditTest extends TestCase */ public function testGetColumnTitle() { - $column = array(); + $column = []; $column['Field'] = 'f1<'; $column['Field_html'] = 'f1<'; $this->assertEquals( $this->callProtectedMethod('getColumnTitle', [ - $column, array() + $column, [] ]), 'f1<' ); - $comments = array(); + $comments = []; $comments['f1<'] = 'comment>'; $result = $this->callProtectedMethod('getColumnTitle', [ @@ -477,8 +477,8 @@ class InsertEditTest extends TestCase */ public function testIsColumn() { - $column = array(); - $types = array('binary', 'varbinary'); + $column = []; + $types = ['binary', 'varbinary']; $column['Type'] = 'binaryfoo'; $this->assertTrue($this->insertEdit->isColumn($column, $types)); @@ -492,7 +492,7 @@ class InsertEditTest extends TestCase $column['Type'] = 'barbinaryfoo'; $this->assertFalse($this->insertEdit->isColumn($column, $types)); - $types = array('char', 'varchar'); + $types = ['char', 'varchar']; $column['Type'] = 'char(10)'; $this->assertTrue($this->insertEdit->isColumn($column, $types)); @@ -503,7 +503,7 @@ class InsertEditTest extends TestCase $column['Type'] = 'foochar'; $this->assertFalse($this->insertEdit->isColumn($column, $types)); - $types = array('blob', 'tinyblob', 'mediumblob', 'longblob'); + $types = ['blob', 'tinyblob', 'mediumblob', 'longblob']; $column['Type'] = 'blob'; $this->assertTrue($this->insertEdit->isColumn($column, $types)); @@ -531,10 +531,10 @@ class InsertEditTest extends TestCase */ public function testGetEnumAndTimestampColumns() { - $column = array(); + $column = []; $column['True_Type'] = 'set'; $this->assertEquals( - array('set', '', false), + ['set', '', false], $this->callProtectedMethod('getEnumSetAndTimestampColumns', [ $column, false ]) @@ -542,7 +542,7 @@ class InsertEditTest extends TestCase $column['True_Type'] = 'enum'; $this->assertEquals( - array('enum', '', false), + ['enum', '', false], $this->callProtectedMethod('getEnumSetAndTimestampColumns', [ $column, false ]) @@ -551,7 +551,7 @@ class InsertEditTest extends TestCase $column['True_Type'] = 'timestamp'; $column['Type'] = 'date'; $this->assertEquals( - array('date', ' nowrap', true), + ['date', ' nowrap', true], $this->callProtectedMethod('getEnumSetAndTimestampColumns', [ $column, false ]) @@ -560,7 +560,7 @@ class InsertEditTest extends TestCase $column['True_Type'] = 'timestamp'; $column['Type'] = 'date'; $this->assertEquals( - array('date', ' nowrap', false), + ['date', ' nowrap', false], $this->callProtectedMethod('getEnumSetAndTimestampColumns', [ $column, true ]) @@ -569,7 +569,7 @@ class InsertEditTest extends TestCase $column['True_Type'] = 'SET'; $column['Type'] = 'num'; $this->assertEquals( - array('num', ' nowrap', false), + ['num', ' nowrap', false], $this->callProtectedMethod('getEnumSetAndTimestampColumns', [ $column, false ]) @@ -578,7 +578,7 @@ class InsertEditTest extends TestCase $column['True_Type'] = ''; $column['Type'] = 'num'; $this->assertEquals( - array('num', ' nowrap', false), + ['num', ' nowrap', false], $this->callProtectedMethod('getEnumSetAndTimestampColumns', [ $column, false ]) @@ -593,12 +593,12 @@ class InsertEditTest extends TestCase public function testGetFunctionColumn() { $GLOBALS['cfg']['ProtectBinary'] = 'blob'; - $column = array(); + $column = []; $column['is_blob'] = true; $this->assertContains( '<td class="center">Binary</td>', $this->callProtectedMethod('getFunctionColumn', [ - $column, false, '', '', array(), 0, 0, 0, false, false, array() + $column, false, '', '', [], 0, 0, 0, false, false, [] ]) ); @@ -607,7 +607,7 @@ class InsertEditTest extends TestCase $this->assertContains( '<td class="center">Binary</td>', $this->callProtectedMethod('getFunctionColumn', [ - $column, true, '', '', array(), 0, 0, 0, false, false, array() + $column, true, '', '', [], 0, 0, 0, false, false, [] ]) ); @@ -616,7 +616,7 @@ class InsertEditTest extends TestCase $this->assertContains( '<td class="center">Binary</td>', $this->callProtectedMethod('getFunctionColumn', [ - $column, true, '', '', array(), 0, 0, 0, false, false, array() + $column, true, '', '', [], 0, 0, 0, false, false, [] ]) ); @@ -625,7 +625,7 @@ class InsertEditTest extends TestCase $this->assertContains( '<td class="center">--</td>', $this->callProtectedMethod('getFunctionColumn', [ - $column, true, '', '', array(), 0, 0, 0, false, false, array() + $column, true, '', '', [], 0, 0, 0, false, false, [] ]) ); @@ -633,7 +633,7 @@ class InsertEditTest extends TestCase $this->assertContains( '<td class="center">--</td>', $this->callProtectedMethod('getFunctionColumn', [ - $column, true, '', '', array(), 0, 0, 0, false, false, array() + $column, true, '', '', [], 0, 0, 0, false, false, [] ]) ); @@ -642,7 +642,7 @@ class InsertEditTest extends TestCase $this->assertContains( '<td class="center">--</td>', $this->callProtectedMethod('getFunctionColumn', [ - $column, true, '', '', array('int'), 0, 0, 0, false, false, array() + $column, true, '', '', ['int'], 0, 0, 0, false, false, [] ]) ); @@ -650,7 +650,7 @@ class InsertEditTest extends TestCase $this->assertContains( '<select name="funcsa" b tabindex="5" id="field_3_1"', $this->callProtectedMethod('getFunctionColumn', [ - $column, true, 'a', 'b', array(), 2, 3, 3, false, false, array() + $column, true, 'a', 'b', [], 2, 3, 3, false, false, [] ]) ); } @@ -662,18 +662,18 @@ class InsertEditTest extends TestCase */ public function testGetNullColumn() { - $column = array('Field' => ''); + $column = ['Field' => '']; $column['Null'] = 'YES'; $column['first_timestamp'] = false; $column['True_Type'] = 'enum'; $column['Type'] = 0; $column['Field_md5'] = 'foobar'; - $foreigners = array( - 'foreign_keys_data' => array() - ); + $foreigners = [ + 'foreign_keys_data' => [] + ]; $result = $this->callProtectedMethod('getNullColumn', [ - $column, 'a', true, 2, 0, 1, "<script>", $foreigners, array(), false + $column, 'a', true, 2, 0, 1, "<script>", $foreigners, [], false ]); $this->assertContains( @@ -708,7 +708,7 @@ class InsertEditTest extends TestCase // case 2 $column['Null'] = 'NO'; $result = $this->callProtectedMethod('getNullColumn', [ - $column, 'a', true, 2, 0, 1, "<script>", array(), array(), false + $column, 'a', true, 2, 0, 1, "<script>", [], [], false ]); $this->assertEquals( @@ -719,7 +719,7 @@ class InsertEditTest extends TestCase // case 3 $column['Null'] = 'YES'; $result = $this->callProtectedMethod('getNullColumn', [ - $column, 'a', true, 2, 0, 1, "<script>", array(), array(), true + $column, 'a', true, 2, 0, 1, "<script>", [], [], true ]); $this->assertEquals( @@ -735,17 +735,17 @@ class InsertEditTest extends TestCase */ public function testGetNullifyCodeForNullColumn() { - $column = $foreignData = array(); - $foreigners = array( - 'foreign_keys_data' => array() - ); + $column = $foreignData = []; + $foreigners = [ + 'foreign_keys_data' => [] + ]; $column['Field'] = 'f'; $column['True_Type'] = 'enum'; $column['Type'] = 'ababababababababababa'; $this->assertEquals( '1', $this->callProtectedMethod('getNullifyCodeForNullColumn', [ - $column, $foreigners, array() + $column, $foreigners, [] ]) ); @@ -754,7 +754,7 @@ class InsertEditTest extends TestCase $this->assertEquals( '2', $this->callProtectedMethod('getNullifyCodeForNullColumn', [ - $column, $foreigners, array() + $column, $foreigners, [] ]) ); @@ -762,7 +762,7 @@ class InsertEditTest extends TestCase $this->assertEquals( '3', $this->callProtectedMethod('getNullifyCodeForNullColumn', [ - $column, $foreigners, array() + $column, $foreigners, [] ]) ); @@ -784,12 +784,12 @@ class InsertEditTest extends TestCase */ public function testGetForeignLink() { - $column = $titles = array(); + $column = $titles = []; $column['Field'] = 'f'; $titles['Browse'] = "'"; $GLOBALS['cfg']['ServerDefault'] = 2; $result = $this->callProtectedMethod('getForeignLink', [ - $column, 'a', 'b', 'd', 2, 0, 1, "abc", array('tbl', 'db'), 8, + $column, 'a', 'b', 'd', 2, 0, 1, "abc", ['tbl', 'db'], 8, $titles, false ]); @@ -819,10 +819,10 @@ class InsertEditTest extends TestCase */ public function testDispRowForeignData() { - $column = array(); + $column = []; $column['is_binary'] = false; - $foreignData = array(); - $foreignData['disp_row'] = array(); + $foreignData = []; + $foreignData['disp_row'] = []; $foreignData['foreign_field'] = null; $foreignData['foreign_display'] = null; $GLOBALS['cfg']['ForeignKeyMaxLimit'] = 1; @@ -855,10 +855,10 @@ class InsertEditTest extends TestCase */ public function testDispRowForeignDataWithHex() { - $column = array(); + $column = []; $column['is_binary'] = true; - $foreignData = array(); - $foreignData['disp_row'] = array(); + $foreignData = []; + $foreignData['disp_row'] = []; $foreignData['foreign_field'] = null; $foreignData['foreign_display'] = null; $GLOBALS['cfg']['ForeignKeyMaxLimit'] = 1; @@ -897,7 +897,7 @@ class InsertEditTest extends TestCase $GLOBALS['cfg']['CharTextareaCols'] = 1; $GLOBALS['cfg']['LimitChars'] = 20; - $column = array(); + $column = []; $column['is_char'] = true; $column['Type'] = 'char(10)'; $column['True_Type'] = 'char'; @@ -920,15 +920,15 @@ class InsertEditTest extends TestCase */ public function testGetPmaTypeEnum() { - $extracted_columnspec = $column = array(); - $extracted_columnspec['enum_set_values'] = array(); + $extracted_columnspec = $column = []; + $extracted_columnspec['enum_set_values'] = []; $column['Type'] = 'abababababababababab'; - $column['values'] = array( - array( + $column['values'] = [ + [ 'html' => 'foo', 'plain' => 'data' - ) - ); + ] + ]; $result = $this->callProtectedMethod('getPmaTypeEnum', [ $column, 'a', 'b', $extracted_columnspec, 'd', 2, 0, 1, 'foobar', false @@ -969,10 +969,10 @@ class InsertEditTest extends TestCase */ public function testGetColumnEnumValues() { - $extracted_columnspec = $column = array(); - $extracted_columnspec['enum_set_values'] = array( + $extracted_columnspec = $column = []; + $extracted_columnspec['enum_set_values'] = [ '<abc>', '"foo"' - ); + ]; $column['values'] = 'abc'; @@ -980,10 +980,10 @@ class InsertEditTest extends TestCase $column, $extracted_columnspec ]); $this->assertEquals( - array( - array('plain' => '<abc>', 'html' => '<abc>'), - array('plain' => '"foo"', 'html' => '"foo"'), - ), + [ + ['plain' => '<abc>', 'html' => '<abc>'], + ['plain' => '"foo"', 'html' => '"foo"'], + ], $result ); } @@ -995,19 +995,19 @@ class InsertEditTest extends TestCase */ public function testGetDropDownDependingOnLength() { - $column_enum_values = array( - array( + $column_enum_values = [ + [ 'html' => 'foo', 'plain' => 'data' - ), - array( + ], + [ 'html' => 'bar', 'plain' => '' - ) - ); + ] + ]; $result = $this->callProtectedMethod('getDropDownDependingOnLength', [ - array(), 'a', 'b', 2, 0, 1, 'data', $column_enum_values, false + [], 'a', 'b', 2, 0, 1, 'data', $column_enum_values, false ]); $this->assertContains( @@ -1027,14 +1027,14 @@ class InsertEditTest extends TestCase ); // case 2 - $column_enum_values = array( - array( + $column_enum_values = [ + [ 'html' => 'foo', 'plain' => 'data' - ) - ); + ] + ]; - $column = array(); + $column = []; $column['Default'] = 'data'; $column['Null'] = 'YES'; $result = $this->callProtectedMethod('getDropDownDependingOnLength', [ @@ -1054,19 +1054,19 @@ class InsertEditTest extends TestCase */ public function testGetRadioButtonDependingOnLength() { - $column_enum_values = array( - array( + $column_enum_values = [ + [ 'html' => 'foo', 'plain' => 'data' - ), - array( + ], + [ 'html' => 'bar', 'plain' => '' - ) - ); + ] + ]; $result = $this->callProtectedMethod('getRadioButtonDependingOnLength', [ - 'a', 'b', 2, array(), 0, 1, 'data', $column_enum_values, false + 'a', 'b', 2, [], 0, 1, 'data', $column_enum_values, false ]); $this->assertContains( @@ -1092,14 +1092,14 @@ class InsertEditTest extends TestCase ); // case 2 - $column_enum_values = array( - array( + $column_enum_values = [ + [ 'html' => 'foo', 'plain' => 'data' - ) - ); + ] + ]; - $column = array(); + $column = []; $column['Default'] = 'data'; $column['Null'] = 'YES'; $result = $this->callProtectedMethod('getRadioButtonDependingOnLength', [ @@ -1120,18 +1120,18 @@ class InsertEditTest extends TestCase */ public function testGetPmaTypeSet() { - $column = array(); - $column['values'] = array( - array( + $column = []; + $column['values'] = [ + [ 'html' => '<', 'plain' => '<' - ) - ); + ] + ]; $column['select_size'] = 1; $result = $this->callProtectedMethod('getPmaTypeSet', [ - $column, array(), 'a', 'b', 'c', 2, 0, 1, 'data,<', false + $column, [], 'a', 'b', 'c', 2, 0, 1, 'data,<', false ]); $this->assertContains("a\n", $result); @@ -1160,34 +1160,34 @@ class InsertEditTest extends TestCase */ public function testGetColumnSetValueAndSelectSize() { - $extracted_columnspec = $column = array(); - $extracted_columnspec['enum_set_values'] = array('a', '<'); + $extracted_columnspec = $column = []; + $extracted_columnspec['enum_set_values'] = ['a', '<']; $result = $this->callProtectedMethod('getColumnSetValueAndSelectSize', [ - array(), $extracted_columnspec + [], $extracted_columnspec ]); $this->assertEquals( - array( - array( - array('plain' => 'a', 'html' => 'a'), - array('plain' => '<', 'html' => '<') - ), + [ + [ + ['plain' => 'a', 'html' => 'a'], + ['plain' => '<', 'html' => '<'] + ], 2 - ), + ], $result ); - $column['values'] = array(1, 2); + $column['values'] = [1, 2]; $column['select_size'] = 3; $result = $this->callProtectedMethod('getColumnSetValueAndSelectSize', [ $column, $extracted_columnspec ]); $this->assertEquals( - array( - array(1, 2), + [ + [1, 2], 3 - ), + ], $result ); } @@ -1201,7 +1201,7 @@ class InsertEditTest extends TestCase { $GLOBALS['cfg']['ProtectBinary'] = 'blob'; $GLOBALS['cfg']['ShowFunctionFields'] = true; - $column = array(); + $column = []; $column['is_blob'] = true; $column['Field_md5'] = '123'; $column['pma_type'] = 'blob'; @@ -1338,7 +1338,7 @@ class InsertEditTest extends TestCase public function testGetHTMLinput() { $GLOBALS['cfg']['ShowFunctionFields'] = true; - $column = array(); + $column = []; $column['pma_type'] = 'date'; $column['True_Type'] = 'date'; $result = $this->callProtectedMethod('getHtmlInput', [ @@ -1384,14 +1384,14 @@ class InsertEditTest extends TestCase public function testGetMaxUploadSize() { $GLOBALS['max_upload_size'] = 257; - $column = array(); + $column = []; $column['pma_type'] = 'tinyblob'; $result = $this->callProtectedMethod('getMaxUploadSize', [ $column, 256 ]); $this->assertEquals( - array("(Max: 256B)\n", 256), + ["(Max: 256B)\n", 256], $result ); @@ -1403,7 +1403,7 @@ class InsertEditTest extends TestCase ]); $this->assertEquals( - array("(Max: 250B)\n", 250), + ["(Max: 250B)\n", 250], $result ); } @@ -1415,7 +1415,7 @@ class InsertEditTest extends TestCase */ public function testGetValueColumnForOtherDatatypes() { - $column = array(); + $column = []; $column['len'] = 20; $column['is_char'] = true; $column['Type'] = 'char(25)'; @@ -1430,7 +1430,7 @@ class InsertEditTest extends TestCase $GLOBALS['cfg']['LimitChars'] = 50; $GLOBALS['cfg']['ShowFunctionFields'] = true; - $extracted_columnspec = array(); + $extracted_columnspec = []; $extracted_columnspec['spec_in_brackets'] = 25; $result = $this->callProtectedMethod('getValueColumnForOtherDatatypes', [ $column, 'defchar', 'a', 'b', 'c', 22, '<', 12, 1, "/", "<", @@ -1485,7 +1485,7 @@ class InsertEditTest extends TestCase */ public function testGetColumnSize() { - $column = $extracted_columnspec = array(); + $column = $extracted_columnspec = []; $column['is_char'] = true; $extracted_columnspec['spec_in_brackets'] = 45; $GLOBALS['cfg']['MinSizeForInputField'] = 30; @@ -1538,7 +1538,7 @@ class InsertEditTest extends TestCase */ public function testGetContinueInsertionForm() { - $where_clause_array = array("a<b"); + $where_clause_array = ["a<b"]; $GLOBALS['cfg']['InsertRows'] = 1; $GLOBALS['cfg']['ServerDefault'] = 1; $GLOBALS['goto'] = "index.php"; @@ -1621,7 +1621,7 @@ class InsertEditTest extends TestCase public function testGetSubmitTypeDropDown() { $result = $this->callProtectedMethod('getSubmitTypeDropDown', [ - array(), 2, 2 + [], 2, 2 ]); $this->assertContains( @@ -1703,7 +1703,7 @@ class InsertEditTest extends TestCase $GLOBALS['cfg']['ShowFieldTypesInDataEditView'] = true; $GLOBALS['cfg']['ShowFunctionFields'] = true; $GLOBALS['cfg']['ServerDefault'] = 1; - $url_params = array('ShowFunctionFields' => 2); + $url_params = ['ShowFunctionFields' => 2]; $result = $this->callProtectedMethod('getHeadAndFootOfInsertRowTable', [ $url_params @@ -1727,7 +1727,7 @@ class InsertEditTest extends TestCase */ public function testGetSpecialCharsAndBackupFieldForExistingRow() { - $column = $current_row = $extracted_columnspec = array(); + $column = $current_row = $extracted_columnspec = []; $column['Field'] = 'f'; $current_row['f'] = null; $_REQUEST['default_action'] = 'insert'; @@ -1735,17 +1735,17 @@ class InsertEditTest extends TestCase $column['Extra'] = 'fooauto_increment'; $result = $this->callProtectedMethod('getSpecialCharsAndBackupFieldForExistingRow', [ - $current_row, $column, array(), false, array(), 'a', false + $current_row, $column, [], false, [], 'a', false ]); $this->assertEquals( - array( + [ true, null, null, null, '<input type="hidden" name="fields_preva" value="" />' - ), + ], $result ); @@ -1757,33 +1757,33 @@ class InsertEditTest extends TestCase $column['True_Type'] = 'bit'; $result = $this->callProtectedMethod('getSpecialCharsAndBackupFieldForExistingRow', [ - $current_row, $column, $extracted_columnspec, false, array(), 'a', false + $current_row, $column, $extracted_columnspec, false, [], 'a', false ]); $this->assertEquals( - array( + [ false, "", "00000000000001111011", null, '<input type="hidden" name="fields_preva" value="123" />' - ), + ], $result ); $current_row['f'] = "abcd"; $result = $this->callProtectedMethod('getSpecialCharsAndBackupFieldForExistingRow', [ - $current_row, $column, $extracted_columnspec, false, array(), 'a', true + $current_row, $column, $extracted_columnspec, false, [], 'a', true ]); $this->assertEquals( - array( + [ false, "", "abcd", null, '<input type="hidden" name="fields_preva" value="abcd" />' - ), + ], $result ); @@ -1801,17 +1801,17 @@ class InsertEditTest extends TestCase $result = $this->callProtectedMethod('getSpecialCharsAndBackupFieldForExistingRow', [ $current_row, $column, $extracted_columnspec, - false, array('int'), 'a', false + false, ['int'], 'a', false ]); $this->assertEquals( - array( + [ false, "", "'',", null, '<input type="hidden" name="fields_preva" value="\'\'," />' - ), + ], $result ); @@ -1826,17 +1826,17 @@ class InsertEditTest extends TestCase $result = $this->callProtectedMethod('getSpecialCharsAndBackupFieldForExistingRow', [ $current_row, $column, $extracted_columnspec, - false, array('int'), 'a', false + false, ['int'], 'a', false ]); $this->assertEquals( - array( + [ false, "3131303031", "3131303031", "3131303031", '<input type="hidden" name="fields_preva" value="3131303031" />' - ), + ], $result ); @@ -1845,17 +1845,17 @@ class InsertEditTest extends TestCase $result = $this->callProtectedMethod('getSpecialCharsAndBackupFieldForExistingRow', [ $current_row, $column, $extracted_columnspec, - false, array('int'), 'a', false + false, ['int'], 'a', false ]); $this->assertEquals( - array( + [ false, "313130303100", "313130303100", "313130303100", '<input type="hidden" name="fields_preva" value="313130303100" />' - ), + ], $result ); } @@ -1867,7 +1867,7 @@ class InsertEditTest extends TestCase */ public function testGetSpecialCharsAndBackupFieldForInsertingMode() { - $column = array(); + $column = []; $column['True_Type'] = 'bit'; $column['Default'] = b'101'; $column['is_binary'] = true; @@ -1879,13 +1879,13 @@ class InsertEditTest extends TestCase ]); $this->assertEquals( - array( + [ false, '101', '101', '', '101' - ), + ], $result ); @@ -1898,13 +1898,13 @@ class InsertEditTest extends TestCase ]); $this->assertEquals( - array( + [ true, '', '', '', '' - ), + ], $result ); } @@ -1922,27 +1922,27 @@ class InsertEditTest extends TestCase $result = $this->insertEdit->getParamsForUpdateOrInsert(); $this->assertEquals( - array( - array('LIMIT 1'), + [ + ['LIMIT 1'], true, true, false - ), + ], $result ); // case 2 (else) unset($_REQUEST['where_clause']); - $_REQUEST['fields']['multi_edit'] = array('a' => 'b', 'c' => 'd'); + $_REQUEST['fields']['multi_edit'] = ['a' => 'b', 'c' => 'd']; $result = $this->insertEdit->getParamsForUpdateOrInsert(); $this->assertEquals( - array( - array('a', 'c'), + [ + ['a', 'c'], false, true, false - ), + ], $result ); } @@ -1959,7 +1959,7 @@ class InsertEditTest extends TestCase $scriptsMock = $this->getMockBuilder('PhpMyAdmin\Scripts') ->disableOriginalConstructor() - ->setMethods(array('addFile')) + ->setMethods(['addFile']) ->getMock(); $scriptsMock->expects($this->exactly(2)) @@ -1967,7 +1967,7 @@ class InsertEditTest extends TestCase $headerMock = $this->getMockBuilder('PhpMyAdmin\Header') ->disableOriginalConstructor() - ->setMethods(array('getScripts')) + ->setMethods(['getScripts']) ->getMock(); $headerMock->expects($this->once()) @@ -1976,7 +1976,7 @@ class InsertEditTest extends TestCase $responseMock = $this->getMockBuilder('PhpMyAdmin\Response') ->disableOriginalConstructor() - ->setMethods(array('getHeader')) + ->setMethods(['getHeader']) ->getMock(); $responseMock->expects($this->once()) @@ -2007,9 +2007,9 @@ class InsertEditTest extends TestCase $temp->table = 'table'; $temp->type = 'real'; $temp->primary_key = 1; - $meta_arr = array($temp); + $meta_arr = [$temp]; - $row = array('1' => 1); + $row = ['1' => 1]; $res = 'foobar'; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') @@ -2093,13 +2093,13 @@ class InsertEditTest extends TestCase $GLOBALS['cfg']['ServerDefault'] = 1; $this->assertEquals( 'tbl_change.php?lang=en', - $this->insertEdit->getErrorUrl(array()) + $this->insertEdit->getErrorUrl([]) ); $_REQUEST['err_url'] = 'localhost'; $this->assertEquals( 'localhost', - $this->insertEdit->getErrorUrl(array()) + $this->insertEdit->getErrorUrl([]) ); } @@ -2112,16 +2112,16 @@ class InsertEditTest extends TestCase { $GLOBALS['db'] = 'db'; $GLOBALS['table'] = 'table'; - $query_fields = array('a', 'b'); - $value_sets = array(1, 2); + $query_fields = ['a', 'b']; + $value_sets = [1, 2]; $this->assertEquals( - array('INSERT IGNORE INTO `table` (a, b) VALUES (1), (2)'), + ['INSERT IGNORE INTO `table` (a, b) VALUES (1), (2)'], $this->insertEdit->buildSqlQuery(true, $query_fields, $value_sets) ); $this->assertEquals( - array('INSERT INTO `table` (a, b) VALUES (1), (2)'), + ['INSERT INTO `table` (a, b) VALUES (1), (2)'], $this->insertEdit->buildSqlQuery(false, $query_fields, $value_sets) ); } @@ -2133,7 +2133,7 @@ class InsertEditTest extends TestCase */ public function testExecuteSqlQuery() { - $query = array('SELECT 1', 'SELECT 2'); + $query = ['SELECT 1', 'SELECT 2']; $GLOBALS['sql_query'] = 'SELECT'; $GLOBALS['cfg']['IgnoreMultiSubmitErrors'] = false; $_REQUEST['submit_type'] = ''; @@ -2166,15 +2166,15 @@ class InsertEditTest extends TestCase $dbi->expects($this->exactly(2)) ->method('getWarnings') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $GLOBALS['dbi'] = $dbi; $this->insertEdit = new InsertEdit($GLOBALS['dbi']); - $result = $this->insertEdit->executeSqlQuery(array(), $query); + $result = $this->insertEdit->executeSqlQuery([], $query); $this->assertEquals( - array('sql_query' => 'SELECT'), + ['sql_query' => 'SELECT'], $result[0] ); @@ -2193,17 +2193,17 @@ class InsertEditTest extends TestCase $reflectionMsg->setAccessible(true); $this->assertEquals( - array(2), + [2], $reflectionMsg->getValue($msg) ); $this->assertEquals( - array(), + [], $result[3] ); $this->assertEquals( - array('err'), + ['err'], $result[4] ); @@ -2220,7 +2220,7 @@ class InsertEditTest extends TestCase */ public function testExecuteSqlQueryWithTryQuery() { - $query = array('SELECT 1', 'SELECT 2'); + $query = ['SELECT 1', 'SELECT 2']; $GLOBALS['sql_query'] = 'SELECT'; $GLOBALS['cfg']['IgnoreMultiSubmitErrors'] = true; $_REQUEST['submit_type'] = ''; @@ -2253,15 +2253,15 @@ class InsertEditTest extends TestCase $dbi->expects($this->exactly(2)) ->method('getWarnings') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $GLOBALS['dbi'] = $dbi; $this->insertEdit = new InsertEdit($GLOBALS['dbi']); - $result = $this->insertEdit->executeSqlQuery(array(), $query); + $result = $this->insertEdit->executeSqlQuery([], $query); $this->assertEquals( - array('sql_query' => 'SELECT'), + ['sql_query' => 'SELECT'], $result[0] ); @@ -2280,17 +2280,17 @@ class InsertEditTest extends TestCase $reflectionMsg->setAccessible(true); $this->assertEquals( - array(2), + [2], $reflectionMsg->getValue($msg) ); $this->assertEquals( - array(), + [], $result[3] ); $this->assertEquals( - array('err'), + ['err'], $result[4] ); @@ -2307,10 +2307,10 @@ class InsertEditTest extends TestCase */ public function testGetWarningMessages() { - $warnings = array( - array('Level' => 1, 'Code' => 42, 'Message' => 'msg1'), - array('Level' => 2, 'Code' => 43, 'Message' => 'msg2'), - ); + $warnings = [ + ['Level' => 1, 'Code' => 42, 'Message' => 'msg1'], + ['Level' => 2, 'Code' => 43, 'Message' => 'msg2'], + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -2326,10 +2326,10 @@ class InsertEditTest extends TestCase $result = $this->callProtectedMethod('getWarningMessages'); $this->assertEquals( - array( + [ "1: #42 msg1", "2: #43 msg2" - ), + ], $result ); } @@ -2341,7 +2341,7 @@ class InsertEditTest extends TestCase */ public function testGetDisplayValueForForeignTableColumn() { - $map = array(); + $map = []; $map['f']['foreign_db'] = 'information_schema'; $map['f']['foreign_table'] = 'TABLES'; $map['f']['foreign_field'] = 'f'; @@ -2368,7 +2368,7 @@ class InsertEditTest extends TestCase $dbi->expects($this->once()) ->method('fetchRow') ->with('r1', 0) - ->will($this->returnValue(array('2'))); + ->will($this->returnValue(['2'])); $GLOBALS['dbi'] = $dbi; $this->insertEdit = new InsertEdit($GLOBALS['dbi']); @@ -2387,7 +2387,7 @@ class InsertEditTest extends TestCase { $GLOBALS['cfg']['ServerDefault'] = 1; $_SESSION['tmpval']['relational_display'] = 'K'; - $map = array(); + $map = []; $map['f']['foreign_db'] = 'information_schema'; $map['f']['foreign_table'] = 'TABLES'; $map['f']['foreign_field'] = 'f'; @@ -2419,23 +2419,23 @@ class InsertEditTest extends TestCase */ public function testTransformEditedValues() { - $edited_values = array( - array('c' => 'cname') - ); + $edited_values = [ + ['c' => 'cname'] + ]; $GLOBALS['cfg']['DefaultTransformations']['PreApPend'] = ['', '']; $GLOBALS['cfg']['ServerDefault'] = 1; $_REQUEST['where_clause'] = 1; - $transformation = array( + $transformation = [ 'transformation_options' => "'','option ,, quoted',abd" - ); + ]; $result = $this->insertEdit->transformEditedValues( 'db', 'table', $transformation, $edited_values, - 'Text_Plain_PreApPend.php', 'c', array('a' => 'b'), + 'Text_Plain_PreApPend.php', 'c', ['a' => 'b'], 'transformation' ); $this->assertEquals( - array('a' => 'b', 'transformations' => array("cnameoption ,, quoted")), + ['a' => 'b', 'transformations' => ["cnameoption ,, quoted"]], $result ); } @@ -2447,57 +2447,57 @@ class InsertEditTest extends TestCase */ public function testGetQueryValuesForInsertAndUpdateInMultipleEdit() { - $multi_edit_columns_name = array('0' => 'fld'); + $multi_edit_columns_name = ['0' => 'fld']; $result = $this->insertEdit->getQueryValuesForInsertAndUpdateInMultipleEdit( - $multi_edit_columns_name, array(), '', array(), array(), true, array(1), - array(2), 'foo', array(), '0', array() + $multi_edit_columns_name, [], '', [], [], true, [1], + [2], 'foo', [], '0', [] ); $this->assertEquals( - array( - array(1, 'foo'), - array(2, '`fld`') - ), + [ + [1, 'foo'], + [2, '`fld`'] + ], $result ); $result = $this->insertEdit->getQueryValuesForInsertAndUpdateInMultipleEdit( - $multi_edit_columns_name, array(), '', array(), array(), false, array(1), - array(2), 'foo', array(), '0', array('a') + $multi_edit_columns_name, [], '', [], [], false, [1], + [2], 'foo', [], '0', ['a'] ); $this->assertEquals( - array( - array(1, '`fld` = foo'), - array(2) - ), + [ + [1, '`fld` = foo'], + [2] + ], $result ); $result = $this->insertEdit->getQueryValuesForInsertAndUpdateInMultipleEdit( - $multi_edit_columns_name, array('b'), "'`c`'", array('c'), array(), - false, array(1), array(2), 'foo', array(), '0', array('a') + $multi_edit_columns_name, ['b'], "'`c`'", ['c'], [], + false, [1], [2], 'foo', [], '0', ['a'] ); $this->assertEquals( - array( - array(1), - array(2) - ), + [ + [1], + [2] + ], $result ); $result = $this->insertEdit->getQueryValuesForInsertAndUpdateInMultipleEdit( - $multi_edit_columns_name, array('b'), "'`c`'", array('c'), array(3), - false, array(1), array(2), 'foo', array(), 0, array() + $multi_edit_columns_name, ['b'], "'`c`'", ['c'], [3], + false, [1], [2], 'foo', [], 0, [] ); $this->assertEquals( - array( - array(1, '`fld` = foo'), - array(2) - ), + [ + [1, '`fld` = foo'], + [2] + ], $result ); } @@ -2510,14 +2510,14 @@ class InsertEditTest extends TestCase public function testGetCurrentValueAsAnArrayForMultipleEdit() { $result = $this->insertEdit->getCurrentValueAsAnArrayForMultipleEdit( - array(), array(), array(), 'currVal', array(), - array(), array(), '0' + [], [], [], 'currVal', [], + [], [], '0' ); $this->assertEquals('currVal', $result); // case 2 - $multi_edit_funcs = array('UUID'); + $multi_edit_funcs = ['UUID']; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -2532,34 +2532,34 @@ class InsertEditTest extends TestCase $this->insertEdit = new InsertEdit($GLOBALS['dbi']); $result = $this->insertEdit->getCurrentValueAsAnArrayForMultipleEdit( - $multi_edit_funcs, array(), array(), 'currVal', array(), - array(), array(), '0' + $multi_edit_funcs, [], [], 'currVal', [], + [], [], '0' ); $this->assertEquals("'uuid1234'", $result); // case 3 - $multi_edit_funcs = array('AES_ENCRYPT'); - $multi_edit_salt = array(""); + $multi_edit_funcs = ['AES_ENCRYPT']; + $multi_edit_salt = [""]; $result = $this->insertEdit->getCurrentValueAsAnArrayForMultipleEdit( - $multi_edit_funcs, $multi_edit_salt, array(), "'''", array(), - array('func'), array('func'), '0' + $multi_edit_funcs, $multi_edit_salt, [], "'''", [], + ['func'], ['func'], '0' ); $this->assertEquals("AES_ENCRYPT(''','')", $result); // case 4 - $multi_edit_funcs = array('func'); - $multi_edit_salt = array(); + $multi_edit_funcs = ['func']; + $multi_edit_salt = []; $result = $this->insertEdit->getCurrentValueAsAnArrayForMultipleEdit( - $multi_edit_funcs, $multi_edit_salt, array(), "'''", array(), - array('func'), array('func'), '0' + $multi_edit_funcs, $multi_edit_salt, [], "'''", [], + ['func'], ['func'], '0' ); $this->assertEquals("func(''')", $result); // case 5 $result = $this->insertEdit->getCurrentValueAsAnArrayForMultipleEdit( - $multi_edit_funcs, $multi_edit_salt, array(), "''", array(), - array('func'), array('func'), '0' + $multi_edit_funcs, $multi_edit_salt, [], "''", [], + ['func'], ['func'], '0' ); $this->assertEquals("func()", $result); } @@ -2571,7 +2571,7 @@ class InsertEditTest extends TestCase */ public function testGetCurrentValueForDifferentTypes() { - $prow = array(); + $prow = []; $prow['a'] = b'101'; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') @@ -2593,8 +2593,8 @@ class InsertEditTest extends TestCase $this->insertEdit = new InsertEdit($GLOBALS['dbi']); $result = $this->insertEdit->getCurrentValueForDifferentTypes( - '123', '0', array(), '', array(), 0, array(), array(), - array(), true, true, '1', 'table', array() + '123', '0', [], '', [], 0, [], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2604,8 +2604,8 @@ class InsertEditTest extends TestCase // case 2 $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('test'), '', array(1), 0, array(), array(), - array(), true, true, '1', 'table', array() + false, '0', ['test'], '', [1], 0, [], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2615,8 +2615,8 @@ class InsertEditTest extends TestCase // case 3 $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('test'), '', array(), 0, array(), array(), - array(), true, true, '1', 'table', array() + false, '0', ['test'], '', [], 0, [], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2625,10 +2625,10 @@ class InsertEditTest extends TestCase ); // case 4 - $_REQUEST['fields']['multi_edit'][0][0] = array(); + $_REQUEST['fields']['multi_edit'][0][0] = []; $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('set'), '', array(), 0, array(), array(), - array(), true, true, '1', 'table', array() + false, '0', ['set'], '', [], 0, [], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2638,8 +2638,8 @@ class InsertEditTest extends TestCase // case 5 $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('protected'), '', array(), 0, array('a'), array(), - array(), true, true, '1', 'table', array() + false, '0', ['protected'], '', [], 0, ['a'], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2649,8 +2649,8 @@ class InsertEditTest extends TestCase // case 6 $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('protected'), '', array(), 0, array('a'), array(), - array(), true, true, '1', 'table', array() + false, '0', ['protected'], '', [], 0, ['a'], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2660,8 +2660,8 @@ class InsertEditTest extends TestCase // case 7 $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('bit'), '20\'12', array(), 0, array('a'), array(), - array(), true, true, '1', 'table', array() + false, '0', ['bit'], '20\'12', [], 0, ['a'], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2671,8 +2671,8 @@ class InsertEditTest extends TestCase // case 7 $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('date'), '20\'12', array(), 0, array('a'), array(), - array(), true, true, '1', 'table', array() + false, '0', ['date'], '20\'12', [], 0, ['a'], [], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2681,10 +2681,10 @@ class InsertEditTest extends TestCase ); // case 8 - $_REQUEST['fields']['multi_edit'][0][0] = array(); + $_REQUEST['fields']['multi_edit'][0][0] = []; $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('set'), '', array(), 0, array(), array(1), - array(), true, true, '1', 'table', array() + false, '0', ['set'], '', [], 0, [], [1], + [], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2694,8 +2694,8 @@ class InsertEditTest extends TestCase // case 9 $result = $this->insertEdit->getCurrentValueForDifferentTypes( - false, '0', array('protected'), '', array(), 0, array('a'), array(), - array(1), true, true, '1', 'table', array() + false, '0', ['protected'], '', [], 0, ['a'], [], + [1], true, true, '1', 'table', [] ); $this->assertEquals( @@ -2711,7 +2711,7 @@ class InsertEditTest extends TestCase */ public function testVerifyWhetherValueCanBeTruncatedAndAppendExtraData() { - $extra_data = array('isNeedToRecheck' => true); + $extra_data = ['isNeedToRecheck' => true]; $meta = new stdClass(); $_REQUEST['where_clause'][0] = 1; @@ -2726,7 +2726,7 @@ class InsertEditTest extends TestCase $meta->type = 'int'; $dbi->expects($this->at(1)) ->method('getFieldsMeta') - ->will($this->returnValue(array($meta))); + ->will($this->returnValue([$meta])); $dbi->expects($this->at(2)) ->method('fetchRow') @@ -2742,11 +2742,11 @@ class InsertEditTest extends TestCase $meta->type = 'int'; $dbi->expects($this->at(5)) ->method('getFieldsMeta') - ->will($this->returnValue(array($meta))); + ->will($this->returnValue([$meta])); $dbi->expects($this->at(6)) ->method('fetchRow') - ->will($this->returnValue(array(0 => '123'))); + ->will($this->returnValue([0 => '123'])); $dbi->expects($this->at(7)) ->method('freeResult'); @@ -2758,11 +2758,11 @@ class InsertEditTest extends TestCase $meta->type = 'timestamp'; $dbi->expects($this->at(9)) ->method('getFieldsMeta') - ->will($this->returnValue(array($meta))); + ->will($this->returnValue([$meta])); $dbi->expects($this->at(10)) ->method('fetchRow') - ->will($this->returnValue(array(0 => '2013-08-28 06:34:14'))); + ->will($this->returnValue([0 => '2013-08-28 06:34:14'])); $dbi->expects($this->at(11)) ->method('freeResult'); @@ -2811,7 +2811,7 @@ class InsertEditTest extends TestCase $dbi->expects($this->at(1)) ->method('getColumns') ->with('db', 'table') - ->will($this->returnValue(array('a' => 'b', 'c' => 'd'))); + ->will($this->returnValue(['a' => 'b', 'c' => 'd'])); $GLOBALS['dbi'] = $dbi; $this->insertEdit = new InsertEdit($GLOBALS['dbi']); @@ -2819,7 +2819,7 @@ class InsertEditTest extends TestCase $result = $this->insertEdit->getTableColumns('db', 'table'); $this->assertEquals( - array('b', 'd'), + ['b', 'd'], $result ); } @@ -2847,7 +2847,7 @@ class InsertEditTest extends TestCase $responseMock = $this->getMockBuilder('PhpMyAdmin\Response') ->disableOriginalConstructor() - ->setMethods(array('addHtml')) + ->setMethods(['addHtml']) ->getMock(); $restoreInstance = Response::getInstance(); @@ -2860,16 +2860,16 @@ class InsertEditTest extends TestCase $result = $this->insertEdit->determineInsertOrEdit('1', 'db', 'table'); $this->assertEquals( - array( + [ false, null, - array(1), + [1], null, - array(null), - array(null), + [null], + [null], false, "edit_next" - ), + ], $result ); @@ -2883,16 +2883,16 @@ class InsertEditTest extends TestCase $response->setValue($restoreInstance); $this->assertEquals( - array( + [ true, null, - array(), + [], null, null, - array(false, false), + [false, false], false, "edit_next" - ), + ], $result ); } @@ -2915,7 +2915,7 @@ class InsertEditTest extends TestCase ->with('db', 'table', null, true) ->will( $this->returnValue( - array(array('Comment' => 'b', 'Field' => 'd')) + [['Comment' => 'b', 'Field' => 'd']] ) ); @@ -2931,14 +2931,14 @@ class InsertEditTest extends TestCase $this->insertEdit = new InsertEdit($GLOBALS['dbi']); $this->assertEquals( - array(), + [], $this->insertEdit->getCommentsMap('db', 'table') ); $GLOBALS['cfg']['ShowPropertyComments'] = true; $this->assertEquals( - array('d' => 'b'), + ['d' => 'b'], $this->insertEdit->getCommentsMap('db', 'table') ); } @@ -2954,11 +2954,11 @@ class InsertEditTest extends TestCase $GLOBALS['goto'] = 'tbl_change.php'; $this->assertEquals( - array( + [ 'db' => 'foo', 'sql_query' => 'SELECT', 'table' => 'bar' - ), + ], $this->insertEdit->getUrlParameters('foo', 'bar') ); } @@ -2994,28 +2994,28 @@ class InsertEditTest extends TestCase { $o_rows = 0; $tabindex = 0; - $GLOBALS['plugin_scripts'] = array(); - $table_columns = array( - array( + $GLOBALS['plugin_scripts'] = []; + $table_columns = [ + [ 'Field' => 'col', 'Type' => 'varchar(20)', 'Null' => 'Yes', 'Privileges' => 'insert,update,select' - ) - ); - $repopulate = array( + ] + ]; + $repopulate = [ md5('col') => 'val' - ); - $column_mime = array( + ]; + $column_mime = [ 'input_transformation' => 'Input/Image_JPEG_Upload.php', 'input_transformation_options' => '150' - ); + ]; // Test w/ input transformation $actual = $this->callProtectedMethod('getHtmlForInsertEditFormColumn', [ - $table_columns, 0, array(), false, array(), '', '', - '', false, array(), &$o_rows, &$tabindex, 0, false, 0, - array(), 0, 0, 'table', 'db', 0, array(), 0, '', '', + $table_columns, 0, [], false, [], '', '', + '', false, [], &$o_rows, &$tabindex, 0, false, 0, + [], 0, 0, 'table', 'db', 0, [], 0, '', '', $repopulate, $column_mime, '' ]); @@ -3054,8 +3054,8 @@ class InsertEditTest extends TestCase ); // Test w/o input_transformation - $table_columns = array( - array( + $table_columns = [ + [ 'Field' => 'qwerty', 'Type' => 'datetime', 'Null' => 'Yes', @@ -3063,16 +3063,16 @@ class InsertEditTest extends TestCase 'Extra' => '', 'Default' => null, 'Privileges' => 'insert,update,select' - ) - ); - $repopulate = array( + ] + ]; + $repopulate = [ md5('qwerty') => '12-10-14' - ); + ]; $actual = $this->callProtectedMethod('getHtmlForInsertEditFormColumn', [ - $table_columns, 0, array(), false, array(), '', '', - '', true, array(), &$o_rows, &$tabindex, 0, false, 0, - array(), 0, 0, 'table', 'db', 0, array(), 0, '', '', - $repopulate, array(), '' + $table_columns, 0, [], false, [], '', '', + '', true, [], &$o_rows, &$tabindex, 0, false, 0, + [], 0, 0, 'table', 'db', 0, [], 0, '', '', + $repopulate, [], '' ]); $this->assertContains( 'qwerty', @@ -3103,24 +3103,24 @@ class InsertEditTest extends TestCase { $o_rows = 0; $tabindex = 0; - $GLOBALS['plugin_scripts'] = array(); + $GLOBALS['plugin_scripts'] = []; $GLOBALS['cfg']['LongtextDoubleTextarea'] = true; $GLOBALS['cfg']['CharEditing'] = true; - $table_columns = array( - array( + $table_columns = [ + [ 'Field' => 'test', 'Type' => 'longtext', 'Null' => 'Yes', 'pma_type' => 'longtext', 'True_Type' => 'longtext', 'Privileges' => 'select,insert,update,references', - ) - ); + ] + ]; $actual = $this->insertEdit->getHtmlForInsertEditRow( - array(), $table_columns, array(), false, array(), '', '', - '', false, array(), $o_rows, $tabindex, 1, false, 0, - array(), 0, 0, 'table', 'db', 0, array(), 0, '', - array(), array('wc') + [], $table_columns, [], false, [], '', '', + '', false, [], $o_rows, $tabindex, 1, false, 0, + [], 0, 0, 'table', 'db', 0, [], 0, '', + [], ['wc'] ); $this->assertContains( 'test', @@ -3157,34 +3157,34 @@ class InsertEditTest extends TestCase { $o_rows = 0; $tabindex = 0; - $GLOBALS['plugin_scripts'] = array(); + $GLOBALS['plugin_scripts'] = []; $GLOBALS['cfg']['LongtextDoubleTextarea'] = true; $GLOBALS['cfg']['CharEditing'] = true; // edit - $table_columns = array( - array( + $table_columns = [ + [ 'Field' => 'foo', 'Type' => 'longtext', 'Null' => 'Yes', 'pma_type' => 'longtext', 'True_Type' => 'longtext', 'Privileges' => 'select,insert,update,references', - ), - array( + ], + [ 'Field' => 'bar', 'Type' => 'longtext', 'Null' => 'Yes', 'pma_type' => 'longtext', 'True_Type' => 'longtext', 'Privileges' => 'select,insert,references', - ) - ); + ] + ]; $actual = $this->insertEdit->getHtmlForInsertEditRow( - array(), $table_columns, array(), false, array(), '', '', - '', false, array(), $o_rows, $tabindex, 1, false, 0, - array(), 0, 0, 'table', 'db', 0, array(), 0, '', - array(), array('wc') + [], $table_columns, [], false, [], '', '', + '', false, [], $o_rows, $tabindex, 1, false, 0, + [], 0, 0, 'table', 'db', 0, [], 0, '', + [], ['wc'] ); $this->assertContains( 'foo', @@ -3196,8 +3196,8 @@ class InsertEditTest extends TestCase ); // insert - $table_columns = array( - array( + $table_columns = [ + [ 'Field' => 'foo', 'Type' => 'longtext', 'Null' => 'Yes', @@ -3205,8 +3205,8 @@ class InsertEditTest extends TestCase 'pma_type' => 'longtext', 'True_Type' => 'longtext', 'Privileges' => 'select,insert,update,references', - ), - array( + ], + [ 'Field' => 'bar', 'Type' => 'longtext', 'Null' => 'Yes', @@ -3214,13 +3214,13 @@ class InsertEditTest extends TestCase 'pma_type' => 'longtext', 'True_Type' => 'longtext', 'Privileges' => 'select,update,references', - ) - ); + ] + ]; $actual = $this->insertEdit->getHtmlForInsertEditRow( - array(), $table_columns, array(), false, array(), '', '', - '', true, array(), $o_rows, $tabindex, 2, false, 0, - array(), 0, 0, 'table', 'db', 0, array(), 0, '', - array(), array('wc') + [], $table_columns, [], false, [], '', '', + '', true, [], $o_rows, $tabindex, 2, false, 0, + [], 0, 0, 'table', 'db', 0, [], 0, '', + [], ['wc'] ); $this->assertContains( 'foo', diff --git a/test/classes/IpAllowDenyTest.php b/test/classes/IpAllowDenyTest.php index fe3574c2e2..93ac0d7151 100644 --- a/test/classes/IpAllowDenyTest.php +++ b/test/classes/IpAllowDenyTest.php @@ -68,7 +68,7 @@ class IpAllowDenyTest extends TestCase { unset($_SERVER['REMOTE_ADDR']); unset($_SERVER['TEST_FORWARDED_HEADER']); - $GLOBALS['cfg']['TrustedProxies'] = array(); + $GLOBALS['cfg']['TrustedProxies'] = []; if (!is_null($remote)) { $_SERVER['REMOTE_ADDR'] = $remote; @@ -89,7 +89,7 @@ class IpAllowDenyTest extends TestCase unset($_SERVER['REMOTE_ADDR']); unset($_SERVER['TEST_FORWARDED_HEADER']); - $GLOBALS['cfg']['TrustedProxies'] = array(); + $GLOBALS['cfg']['TrustedProxies'] = []; } /** @@ -99,20 +99,20 @@ class IpAllowDenyTest extends TestCase */ public function proxyIPs() { - return array( + return [ // Nothing set - array(null, null, false), + [null, null, false], // Remote IP set - array('101.0.0.25', null, '101.0.0.25'), + ['101.0.0.25', null, '101.0.0.25'], // Proxy - array('101.0.0.25', '192.168.10.10', '192.168.10.10'), + ['101.0.0.25', '192.168.10.10', '192.168.10.10'], // Several proxies - array('101.0.0.25', '192.168.10.1, 192.168.100.100', '192.168.10.1'), + ['101.0.0.25', '192.168.10.1, 192.168.100.100', '192.168.10.1'], // Invalid proxy - array('101.0.0.25', 'invalid', false), + ['101.0.0.25', 'invalid', false], // Direct IP with proxy enabled - array('101.0.0.25', '192.168.10.10', '101.0.0.25', '10.10.10.10'), - ); + ['101.0.0.25', '192.168.10.10', '101.0.0.25', '10.10.10.10'], + ]; } /** diff --git a/test/classes/LanguageTest.php b/test/classes/LanguageTest.php index cd7c1e3b49..95d5d0d9a2 100644 --- a/test/classes/LanguageTest.php +++ b/test/classes/LanguageTest.php @@ -194,21 +194,21 @@ class LanguageTest extends PmaTestCase */ public function selectDataProvider() { - return array( - array('cs', 'en', '', '' ,'' ,'', '', 'Czech'), - array('', 'cs', '', '' ,'' ,'', '', 'Czech'), - array('', 'cs', 'en', '' ,'' ,'', '', 'Czech'), - array('', '', 'cs', '' ,'' ,'', '', 'Czech'), - array('', '', '', 'cs' ,'' ,'', '', 'Czech'), - array('', '', '', '' ,'cs,en-US;q=0.7,en;q=0.3' ,'', '', 'Czech'), - array( + return [ + ['cs', 'en', '', '' ,'' ,'', '', 'Czech'], + ['', 'cs', '', '' ,'' ,'', '', 'Czech'], + ['', 'cs', 'en', '' ,'' ,'', '', 'Czech'], + ['', '', 'cs', '' ,'' ,'', '', 'Czech'], + ['', '', '', 'cs' ,'' ,'', '', 'Czech'], + ['', '', '', '' ,'cs,en-US;q=0.7,en;q=0.3' ,'', '', 'Czech'], + [ '', '', '', '', '', 'Mozilla/5.0 (Linux; U; Android 2.2.2; tr-tr; GM FOX)', '', 'Turkish' - ), - array('', '', '', '' ,'' ,'', 'cs', 'Czech'), - array('', '', '', '' ,'' ,'', '', 'English'), - ); + ], + ['', '', '', '' ,'' ,'', 'cs', 'Czech'], + ['', '', '', '' ,'' ,'', '', 'English'], + ]; } /** @@ -243,9 +243,9 @@ class LanguageTest extends PmaTestCase */ public function listLocales() { - $ret = array(); + $ret = []; foreach (LanguageManager::getInstance()->availableLanguages() as $language) { - $ret[] = array($language->getCode()); + $ret[] = [$language->getCode()]; } return $ret; } diff --git a/test/classes/LinterTest.php b/test/classes/LinterTest.php index e8a4fcf5ef..344c075dcb 100644 --- a/test/classes/LinterTest.php +++ b/test/classes/LinterTest.php @@ -26,9 +26,9 @@ class LinterTest extends PmaTestCase */ public function testGetLines() { - $this->assertEquals(array(0), Linter::getLines('')); - $this->assertEquals(array(0, 2), Linter::getLines("a\nb")); - $this->assertEquals(array(0, 4, 7), Linter::getLines("abc\nde\n")); + $this->assertEquals([0], Linter::getLines('')); + $this->assertEquals([0, 2], Linter::getLines("a\nb")); + $this->assertEquals([0, 4, 7], Linter::getLines("abc\nde\n")); } /** @@ -50,20 +50,20 @@ class LinterTest extends PmaTestCase // ( d, 4), ( e, 5), (\n, 6), // (\n, 7). $this->assertEquals( - array(1, 0), - Linter::findLineNumberAndColumn(array(0, 4, 7), 4) + [1, 0], + Linter::findLineNumberAndColumn([0, 4, 7], 4) ); $this->assertEquals( - array(1, 1), - Linter::findLineNumberAndColumn(array(0, 4, 7), 5) + [1, 1], + Linter::findLineNumberAndColumn([0, 4, 7], 5) ); $this->assertEquals( - array(1, 2), - Linter::findLineNumberAndColumn(array(0, 4, 7), 6) + [1, 2], + Linter::findLineNumberAndColumn([0, 4, 7], 6) ); $this->assertEquals( - array(2, 0), - Linter::findLineNumberAndColumn(array(0, 4, 7), 7) + [2, 0], + Linter::findLineNumberAndColumn([0, 4, 7], 7) ); } @@ -89,18 +89,18 @@ class LinterTest extends PmaTestCase */ public static function lintProvider() { - return array( - array( - array(), + return [ + [ + [], '', - ), - array( - array(), + ], + [ + [], 'SELECT * FROM tbl' - ), - array( - array( - array( + ], + [ + [ + [ 'message' => 'Unrecognized data type. (near ' . '<code>IN</code>)', 'fromLine' => 0, @@ -108,8 +108,8 @@ class LinterTest extends PmaTestCase 'toLine' => 0, 'toColumn' => 24, 'severity' => 'error', - ), - array( + ], + [ 'message' => 'A closing bracket was expected. (near ' . '<code>IN</code>)', 'fromLine' => 0, @@ -117,13 +117,13 @@ class LinterTest extends PmaTestCase 'toLine' => 0, 'toColumn' => 24, 'severity' => 'error', - ) - ), + ] + ], 'CREATE TABLE tbl ( id IN' - ), - array( - array( - array( + ], + [ + [ + [ 'message' => 'Linting is disabled for this query because ' . 'it exceeds the maximum length.', 'fromLine' => 0, @@ -131,10 +131,10 @@ class LinterTest extends PmaTestCase 'toLine' => 0, 'toColumn' => 0, 'severity' => 'warning', - ) - ), + ] + ], str_repeat(";", 10001) - ) - ); + ] + ]; } } diff --git a/test/classes/ListDatabaseTest.php b/test/classes/ListDatabaseTest.php index 42c7cfc964..b1395abdef 100644 --- a/test/classes/ListDatabaseTest.php +++ b/test/classes/ListDatabaseTest.php @@ -30,7 +30,7 @@ class ListDatabaseTest extends PmaTestCase */ public function setup() { - $GLOBALS['cfg']['Server']['only_db'] = array('single\\_db'); + $GLOBALS['cfg']['Server']['only_db'] = ['single\\_db']; $this->object = new ListDatabase(); } @@ -97,7 +97,7 @@ class ListDatabaseTest extends PmaTestCase $this->assertEquals( $this->_callProtectedFunction( 'checkHideDatabase', - array() + [] ), '' ); diff --git a/test/classes/MessageTest.php b/test/classes/MessageTest.php index b557cdb3bb..23f019e52a 100644 --- a/test/classes/MessageTest.php +++ b/test/classes/MessageTest.php @@ -210,17 +210,17 @@ class MessageTest extends PmaTestCase { $this->object->addParam(Message::notice('test')); $this->assertEquals( - array(Message::notice('test')), + [Message::notice('test')], $this->object->getParams() ); $this->object->addParam('test'); $this->assertEquals( - array(Message::notice('test'), 'test'), + [Message::notice('test'), 'test'], $this->object->getParams() ); $this->object->addParam('test'); $this->assertEquals( - array(Message::notice('test'), 'test', Message::notice('test')), + [Message::notice('test'), 'test', Message::notice('test')], $this->object->getParams() ); } @@ -251,16 +251,16 @@ class MessageTest extends PmaTestCase { $this->object->addText('test', '*'); $this->assertEquals( - array('*', Message::notice('test')), + ['*', Message::notice('test')], $this->object->getAddedMessages() ); $this->object->addText('test', ''); $this->assertEquals( - array( + [ '*', Message::notice('test'), Message::notice('test') - ), + ], $this->object->getAddedMessages() ); } @@ -274,16 +274,16 @@ class MessageTest extends PmaTestCase { $this->object->addText('test<>', ''); $this->assertEquals( - array(Message::notice('test<>')), + [Message::notice('test<>')], $this->object->getAddedMessages() ); $this->object->addHtml('<b>test</b>'); $this->assertEquals( - array( + [ Message::notice('test<>'), ' ', Message::rawNotice('<b>test</b>') - ), + ], $this->object->getAddedMessages() ); $this->object->addMessage(Message::notice('test<>')); @@ -300,18 +300,18 @@ class MessageTest extends PmaTestCase */ public function testAddMessages() { - $messages = array(); + $messages = []; $messages[] = new Message("Test1"); $messages[] = new Message("PMA_Test2", Message::ERROR); $messages[] = new Message("Test3"); $this->object->addMessages($messages, ''); $this->assertEquals( - array( + [ Message::notice('Test1'), Message::error("PMA_Test2"), Message::notice('Test3') - ), + ], $this->object->getAddedMessages() ); } @@ -323,15 +323,15 @@ class MessageTest extends PmaTestCase */ public function testAddMessagesString() { - $messages = array('test1', 'test<b>', 'test2'); + $messages = ['test1', 'test<b>', 'test2']; $this->object->addMessagesString($messages, ''); $this->assertEquals( - array( + [ Message::notice('test1'), Message::notice('test<b>'), Message::notice('test2') - ), + ], $this->object->getAddedMessages() ); @@ -367,8 +367,8 @@ class MessageTest extends PmaTestCase Message::sanitize($this->object) ); $this->assertEquals( - array('test&string<>', 'test&string<>'), - Message::sanitize(array($this->object, $this->object)) + ['test&string<>', 'test&string<>'], + Message::sanitize([$this->object, $this->object]) ); } @@ -379,39 +379,39 @@ class MessageTest extends PmaTestCase */ public function decodeBBDataProvider() { - return array( - array( + return [ + [ '[em]test[/em][em]aa[em/][em]test[/em]', '<em>test</em><em>aa[em/]<em>test</em>' - ), - array( + ], + [ '[strong]test[/strong][strong]test[/strong]', '<strong>test</strong><strong>test</strong>' - ), - array( + ], + [ '[code]test[/code][code]test[/code]', '<code>test</code><code>test</code>' - ), - array( + ], + [ '[kbd]test[/kbd][br][sup]test[/sup]', '<kbd>test</kbd><br /><sup>test</sup>' - ), - array( + ], + [ '[a@https://example.com/@Documentation]link[/a]', '<a href="./url.php?url=https%3A%2F%2Fexample.com%2F"' . ' target="Documentation">link</a>' - ), - array( + ], + [ '[a@./non-existing@Documentation]link[/a]', '[a@./non-existing@Documentation]link</a>' - ), - array( + ], + [ '[doc@foo]link[/doc]', '<a href="./url.php?url=https%3A%2F%2Fdocs.phpmyadmin.net%2Fen%2F' . 'latest%2Fsetup.html%23foo" ' . 'target="documentation">link</a>' - ), - ); + ], + ]; } /** @@ -447,11 +447,11 @@ class MessageTest extends PmaTestCase ); $this->assertEquals( 'test string', - Message::format('test string', array()) + Message::format('test string', []) ); $this->assertEquals( 'test string', - Message::format('%s string', array('test')) + Message::format('%s string', ['test']) ); } @@ -585,23 +585,23 @@ class MessageTest extends PmaTestCase */ public function providerAffectedRows() { - return array( - array( + return [ + [ 1, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 1 row affected.</div>' - ), - array( + ], + [ 2, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 2 rows affected.</div>' - ), - array( + ], + [ 10000, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 10000 rows affected.</div>' - ) - ); + ] + ]; } /** @@ -630,23 +630,23 @@ class MessageTest extends PmaTestCase */ public function providerInsertedRows() { - return array( - array( + return [ + [ 1, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 1 row inserted.</div>' - ), - array( + ], + [ 2, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 2 rows inserted.</div>' - ), - array( + ], + [ 100000, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 100000 rows inserted.</div>' - ) - ); + ] + ]; } /** @@ -675,23 +675,23 @@ class MessageTest extends PmaTestCase */ public function providerDeletedRows() { - return array( - array( + return [ + [ 1, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 1 row deleted.</div>' - ), - array( + ], + [ 2, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 2 rows deleted.</div>' - ), - array( + ], + [ 500000, '<div class="notice"><img src="themes/dot.gif" title="" alt="" ' . 'class="icon ic_s_notice" /> 500000 rows deleted.</div>' - ) - ); + ] + ]; } /** diff --git a/test/classes/MimeTest.php b/test/classes/MimeTest.php index 861203615e..350ca0d3fc 100644 --- a/test/classes/MimeTest.php +++ b/test/classes/MimeTest.php @@ -44,23 +44,23 @@ class MimeTest extends TestCase */ public function providerForTestDetect() { - return array( - array( + return [ + [ 'pma', 'application/octet-stream' - ), - array( + ], + [ 'GIF', 'image/gif' - ), - array( + ], + [ "\x89PNG", 'image/png' - ), - array( + ], + [ chr(0xff) . chr(0xd8), 'image/jpeg' - ), - ); + ], + ]; } } diff --git a/test/classes/Navigation/NavigationTest.php b/test/classes/Navigation/NavigationTest.php index a0ac1f028d..070501c80e 100644 --- a/test/classes/Navigation/NavigationTest.php +++ b/test/classes/Navigation/NavigationTest.php @@ -121,20 +121,20 @@ class NavigationTest extends PmaTestCase ->method('fetchArray') ->will( $this->returnValue( - array( + [ 'item_name' => 'tableName', 'item_type' => 'table' - ) + ] ) ); $dbi->expects($this->at(4)) ->method('fetchArray') ->will( $this->returnValue( - array( + [ 'item_name' => 'viewName', 'item_type' => 'view' - ) + ] ) ); $dbi->expects($this->at(5)) diff --git a/test/classes/Navigation/Nodes/NodeDatabaseChildTest.php b/test/classes/Navigation/Nodes/NodeDatabaseChildTest.php index 5123bf9264..a3a17afc7c 100644 --- a/test/classes/Navigation/Nodes/NodeDatabaseChildTest.php +++ b/test/classes/Navigation/Nodes/NodeDatabaseChildTest.php @@ -41,7 +41,7 @@ class NodeDatabaseChildTest extends PmaTestCase $_SESSION['relation'][1]['PMA_VERSION'] = PMA_VERSION; $_SESSION['relation'][1]['navwork'] = true; $this->object = $this->getMockForAbstractClass( - 'PhpMyAdmin\Navigation\Nodes\NodeDatabaseChild', array('child') + 'PhpMyAdmin\Navigation\Nodes\NodeDatabaseChild', ['child'] ); } diff --git a/test/classes/Navigation/Nodes/NodeDatabaseTest.php b/test/classes/Navigation/Nodes/NodeDatabaseTest.php index da3c158808..f08c5910eb 100644 --- a/test/classes/Navigation/Nodes/NodeDatabaseTest.php +++ b/test/classes/Navigation/Nodes/NodeDatabaseTest.php @@ -30,7 +30,7 @@ class NodeDatabaseTest extends PmaTestCase $GLOBALS['server'] = 0; $GLOBALS['cfg']['DefaultTabDatabase'] = 'structure'; $GLOBALS['cfg']['MaxNavigationItems'] = 250; - $GLOBALS['cfg']['Server'] = array(); + $GLOBALS['cfg']['Server'] = []; $GLOBALS['cfg']['Server']['DisableIS'] = true; } diff --git a/test/classes/Navigation/Nodes/NodeTableTest.php b/test/classes/Navigation/Nodes/NodeTableTest.php index c695797679..4ef07cb7c6 100644 --- a/test/classes/Navigation/Nodes/NodeTableTest.php +++ b/test/classes/Navigation/Nodes/NodeTableTest.php @@ -81,12 +81,12 @@ class NodeTableTest extends PmaTestCase */ public function providerForTestIcon() { - return array( - array('structure', 'b_props'), - array('search', 'b_search'), - array('insert', 'b_insrow'), - array('sql', 'b_sql'), - array('browse', 'b_browse'), - ); + return [ + ['structure', 'b_props'], + ['search', 'b_search'], + ['insert', 'b_insrow'], + ['sql', 'b_sql'], + ['browse', 'b_browse'], + ]; } } diff --git a/test/classes/Navigation/Nodes/NodeTest.php b/test/classes/Navigation/Nodes/NodeTest.php index d1abfdbc89..d2b6988c6d 100644 --- a/test/classes/Navigation/Nodes/NodeTest.php +++ b/test/classes/Navigation/Nodes/NodeTest.php @@ -175,16 +175,16 @@ class NodeTest extends PmaTestCase public function testParents() { $parent = NodeFactory::getInstance(); - $this->assertEquals($parent->parents(), array()); // exclude self - $this->assertEquals($parent->parents(true), array($parent)); // include self + $this->assertEquals($parent->parents(), []); // exclude self + $this->assertEquals($parent->parents(true), [$parent]); // include self $child = NodeFactory::getInstance(); $parent->addChild($child); - $this->assertEquals($child->parents(), array($parent)); // exclude self + $this->assertEquals($child->parents(), [$parent]); // exclude self $this->assertEquals( $child->parents(true), - array($child, $parent) + [$child, $parent] ); // include self } @@ -300,7 +300,7 @@ class NodeTest extends PmaTestCase ); if (! isset($GLOBALS['cfg']['Server'])) { - $GLOBALS['cfg']['Server'] = array(); + $GLOBALS['cfg']['Server'] = []; } // When hide_db regular expression is present @@ -320,7 +320,7 @@ class NodeTest extends PmaTestCase unset($GLOBALS['cfg']['Server']['only_db']); // When only_db directive is present and it's an array of dbs - $GLOBALS['cfg']['Server']['only_db'] = array('onlyDbOne', 'onlyDbTwo'); + $GLOBALS['cfg']['Server']['only_db'] = ['onlyDbOne', 'onlyDbTwo']; $this->assertEquals( "WHERE TRUE AND ( `SCHEMA_NAME` LIKE 'onlyDbOne' " . "OR `SCHEMA_NAME` LIKE 'onlyDbTwo' ) ", @@ -446,12 +446,12 @@ class NodeTest extends PmaTestCase $dbi->expects($this->exactly(3)) ->method('fetchArray') ->willReturnOnConsecutiveCalls( - array( + [ '0' => 'db' - ), - array( + ], + [ '0' => 'aa_db' - ), + ], false ); diff --git a/test/classes/OperationsTest.php b/test/classes/OperationsTest.php index 7ed729c83e..d1c0e65771 100644 --- a/test/classes/OperationsTest.php +++ b/test/classes/OperationsTest.php @@ -36,11 +36,11 @@ class OperationsTest extends TestCase $GLOBALS['server'] = 1; $GLOBALS['table'] = 'table'; $GLOBALS['db'] = 'db'; - $GLOBALS['cfg'] = array( + $GLOBALS['cfg'] = [ 'ServerDefault' => 1, 'ActionLinksMode' => 'icons', 'LinkLengthLimit' => 1000, - ); + ]; $GLOBALS['cfg']['DBG']['sql'] = false; $GLOBALS['server'] = 1; @@ -143,7 +143,7 @@ class OperationsTest extends TestCase $this->assertRegExp( '/.*tbl_operations.php(.|[\n])*Alter table order by([\n]|.)*order_order.*/m', $this->operations->getHtmlForOrderTheTable( - array(array('Field' => "column1"), array('Field' => "column2")) + [['Field' => "column1"], ['Field' => "column2"]] ) ); } @@ -198,7 +198,7 @@ class OperationsTest extends TestCase $this->assertRegExp( '/.*Delete data or table.*Empty the table.*Delete the table.*/m', $this->operations->getHtmlForDeleteDataOrTable( - array("truncate" => 'foo'), array("drop" => 'bar') + ["truncate" => 'foo'], ["drop" => 'bar'] ) ); } @@ -214,7 +214,7 @@ class OperationsTest extends TestCase $this->assertRegExp( '/.*TRUNCATE.TABLE.foo.*id_truncate.*Truncate table.*/m', $this->operations->getDeleteDataOrTablelink( - array("sql" => 'TRUNCATE TABLE foo'), + ["sql" => 'TRUNCATE TABLE foo'], "TRUNCATE_TABLE", "Truncate table", "id_truncate" @@ -230,8 +230,8 @@ class OperationsTest extends TestCase public function testGetHtmlForPartitionMaintenance() { $html = $this->operations->getHtmlForPartitionMaintenance( - array("partition1", "partion2"), - array("param1" => 'foo', "param2" => 'bar') + ["partition1", "partion2"], + ["param1" => 'foo', "param2" => 'bar'] ); $this->assertRegExp('/.*action="tbl_operations.php".*/', $html); $this->assertRegExp('/.*ANALYZE.*/', $html); @@ -249,14 +249,14 @@ class OperationsTest extends TestCase $this->assertRegExp( '/.*Check referential integrity.*href="sql.php(.|[\n])*/m', $this->operations->getHtmlForReferentialIntegrityCheck( - array( - array( + [ + [ 'foreign_db' => 'db1', 'foreign_table' => "foreign1", 'foreign_field' => "foreign2" - ) - ), - array("param1" => 'a', "param2" => 'b') + ] + ], + ["param1" => 'a', "param2" => 'b'] ) ); } diff --git a/test/classes/Plugins/Auth/AuthenticationConfigTest.php b/test/classes/Plugins/Auth/AuthenticationConfigTest.php index 95dd00525a..3c753e4993 100644 --- a/test/classes/Plugins/Auth/AuthenticationConfigTest.php +++ b/test/classes/Plugins/Auth/AuthenticationConfigTest.php @@ -70,10 +70,10 @@ class AuthenticationConfigTest extends PmaTestCase */ public function testAuthCheck() { - $GLOBALS['cfg']['Server'] = array( + $GLOBALS['cfg']['Server'] = [ 'user' => 'username', 'password' => 'password', - ); + ]; $this->assertTrue( $this->object->readCredentials() ); @@ -100,7 +100,7 @@ class AuthenticationConfigTest extends PmaTestCase { $removeConstant = false; $GLOBALS['error_handler'] = new ErrorHandler; - $GLOBALS['cfg']['Servers'] = array(1); + $GLOBALS['cfg']['Servers'] = [1]; $GLOBALS['allowDeny_forbidden'] = false; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php index ba2c09011f..a3909840f5 100644 --- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php +++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php @@ -107,7 +107,7 @@ class AuthenticationCookieTest extends PmaTestCase // mock footer $mockFooter = $this->getMockBuilder('PhpMyAdmin\Footer') ->disableOriginalConstructor() - ->setMethods(array('setMinimal')) + ->setMethods(['setMinimal']) ->getMock(); $mockFooter->expects($this->once()) @@ -119,12 +119,12 @@ class AuthenticationCookieTest extends PmaTestCase $mockHeader = $this->getMockBuilder('PhpMyAdmin\Header') ->disableOriginalConstructor() ->setMethods( - array( + [ 'setBodyId', 'setTitle', 'disableMenuAndConsole', 'disableWarnings' - ) + ] ) ->getMock(); @@ -157,13 +157,13 @@ class AuthenticationCookieTest extends PmaTestCase ->will($this->returnValue($mockHeader)); $GLOBALS['pmaThemeImage'] = 'test'; - $GLOBALS['cfg']['Servers'] = array(1, 2); + $GLOBALS['cfg']['Servers'] = [1, 2]; // mock error handler $mockErrorHandler = $this->getMockBuilder('PhpMyAdmin\ErrorHandler') ->disableOriginalConstructor() - ->setMethods(array('hasDisplayErrors', 'dispErrors')) + ->setMethods(['hasDisplayErrors', 'dispErrors']) ->getMock(); $mockErrorHandler->expects($this->once()) @@ -297,7 +297,7 @@ class AuthenticationCookieTest extends PmaTestCase $GLOBALS['pmaThemeImage'] = 'test'; $GLOBALS['cfg']['Lang'] = ''; $GLOBALS['cfg']['AllowArbitraryServer'] = false; - $GLOBALS['cfg']['Servers'] = array(1); + $GLOBALS['cfg']['Servers'] = [1]; $GLOBALS['cfg']['CaptchaLoginPrivateKey'] = 'testprivkey'; $GLOBALS['cfg']['CaptchaLoginPublicKey'] = 'testpubkey'; $GLOBALS['server'] = 0; @@ -354,7 +354,7 @@ class AuthenticationCookieTest extends PmaTestCase public function testAuthHeader() { $GLOBALS['cfg']['LoginCookieDeleteAll'] = false; - $GLOBALS['cfg']['Servers'] = array(1); + $GLOBALS['cfg']['Servers'] = [1]; $this->mockResponse('Location: https://example.com/logout'); @@ -372,7 +372,7 @@ class AuthenticationCookieTest extends PmaTestCase public function testAuthHeaderPartial() { $GLOBALS['cfg']['LoginCookieDeleteAll'] = false; - $GLOBALS['cfg']['Servers'] = array(1, 2, 3); + $GLOBALS['cfg']['Servers'] = [1, 2, 3]; $GLOBALS['cfg']['Server']['LogoutURL'] = 'https://example.com/logout'; $GLOBALS['cfg']['Server']['auth_type'] = 'cookie'; @@ -418,7 +418,7 @@ class AuthenticationCookieTest extends PmaTestCase $GLOBALS['cfg']['CaptchaLoginPublicKey'] = ''; $GLOBALS['cfg']['LoginCookieDeleteAll'] = true; $GLOBALS['PMA_Config']->set('PmaAbsoluteUri', ''); - $GLOBALS['cfg']['Servers'] = array(1); + $GLOBALS['cfg']['Servers'] = [1]; $_COOKIE['pmaAuth-0'] = 'test'; @@ -443,9 +443,9 @@ class AuthenticationCookieTest extends PmaTestCase $GLOBALS['cfg']['CaptchaLoginPublicKey'] = ''; $GLOBALS['cfg']['LoginCookieDeleteAll'] = false; $GLOBALS['PMA_Config']->set('PmaAbsoluteUri', ''); - $GLOBALS['cfg']['Servers'] = array(1); + $GLOBALS['cfg']['Servers'] = [1]; $GLOBALS['server'] = 1; - $GLOBALS['cfg']['Server'] = array('auth_type' => 'cookie'); + $GLOBALS['cfg']['Server'] = ['auth_type' => 'cookie']; $_COOKIE['pmaAuth-1'] = 'test'; @@ -559,7 +559,7 @@ class AuthenticationCookieTest extends PmaTestCase // mock for blowfish function $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('cookieDecrypt')) + ->setMethods(['cookieDecrypt']) ->getMock(); $this->object->expects($this->once()) @@ -599,7 +599,7 @@ class AuthenticationCookieTest extends PmaTestCase // mock for blowfish function $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('cookieDecrypt')) + ->setMethods(['cookieDecrypt']) ->getMock(); $this->object->expects($this->at(1)) @@ -643,7 +643,7 @@ class AuthenticationCookieTest extends PmaTestCase // mock for blowfish function $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('showFailure', 'cookieDecrypt')) + ->setMethods(['showFailure', 'cookieDecrypt']) ->getMock(); $this->object->expects($this->once()) @@ -666,13 +666,13 @@ class AuthenticationCookieTest extends PmaTestCase public function testAuthSetUser() { $this->object->user = 'pmaUser2'; - $arr = array( + $arr = [ 'host' => 'a', 'port' => 1, 'socket' => true, 'ssl' => true, 'user' => 'pmaUser2' - ); + ]; $GLOBALS['cfg']['Server'] = $arr; $GLOBALS['cfg']['Server']['user'] = 'pmaUser'; @@ -716,13 +716,13 @@ class AuthenticationCookieTest extends PmaTestCase public function testAuthSetUserWithHeaders() { $this->object->user = 'pmaUser2'; - $arr = array( + $arr = [ 'host' => 'a', 'port' => 1, 'socket' => true, 'ssl' => true, 'user' => 'pmaUser2' - ); + ]; $GLOBALS['cfg']['Server'] = $arr; $GLOBALS['cfg']['Server']['host'] = 'b'; @@ -752,15 +752,15 @@ class AuthenticationCookieTest extends PmaTestCase { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; $_COOKIE['pmaAuth-2'] = 'pass'; $this->mockResponse( - array('Cache-Control: no-store, no-cache, must-revalidate'), - array('Pragma: no-cache') + ['Cache-Control: no-store, no-cache, must-revalidate'], + ['Pragma: no-cache'] ); $this->object->showFailure('empty-denied'); @@ -779,15 +779,15 @@ class AuthenticationCookieTest extends PmaTestCase { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; $_COOKIE['pmaAuth-2'] = 'pass'; $this->mockResponse( - array('Cache-Control: no-store, no-cache, must-revalidate'), - array('Pragma: no-cache') + ['Cache-Control: no-store, no-cache, must-revalidate'], + ['Pragma: no-cache'] ); $this->object->showFailure('allow-denied'); @@ -804,7 +804,7 @@ class AuthenticationCookieTest extends PmaTestCase { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; @@ -814,8 +814,8 @@ class AuthenticationCookieTest extends PmaTestCase $GLOBALS['cfg']['LoginCookieValidity'] = 10; $this->mockResponse( - array('Cache-Control: no-store, no-cache, must-revalidate'), - array('Pragma: no-cache') + ['Cache-Control: no-store, no-cache, must-revalidate'], + ['Pragma: no-cache'] ); $this->object->showFailure('no-activity'); @@ -832,7 +832,7 @@ class AuthenticationCookieTest extends PmaTestCase { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $GLOBALS['server'] = 2; @@ -850,8 +850,8 @@ class AuthenticationCookieTest extends PmaTestCase $GLOBALS['errno'] = 42; $this->mockResponse( - array('Cache-Control: no-store, no-cache, must-revalidate'), - array('Pragma: no-cache') + ['Cache-Control: no-store, no-cache, must-revalidate'], + ['Pragma: no-cache'] ); $this->object->showFailure(''); @@ -868,7 +868,7 @@ class AuthenticationCookieTest extends PmaTestCase { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationCookie') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') @@ -886,8 +886,8 @@ class AuthenticationCookieTest extends PmaTestCase unset($GLOBALS['errno']); $this->mockResponse( - array('Cache-Control: no-store, no-cache, must-revalidate'), - array('Pragma: no-cache') + ['Cache-Control: no-store, no-cache, must-revalidate'], + ['Pragma: no-cache'] ); $this->object->showFailure(''); @@ -1101,10 +1101,10 @@ class AuthenticationCookieTest extends PmaTestCase $this->object->handlePasswordChange($newPassword); - $payload = array( + $payload = [ 'password' => $newPassword, 'server' => 'b 2' - ); + ]; $method = new ReflectionMethod( 'PhpMyAdmin\Plugins\Auth\AuthenticationCookie', '_getSessionEncryptionSecret' @@ -1127,38 +1127,38 @@ class AuthenticationCookieTest extends PmaTestCase */ public function secretsProvider() { - return array( + return [ // Optimal case - array( + [ '1234567890123456abcdefghijklmnop', '1234567890123456', 'abcdefghijklmnop', - ), + ], // Overlapping secret - array( + [ '12345678901234567', '1234567890123456', '2345678901234567', - ), + ], // Short secret - array( + [ '1234567890123456', '1234567890123451', '2345678901234562', - ), + ], // Really short secret - array( + [ '12', '1111111111111111', '2222222222222222', - ), + ], // Too short secret - array( + [ '1', '1111111111111111', '1111111111111111', - ), - ); + ], + ]; } /** @@ -1239,133 +1239,133 @@ class AuthenticationCookieTest extends PmaTestCase */ public function checkRulesProvider() { - return array( - 'nopass-ok' => array( + return [ + 'nopass-ok' => [ 'testUser', '', '1.2.3.4', true, true, - array(), + [], '', - ), - 'nopass' => array( + ], + 'nopass' => [ 'testUser', '', '1.2.3.4', true, false, - array(), + [], 'Login without a password is forbidden', - ), - 'root-ok' => array( + ], + 'root-ok' => [ 'root', 'root', '1.2.3.4', true, true, - array(), + [], '', - ), - 'root' => array( + ], + 'root' => [ 'root', 'root', '1.2.3.4', false, true, - array(), + [], 'Access denied!', - ), - 'rules-deny-allow-ok' => array( + ], + 'rules-deny-allow-ok' => [ 'root', 'root', '1.2.3.4', true, true, - array( + [ 'order' => 'deny,allow', - 'rules' => array( + 'rules' => [ 'allow root 1.2.3.4', 'deny % from all', - ), - ), + ], + ], '', - ), - 'rules-deny-allow-reject' => array( + ], + 'rules-deny-allow-reject' => [ 'user', 'root', '1.2.3.4', true, true, - array( + [ 'order' => 'deny,allow', - 'rules' => array( + 'rules' => [ 'allow root 1.2.3.4', 'deny % from all', - ), - ), + ], + ], 'Access denied!', - ), - 'rules-allow-deny-ok' => array( + ], + 'rules-allow-deny-ok' => [ 'root', 'root', '1.2.3.4', true, true, - array( + [ 'order' => 'allow,deny', - 'rules' => array( + 'rules' => [ 'deny user from all', 'allow root 1.2.3.4', - ), - ), + ], + ], '', - ), - 'rules-allow-deny-reject' => array( + ], + 'rules-allow-deny-reject' => [ 'user', 'root', '1.2.3.4', true, true, - array( + [ 'order' => 'allow,deny', - 'rules' => array( + 'rules' => [ 'deny user from all', 'allow root 1.2.3.4', - ), - ), + ], + ], 'Access denied!', - ), - 'rules-explicit-ok' => array( + ], + 'rules-explicit-ok' => [ 'root', 'root', '1.2.3.4', true, true, - array( + [ 'order' => 'explicit', - 'rules' => array( + 'rules' => [ 'deny user from all', 'allow root 1.2.3.4', - ), - ), + ], + ], '', - ), - 'rules-explicit-reject' => array( + ], + 'rules-explicit-reject' => [ 'user', 'root', '1.2.3.4', true, true, - array( + [ 'order' => 'explicit', - 'rules' => array( + 'rules' => [ 'deny user from all', 'allow root 1.2.3.4', - ), - ), + ], + ], 'Access denied!', - ), - ); + ], + ]; } } diff --git a/test/classes/Plugins/Auth/AuthenticationHttpTest.php b/test/classes/Plugins/Auth/AuthenticationHttpTest.php index fe98e14fc6..5f1da34acf 100644 --- a/test/classes/Plugins/Auth/AuthenticationHttpTest.php +++ b/test/classes/Plugins/Auth/AuthenticationHttpTest.php @@ -34,7 +34,7 @@ class AuthenticationHttpTest extends PmaTestCase { $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); - $GLOBALS['cfg']['Servers'] = array(); + $GLOBALS['cfg']['Servers'] = []; $GLOBALS['server'] = 0; $GLOBALS['db'] = 'db'; $GLOBALS['table'] = 'table'; @@ -70,7 +70,7 @@ class AuthenticationHttpTest extends PmaTestCase // mock footer $mockFooter = $this->getMockBuilder('PhpMyAdmin\Footer') ->disableOriginalConstructor() - ->setMethods(array('setMinimal')) + ->setMethods(['setMinimal']) ->getMock(); $mockFooter->expects($this->exactly($set_minimal)) @@ -82,7 +82,7 @@ class AuthenticationHttpTest extends PmaTestCase $mockHeader = $this->getMockBuilder('PhpMyAdmin\Header') ->disableOriginalConstructor() ->setMethods( - array('setBodyId', 'setTitle', 'disableMenuAndConsole', 'addHTML') + ['setBodyId', 'setTitle', 'disableMenuAndConsole', 'addHTML'] ) ->getMock(); @@ -137,7 +137,7 @@ class AuthenticationHttpTest extends PmaTestCase $this->doMockResponse( 0, 0, 0, - array('Location: https://example.com/logout') + ['Location: https://example.com/logout'] ); } @@ -151,8 +151,8 @@ class AuthenticationHttpTest extends PmaTestCase $this->doMockResponse( 1, 1, 1, - array('WWW-Authenticate: Basic realm="phpMyAdmin verboseMessag"'), - array('status: 401 Unauthorized'), + ['WWW-Authenticate: Basic realm="phpMyAdmin verboseMessag"'], + ['status: 401 Unauthorized'], 401 ); } @@ -167,8 +167,8 @@ class AuthenticationHttpTest extends PmaTestCase $this->doMockResponse( 1, 1, 1, - array('WWW-Authenticate: Basic realm="phpMyAdmin hst"'), - array('status: 401 Unauthorized'), + ['WWW-Authenticate: Basic realm="phpMyAdmin hst"'], + ['status: 401 Unauthorized'], 401 ); } @@ -183,8 +183,8 @@ class AuthenticationHttpTest extends PmaTestCase $this->doMockResponse( 1, 1, 1, - array('WWW-Authenticate: Basic realm="realmmessage"'), - array('status: 401 Unauthorized'), + ['WWW-Authenticate: Basic realm="realmmessage"'], + ['status: 401 Unauthorized'], 401 ); } @@ -238,8 +238,8 @@ class AuthenticationHttpTest extends PmaTestCase */ public function readCredentialsProvider() { - return array( - array( + return [ + [ 'Basic ' . base64_encode('foo:bar'), 'pswd', 'PHP_AUTH_USER', @@ -248,8 +248,8 @@ class AuthenticationHttpTest extends PmaTestCase '', 'bar', 'foo' - ), - array( + ], + [ 'Basic ' . base64_encode('foobar'), 'pswd', 'REMOTE_USER', @@ -257,8 +257,8 @@ class AuthenticationHttpTest extends PmaTestCase true, 'Basic Zm9vYmFy', 'pswd' - ), - array( + ], + [ 'Basic ' . base64_encode('foobar:'), 'pswd', 'AUTH_USER', @@ -266,8 +266,8 @@ class AuthenticationHttpTest extends PmaTestCase true, 'foobar', false - ), - array( + ], + [ 'Basic ' . base64_encode(':foobar'), 'pswd', 'HTTP_AUTHORIZATION', @@ -275,8 +275,8 @@ class AuthenticationHttpTest extends PmaTestCase true, 'Basic OmZvb2Jhcg==', 'pswd' - ), - array( + ], + [ 'BasicTest', 'pswd', 'Authorization', @@ -284,8 +284,8 @@ class AuthenticationHttpTest extends PmaTestCase true, 'BasicTest', 'pswd' - ), - ); + ], + ]; } /** @@ -329,27 +329,27 @@ class AuthenticationHttpTest extends PmaTestCase // case 2 $this->object->user = 'testUser'; $this->object->password = 'testPass'; - $GLOBALS['cfg']['Servers'][1] = array( + $GLOBALS['cfg']['Servers'][1] = [ 'host' => 'a', 'user' => 'testUser', 'foo' => 'bar' - ); + ]; - $GLOBALS['cfg']['Server']= array( + $GLOBALS['cfg']['Server']= [ 'host' => 'a', 'user' => 'user2' - ); + ]; $this->assertTrue( $this->object->storeCredentials() ); $this->assertEquals( - array( + [ 'user' => 'testUser', 'password' => 'testPass', 'host' => 'a', - ), + ], $GLOBALS['cfg']['Server'] ); @@ -362,27 +362,27 @@ class AuthenticationHttpTest extends PmaTestCase $GLOBALS['server'] = 3; $this->object->user = 'testUser'; $this->object->password = 'testPass'; - $GLOBALS['cfg']['Servers'][1] = array( + $GLOBALS['cfg']['Servers'][1] = [ 'host' => 'a', 'user' => 'testUsers', 'foo' => 'bar' - ); + ]; - $GLOBALS['cfg']['Server']= array( + $GLOBALS['cfg']['Server']= [ 'host' => 'a', 'user' => 'user2' - ); + ]; $this->assertTrue( $this->object->storeCredentials() ); $this->assertEquals( - array( + [ 'user' => 'testUser', 'password' => 'testPass', 'host' => 'a' - ), + ], $GLOBALS['cfg']['Server'] ); @@ -432,7 +432,7 @@ class AuthenticationHttpTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationHttp') ->disableOriginalConstructor() - ->setMethods(array('authForm')) + ->setMethods(['authForm']) ->getMock(); $this->object->expects($this->exactly(2)) diff --git a/test/classes/Plugins/Auth/AuthenticationSignonTest.php b/test/classes/Plugins/Auth/AuthenticationSignonTest.php index 3ff893d201..4b58fcbcbb 100644 --- a/test/classes/Plugins/Auth/AuthenticationSignonTest.php +++ b/test/classes/Plugins/Auth/AuthenticationSignonTest.php @@ -92,7 +92,7 @@ class AuthenticationSignonTest extends PmaTestCase { $this->mockResponse('Location: https://example.com/SignonURL'); - $GLOBALS['header'] = array(); + $GLOBALS['header'] = []; $GLOBALS['cfg']['Server']['SignonURL'] = 'https://example.com/SignonURL'; $GLOBALS['cfg']['Server']['LogoutURL'] = ''; @@ -125,7 +125,7 @@ class AuthenticationSignonTest extends PmaTestCase $_SESSION['LAST_SIGNON_URL'] = 'https://example.com/SignonURL'; $GLOBALS['cfg']['Server']['SignonScript'] = './examples/signon-script.php'; $GLOBALS['cfg']['Server']['SignonSession'] = 'session123'; - $GLOBALS['cfg']['Server']['SignonCookieParams'] = array(); + $GLOBALS['cfg']['Server']['SignonCookieParams'] = []; $GLOBALS['cfg']['Server']['host'] = 'localhost'; $GLOBALS['cfg']['Server']['port'] = '80'; $GLOBALS['cfg']['Server']['user'] = 'user'; @@ -161,7 +161,7 @@ class AuthenticationSignonTest extends PmaTestCase $GLOBALS['cfg']['Server']['SignonURL'] = 'https://example.com/SignonURL'; $GLOBALS['cfg']['Server']['SignonSession'] = 'session123'; - $GLOBALS['cfg']['Server']['SignonCookieParams'] = array(); + $GLOBALS['cfg']['Server']['SignonCookieParams'] = []; $GLOBALS['cfg']['Server']['host'] = 'localhost'; $GLOBALS['cfg']['Server']['port'] = '80'; $GLOBALS['cfg']['Server']['user'] = 'user'; @@ -171,7 +171,7 @@ class AuthenticationSignonTest extends PmaTestCase $_SESSION['PMA_single_signon_password'] = 'pass123'; $_SESSION['PMA_single_signon_host'] = 'local'; $_SESSION['PMA_single_signon_port'] = '12'; - $_SESSION['PMA_single_signon_cfgupdate'] = array('foo' => 'bar'); + $_SESSION['PMA_single_signon_cfgupdate'] = ['foo' => 'bar']; $_SESSION['PMA_single_signon_token'] = 'pmaToken'; $sessionName = session_name(); $sessionID = session_id(); @@ -179,15 +179,15 @@ class AuthenticationSignonTest extends PmaTestCase $this->object->logOut(); $this->assertEquals( - array( + [ 'SignonURL' => 'https://example.com/SignonURL', 'SignonScript' => '', 'SignonSession' => 'session123', - 'SignonCookieParams' => array(), + 'SignonCookieParams' => [], 'host' => 'localhost', 'port' => '80', 'user' => 'user', - ), + ], $GLOBALS['cfg']['Server'] ); @@ -216,7 +216,7 @@ class AuthenticationSignonTest extends PmaTestCase { $GLOBALS['cfg']['Server']['SignonURL'] = 'https://example.com/SignonURL'; $GLOBALS['cfg']['Server']['SignonSession'] = 'session123'; - $GLOBALS['cfg']['Server']['SignonCookieParams'] = array(); + $GLOBALS['cfg']['Server']['SignonCookieParams'] = []; $GLOBALS['cfg']['Server']['host'] = 'localhost'; $GLOBALS['cfg']['Server']['port'] = '80'; $GLOBALS['cfg']['Server']['user'] = 'user'; @@ -227,7 +227,7 @@ class AuthenticationSignonTest extends PmaTestCase $_SESSION['PMA_single_signon_password'] = 'pass123'; $_SESSION['PMA_single_signon_host'] = 'local'; $_SESSION['PMA_single_signon_port'] = '12'; - $_SESSION['PMA_single_signon_cfgupdate'] = array('foo' => 'bar'); + $_SESSION['PMA_single_signon_cfgupdate'] = ['foo' => 'bar']; $_SESSION['PMA_single_signon_token'] = 'pmaToken'; $this->assertTrue( @@ -282,7 +282,7 @@ class AuthenticationSignonTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationSignon') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -309,7 +309,7 @@ class AuthenticationSignonTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationSignon') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -335,7 +335,7 @@ class AuthenticationSignonTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationSignon') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -363,7 +363,7 @@ class AuthenticationSignonTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationSignon') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) @@ -399,7 +399,7 @@ class AuthenticationSignonTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Auth\AuthenticationSignon') ->disableOriginalConstructor() - ->setMethods(array('showLoginForm')) + ->setMethods(['showLoginForm']) ->getMock(); $this->object->expects($this->exactly(1)) diff --git a/test/classes/Plugins/Export/ExportCodegenTest.php b/test/classes/Plugins/Export/ExportCodegenTest.php index b807ca2902..196083687d 100644 --- a/test/classes/Plugins/Export/ExportCodegenTest.php +++ b/test/classes/Plugins/Export/ExportCodegenTest.php @@ -65,18 +65,18 @@ class ExportCodegenTest extends PmaTestCase $attrCgHandlers->setAccessible(true); $this->assertEquals( - array( + [ "NHibernate C# DO", "NHibernate XML" - ), + ], $attrCgFormats->getValue($this->object) ); $this->assertEquals( - array( + [ "_handleNHibernateCSBody", "_handleNHibernateXMLBody" - ), + ], $attrCgHandlers->getValue($this->object) ); } @@ -178,10 +178,10 @@ class ExportCodegenTest extends PmaTestCase ); $this->assertEquals( - array( + [ "NHibernate C# DO", "NHibernate XML" - ), + ], $select->getValues() ); } @@ -332,7 +332,7 @@ class ExportCodegenTest extends PmaTestCase $dbi->expects($this->at(1)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array('a', 'b', 'c', false, 'e', 'f'))); + ->will($this->returnValue(['a', 'b', 'c', false, 'e', 'f'])); $dbi->expects($this->at(2)) ->method('fetchRow') @@ -397,12 +397,12 @@ class ExportCodegenTest extends PmaTestCase $dbi->expects($this->at(1)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array('a', 'b', 'c', false, 'e', 'f'))); + ->will($this->returnValue(['a', 'b', 'c', false, 'e', 'f'])); $dbi->expects($this->at(2)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array('g', 'h', 'i', 'PRI', 'j', 'k'))); + ->will($this->returnValue(['g', 'h', 'i', 'PRI', 'j', 'k'])); $dbi->expects($this->at(3)) ->method('fetchRow') @@ -450,10 +450,10 @@ class ExportCodegenTest extends PmaTestCase $getter->setAccessible(true); $setter->setAccessible(true); - $setter->invoke($this->object, array(1, 2)); + $setter->invoke($this->object, [1, 2]); $this->assertEquals( - array(1, 2), + [1, 2], $getter->invoke($this->object) ); } @@ -475,10 +475,10 @@ class ExportCodegenTest extends PmaTestCase $getter->setAccessible(true); $setter->setAccessible(true); - $setter->invoke($this->object, array(1, 2)); + $setter->invoke($this->object, [1, 2]); $this->assertEquals( - array(1, 2), + [1, 2], $getter->invoke($this->object) ); } diff --git a/test/classes/Plugins/Export/ExportCsvTest.php b/test/classes/Plugins/Export/ExportCsvTest.php index 8304e89021..41c8ffbdbe 100644 --- a/test/classes/Plugins/Export/ExportCsvTest.php +++ b/test/classes/Plugins/Export/ExportCsvTest.php @@ -525,7 +525,7 @@ class ExportCsvTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array(null, 'b', 'c', false, 'e', 'f'))); + ->will($this->returnValue([null, 'b', 'c', false, 'e', 'f'])); $dbi->expects($this->at(4)) ->method('fetchRow') @@ -578,7 +578,7 @@ class ExportCsvTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array(1 => 'a'))); + ->will($this->returnValue([1 => 'a'])); $dbi->expects($this->at(4)) ->method('fetchRow') @@ -625,7 +625,7 @@ class ExportCsvTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array("test\015\012\n"))); + ->will($this->returnValue(["test\015\012\n"])); $dbi->expects($this->at(4)) ->method('fetchRow') @@ -675,7 +675,7 @@ class ExportCsvTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array("test\015\n"))); + ->will($this->returnValue(["test\015\n"])); $dbi->expects($this->at(4)) ->method('fetchRow') @@ -723,7 +723,7 @@ class ExportCsvTest extends PmaTestCase $dbi->expects($this->at(4)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array("test\015\n", "test\n"))); + ->will($this->returnValue(["test\015\n", "test\n"])); $dbi->expects($this->at(5)) ->method('fetchRow') diff --git a/test/classes/Plugins/Export/ExportExcelTest.php b/test/classes/Plugins/Export/ExportExcelTest.php index 2257b28a71..85a713eac1 100644 --- a/test/classes/Plugins/Export/ExportExcelTest.php +++ b/test/classes/Plugins/Export/ExportExcelTest.php @@ -176,11 +176,11 @@ class ExportExcelTest extends PmaTestCase ); $this->assertEquals( - array( + [ 'win' => 'Windows', 'mac_excel2003' => 'Excel 2003 / Macintosh', 'mac_excel2008' => 'Excel 2008 / Macintosh' - ), + ], $property->getValues() ); diff --git a/test/classes/Plugins/Export/ExportHtmlwordTest.php b/test/classes/Plugins/Export/ExportHtmlwordTest.php index 8ef0c81eed..93922c1392 100644 --- a/test/classes/Plugins/Export/ExportHtmlwordTest.php +++ b/test/classes/Plugins/Export/ExportHtmlwordTest.php @@ -140,11 +140,11 @@ class ExportHtmlwordTest extends PmaTestCase ); $this->assertEquals( - array( + [ 'structure' => __('structure'), 'data' => __('data'), 'structure_and_data' => __('structure and data') - ), + ], $property->getValues() ); @@ -356,7 +356,7 @@ class ExportHtmlwordTest extends PmaTestCase $dbi->expects($this->at(7)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array(null, '0', 'test', false))); + ->will($this->returnValue([null, '0', 'test', false])); $dbi->expects($this->at(8)) ->method('fetchRow') @@ -404,21 +404,21 @@ class ExportHtmlwordTest extends PmaTestCase public function testGetTableDefStandIn() { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportHtmlword') - ->setMethods(array('formatOneColumnDefinition')) + ->setMethods(['formatOneColumnDefinition']) ->getMock(); // case 1 - $keys = array( - array( + $keys = [ + [ 'Non_unique' => 0, 'Column_name' => 'name1' - ), - array( + ], + [ 'Non_unique' => 1, 'Column_name' => 'name2' - ) - ); + ] + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -432,13 +432,13 @@ class ExportHtmlwordTest extends PmaTestCase $dbi->expects($this->once()) ->method('getColumns') ->with('database', 'view') - ->will($this->returnValue(array(array('Field' => 'column')))); + ->will($this->returnValue([['Field' => 'column']])); $GLOBALS['dbi'] = $dbi; $this->object->expects($this->once()) ->method('formatOneColumnDefinition') - ->with(array('Field' => 'column'), array('name1'), 'column') + ->with(['Field' => 'column'], ['name1'], 'column') ->will($this->returnValue(1)); $this->assertEquals( @@ -460,19 +460,19 @@ class ExportHtmlwordTest extends PmaTestCase public function testGetTableDef() { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportHtmlword') - ->setMethods(array('formatOneColumnDefinition')) + ->setMethods(['formatOneColumnDefinition']) ->getMock(); - $keys = array( - array( + $keys = [ + [ 'Non_unique' => 0, 'Column_name' => 'name1' - ), - array( + ], + [ 'Non_unique' => 1, 'Column_name' => 'name2' - ) - ); + ] + ]; // case 1 @@ -483,14 +483,14 @@ class ExportHtmlwordTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array(), - array( - 'fieldname' => array( + [], + [ + 'fieldname' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<' - ) - ) + ] + ] ); $dbi->expects($this->once()) @@ -498,13 +498,13 @@ class ExportHtmlwordTest extends PmaTestCase ->with('database', '') ->will($this->returnValue($keys)); - $columns = array( + $columns = [ 'Field' => 'fieldname' - ); + ]; $dbi->expects($this->once()) ->method('getColumns') ->with('database', '') - ->will($this->returnValue(array($columns))); + ->will($this->returnValue([$columns])); $dbi->expects($this->any()) ->method('query') @@ -518,9 +518,9 @@ class ExportHtmlwordTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('fieldname' => 'testComment') - ) + [ + 'comment' => ['fieldname' => 'testComment'] + ] ) ); $dbi->expects($this->any())->method('escapeString') @@ -530,11 +530,11 @@ class ExportHtmlwordTest extends PmaTestCase $this->object->expects($this->exactly(3)) ->method('formatOneColumnDefinition') - ->with($columns, array('name1')) + ->with($columns, ['name1']) ->will($this->returnValue(1)); $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -542,7 +542,7 @@ class ExportHtmlwordTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; $result = $this->object->getTableDef( 'database', @@ -573,19 +573,19 @@ class ExportHtmlwordTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array( - 'fieldname' => array( + [ + 'fieldname' => [ 'foreign_table' => 'ftable', 'foreign_field' => 'ffield' - ) - ), - array( - 'field' => array( + ] + ], + [ + 'field' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<' - ) - ) + ] + ] ); $dbi->expects($this->once()) @@ -593,14 +593,14 @@ class ExportHtmlwordTest extends PmaTestCase ->with('database', '') ->will($this->returnValue($keys)); - $columns = array( + $columns = [ 'Field' => 'fieldname' - ); + ]; $dbi->expects($this->once()) ->method('getColumns') ->with('database', '') - ->will($this->returnValue(array($columns))); + ->will($this->returnValue([$columns])); $dbi->expects($this->any()) ->method('query') @@ -614,9 +614,9 @@ class ExportHtmlwordTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('field' => 'testComment') - ) + [ + 'comment' => ['field' => 'testComment'] + ] ) ); $dbi->expects($this->any())->method('escapeString') @@ -625,7 +625,7 @@ class ExportHtmlwordTest extends PmaTestCase $GLOBALS['dbi'] = $dbi; $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -633,7 +633,7 @@ class ExportHtmlwordTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; $result = $this->object->getTableDef( 'database', @@ -664,14 +664,14 @@ class ExportHtmlwordTest extends PmaTestCase ->with('database', '') ->will($this->returnValue($keys)); - $columns = array( + $columns = [ 'Field' => 'fieldname' - ); + ]; $dbi->expects($this->once()) ->method('getColumns') ->with('database', '') - ->will($this->returnValue(array($columns))); + ->will($this->returnValue([$columns])); $dbi->expects($this->any()) ->method('query') @@ -685,9 +685,9 @@ class ExportHtmlwordTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('field' => 'testComment') - ) + [ + 'comment' => ['field' => 'testComment'] + ] ) ); $dbi->expects($this->any())->method('escapeString') @@ -696,7 +696,7 @@ class ExportHtmlwordTest extends PmaTestCase $GLOBALS['dbi'] = $dbi; $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => false, 'commwork' => false, @@ -704,7 +704,7 @@ class ExportHtmlwordTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; $result = $this->object->getTableDef( 'database', @@ -735,14 +735,14 @@ class ExportHtmlwordTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $triggers = array( - array( + $triggers = [ + [ 'name' => 'tna"me', 'action_timing' => 'ac>t', 'event_manipulation' => 'manip&', 'definition' => 'def' - ) - ); + ] + ]; $dbi->expects($this->once()) ->method('getTriggers') @@ -782,7 +782,7 @@ class ExportHtmlwordTest extends PmaTestCase ->will($this->returnValue(1)); $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportHtmlword') - ->setMethods(array('getTableDef', 'getTriggers', 'getTableDefStandIn')) + ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) @@ -797,7 +797,7 @@ class ExportHtmlwordTest extends PmaTestCase $this->object->expects($this->at(2)) ->method('getTableDef') - ->with('db', 'tbl', false, false, false, true, array()) + ->with('db', 'tbl', false, false, false, true, []) ->will($this->returnValue('dumpText3')); $this->object->expects($this->once()) @@ -872,16 +872,16 @@ class ExportHtmlwordTest extends PmaTestCase ); $method->setAccessible(true); - $cols = array( + $cols = [ 'Null' => 'Yes', 'Field' => 'field', 'Key' => 'PRI', 'Type' => 'set(abc)enum123' - ); + ]; - $unique_keys = array( + $unique_keys = [ 'field' - ); + ]; $this->assertEquals( '<tr class="print-category"><td class="print"><em>' . @@ -890,17 +890,17 @@ class ExportHtmlwordTest extends PmaTestCase $method->invoke($this->object, $cols, $unique_keys) ); - $cols = array( + $cols = [ 'Null' => 'NO', 'Field' => 'fields', 'Key' => 'COMP', 'Type' => '', 'Default' => 'def' - ); + ]; - $unique_keys = array( + $unique_keys = [ 'field' - ); + ]; $this->assertEquals( '<tr class="print-category"><td class="print">fields</td>' . diff --git a/test/classes/Plugins/Export/ExportJsonTest.php b/test/classes/Plugins/Export/ExportJsonTest.php index 460cf75a1c..b757860e59 100644 --- a/test/classes/Plugins/Export/ExportJsonTest.php +++ b/test/classes/Plugins/Export/ExportJsonTest.php @@ -234,12 +234,12 @@ class ExportJsonTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchRow') ->with(null) - ->will($this->returnValue(array('foo'))); + ->will($this->returnValue(['foo'])); $dbi->expects($this->at(4)) ->method('fetchRow') ->with(null) - ->will($this->returnValue(array('bar'))); + ->will($this->returnValue(['bar'])); $dbi->expects($this->at(5)) ->method('fetchRow') diff --git a/test/classes/Plugins/Export/ExportLatexTest.php b/test/classes/Plugins/Export/ExportLatexTest.php index 5ef6ddf8e8..10f9ce816a 100644 --- a/test/classes/Plugins/Export/ExportLatexTest.php +++ b/test/classes/Plugins/Export/ExportLatexTest.php @@ -37,7 +37,7 @@ class ExportLatexTest extends PmaTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = true; $GLOBALS['save_on_server'] = false; - $GLOBALS['plugin_param'] = array(); + $GLOBALS['plugin_param'] = []; $GLOBALS['plugin_param']['export_type'] = 'table'; $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfgRelation']['relation'] = true; @@ -177,11 +177,11 @@ class ExportLatexTest extends PmaTestCase ); $this->assertEquals( - array( + [ 'structure' => __('structure'), 'data' => __('data'), 'structure_and_data' => __('structure and data') - ), + ], $property->getValues() ); @@ -576,12 +576,12 @@ class ExportLatexTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchAssoc') ->with(null) - ->will($this->returnValue(array('f1' => 'foo$%'))); + ->will($this->returnValue(['f1' => 'foo$%'])); $dbi->expects($this->at(4)) ->method('fetchAssoc') ->with(null) - ->will($this->returnValue(array('f1' => null))); + ->will($this->returnValue(['f1' => null])); $dbi->expects($this->at(5)) ->method('fetchAssoc') @@ -632,12 +632,12 @@ class ExportLatexTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchAssoc') ->with(null) - ->will($this->returnValue(array('f1' => 'foo$%'))); + ->will($this->returnValue(['f1' => 'foo$%'])); $dbi->expects($this->at(4)) ->method('fetchAssoc') ->with(null) - ->will($this->returnValue(array('f1' => null))); + ->will($this->returnValue(['f1' => null])); $dbi->expects($this->at(5)) ->method('fetchAssoc') @@ -669,16 +669,16 @@ class ExportLatexTest extends PmaTestCase // ->setMethods(array('formatOneColumnDefinition')) // ->getMock(); - $keys = array( - array( + $keys = [ + [ 'Non_unique' => 0, 'Column_name' => 'name1' - ), - array( + ], + [ 'Non_unique' => 1, 'Column_name' => 'name2' - ) - ); + ] + ]; // case 1 @@ -694,31 +694,31 @@ class ExportLatexTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array(), - array( - 'name1' => array( + [], + [ + 'name1' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'testmimetype_' - ) - ) + ] + ] ); - $columns = array( - array( + $columns = [ + [ 'Null' => 'Yes', 'Field' => 'name1', 'Key' => 'PRI', 'Type' => 'set(abc)enum123' - ), - array( + ], + [ 'Null' => 'NO', 'Field' => 'fields', 'Key' => 'COMP', 'Type' => '', 'Default' => 'def' - ) - ); + ] + ]; $dbi->expects($this->once()) ->method('getColumns') ->with('database', '') @@ -736,9 +736,9 @@ class ExportLatexTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('name1' => 'testComment') - ) + [ + 'comment' => ['name1' => 'testComment'] + ] ) ); @@ -748,7 +748,7 @@ class ExportLatexTest extends PmaTestCase } $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -756,7 +756,7 @@ class ExportLatexTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; ob_start(); $this->assertTrue( @@ -807,20 +807,20 @@ class ExportLatexTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array( - 'name1' => array( + [ + 'name1' => [ 'foreign_table' => 'ftable', 'foreign_field' => 'ffield' - ), - 'foreign_keys_data' => array() - ), - array( - 'field' => array( + ], + 'foreign_keys_data' => [] + ], + [ + 'field' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<' - ) - ) + ] + ] ); $dbi->expects($this->once()) @@ -845,16 +845,16 @@ class ExportLatexTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('field' => 'testComment') - ) + [ + 'comment' => ['field' => 'testComment'] + ] ) ); $GLOBALS['dbi'] = $dbi; $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -862,7 +862,7 @@ class ExportLatexTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; ob_start(); $this->assertTrue( @@ -914,9 +914,9 @@ class ExportLatexTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('field' => 'testComment') - ) + [ + 'comment' => ['field' => 'testComment'] + ] ) ); @@ -930,7 +930,7 @@ class ExportLatexTest extends PmaTestCase $GLOBALS['cfg']['Server']['host'] = 'localhost'; $GLOBALS['cfg']['Server']['verbose'] = 'verb'; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => false, 'commwork' => false, @@ -938,7 +938,7 @@ class ExportLatexTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; ob_start(); $this->assertTrue( diff --git a/test/classes/Plugins/Export/ExportMediawikiTest.php b/test/classes/Plugins/Export/ExportMediawikiTest.php index 11a0f24200..dec60dbb39 100644 --- a/test/classes/Plugins/Export/ExportMediawikiTest.php +++ b/test/classes/Plugins/Export/ExportMediawikiTest.php @@ -153,11 +153,11 @@ class ExportMediawikiTest extends PmaTestCase ); $this->assertEquals( - array( + [ 'structure' => __('structure'), 'data' => __('data'), 'structure_and_data' => __('structure and data') - ), + ], $sgHeader->getValues() ); @@ -267,24 +267,24 @@ class ExportMediawikiTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $columns = array( - array( + $columns = [ + [ 'Null' => 'Yes', 'Field' => 'name1', 'Key' => 'PRI', 'Type' => 'set(abc)enum123', 'Default' => '', 'Extra' => '' - ), - array( + ], + [ 'Null' => 'NO', 'Field' => 'fields', 'Key' => 'COMP', 'Type' => '', 'Default' => 'def', 'Extra' => 'ext' - ) - ); + ] + ]; $dbi->expects($this->at(0)) ->method('getColumns') @@ -348,7 +348,7 @@ class ExportMediawikiTest extends PmaTestCase $dbi->expects($this->once()) ->method('getColumnNames') ->with('db', 'table') - ->will($this->returnValue(array('name1', 'fields'))); + ->will($this->returnValue(['name1', 'fields'])); $dbi->expects($this->once()) ->method('query') @@ -363,12 +363,12 @@ class ExportMediawikiTest extends PmaTestCase $dbi->expects($this->at(3)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array('r1', 'r2'))); + ->will($this->returnValue(['r1', 'r2'])); $dbi->expects($this->at(4)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array('r3', ''))); + ->will($this->returnValue(['r3', ''])); $dbi->expects($this->at(4)) ->method('fetchRow') diff --git a/test/classes/Plugins/Export/ExportOdsTest.php b/test/classes/Plugins/Export/ExportOdsTest.php index 6885180d81..5ce85ea51e 100644 --- a/test/classes/Plugins/Export/ExportOdsTest.php +++ b/test/classes/Plugins/Export/ExportOdsTest.php @@ -272,7 +272,7 @@ class ExportOdsTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $a = new stdClass; $flags[] = $a; @@ -346,10 +346,10 @@ class ExportOdsTest extends PmaTestCase ->with(true) ->will( $this->returnValue( - array( + [ null, '01-01-2000', '01-01-2000', '01-01-2000 10:00:00', "01-01-2014 10:02:00", "t>s", "a&b", "<" - ) + ] ) ); @@ -397,7 +397,7 @@ class ExportOdsTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $dbi->expects($this->once()) ->method('getFieldsMeta') @@ -462,7 +462,7 @@ class ExportOdsTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $dbi->expects($this->once()) ->method('getFieldsMeta') diff --git a/test/classes/Plugins/Export/ExportOdtTest.php b/test/classes/Plugins/Export/ExportOdtTest.php index 6fd5c0cae9..5257fd9ff2 100644 --- a/test/classes/Plugins/Export/ExportOdtTest.php +++ b/test/classes/Plugins/Export/ExportOdtTest.php @@ -39,7 +39,7 @@ class ExportOdtTest extends PmaTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = true; $GLOBALS['save_on_server'] = false; - $GLOBALS['plugin_param'] = array(); + $GLOBALS['plugin_param'] = []; $GLOBALS['plugin_param']['export_type'] = 'table'; $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfgRelation']['relation'] = true; @@ -150,11 +150,11 @@ class ExportOdtTest extends PmaTestCase ); $this->assertEquals( - array( + [ 'structure' => __('structure'), 'data' => __('data'), 'structure_and_data' => __('structure and data') - ), + ], $property->getValues() ); @@ -414,7 +414,7 @@ class ExportOdtTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $a = new stdClass; $flags[] = $a; @@ -462,9 +462,9 @@ class ExportOdtTest extends PmaTestCase ->with(true) ->will( $this->returnValue( - array( + [ null, 'a<b', 'a>b', 'a&b' - ) + ] ) ); @@ -510,7 +510,7 @@ class ExportOdtTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $dbi->expects($this->once()) ->method('getFieldsMeta') @@ -575,7 +575,7 @@ class ExportOdtTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $dbi->expects($this->once()) ->method('getFieldsMeta') @@ -638,13 +638,13 @@ class ExportOdtTest extends PmaTestCase $dbi->expects($this->once()) ->method('getColumns') ->with('db', 'v&w') - ->will($this->returnValue(array(1, 2))); + ->will($this->returnValue([1, 2])); $GLOBALS['dbi'] = $dbi; $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportOdt') ->disableOriginalConstructor() - ->setMethods(array('formatOneColumnDefinition')) + ->setMethods(['formatOneColumnDefinition']) ->getMock(); $this->object->expects($this->at(0)) @@ -681,7 +681,7 @@ class ExportOdtTest extends PmaTestCase public function testGetTableDef() { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportOdt') - ->setMethods(array('formatOneColumnDefinition')) + ->setMethods(['formatOneColumnDefinition']) ->getMock(); // case 1 @@ -693,23 +693,23 @@ class ExportOdtTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array(), - array( - 'fieldname' => array( + [], + [ + 'fieldname' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<' - ) - ) + ] + ] ); - $columns = array( + $columns = [ 'Field' => 'fieldname' - ); + ]; $dbi->expects($this->once()) ->method('getColumns') ->with('database', '') - ->will($this->returnValue(array($columns))); + ->will($this->returnValue([$columns])); $dbi->expects($this->any()) ->method('query') @@ -723,9 +723,9 @@ class ExportOdtTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('fieldname' => 'testComment') - ) + [ + 'comment' => ['fieldname' => 'testComment'] + ] ) ); @@ -733,11 +733,11 @@ class ExportOdtTest extends PmaTestCase $this->object->expects($this->exactly(2)) ->method('formatOneColumnDefinition') - ->with(array('Field' => 'fieldname')) + ->with(['Field' => 'fieldname']) ->will($this->returnValue(1)); $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -745,7 +745,7 @@ class ExportOdtTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; $this->assertTrue( $this->object->getTableDef( 'database', @@ -793,29 +793,29 @@ class ExportOdtTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array( - 'fieldname' => array( + [ + 'fieldname' => [ 'foreign_table' => 'ftable', 'foreign_field' => 'ffield' - ) - ), - array( - 'field' => array( + ] + ], + [ + 'field' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<' - ) - ) + ] + ] ); - $columns = array( + $columns = [ 'Field' => 'fieldname' - ); + ]; $dbi->expects($this->once()) ->method('getColumns') ->with('database', '') - ->will($this->returnValue(array($columns))); + ->will($this->returnValue([$columns])); $dbi->expects($this->any()) ->method('query') @@ -829,16 +829,16 @@ class ExportOdtTest extends PmaTestCase ->method('fetchAssoc') ->will( $this->returnValue( - array( - 'comment' => array('field' => 'testComment') - ) + [ + 'comment' => ['field' => 'testComment'] + ] ) ); $GLOBALS['dbi'] = $dbi; $GLOBALS['odt_buffer'] = ''; $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -846,7 +846,7 @@ class ExportOdtTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; $this->assertTrue( $this->object->getTableDef( @@ -877,14 +877,14 @@ class ExportOdtTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $triggers = array( - array( + $triggers = [ + [ 'name' => 'tna"me', 'action_timing' => 'ac>t', 'event_manipulation' => 'manip&', 'definition' => 'def' - ) - ); + ] + ]; $dbi->expects($this->once()) ->method('getTriggers') @@ -945,7 +945,7 @@ class ExportOdtTest extends PmaTestCase ->will($this->returnValue(1)); $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportOdt') - ->setMethods(array('getTableDef', 'getTriggers', 'getTableDefStandIn')) + ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) @@ -1043,12 +1043,12 @@ class ExportOdtTest extends PmaTestCase ); $method->setAccessible(true); - $cols = array( + $cols = [ 'Null' => 'Yes', 'Field' => 'field', 'Key' => 'PRI', 'Type' => 'set(abc)enum123' - ); + ]; $col_alias = 'alias'; @@ -1062,13 +1062,13 @@ class ExportOdtTest extends PmaTestCase $method->invoke($this->object, $cols, $col_alias) ); - $cols = array( + $cols = [ 'Null' => 'NO', 'Field' => 'fields', 'Key' => 'COMP', 'Type' => '', 'Default' => 'def' - ); + ]; $this->assertEquals( '<table:table-row><table:table-cell office:value-type="string">' . diff --git a/test/classes/Plugins/Export/ExportPdfTest.php b/test/classes/Plugins/Export/ExportPdfTest.php index b9ba1de3fe..7c714e2f15 100644 --- a/test/classes/Plugins/Export/ExportPdfTest.php +++ b/test/classes/Plugins/Export/ExportPdfTest.php @@ -167,11 +167,11 @@ class ExportPdfTest extends PmaTestCase ); $this->assertEquals( - array( + [ 'structure' => __('structure'), 'data' => __('data'), 'structure_and_data' => __('structure and data') - ), + ], $property->getValues() ); @@ -279,11 +279,11 @@ class ExportPdfTest extends PmaTestCase $pdf->expects($this->once()) ->method('setAttributes') ->with( - array( + [ 'currentDb' => 'db', 'currentTable' => 'table', 'dbAlias' => 'db', 'tableAlias' => 'table', - 'aliases' => array() - ) + 'aliases' => [] + ] ); $pdf->expects($this->once()) diff --git a/test/classes/Plugins/Export/ExportPhparrayTest.php b/test/classes/Plugins/Export/ExportPhparrayTest.php index 9bbb963a3d..9e6354bae0 100644 --- a/test/classes/Plugins/Export/ExportPhparrayTest.php +++ b/test/classes/Plugins/Export/ExportPhparrayTest.php @@ -238,7 +238,7 @@ class ExportPhparrayTest extends PmaTestCase $dbi->expects($this->at(4)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array(1, 'a'))); + ->will($this->returnValue([1, 'a'])); $dbi->expects($this->at(5)) ->method('fetchRow') diff --git a/test/classes/Plugins/Export/ExportSqlTest.php b/test/classes/Plugins/Export/ExportSqlTest.php index bda8104de0..087d70aceb 100644 --- a/test/classes/Plugins/Export/ExportSqlTest.php +++ b/test/classes/Plugins/Export/ExportSqlTest.php @@ -40,7 +40,7 @@ class ExportSqlTest extends PmaTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = false; $GLOBALS['save_on_server'] = false; - $GLOBALS['plugin_param'] = array(); + $GLOBALS['plugin_param'] = []; $GLOBALS['plugin_param']['export_type'] = 'table'; $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfgRelation']['relation'] = true; @@ -89,7 +89,7 @@ class ExportSqlTest extends PmaTestCase $dbi->expects($this->once()) ->method('getCompatibilities') - ->will($this->returnValue(array('v1', 'v2'))); + ->will($this->returnValue(['v1', 'v2'])); $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); @@ -200,10 +200,10 @@ class ExportSqlTest extends PmaTestCase ); $this->assertEquals( - array( + [ 'v1' => 'v1', 'v2' => 'v2' - ), + ], $property->getValues() ); @@ -335,12 +335,12 @@ class ExportSqlTest extends PmaTestCase $dbi->expects($this->at(0)) ->method('getProceduresOrFunctions') ->with('db', 'PROCEDURE') - ->will($this->returnValue(array('p1', 'p2'))); + ->will($this->returnValue(['p1', 'p2'])); $dbi->expects($this->at(1)) ->method('getProceduresOrFunctions') ->with('db', 'FUNCTION') - ->will($this->returnValue(array('f1'))); + ->will($this->returnValue(['f1'])); $dbi->expects($this->at(2)) ->method('getDefinition') @@ -706,16 +706,16 @@ class ExportSqlTest extends PmaTestCase 'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE' . ' EVENT_SCHEMA= \'db\';' ) - ->will($this->returnValue(array('f1', 'f2'))); + ->will($this->returnValue(['f1', 'f2'])); $dbi->expects($this->exactly(2)) ->method('getDefinition') ->will( $this->returnValueMap( - array( - array('db', 'EVENT', 'f1', DatabaseInterface::CONNECT_USER, 'f1event'), - array('db', 'EVENT', 'f2', DatabaseInterface::CONNECT_USER, 'f2event') - ) + [ + ['db', 'EVENT', 'f1', DatabaseInterface::CONNECT_USER, 'f1event'], + ['db', 'EVENT', 'f2', DatabaseInterface::CONNECT_USER, 'f2event'] + ] ) ); $dbi->expects($this->any())->method('escapeString') @@ -803,7 +803,7 @@ class ExportSqlTest extends PmaTestCase ->with('db', 'view') ->will( $this->returnValue( - array('cname' => array('Type' => 'int')) + ['cname' => ['Type' => 'int']] ) ); @@ -843,16 +843,16 @@ class ExportSqlTest extends PmaTestCase ->with('db', 'view') ->will( $this->returnValue( - array( - 'cname' => array( + [ + 'cname' => [ 'Type' => 'char', 'Collation' => 'utf-8', 'Null' => 'NO', 'Default' => 'a', 'Comment' => 'cmt', 'Field' => 'fname' - ) - ) + ] + ] ) ); @@ -886,15 +886,15 @@ class ExportSqlTest extends PmaTestCase ->with('db', 'view') ->will( $this->returnValue( - array( - 'cname' => array( + [ + 'cname' => [ 'Type' => 'char', 'Collation' => 'utf-8', 'Null' => 'YES', 'Comment' => 'cmt', 'Field' => 'fname' - ) - ) + ] + ] ) ); $GLOBALS['dbi'] = $dbi; @@ -955,12 +955,12 @@ class ExportSqlTest extends PmaTestCase ->method('fetchValue') ->will($this->returnValue(false)); - $tmpres = array( + $tmpres = [ 'Auto_increment' => 1, 'Create_time' => '2000-01-01 10:00:00', 'Update_time' => '2000-01-02 12:00:00', 'Check_time' => '2000-01-02 13:00:00', - ); + ]; $dbi->expects($this->once()) ->method('fetchAssoc') @@ -970,15 +970,15 @@ class ExportSqlTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('tryQuery') ->withConsecutive( - array("SHOW TABLE STATUS FROM `db` WHERE Name = 'table'"), - array('SHOW CREATE TABLE `db`.`table`') + ["SHOW TABLE STATUS FROM `db` WHERE Name = 'table'"], + ['SHOW CREATE TABLE `db`.`table`'] ) ->willReturnOnConsecutiveCalls( 'res', 'res' ); - $row = array( + $row = [ '', "CREATE TABLE `table` (\n" . "`payment_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,\n" . @@ -996,15 +996,15 @@ class ExportSqlTest extends PmaTestCase "CONSTRAINT `fk_payment_rental` FOREIGN KEY (`rental_id`) REFERENCES `rental` (`rental_id`) ON DELETE SET NULL ON UPDATE CASCADE,\n" . "CONSTRAINT `fk_payment_staff` FOREIGN KEY (`staff_id`) REFERENCES `staff` (`staff_id`) ON UPDATE CASCADE\n" . ") ENGINE=InnoDB AUTO_INCREMENT=16050 DEFAULT CHARSET=utf8\n" - ); + ]; $dbi->expects($this->exactly(1)) ->method('fetchRow') ->will( $this->returnValueMap( - array( - array('res', $row) - ) + [ + ['res', $row] + ] ) ); $dbi->expects($this->once()) @@ -1129,12 +1129,12 @@ class ExportSqlTest extends PmaTestCase ->method('fetchValue') ->will($this->returnValue(false)); - $tmpres = array( + $tmpres = [ 'Auto_increment' => 1, 'Create_time' => '2000-01-01 10:00:00', 'Update_time' => '2000-01-02 12:00:00', 'Check_time' => '2000-01-02 13:00:00', - ); + ]; $dbi->expects($this->once()) ->method('fetchAssoc') @@ -1144,8 +1144,8 @@ class ExportSqlTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('tryQuery') ->withConsecutive( - array("SHOW TABLE STATUS FROM `db` WHERE Name = 'table'"), - array('SHOW CREATE TABLE `db`.`table`') + ["SHOW TABLE STATUS FROM `db` WHERE Name = 'table'"], + ['SHOW CREATE TABLE `db`.`table`'] ) ->willReturnOnConsecutiveCalls( 'res', @@ -1183,7 +1183,7 @@ class ExportSqlTest extends PmaTestCase */ public function testGetTableComments() { - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -1191,7 +1191,7 @@ class ExportSqlTest extends PmaTestCase 'db' => 'database', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; $GLOBALS['sql_include_comments'] = true; $GLOBALS['crlf'] = "\n"; @@ -1205,19 +1205,19 @@ class ExportSqlTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array( - 'foo' => array( + [ + 'foo' => [ 'foreign_table' => 'ftable', 'foreign_field' => 'ffield' - ) - ), - array( - 'fieldname' => array( + ] + ], + [ + 'fieldname' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<' - ) - ) + ] + ] ); $GLOBALS['dbi'] = $dbi; @@ -1263,14 +1263,14 @@ class ExportSqlTest extends PmaTestCase ->with('db', 't&bl') ->will( $this->returnValue( - array( - array('create' => 'bar', 'drop' => 'foo') - ) + [ + ['create' => 'bar', 'drop' => 'foo'] + ] ) ); $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportSql') - ->setMethods(array('getTableDef', 'getTriggers', 'getTableDefStandIn')) + ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) @@ -1376,7 +1376,7 @@ class ExportSqlTest extends PmaTestCase ->method('getColumns') ->will( $this->returnValue( - array() + [] ) ); $GLOBALS['dbi'] = $dbi; @@ -1428,7 +1428,7 @@ class ExportSqlTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $a = new stdClass; $a->blob = false; $a->numeric = true; @@ -1495,7 +1495,7 @@ class ExportSqlTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchRow') ->willReturnOnConsecutiveCalls( - array(null, 'test', '10', '6', "\x00\x0a\x0d\x1a"), + [null, 'test', '10', '6', "\x00\x0a\x0d\x1a"], null ); $dbi->expects($this->any())->method('escapeString') @@ -1576,7 +1576,7 @@ class ExportSqlTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $flags = array(); + $flags = []; $a = new stdClass; $a->blob = false; $a->numeric = true; @@ -1626,7 +1626,7 @@ class ExportSqlTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchRow') ->willReturnOnConsecutiveCalls( - array(null, null), + [null, null], null ); @@ -1842,19 +1842,19 @@ class ExportSqlTest extends PmaTestCase */ public function testInitAlias() { - $aliases = array( - 'a' => array( + $aliases = [ + 'a' => [ 'alias' => 'aliastest', - 'tables' => array( - 'foo' => array( + 'tables' => [ + 'foo' => [ 'alias' => 'qwerty' - ), - 'bar' => array( + ], + 'bar' => [ 'alias' => 'f' - ) - ) - ) - ); + ] + ] + ] + ]; $db = 'a'; $table = null; @@ -1884,26 +1884,26 @@ class ExportSqlTest extends PmaTestCase */ public function testGetAlias() { - $aliases = array( - 'a' => array( + $aliases = [ + 'a' => [ 'alias' => 'aliastest', - 'tables' => array( - 'foo' => array( + 'tables' => [ + 'foo' => [ 'alias' => 'qwerty', - 'columns' => array( + 'columns' => [ 'baz' => 'p', 'pqr' => 'pphymdain' - ) - ), - 'bar' => array( + ] + ], + 'bar' => [ 'alias' => 'f', - 'columns' => array( + 'columns' => [ 'xy' => 'n' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertEquals( 'f', $this->object->getAlias($aliases, 'bar') @@ -1929,26 +1929,26 @@ class ExportSqlTest extends PmaTestCase */ public function testReplaceWithAlias() { - $aliases = array( - 'a' => array( + $aliases = [ + 'a' => [ 'alias' => 'aliastest', - 'tables' => array( - 'foo' => array( + 'tables' => [ + 'foo' => [ 'alias' => 'bartest', - 'columns' => array( + 'columns' => [ 'baz' => 'p', 'pqr' => 'pphymdain' - ) - ), - 'bar' => array( + ] + ], + 'bar' => [ 'alias' => 'f', - 'columns' => array( + 'columns' => [ 'xy' => 'n' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $db = 'a'; $table = 'foo'; @@ -1976,7 +1976,7 @@ class ExportSqlTest extends PmaTestCase $result ); - $result = $this->object->replaceWithAliases($sql_query, array(), '', ''); + $result = $this->object->replaceWithAliases($sql_query, [], '', ''); $this->assertEquals( "CREATE TABLE IF NOT EXISTS foo (\n" . diff --git a/test/classes/Plugins/Export/ExportTexytextTest.php b/test/classes/Plugins/Export/ExportTexytextTest.php index 4b6e1c3c80..4cb1445bab 100644 --- a/test/classes/Plugins/Export/ExportTexytextTest.php +++ b/test/classes/Plugins/Export/ExportTexytextTest.php @@ -37,7 +37,7 @@ class ExportTexytextTest extends PmaTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = false; $GLOBALS['save_on_server'] = false; - $GLOBALS['plugin_param'] = array(); + $GLOBALS['plugin_param'] = []; $GLOBALS['plugin_param']['export_type'] = 'table'; $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfgRelation']['relation'] = true; @@ -267,7 +267,7 @@ class ExportTexytextTest extends PmaTestCase $dbi->expects($this->at(5)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array(null, '0', 'test'))); + ->will($this->returnValue([null, '0', 'test'])); $GLOBALS['dbi'] = $dbi; $GLOBALS['what'] = 'foo'; @@ -308,18 +308,18 @@ class ExportTexytextTest extends PmaTestCase $dbi->expects($this->once()) ->method('getColumns') ->with('db', 'view') - ->will($this->returnValue(array(1, 2))); + ->will($this->returnValue([1, 2])); - $keys = array( - array( + $keys = [ + [ 'Non_unique' => 0, 'Column_name' => 'cname' - ), - array( + ], + [ 'Non_unique' => 1, 'Column_name' => 'cname2' - ) - ); + ] + ]; $dbi->expects($this->once()) ->method('getTableIndexes') @@ -334,17 +334,17 @@ class ExportTexytextTest extends PmaTestCase $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportTexytext') ->disableOriginalConstructor() - ->setMethods(array('formatOneColumnDefinition')) + ->setMethods(['formatOneColumnDefinition']) ->getMock(); $this->object->expects($this->at(0)) ->method('formatOneColumnDefinition') - ->with(1, array('cname')) + ->with(1, ['cname']) ->will($this->returnValue('c1')); $this->object->expects($this->at(1)) ->method('formatOneColumnDefinition') - ->with(2, array('cname')) + ->with(2, ['cname']) ->will($this->returnValue('c2')); $result = $this->object->getTableDefStandIn('db', 'view', '#'); @@ -363,7 +363,7 @@ class ExportTexytextTest extends PmaTestCase public function testGetTableDef() { $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportTexytext') - ->setMethods(array('formatOneColumnDefinition')) + ->setMethods(['formatOneColumnDefinition']) ->getMock(); // case 1 @@ -372,16 +372,16 @@ class ExportTexytextTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $keys = array( - array( + $keys = [ + [ 'Non_unique' => 0, 'Column_name' => 'cname' - ), - array( + ], + [ 'Non_unique' => 1, 'Column_name' => 'cname2' - ) - ); + ] + ]; $dbi->expects($this->once()) ->method('getTableIndexes') @@ -391,19 +391,19 @@ class ExportTexytextTest extends PmaTestCase $dbi->expects($this->exactly(2)) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array( - 'fname' => array( + [ + 'fname' => [ 'foreign_table' => '<ftable', 'foreign_field' => 'ffield>' - ) - ), - array( - 'fname' => array( + ] + ], + [ + 'fname' => [ 'values' => 'test-', 'transformation' => 'testfoo', 'mimetype' => 'test<' - ) - ) + ] + ] ); $dbi->expects($this->once()) @@ -414,25 +414,25 @@ class ExportTexytextTest extends PmaTestCase ) ); - $columns = array( + $columns = [ 'Field' => 'fname', 'Comment' => 'comm' - ); + ]; $dbi->expects($this->exactly(2)) ->method('getColumns') ->with('db', 'table') - ->will($this->returnValue(array($columns))); + ->will($this->returnValue([$columns])); $GLOBALS['dbi'] = $dbi; $this->object->expects($this->exactly(1)) ->method('formatOneColumnDefinition') - ->with(array('Field' => 'fname', 'Comment' => 'comm'), array('cname')) + ->with(['Field' => 'fname', 'Comment' => 'comm'], ['cname']) ->will($this->returnValue(1)); $GLOBALS['cfgRelation']['relation'] = true; - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'relwork' => true, 'commwork' => true, @@ -440,7 +440,7 @@ class ExportTexytextTest extends PmaTestCase 'db' => 'db', 'relation' => 'rel', 'column_info' => 'col' - ); + ]; $result = $this->object->getTableDef( 'db', @@ -469,14 +469,14 @@ class ExportTexytextTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $triggers = array( - array( + $triggers = [ + [ 'name' => 'tna"me', 'action_timing' => 'ac>t', 'event_manipulation' => 'manip&', 'definition' => 'def' - ) - ); + ] + ]; $dbi->expects($this->once()) ->method('getTriggers') @@ -517,7 +517,7 @@ class ExportTexytextTest extends PmaTestCase ->will($this->returnValue(1)); $this->object = $this->getMockBuilder('PhpMyAdmin\Plugins\Export\ExportTexytext') - ->setMethods(array('getTableDef', 'getTriggers', 'getTableDefStandIn')) + ->setMethods(['getTableDef', 'getTriggers', 'getTableDefStandIn']) ->getMock(); $this->object->expects($this->at(0)) @@ -609,33 +609,33 @@ class ExportTexytextTest extends PmaTestCase */ public function testFormatOneColumnDefinition() { - $cols = array( + $cols = [ 'Null' => 'Yes', 'Field' => 'field', 'Key' => 'PRI', 'Type' => 'set(abc)enum123' - ); + ]; - $unique_keys = array( + $unique_keys = [ 'field' - ); + ]; $this->assertEquals( '|//**field**//|set(abc)|Yes|NULL', $this->object->formatOneColumnDefinition($cols, $unique_keys) ); - $cols = array( + $cols = [ 'Null' => 'NO', 'Field' => 'fields', 'Key' => 'COMP', 'Type' => '', 'Default' => 'def' - ); + ]; - $unique_keys = array( + $unique_keys = [ 'field' - ); + ]; $this->assertEquals( '|fields|&nbsp;|No|def', diff --git a/test/classes/Plugins/Export/ExportXmlTest.php b/test/classes/Plugins/Export/ExportXmlTest.php index 1e409a3d4b..6b20f756a6 100644 --- a/test/classes/Plugins/Export/ExportXmlTest.php +++ b/test/classes/Plugins/Export/ExportXmlTest.php @@ -38,7 +38,7 @@ class ExportXmlTest extends PmaTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = false; $GLOBALS['save_on_server'] = false; - $GLOBALS['plugin_param'] = array(); + $GLOBALS['plugin_param'] = []; $GLOBALS['plugin_param']['export_type'] = 'table'; $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfgRelation']['relation'] = true; @@ -220,14 +220,14 @@ class ExportXmlTest extends PmaTestCase $GLOBALS['crlf'] = "\n"; $GLOBALS['db'] = 'd<"b'; - $result = array( - 0 => array( + $result = [ + 0 => [ 'DEFAULT_COLLATION_NAME' => 'utf8_general_ci', 'DEFAULT_CHARACTER_SET_NAME' => 'utf-8', - ), - 'table' => array(null, '"tbl"') - ); + ], + 'table' => [null, '"tbl"'] + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); @@ -245,24 +245,24 @@ class ExportXmlTest extends PmaTestCase ->with('d<"b', 'table') ->will( $this->returnValue( - array( - array( + [ + [ 'create' => 'crt', 'name' => 'trname' - ) - ) + ] + ] ) ); $dbi->expects($this->exactly(2)) ->method('getProceduresOrFunctions') ->willReturnOnConsecutiveCalls( - array( + [ 'fn' - ), - array( + ], + [ 'pr' - ) + ] ); $dbi->expects($this->exactly(2)) @@ -280,7 +280,7 @@ class ExportXmlTest extends PmaTestCase $GLOBALS['dbi'] = $dbi; - $GLOBALS['tables'] = array(); + $GLOBALS['tables'] = []; $GLOBALS['table'] = 'table'; ob_start(); @@ -329,20 +329,20 @@ class ExportXmlTest extends PmaTestCase ->disableOriginalConstructor() ->getMock(); - $result_1 = array( - array( + $result_1 = [ + [ 'DEFAULT_COLLATION_NAME' => 'utf8_general_ci', 'DEFAULT_CHARACTER_SET_NAME' => 'utf-8', - ) - ); - $result_2 = array( - 't1' => array(null, '"tbl"') - ); + ] + ]; + $result_2 = [ + 't1' => [null, '"tbl"'] + ]; - $result_3 = array( - 't2' => array(null, '"tbl"') - ); + $result_3 = [ + 't2' => [null, '"tbl"'] + ]; $dbi->expects($this->exactly(5)) ->method('fetchResult') @@ -360,7 +360,7 @@ class ExportXmlTest extends PmaTestCase $GLOBALS['dbi'] = $dbi; - $GLOBALS['tables'] = array('t1', 't2'); + $GLOBALS['tables'] = ['t1', 't2']; ob_start(); $this->assertTrue( @@ -515,7 +515,7 @@ class ExportXmlTest extends PmaTestCase $dbi->expects($this->at(6)) ->method('fetchRow') ->with(true) - ->will($this->returnValue(array(null, '<a>'))); + ->will($this->returnValue([null, '<a>'])); $GLOBALS['dbi'] = $dbi; diff --git a/test/classes/Plugins/Export/ExportYamlTest.php b/test/classes/Plugins/Export/ExportYamlTest.php index fd6cf28f99..6bd9ce711e 100644 --- a/test/classes/Plugins/Export/ExportYamlTest.php +++ b/test/classes/Plugins/Export/ExportYamlTest.php @@ -235,7 +235,7 @@ class ExportYamlTest extends PmaTestCase ->with(true) ->will( $this->returnValue( - array(null, '123', "\"c\\a\nb\r") + [null, '123', "\"c\\a\nb\r"] ) ); @@ -244,7 +244,7 @@ class ExportYamlTest extends PmaTestCase ->with(true) ->will( $this->returnValue( - array(null) + [null] ) ); diff --git a/test/classes/Plugins/Export/Helpers/TablePropertyTest.php b/test/classes/Plugins/Export/Helpers/TablePropertyTest.php index 5aa0f8bea9..64a5e2eb10 100644 --- a/test/classes/Plugins/Export/Helpers/TablePropertyTest.php +++ b/test/classes/Plugins/Export/Helpers/TablePropertyTest.php @@ -29,7 +29,7 @@ class TablePropertyTest extends PmaTestCase function setup() { $GLOBALS['server'] = 0; - $row = array(' name ', 'int ', true, ' PRI', '0', 'mysql'); + $row = [' name ', 'int ', true, ' PRI', '0', 'mysql']; $this->object = new TableProperty($row); } @@ -129,11 +129,11 @@ class TablePropertyTest extends PmaTestCase */ public function isNotNullProvider() { - return array( - array("NO", "true"), - array("", "false"), - array("no", "false") - ); + return [ + ["NO", "true"], + ["", "false"], + ["no", "false"] + ]; } /** @@ -162,13 +162,13 @@ class TablePropertyTest extends PmaTestCase */ public function isUniqueProvider() { - return array( - array("PRI", "true"), - array("UNI", "true"), - array("", "false"), - array("pri", "false"), - array("uni", "false"), - ); + return [ + ["PRI", "true"], + ["UNI", "true"], + ["", "false"], + ["pri", "false"], + ["uni", "false"], + ]; } /** @@ -197,19 +197,19 @@ class TablePropertyTest extends PmaTestCase */ public function getDotNetPrimitiveTypeProvider() { - return array( - array("int", "int"), - array("long", "long"), - array("char", "string"), - array("varchar", "string"), - array("text", "string"), - array("longtext", "string"), - array("tinyint", "bool"), - array("datetime", "DateTime"), - array("", "unknown"), - array("dummy", "unknown"), - array("INT", "unknown") - ); + return [ + ["int", "int"], + ["long", "long"], + ["char", "string"], + ["varchar", "string"], + ["text", "string"], + ["longtext", "string"], + ["tinyint", "bool"], + ["datetime", "DateTime"], + ["", "unknown"], + ["dummy", "unknown"], + ["INT", "unknown"] + ]; } /** @@ -238,19 +238,19 @@ class TablePropertyTest extends PmaTestCase */ public function getDotNetObjectTypeProvider() { - return array( - array("int", "Int32"), - array("long", "Long"), - array("char", "String"), - array("varchar", "String"), - array("text", "String"), - array("longtext", "String"), - array("tinyint", "Boolean"), - array("datetime", "DateTime"), - array("", "Unknown"), - array("dummy", "Unknown"), - array("INT", "Unknown") - ); + return [ + ["int", "Int32"], + ["long", "Long"], + ["char", "String"], + ["varchar", "String"], + ["text", "String"], + ["longtext", "String"], + ["tinyint", "Boolean"], + ["datetime", "DateTime"], + ["", "Unknown"], + ["dummy", "Unknown"], + ["INT", "Unknown"] + ]; } /** diff --git a/test/classes/Plugins/Import/ImportLdiTest.php b/test/classes/Plugins/Import/ImportLdiTest.php index a4075c8cfc..b3a7c95bbb 100644 --- a/test/classes/Plugins/Import/ImportLdiTest.php +++ b/test/classes/Plugins/Import/ImportLdiTest.php @@ -120,7 +120,7 @@ class ImportLdiTest extends PmaTestCase $this->dbi->expects($this->any())->method('numRows') ->will($this->returnValue(10)); - $fetchRowResult = array("ON"); + $fetchRowResult = ["ON"]; $this->dbi->expects($this->any())->method('fetchRow') ->will($this->returnValue($fetchRowResult)); diff --git a/test/classes/Plugins/Import/ImportMediawikiTest.php b/test/classes/Plugins/Import/ImportMediawikiTest.php index 490a525532..4373ba338f 100644 --- a/test/classes/Plugins/Import/ImportMediawikiTest.php +++ b/test/classes/Plugins/Import/ImportMediawikiTest.php @@ -91,7 +91,7 @@ class ImportMediawikiTest extends PmaTestCase $properties->getMimeType() ); $this->assertEquals( - array(), + [], $properties->getOptions() ); $this->assertEquals( diff --git a/test/classes/Plugins/Import/ImportShpTest.php b/test/classes/Plugins/Import/ImportShpTest.php index 6bd6c9dd49..ba3c1e5cdc 100644 --- a/test/classes/Plugins/Import/ImportShpTest.php +++ b/test/classes/Plugins/Import/ImportShpTest.php @@ -113,7 +113,7 @@ class ImportShpTest extends PmaTestCase $properties->getExtension() ); $this->assertEquals( - array(), + [], $properties->getOptions() ); $this->assertEquals( diff --git a/test/classes/Plugins/Import/ImportXmlTest.php b/test/classes/Plugins/Import/ImportXmlTest.php index 4c01d33428..4e50baf288 100644 --- a/test/classes/Plugins/Import/ImportXmlTest.php +++ b/test/classes/Plugins/Import/ImportXmlTest.php @@ -92,7 +92,7 @@ class ImportXmlTest extends PmaTestCase $properties->getMimeType() ); $this->assertEquals( - array(), + [], $properties->getOptions() ); $this->assertEquals( diff --git a/test/classes/Plugins/Schema/DiaRelationSchemaTest.php b/test/classes/Plugins/Schema/DiaRelationSchemaTest.php index 3909e44b35..4bc0f508f9 100644 --- a/test/classes/Plugins/Schema/DiaRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/DiaRelationSchemaTest.php @@ -38,16 +38,16 @@ class DiaRelationSchemaTest extends PmaTestCase $_REQUEST['dia_show_keys'] = true; $_REQUEST['dia_orientation'] = 'orientation'; $_REQUEST['dia_paper'] = 'paper'; - $_REQUEST['t_h'] = array('information_schema.files' => 1); - $_REQUEST['t_x'] = array('information_schema.files' => 0); - $_REQUEST['t_y'] = array('information_schema.files' => 0); + $_REQUEST['t_h'] = ['information_schema.files' => 1]; + $_REQUEST['t_x'] = ['information_schema.files' => 0]; + $_REQUEST['t_y'] = ['information_schema.files' => 0]; $GLOBALS['server'] = 1; $GLOBALS['db'] = 'information_schema'; $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; //_SESSION - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'table_coords' => "table_name", 'displaywork' => 'displaywork', @@ -55,7 +55,7 @@ class DiaRelationSchemaTest extends PmaTestCase 'table_info' => 'table_info', 'relwork' => 'relwork', 'relation' => 'relation' - ); + ]; $relation = new Relation(); $relation->getRelationsParam(); @@ -75,15 +75,15 @@ class DiaRelationSchemaTest extends PmaTestCase ->method('tryQuery') ->will($this->returnValue("executed_1")); - $fetchArrayReturn = array( + $fetchArrayReturn = [ //table name in information_schema_relations 'table_name' => 'CHARACTER_SETS' - ); + ]; - $fetchArrayReturn2 = array( + $fetchArrayReturn2 = [ //table name in information_schema_relations 'table_name' => 'COLLATIONS' - ); + ]; $dbi->expects($this->at(2)) ->method('fetchAssoc') @@ -95,15 +95,15 @@ class DiaRelationSchemaTest extends PmaTestCase ->method('fetchAssoc') ->will($this->returnValue(false)); - $getIndexesResult = array( - array( + $getIndexesResult = [ + [ 'Table' => 'pma_tbl', 'Field' => 'field1', 'Key' => 'PRIMARY', 'Key_name' => "Key_name", 'Column_name' => "Column_name" - ) - ); + ] + ]; $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); diff --git a/test/classes/Plugins/Schema/EpsRelationSchemaTest.php b/test/classes/Plugins/Schema/EpsRelationSchemaTest.php index 0dc56cb2d5..f889d7b865 100644 --- a/test/classes/Plugins/Schema/EpsRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/EpsRelationSchemaTest.php @@ -39,16 +39,16 @@ class EpsRelationSchemaTest extends PmaTestCase $_REQUEST['eps_orientation'] = 'orientation'; $_REQUEST['eps_show_table_dimension'] = true; $_REQUEST['eps_all_tables_same_width'] = true; - $_REQUEST['t_h'] = array('information_schema.files' => 1); - $_REQUEST['t_x'] = array('information_schema.files' => 0); - $_REQUEST['t_y'] = array('information_schema.files' => 0); + $_REQUEST['t_h'] = ['information_schema.files' => 1]; + $_REQUEST['t_x'] = ['information_schema.files' => 0]; + $_REQUEST['t_y'] = ['information_schema.files' => 0]; $GLOBALS['server'] = 1; $GLOBALS['db'] = 'information_schema'; $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; //_SESSION - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'table_coords' => "table_name", 'displaywork' => 'displaywork', @@ -56,7 +56,7 @@ class EpsRelationSchemaTest extends PmaTestCase 'table_info' => 'table_info', 'relwork' => 'relwork', 'relation' => 'relation' - ); + ]; $relation = new Relation(); $relation->getRelationsParam(); @@ -76,15 +76,15 @@ class EpsRelationSchemaTest extends PmaTestCase ->method('tryQuery') ->will($this->returnValue("executed_1")); - $fetchArrayReturn = array( + $fetchArrayReturn = [ //table name in information_schema_relations 'table_name' => 'CHARACTER_SETS' - ); + ]; - $fetchArrayReturn2 = array( + $fetchArrayReturn2 = [ //table name in information_schema_relations 'table_name' => 'COLLATIONS' - ); + ]; $dbi->expects($this->at(2)) ->method('fetchAssoc') @@ -96,15 +96,15 @@ class EpsRelationSchemaTest extends PmaTestCase ->method('fetchAssoc') ->will($this->returnValue(false)); - $getIndexesResult = array( - array( + $getIndexesResult = [ + [ 'Table' => 'pma_tbl', 'Field' => 'field1', 'Key' => 'PRIMARY', 'Key_name' => "Key_name", 'Column_name' => "Column_name" - ) - ); + ] + ]; $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); diff --git a/test/classes/Plugins/Schema/PdfRelationSchemaTest.php b/test/classes/Plugins/Schema/PdfRelationSchemaTest.php index e9238d7c07..971c7bf074 100644 --- a/test/classes/Plugins/Schema/PdfRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/PdfRelationSchemaTest.php @@ -42,9 +42,9 @@ class PdfRelationSchemaTest extends PmaTestCase $_REQUEST['pdf_all_tables_same_width'] = true; $_REQUEST['pdf_paper'] = 'paper'; $_REQUEST['pdf_table_order'] = ''; - $_REQUEST['t_h'] = array('information_schema.files' => 1); - $_REQUEST['t_x'] = array('information_schema.files' => 0); - $_REQUEST['t_y'] = array('information_schema.files' => 0); + $_REQUEST['t_h'] = ['information_schema.files' => 1]; + $_REQUEST['t_x'] = ['information_schema.files' => 0]; + $_REQUEST['t_y'] = ['information_schema.files' => 0]; $GLOBALS['server'] = 1; $GLOBALS['db'] = 'information_schema'; @@ -56,7 +56,7 @@ class PdfRelationSchemaTest extends PmaTestCase $GLOBALS['cfg']['Server']['table_info'] = "table_info"; //_SESSION - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'table_coords' => "table_name", 'displaywork' => 'displaywork', @@ -68,7 +68,7 @@ class PdfRelationSchemaTest extends PmaTestCase 'commwork' => 'commwork', 'column_info' => 'column_info', 'pdf_pages' => 'pdf_pages' - ); + ]; $relation = new Relation(); $relation->getRelationsParam(); @@ -88,15 +88,15 @@ class PdfRelationSchemaTest extends PmaTestCase ->method('tryQuery') ->will($this->returnValue("executed_1")); - $fetchArrayReturn = array( + $fetchArrayReturn = [ //table name in information_schema_relations 'table_name' => 'CHARACTER_SETS' - ); + ]; - $fetchArrayReturn2 = array( + $fetchArrayReturn2 = [ //table name in information_schema_relations 'table_name' => 'COLLATIONS' - ); + ]; $dbi->expects($this->at(2)) ->method('fetchAssoc') @@ -108,10 +108,10 @@ class PdfRelationSchemaTest extends PmaTestCase ->method('fetchAssoc') ->will($this->returnValue(false)); - $fetchRowReturn = array( + $fetchRowReturn = [ 'table_name', 'table_name' - ); + ]; //let fetchRow have more results for ($index=0; $index<4; ++$index) { @@ -120,29 +120,29 @@ class PdfRelationSchemaTest extends PmaTestCase ->will($this->returnValue($fetchRowReturn)); } - $fields_info = array( - "Host" => array( + $fields_info = [ + "Host" => [ "Field" => "host", "Type" => "char(60)", "Null" => "NO", 'Extra' => "Extra", - ) - ); + ] + ]; $dbi->expects($this->any())->method('getColumns') ->will($this->returnValue($fields_info)); $dbi->expects($this->any())->method('selectDb') ->will($this->returnValue(true)); - $getIndexesResult = array( - array( + $getIndexesResult = [ + [ 'Table' => 'pma_tbl', 'Field' => 'field1', 'Key' => 'PRIMARY', 'Key_name' => "Key_name", 'Column_name' => "Column_name" - ) - ); + ] + ]; $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); @@ -160,10 +160,10 @@ class PdfRelationSchemaTest extends PmaTestCase ->method('fetchValue') ->will($this->returnValue($fetchValue)); - $fetchResult = array( - 'column1' => array('mimetype' => 'value1', 'transformation'=> 'pdf'), - 'column2' => array('mimetype' => 'value2', 'transformation'=> 'xml'), - ); + $fetchResult = [ + 'column1' => ['mimetype' => 'value1', 'transformation'=> 'pdf'], + 'column2' => ['mimetype' => 'value2', 'transformation'=> 'xml'], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($fetchResult)); diff --git a/test/classes/Plugins/Schema/SvgRelationSchemaTest.php b/test/classes/Plugins/Schema/SvgRelationSchemaTest.php index b83897241f..d2ad4bda8b 100644 --- a/test/classes/Plugins/Schema/SvgRelationSchemaTest.php +++ b/test/classes/Plugins/Schema/SvgRelationSchemaTest.php @@ -38,16 +38,16 @@ class SvgRelationSchemaTest extends PmaTestCase $_REQUEST['svg_show_keys'] = true; $_REQUEST['svg_show_table_dimension'] = true; $_REQUEST['svg_all_tables_same_width'] = true; - $_REQUEST['t_h'] = array('information_schema.files' => 1); - $_REQUEST['t_x'] = array('information_schema.files' => 0); - $_REQUEST['t_y'] = array('information_schema.files' => 0); + $_REQUEST['t_h'] = ['information_schema.files' => 1]; + $_REQUEST['t_x'] = ['information_schema.files' => 0]; + $_REQUEST['t_y'] = ['information_schema.files' => 0]; $GLOBALS['server'] = 1; $GLOBALS['db'] = 'information_schema'; $GLOBALS['cfg']['Server']['table_coords'] = "table_name"; //_SESSION - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'table_coords' => "table_name", 'displaywork' => 'displaywork', @@ -55,7 +55,7 @@ class SvgRelationSchemaTest extends PmaTestCase 'table_info' => 'table_info', 'relwork' => 'relwork', 'relation' => 'relation' - ); + ]; $relation = new Relation(); $relation->getRelationsParam(); @@ -75,15 +75,15 @@ class SvgRelationSchemaTest extends PmaTestCase ->method('tryQuery') ->will($this->returnValue("executed_1")); - $fetchArrayReturn = array( + $fetchArrayReturn = [ //table name in information_schema_relations 'table_name' => 'CHARACTER_SETS' - ); + ]; - $fetchArrayReturn2 = array( + $fetchArrayReturn2 = [ //table name in information_schema_relations 'table_name' => 'COLLATIONS' - ); + ]; $dbi->expects($this->at(2)) ->method('fetchAssoc') @@ -95,15 +95,15 @@ class SvgRelationSchemaTest extends PmaTestCase ->method('fetchAssoc') ->will($this->returnValue(false)); - $getIndexesResult = array( - array( + $getIndexesResult = [ + [ 'Table' => 'pma_tbl', 'Field' => 'field1', 'Key' => 'PRIMARY', 'Key_name' => "Key_name", 'Column_name' => "Column_name" - ) - ); + ] + ]; $dbi->expects($this->any())->method('getTableIndexes') ->will($this->returnValue($getIndexesResult)); diff --git a/test/classes/Plugins/Transformations/TransformationPluginsTest.php b/test/classes/Plugins/Transformations/TransformationPluginsTest.php index db74f226dd..951f3e2b0c 100644 --- a/test/classes/Plugins/Transformations/TransformationPluginsTest.php +++ b/test/classes/Plugins/Transformations/TransformationPluginsTest.php @@ -47,8 +47,8 @@ class TransformationPluginsTest extends PmaTestCase { // For Application Octetstream Download plugin global $row, $fields_meta; - $fields_meta = array(); - $row = array("pma"=>"aaa", "pca"=>"bbb"); + $fields_meta = []; + $row = ["pma"=>"aaa", "pca"=>"bbb"]; // For Image_*_Inline plugin $GLOBALS['PMA_Config'] = new Config(); @@ -76,54 +76,54 @@ class TransformationPluginsTest extends PmaTestCase */ public function multiDataProvider() { - return array( + return [ // Test data for PhpMyAdmin\Plugins\Transformations\Input\Image_JPEG_Upload plugin - array( + [ new Image_JPEG_Upload(), 'getName', 'Image upload' - ), - array( + ], + [ new Image_JPEG_Upload(), 'getInfo', 'Image upload functionality which also displays a thumbnail.' . ' The options are the width and height of the thumbnail' . ' in pixels. Defaults to 100 X 100.' - ), - array( + ], + [ new Image_JPEG_Upload(), 'getMIMEType', 'Image' - ), - array( + ], + [ new Image_JPEG_Upload(), 'getMIMESubtype', 'JPEG' - ), - array( + ], + [ new Image_JPEG_Upload(), 'getScripts', - array('transformations/image_upload.js') - ), - array( + ['transformations/image_upload.js'] + ], + [ new Image_JPEG_Upload(), 'getInputHtml', '<img src="" width="150" height="100" ' . 'alt="Image preview here"/><br/><input type="file" ' . 'name="fields_uploadtest" accept="image/*" class="image-upload"/>', - array( - array(), + [ + [], 0, 'test', - array('150'), + ['150'], '', 'ltr', 0, 0, 0 - ) - ), - array( + ] + ], + [ new Image_JPEG_Upload(), 'getInputHtml', '<input type="hidden" name="fields_prev2ndtest" ' @@ -133,120 +133,120 @@ class TransformationPluginsTest extends PmaTestCase . 'height="100" alt="Image preview here"/><br/><input type="file" ' . 'name="fields_upload2ndtest" accept="image/*" ' . 'class="image-upload"/>', - array( - array(), + [ + [], 0, '2ndtest', - array( + [ 'wrapper_link' => '?table=a' - ), + ], 'something', 'ltr', 0, 0, 0 - ) - ), + ] + ], // Test data for TextPlainFileupload plugin - array( + [ new Text_Plain_FileUpload(), 'getName', 'Text file upload' - ), - array( + ], + [ new Text_Plain_FileUpload(), 'getInfo', 'File upload functionality for TEXT columns. ' . 'It does not have a textarea for input.' - ), - array( + ], + [ new Text_Plain_FileUpload(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_FileUpload(), 'getMIMESubtype', 'Plain' - ), - array( + ], + [ new Text_Plain_FileUpload(), 'getScripts', - array() - ), - array( + [] + ], + [ new Text_Plain_FileUpload(), 'getInputHtml', '<input type="file" name="fields_uploadtest"/>', - array( - array(), + [ + [], 0, 'test', - array(), + [], '', 'ltr', 0, 0, 0 - ) - ), - array( + ] + ], + [ new Text_Plain_FileUpload(), 'getInputHtml', '<input type="hidden" name="fields_prev2ndtest" ' . 'value="something"/><input type="hidden" name="fields2ndtest" ' . 'value="something"/><input type="file" ' . 'name="fields_upload2ndtest"/>', - array( - array(), + [ + [], 0, '2ndtest', - array(), + [], 'something', 'ltr', 0, 0, 0 - ) - ), + ] + ], // Test data for Text_Plain_Regexvalidation plugin - array( + [ new Text_Plain_RegexValidation(), 'getName', 'Regex Validation' - ), - array( + ], + [ new Text_Plain_RegexValidation(), 'getInfo', 'Validates the string using regular expression ' . 'and performs insert only if string matches it. ' . 'The first option is the Regular Expression.' - ), - array( + ], + [ new Text_Plain_RegexValidation(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_RegexValidation(), 'getMIMESubtype', 'Plain' - ), - array( + ], + [ new Text_Plain_RegexValidation(), 'getInputHtml', '', - array( - array(), 0, '', array(), '', 'ltr', 0, 0, 0 - ) - ), + [ + [], 0, '', [], '', 'ltr', 0, 0, 0 + ] + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Application_Octetstream_Download plugin - array( + [ new Application_Octetstream_Download(), 'getName', 'Download' - ), - array( + ], + [ new Application_Octetstream_Download(), 'getInfo', 'Displays a link to download the binary data of the column. You can' @@ -254,117 +254,117 @@ class TransformationPluginsTest extends PmaTestCase . ' option as the name of a column which contains the filename. If' . ' you use the second option, you need to set the first option to' . ' the empty string.' - ), - array( + ], + [ new Application_Octetstream_Download(), 'getMIMEType', 'Application' - ), - array( + ], + [ new Application_Octetstream_Download(), 'getMIMESubtype', 'OctetStream' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Application_Octetstream_Hex plugin - array( + [ new Application_Octetstream_Hex(), 'getName', 'Hex' - ), - array( + ], + [ new Application_Octetstream_Hex(), 'getInfo', 'Displays hexadecimal representation of data. Optional first' . ' parameter specifies how often space will be added (defaults' . ' to 2 nibbles).' - ), - array( + ], + [ new Application_Octetstream_Hex(), 'getMIMEType', 'Application' - ), - array( + ], + [ new Application_Octetstream_Hex(), 'getMIMESubtype', 'OctetStream' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Image_JPEG_Inline plugin - array( + [ new Image_JPEG_Inline(), 'getName', 'Inline' - ), - array( + ], + [ new Image_JPEG_Inline(), 'getInfo', 'Displays a clickable thumbnail. The options are the maximum width' . ' and height in pixels. The original aspect ratio is preserved.' - ), - array( + ], + [ new Image_JPEG_Inline(), 'getMIMEType', 'Image' - ), - array( + ], + [ new Image_JPEG_Inline(), 'getMIMESubtype', 'JPEG' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Image_JPEG_Link plugin - array( + [ new Image_JPEG_Link(), 'getName', 'ImageLink' - ), - array( + ], + [ new Image_JPEG_Link(), 'getInfo', 'Displays a link to download this image.' - ), - array( + ], + [ new Image_JPEG_Link(), 'getMIMEType', 'Image' - ), - array( + ], + [ new Image_JPEG_Link(), 'getMIMESubtype', 'JPEG' - ), - array( + ], + [ new Image_JPEG_Link(), 'applyTransformationNoWrap', null - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Image_PNG_Inline plugin - array( + [ new Image_PNG_Inline(), 'getName', 'Inline' - ), - array( + ], + [ new Image_PNG_Inline(), 'getInfo', 'Displays a clickable thumbnail. The options are the maximum width' . ' and height in pixels. The original aspect ratio is preserved.' - ), - array( + ], + [ new Image_PNG_Inline(), 'getMIMEType', 'Image' - ), - array( + ], + [ new Image_PNG_Inline(), 'getMIMESubtype', 'PNG' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Text_Plain_Dateformat plugin - array( + [ new Text_Plain_Dateformat(), 'getName', 'Date Format' - ), - array( + ], + [ new Text_Plain_Dateformat(), 'getInfo', 'Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp' @@ -376,24 +376,24 @@ class TransformationPluginsTest extends PmaTestCase . ' that, date format has different value - for "local" see the' . ' documentation for PHP\'s strftime() function and for "utc" it' . ' is done using gmdate() function.' - ), - array( + ], + [ new Text_Plain_Dateformat(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_Dateformat(), 'getMIMESubtype', 'Plain' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Text_Plain_External plugin - array( + [ new Text_Plain_External(), 'getName', 'External' - ), - array( + ], + [ new Text_Plain_External(), 'getInfo', 'LINUX ONLY:' @@ -409,92 +409,92 @@ class TransformationPluginsTest extends PmaTestCase . ' htmlspecialchars() (Default 1). The fourth option, if set to 1,' . ' will prevent wrapping and ensure that the output appears all on' . ' one line (Default 1).' - ), - array( + ], + [ new Text_Plain_External(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_External(), 'getMIMESubtype', 'Plain' - ), - array( + ], + [ new Text_Plain_External(), 'applyTransformationNoWrap', true, - array( - array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q") - ) - ), - array( + [ + ["/dev/null -i -wrap -q", "/dev/null -i -wrap -q"] + ] + ], + [ new Text_Plain_External(), 'applyTransformationNoWrap', true, - array( - array( + [ + [ "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", 1 - ) - ) - ), - array( + ] + ] + ], + [ new Text_Plain_External(), 'applyTransformationNoWrap', true, - array( - array( + [ + [ "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "1" - ) - ) - ), - array( + ] + ] + ], + [ new Text_Plain_External(), 'applyTransformationNoWrap', false, - array( - array( + [ + [ "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", 2 - ) - ) - ), + ] + ] + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Text_Plain_Formatted plugin - array( + [ new Text_Plain_Formatted(), 'getName', 'Formatted' - ), - array( + ], + [ new Text_Plain_Formatted(), 'getInfo', 'Displays the contents of the column as-is, without running it' . ' through htmlspecialchars(). That is, the column is assumed' . ' to contain valid HTML.' - ), - array( + ], + [ new Text_Plain_Formatted(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_Formatted(), 'getMIMESubtype', 'Plain' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Text_Plain_Imagelink plugin - array( + [ new Text_Plain_Imagelink(), 'getName', 'Image Link' - ), - array( + ], + [ new Text_Plain_Imagelink(), 'getInfo', 'Displays an image and a link; ' @@ -502,113 +502,113 @@ class TransformationPluginsTest extends PmaTestCase . ' is a URL prefix like "https://www.example.com/". ' . 'The second and third options' . ' are the width and the height in pixels.' - ), - array( + ], + [ new Text_Plain_Imagelink(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_Imagelink(), 'getMIMESubtype', 'Plain' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Output\Text_Plain_Sql plugin - array( + [ new Text_Plain_Sql(), 'getName', 'SQL' - ), - array( + ], + [ new Text_Plain_Sql(), 'getInfo', 'Formats text as SQL query with syntax highlighting.' - ), - array( + ], + [ new Text_Plain_Sql(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_Sql(), 'getMIMESubtype', 'Plain' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Text_Plain_Link plugin - array( + [ new Text_Plain_Link(), 'getName', 'TextLink' - ), - array( + ], + [ new Text_Plain_Link(), 'getInfo', 'Displays a link; the column contains the filename. The first option' . ' is a URL prefix like "https://www.example.com/".' . ' The second option is a title for the link.' - ), - array( + ], + [ new Text_Plain_Link(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_Link(), 'getMIMESubtype', 'Plain' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Text_Plain_Longtoipv4 plugin - array( + [ new Text_Plain_Longtoipv4(), 'getName', 'Long To IPv4' - ), - array( + ], + [ new Text_Plain_Longtoipv4(), 'getInfo', 'Converts an (IPv4) Internet network address stored as a BIGINT' . ' into a string in Internet standard dotted format.' - ), - array( + ], + [ new Text_Plain_Longtoipv4(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_Longtoipv4(), 'getMIMESubtype', 'Plain' - ), + ], // Test data for Text_Plain_PreApPend plugin - array( + [ new Text_Plain_PreApPend(), 'getName', 'PreApPend' - ), - array( + ], + [ new Text_Plain_PreApPend(), 'getInfo', 'Prepends and/or Appends text to a string. First option is text' . ' to be prepended, second is appended (enclosed in single' . ' quotes, default empty string).' - ), - array( + ], + [ new Text_Plain_PreApPend(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_PreApPend(), 'getMIMESubtype', 'Plain' - ), + ], // Test data for PhpMyAdmin\Plugins\Transformations\Text_Plain_Substring plugin - array( + [ new Text_Plain_Substring(), 'getName', 'Substring' - ), - array( + ], + [ new Text_Plain_Substring(), 'getInfo', 'Displays a part of a string. The first option is the number ' @@ -617,45 +617,45 @@ class TransformationPluginsTest extends PmaTestCase . 'to return (Default: until end of string). The third option is ' . 'the string to append and/or prepend when truncation occurs ' . '(Default: "…").' - ), - array( + ], + [ new Text_Plain_Substring(), 'getMIMEType', 'Text' - ), - array( + ], + [ new Text_Plain_Substring(), 'getMIMESubtype', 'Plain' - ), - array( + ], + [ new Text_Plain_Substring(), 'getOptions', - array('foo', 'bar', 'baz'), - array( - array(), - array('foo', 'bar', 'baz') - ) - ), - array( + ['foo', 'bar', 'baz'], + [ + [], + ['foo', 'bar', 'baz'] + ] + ], + [ new Text_Plain_Substring(), 'getOptions', - array('foo', 'bar', 'baz'), - array( - array('foo', 'bar', 'baz'), - array('foo', 'bar', 'baz') - ) - ), - array( + ['foo', 'bar', 'baz'], + [ + ['foo', 'bar', 'baz'], + ['foo', 'bar', 'baz'] + ] + ], + [ new Text_Plain_Substring(), 'getOptions', - array('foo', 'bar', 'baz'), - array( - array('foo', 'bar', 'baz'), - array(1, 2, 3) - ) - ), - ); + ['foo', 'bar', 'baz'], + [ + ['foo', 'bar', 'baz'], + [1, 2, 3] + ] + ], + ]; } /** @@ -672,7 +672,7 @@ class TransformationPluginsTest extends PmaTestCase * @dataProvider multiDataProvider * @group medium */ - public function testGetMulti($object, $method, $expected, $args = array()) + public function testGetMulti($object, $method, $expected, $args = []) { if (method_exists($object, $method)) { $reflectionMethod = new ReflectionMethod($object, $method); @@ -690,288 +690,288 @@ class TransformationPluginsTest extends PmaTestCase */ public function transformationDataProvider() { - $result = array( - array( + $result = [ + [ new Image_JPEG_Upload(), - array( + [ 'test', - array(150, 100) - ), + [150, 100] + ], 'test' - ), - array( + ], + [ new Text_Plain_FileUpload(), - array( + [ 'test', - array() - ), + [] + ], 'test' - ), - array( + ], + [ new Text_Plain_RegexValidation(), - array( + [ 'phpMyAdmin', - array('/php/i') - ), + ['/php/i'] + ], 'phpMyAdmin', true, '' - ), - array( + ], + [ new Text_Plain_RegexValidation(), - array( + [ 'qwerty', - array('/^a/') - ), + ['/^a/'] + ], 'qwerty', false, 'Validation failed for the input string qwerty.' - ), - array( + ], + [ new Application_Octetstream_Download(), - array( + [ 'PMA_BUFFER', - array("filename", 'wrapper_link'=>'PMA_wrapper_link') - ), + ["filename", 'wrapper_link'=>'PMA_wrapper_link'] + ], '<a href="transformation_wrapper.phpPMA_wrapper_link' . '&ct=application/octet-stream&cn=filename" ' . 'title="filename" class="disableAjax">filename</a>' - ), - array( + ], + [ new Application_Octetstream_Download(), - array( + [ 'PMA_BUFFER', - array("", 'cloumn', 'wrapper_link'=>'PMA_wrapper_link') - ), + ["", 'cloumn', 'wrapper_link'=>'PMA_wrapper_link'] + ], '<a href="transformation_wrapper.phpPMA_wrapper_link&' . 'ct=application/octet-stream&cn=binary_file.dat" ' . 'title="binary_file.dat" class="disableAjax">binary_file.dat</a>' - ), - array( + ], + [ new Application_Octetstream_Hex(), - array( + [ '11111001', - array(3) - ), + [3] + ], '313 131 313 130 303 1 ' - ), - array( + ], + [ new Application_Octetstream_Hex(), - array( + [ '11111001', - array(0) - ), + [0] + ], '3131313131303031' - ), - array( + ], + [ new Application_Octetstream_Hex(), - array( + [ '11111001', - array() - ), + [] + ], '31 31 31 31 31 30 30 31 ' - ), - array( + ], + [ new Image_JPEG_Link(), - array( + [ 'PMA_IMAGE_LINK', - array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link") - ), + ["./image/", "200", "wrapper_link"=>"PMA_wrapper_link"] + ], '<a class="disableAjax" target="_blank" rel="noopener noreferrer"' . ' href="transformation_wrapper.phpPMA_wrapper_link"' . ' alt="[PMA_IMAGE_LINK]">[BLOB]</a>' - ), - array( + ], + [ new Text_Plain_Dateformat(), - array( + [ 12345, - array(0), - (object) array( + [0], + (object) [ 'type' => 'int' - ) - ), + ] + ], '<dfn onclick="alert(\'12345\');" title="12345">' . 'Jan 01, 1970 at 03:25 AM</dfn>' - ), - array( + ], + [ new Text_Plain_Dateformat(), - array( + [ 12345678, - array(0), - (object) array( + [0], + (object) [ 'type' => 'string' - ) - ), + ] + ], '<dfn onclick="alert(\'12345678\');" title="12345678">' . 'May 23, 1970 at 09:21 PM</dfn>' - ), - array( + ], + [ new Text_Plain_Dateformat(), - array( + [ 123456789, - array(0), - (object) array( + [0], + (object) [ 'type' => null - ) - ), + ] + ], '<dfn onclick="alert(\'123456789\');" title="123456789">' . 'Nov 29, 1973 at 09:33 PM</dfn>' - ), - array( + ], + [ new Text_Plain_Dateformat(), - array( + [ '20100201', - array(0), - (object) array( + [0], + (object) [ 'type' => null - ) - ), + ] + ], '<dfn onclick="alert(\'20100201\');" title="20100201">' . 'Feb 01, 2010 at 12:00 AM</dfn>' - ), - array( + ], + [ new Text_Plain_External(), - array( + [ 'PMA_BUFFER', - array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q") - ), + ["/dev/null -i -wrap -q", "/dev/null -i -wrap -q"] + ], 'PMA_BUFFER' - ), - array( + ], + [ new Text_Plain_Formatted(), - array( + [ "<a ref='https://www.example.com/'>PMA_BUFFER</a>", - array("option1", "option2") - ), + ["option1", "option2"] + ], "<iframe srcdoc=\"<a ref='https://www.example.com/'>PMA_BUFFER</a>\" sandbox=\"\"></iframe>" - ), - array( + ], + [ new Text_Plain_Formatted(), - array( + [ "<a ref=\"https://www.example.com/\">PMA_BUFFER</a>", - array("option1", "option2") - ), + ["option1", "option2"] + ], "<iframe srcdoc=\"<a ref='https://www.example.com/'>PMA_BUFFER</a>\" sandbox=\"\"></iframe>" - ), - array( + ], + [ new Text_Plain_Imagelink(), - array( + [ 'PMA_IMAGE', - array("http://image/", "200") - ), + ["http://image/", "200"] + ], '<a href="http://image/PMA_IMAGE" rel="noopener noreferrer" target="_blank">' . '<img src="http://image/PMA_IMAGE" border="0" width="200" ' . 'height="50" />PMA_IMAGE</a>' - ), - array( + ], + [ new Text_Plain_Imagelink(), - array( + [ 'PMA_IMAGE', - array("./image/", "200") - ), + ["./image/", "200"] + ], './image/PMA_IMAGE' - ), - array( + ], + [ new Text_Plain_Sql(), - array( + [ 'select *', - array("option1", "option2") - ), + ["option1", "option2"] + ], '<code class="sql"><pre>' . "\n" . 'select *' . "\n" . '</pre></code>' - ), - array( + ], + [ new Text_Plain_Link(), - array( + [ 'PMA_TXT_LINK', - array("./php/", "text_name") - ), + ["./php/", "text_name"] + ], './php/PMA_TXT_LINK' - ), - array( + ], + [ new Text_Plain_Link(), - array( + [ 'PMA_TXT_LINK', - array(), - ), + [], + ], 'PMA_TXT_LINK' - ), - array( + ], + [ new Text_Plain_Link(), - array( + [ 'https://example.com/PMA_TXT_LINK', - array(), - ), + [], + ], '<a href="https://example.com/PMA_TXT_LINK" title=""' . ' target="_blank" rel="noopener noreferrer">https://example.com/PMA_TXT_LINK</a>' - ), - array( + ], + [ new Text_Plain_Link(), - array( + [ 'PMA_TXT_LINK', - array("./php/", "text_name") - ), + ["./php/", "text_name"] + ], './php/PMA_TXT_LINK' - ), - array( + ], + [ new Text_Plain_Longtoipv4(), - array( + [ 42949672, - array("option1", "option2") - ), + ["option1", "option2"] + ], '2.143.92.40' - ), - array( + ], + [ new Text_Plain_Longtoipv4(), - array( + [ 4294967295, - array("option1", "option2") - ), + ["option1", "option2"] + ], '255.255.255.255' - ), - array( + ], + [ new Text_Plain_PreApPend(), - array( + [ 'My', - array('php', 'Admin') - ), + ['php', 'Admin'] + ], 'phpMyAdmin' - ), - array( + ], + [ new Text_Plain_Substring(), - array( + [ 'PMA_BUFFER', - array(1, 3, 'suffix') - ), + [1, 3, 'suffix'] + ], 'suffixMA_suffix' - ), - ); + ], + ]; if (function_exists('imagecreatetruecolor')) { - $result[] = array( + $result[] = [ new Image_JPEG_Inline(), - array( + [ 'PMA_JPEG_Inline', - array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link") - ), + ["./image/", "200", "wrapper_link"=>"PMA_wrapper_link"] + ], '<a href="transformation_wrapper.phpPMA_wrapper_link" ' . 'rel="noopener noreferrer" target="_blank"><img src="transformation_wrapper.php' . 'PMA_wrapper_link&resize=jpeg&newWidth=0&' . 'newHeight=200" alt="[PMA_JPEG_Inline]" border="0" /></a>' - ); - $result[] = array( + ]; + $result[] = [ new Image_PNG_Inline(), - array( + [ 'PMA_PNG_Inline', - array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link") - ), + ["./image/", "200", "wrapper_link"=>"PMA_wrapper_link"] + ], '<a href="transformation_wrapper.phpPMA_wrapper_link"' . ' rel="noopener noreferrer" target="_blank"><img src="transformation_wrapper.php' . 'PMA_wrapper_link&' . 'resize=jpeg&newWidth=0&newHeight=200" ' . 'alt="[PMA_PNG_Inline]" border="0" /></a>' - ); + ]; } return $result; } diff --git a/test/classes/PmaTestCase.php b/test/classes/PmaTestCase.php index a146274649..de92c87fea 100644 --- a/test/classes/PmaTestCase.php +++ b/test/classes/PmaTestCase.php @@ -53,11 +53,11 @@ class PmaTestCase extends TestCase $mockResponse = $this->getMockBuilder('PhpMyAdmin\Response') ->disableOriginalConstructor() - ->setMethods(array( + ->setMethods([ 'header', 'headersSent', 'disable', 'isAjax', 'setRequestStatus', 'addJSON', 'addHTML', 'getFooter', 'getHeader','httpResponseCode', - )) + ]) ->getMock(); $mockResponse->expects($this->any()) @@ -81,7 +81,7 @@ class PmaTestCase extends TestCase $header_method = $mockResponse->expects($this->exactly(count($param))) ->method('header'); - call_user_func_array(array($header_method, 'withConsecutive'), $param); + call_user_func_array([$header_method, 'withConsecutive'], $param); } else { $mockResponse->expects($this->once()) diff --git a/test/classes/Properties/Options/OptionsPropertyGroupTest.php b/test/classes/Properties/Options/OptionsPropertyGroupTest.php index e76d995ef5..fb530d6258 100644 --- a/test/classes/Properties/Options/OptionsPropertyGroupTest.php +++ b/test/classes/Properties/Options/OptionsPropertyGroupTest.php @@ -51,7 +51,7 @@ class OptionsPropertyGroupTest extends TestCase $properties = new ReflectionProperty('PhpMyAdmin\Properties\Options\OptionsPropertyGroup', '_properties'); $properties->setAccessible(true); - $properties->setValue($this->stub, array(1, 2, 3)); + $properties->setValue($this->stub, [1, 2, 3]); $this->assertNull( $this->stub->addProperty(2) @@ -60,7 +60,7 @@ class OptionsPropertyGroupTest extends TestCase $this->stub->addProperty('2'); $this->assertEquals( - array(1, 2, 3, '2'), + [1, 2, 3, '2'], $properties->getValue($this->stub) ); } @@ -75,15 +75,15 @@ class OptionsPropertyGroupTest extends TestCase $properties = new ReflectionProperty('PhpMyAdmin\Properties\Options\OptionsPropertyGroup', '_properties'); $properties->setAccessible(true); - $properties->setValue($this->stub, array(1, 2, 'test', 3)); + $properties->setValue($this->stub, [1, 2, 'test', 3]); $this->stub->removeProperty('test'); $this->assertEquals( - array( + [ 0 => 1, 1 => 2, 3 => 3 - ), + ], $properties->getValue($this->stub) ); } @@ -110,10 +110,10 @@ class OptionsPropertyGroupTest extends TestCase { $properties = new ReflectionProperty('PhpMyAdmin\Properties\Options\OptionsPropertyGroup', '_properties'); $properties->setAccessible(true); - $properties->setValue($this->stub, array(1, 2, 3)); + $properties->setValue($this->stub, [1, 2, 3]); $this->assertEquals( - array(1, 2, 3), + [1, 2, 3], $this->stub->getProperties() ); } @@ -127,7 +127,7 @@ class OptionsPropertyGroupTest extends TestCase { $properties = new ReflectionProperty('PhpMyAdmin\Properties\Options\OptionsPropertyGroup', '_properties'); $properties->setAccessible(true); - $properties->setValue($this->stub, array(1, 2, 3)); + $properties->setValue($this->stub, [1, 2, 3]); $this->assertEquals( 3, diff --git a/test/classes/Properties/Options/OptionsPropertyOneItemTest.php b/test/classes/Properties/Options/OptionsPropertyOneItemTest.php index fc83262eb7..80ff8a15ee 100644 --- a/test/classes/Properties/Options/OptionsPropertyOneItemTest.php +++ b/test/classes/Properties/Options/OptionsPropertyOneItemTest.php @@ -49,10 +49,10 @@ class OptionsPropertyOneItemTest extends TestCase */ public function testGetSetValues() { - $this->stub->setValues(array(1, 2)); + $this->stub->setValues([1, 2]); $this->assertEquals( - array(1, 2), + [1, 2], $this->stub->getValues() ); } diff --git a/test/classes/RelationCleanupDbiMock.php b/test/classes/RelationCleanupDbiMock.php index ddeaa16ba3..3d6f9e04f6 100644 --- a/test/classes/RelationCleanupDbiMock.php +++ b/test/classes/RelationCleanupDbiMock.php @@ -23,8 +23,8 @@ class RelationCleanupDbiMock extends DatabaseInterface var $index; var $assocIndex; var $totalNum; - var $values = array(); - var $indexs = array(); + var $values = []; + var $indexs = []; /** * Constructor @@ -35,7 +35,7 @@ class RelationCleanupDbiMock extends DatabaseInterface $this->index = 0; $this->assocIndex = 0; $this->totalNum = 2; - $this->values = array( + $this->values = [ 'bookmark', 'relation', 'table_info', @@ -50,8 +50,8 @@ class RelationCleanupDbiMock extends DatabaseInterface 'users', 'usergroups', 'navigationhiding', - ); - $this->indexs = array( + ]; + $this->indexs = [ 'bookmark' => 0, 'relation' => 1, 'table_info' => 2, @@ -66,7 +66,7 @@ class RelationCleanupDbiMock extends DatabaseInterface 'users' => 11, 'usergroups' => 12, 'navigationhiding' => 13, - ); + ]; } /** @@ -78,7 +78,7 @@ class RelationCleanupDbiMock extends DatabaseInterface */ public function fetchRow($result) { - $curr_table = array(); + $curr_table = []; if ($this->index < count($this->values)) { $curr_table[0] = $this->values[$this->index]; $this->index++; @@ -200,9 +200,9 @@ class RelationCleanupDbiMock extends DatabaseInterface string $type = 'ASSOC', $link = null ) { - return array( + return [ 'display_field' => "PMA_display_field" - ); + ]; } /** @@ -214,7 +214,7 @@ class RelationCleanupDbiMock extends DatabaseInterface */ public function fetchAssoc($result) { - $assocResult = array(); + $assocResult = []; if ($this->assocIndex < $this->totalNum) { $assocResult['db_name'] = "db_name" . $this->assocIndex; $assocResult['comment'] = "comment" . $this->assocIndex; diff --git a/test/classes/RelationCleanupTest.php b/test/classes/RelationCleanupTest.php index c744ef0919..d9d80ea896 100644 --- a/test/classes/RelationCleanupTest.php +++ b/test/classes/RelationCleanupTest.php @@ -36,7 +36,7 @@ class RelationCleanupTest extends TestCase */ public function setUp() { - $_SESSION['relation'] = array(); + $_SESSION['relation'] = []; $GLOBALS['server'] = 1; $GLOBALS['cfg']['Server']['user'] = "user"; $GLOBALS['cfg']['Server']['pmadb'] = "pmadb"; @@ -98,7 +98,7 @@ class RelationCleanupTest extends TestCase //validate Relation::getDbComments when commwork = true $db_comments = $this->relation->getDbComments(); $this->assertEquals( - array('db_name0' => 'comment0','db_name1' => 'comment1'), + ['db_name0' => 'comment0','db_name1' => 'comment1'], $db_comments ); diff --git a/test/classes/RelationTest.php b/test/classes/RelationTest.php index f59fbebc1e..df17071e0c 100644 --- a/test/classes/RelationTest.php +++ b/test/classes/RelationTest.php @@ -42,7 +42,7 @@ class RelationTest extends TestCase $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['cfg']['ZeroConf'] = true; $_SESSION['relation'][$GLOBALS['server']] = "PMA_relation"; - $_SESSION['relation'] = array(); + $_SESSION['relation'] = []; $GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath(); $GLOBALS['cfg']['ServerDefault'] = 0; @@ -211,24 +211,24 @@ class RelationTest extends TestCase public function testPMAGetComments() { $GLOBALS['cfg']['ServerDefault'] = 0; - $_SESSION['relation'] = array(); + $_SESSION['relation'] = []; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $getColumnsResult = array( - array( + $getColumnsResult = [ + [ 'Field' => 'field1', 'Type' => 'int(11)', 'Comment' => 'Comment1' - ), - array( + ], + [ 'Field' => 'field2', 'Type' => 'text', 'Comment' => 'Comment1' - ) - ); + ] + ]; $dbi->expects($this->any())->method('getColumns') ->will($this->returnValue($getColumnsResult)); @@ -236,17 +236,17 @@ class RelationTest extends TestCase $db = 'information_schema'; $this->assertEquals( - array(''), + [''], $this->relation->getComments($db) ); $db = 'information_schema'; $table = 'TABLES'; $this->assertEquals( - array( + [ 'field1' => 'Comment1', 'field2' => 'Comment1' - ), + ], $this->relation->getComments($db, $table) ); } @@ -297,28 +297,28 @@ class RelationTest extends TestCase */ public function testPMASearchColumnInForeigners() { - $foreigners = array( - 'value' => array( + $foreigners = [ + 'value' => [ 'master_field' => 'value', 'foreign_db' => 'GSoC14', 'foreign_table' => 'test', 'foreign_field' => 'value' - ), - 'foreign_keys_data' => array( - 0 => array( + ], + 'foreign_keys_data' => [ + 0 => [ 'constraint' => 'ad', - 'index_list' => array('id', 'value'), + 'index_list' => ['id', 'value'], 'ref_db_name' => 'GSoC14', 'ref_table_name' => 'table_1', - 'ref_index_list' => array('id', 'value'), + 'ref_index_list' => ['id', 'value'], 'on_delete' => 'CASCADE', 'on_update' => 'CASCADE' - ) - ) - ); + ] + ] + ]; $foreigner = $this->relation->searchColumnInForeigners($foreigners, 'id'); - $expected = array(); + $expected = []; $expected['foreign_field'] = 'id'; $expected['foreign_db'] = 'GSoC14'; $expected['foreign_table'] = 'table_1'; diff --git a/test/classes/ReplicationGuiTest.php b/test/classes/ReplicationGuiTest.php index bacac3ca93..804defe2f0 100644 --- a/test/classes/ReplicationGuiTest.php +++ b/test/classes/ReplicationGuiTest.php @@ -44,7 +44,7 @@ class ReplicationGuiTest extends TestCase $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; @@ -53,7 +53,7 @@ class ReplicationGuiTest extends TestCase $GLOBALS['cfg']['ShowHint'] = true; $GLOBALS['table'] = "table"; - $GLOBALS['url_params'] = array(); + $GLOBALS['url_params'] = []; $this->replicationGui = new ReplicationGui(); @@ -61,21 +61,21 @@ class ReplicationGuiTest extends TestCase //Mock DBI - $slave_host = array( - array('Server_id'=>'Server_id1', 'Host'=>'Host1'), - array('Server_id'=>'Server_id2', 'Host'=>'Host2'), - ); + $slave_host = [ + ['Server_id'=>'Server_id1', 'Host'=>'Host1'], + ['Server_id'=>'Server_id2', 'Host'=>'Host2'], + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW SLAVE HOSTS", null, null, DatabaseInterface::CONNECT_USER, 0, $slave_host - ), - ); + ], + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -84,13 +84,13 @@ class ReplicationGuiTest extends TestCase $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); - $fields_info = array( - "Host" => array( + $fields_info = [ + "Host" => [ "Field" => "host", "Type" => "char(60)", "Null" => "NO", - ) - ); + ] + ]; $dbi->expects($this->any())->method('getColumns') ->will($this->returnValue($fields_info)); diff --git a/test/classes/Rte/EventsTest.php b/test/classes/Rte/EventsTest.php index 831dd417b1..17dfa63f5d 100644 --- a/test/classes/Rte/EventsTest.php +++ b/test/classes/Rte/EventsTest.php @@ -95,9 +95,9 @@ class EventsTest extends TestCase */ public function providerGetDataFromRequest() { - return array( - array( - array( + return [ + [ + [ 'item_name' => '', 'item_type' => '', 'item_original_name' => '', @@ -111,8 +111,8 @@ class EventsTest extends TestCase 'item_preserve' => '', 'item_comment' => '', 'item_definer' => '' - ), - array( + ], + [ 'item_name' => '', 'item_type' => 'ONE TIME', 'item_type_toggle' => 'RECURRING', @@ -127,10 +127,10 @@ class EventsTest extends TestCase 'item_preserve' => '', 'item_comment' => '', 'item_definer' => '' - ) - ), - array( - array( + ] + ], + [ + [ 'item_name' => 'foo', 'item_type' => 'RECURRING', 'item_original_name' => 'foo', @@ -144,8 +144,8 @@ class EventsTest extends TestCase 'item_preserve' => 'foo', 'item_comment' => 'foo', 'item_definer' => 'foo' - ), - array( + ], + [ 'item_name' => 'foo', 'item_type' => 'RECURRING', 'item_type_toggle' => 'ONE TIME', @@ -160,9 +160,9 @@ class EventsTest extends TestCase 'item_preserve' => 'foo', 'item_comment' => 'foo', 'item_definer' => 'foo' - ) - ), - ); + ] + ], + ]; } /** @@ -191,7 +191,7 @@ class EventsTest extends TestCase */ public function providerGetEditorFormAdd() { - $data = array( + $data = [ 'item_name' => '', 'item_type' => 'ONE TIME', 'item_type_toggle' => 'RECURRING', @@ -206,50 +206,50 @@ class EventsTest extends TestCase 'item_preserve' => '', 'item_comment' => '', 'item_definer' => '' - ); + ]; - return array( - array( + return [ + [ $data, "<input name='add_item'" - ), - array( + ], + [ $data, "<input type='text' name='item_name'" - ), - array( + ], + [ $data, "<select name='item_status'" - ), - array( + ], + [ $data, "<input name='item_type'" - ), - array( + ], + [ $data, "<input type='text' name='item_execute_at'" - ), - array( + ], + [ $data, "<input type='text' name='item_ends'" - ), - array( + ], + [ $data, "<textarea name='item_definition'" - ), - array( + ], + [ $data, "<input type='text' name='item_definer'" - ), - array( + ], + [ $data, "<input type='text' name='item_comment'" - ), - array( + ], + [ $data, "<input type='submit' name='editor_process_add'" - ) - ); + ] + ]; } /** @@ -278,7 +278,7 @@ class EventsTest extends TestCase */ public function providerGetEditorFormEdit() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_type' => 'RECURRING', 'item_type_toggle' => 'ONE TIME', @@ -293,50 +293,50 @@ class EventsTest extends TestCase 'item_preserve' => '', 'item_comment' => '', 'item_definer' => '' - ); + ]; - return array( - array( + return [ + [ $data, "<input name='edit_item'" - ), - array( + ], + [ $data, "<input type='text' name='item_name'" - ), - array( + ], + [ $data, "<select name='item_status'" - ), - array( + ], + [ $data, "<input name='item_type'" - ), - array( + ], + [ $data, "<input type='text' name='item_execute_at'" - ), - array( + ], + [ $data, "<input type='text' name='item_ends'" - ), - array( + ], + [ $data, "<textarea name='item_definition'" - ), - array( + ], + [ $data, "<input type='text' name='item_definer'" - ), - array( + ], + [ $data, "<input type='text' name='item_comment'" - ), - array( + ], + [ $data, "<input type='submit' name='editor_process_edit'" - ) - ); + ] + ]; } /** @@ -367,7 +367,7 @@ class EventsTest extends TestCase */ public function providerGetEditorFormAjax() { - $data = array( + $data = [ 'item_name' => '', 'item_type' => 'RECURRING', 'item_type_toggle' => 'ONE TIME', @@ -382,22 +382,22 @@ class EventsTest extends TestCase 'item_preserve' => '', 'item_comment' => '', 'item_definer' => '' - ); + ]; - return array( - array( + return [ + [ $data, "<select name='item_type'" - ), - array( + ], + [ $data, "<input type='hidden' name='editor_process_edit'" - ), - array( + ], + [ $data, "<input type='hidden' name='ajax_request'" - ) - ); + ] + ]; } /** @@ -415,7 +415,7 @@ class EventsTest extends TestCase { global $_REQUEST, $errors; - $errors = array(); + $errors = []; $this->events->setGlobals(); unset($_REQUEST); @@ -440,21 +440,21 @@ class EventsTest extends TestCase */ public function providerGetQueryFromRequest() { - return array( + return [ // Testing success - array( - array( // simple once-off event + [ + [ // simple once-off event 'item_name' => 's o m e e v e n t\\', 'item_type' => 'ONE TIME', 'item_execute_at' => '2050-01-01 00:00:00', 'item_definition' => 'SET @A=0;' - ), + ], 'CREATE EVENT `s o m e e v e n t\` ON SCHEDULE AT \'2050-01-01 ' . '00:00:00\' ON COMPLETION NOT PRESERVE DO SET @A=0;', 0 - ), - array( - array( // full once-off event + ], + [ + [ // full once-off event 'item_name' => 'evn', 'item_definer' => 'me@home', 'item_type' => 'ONE TIME', @@ -462,26 +462,26 @@ class EventsTest extends TestCase 'item_preserve' => 'ON', 'item_status' => 'ENABLED', 'item_definition' => 'SET @A=0;' - ), + ], 'CREATE DEFINER=`me`@`home` EVENT `evn` ON SCHEDULE AT ' . '\'2050-01-01 00:00:00\' ON COMPLETION PRESERVE ENABLE DO SET @A=0;', 0 - ), - array( - array( // simple recurring event + ], + [ + [ // simple recurring event 'item_name' => 'rec_``evn', 'item_type' => 'RECURRING', 'item_interval_value' => '365', 'item_interval_field' => 'DAY', 'item_status' => 'DISABLED', 'item_definition' => 'SET @A=0;' - ), + ], 'CREATE EVENT `rec_````evn` ON SCHEDULE EVERY 365 DAY ON ' . 'COMPLETION NOT PRESERVE DISABLE DO SET @A=0;', 0 - ), - array( - array( // full recurring event + ], + [ + [ // full recurring event 'item_name' => 'rec_evn2', 'item_definer' => 'evil``user><\\@work\\', 'item_type' => 'RECURRING', @@ -492,57 +492,57 @@ class EventsTest extends TestCase 'item_preserve' => 'ON', 'item_status' => 'SLAVESIDE_DISABLED', 'item_definition' => 'SET @A=0;' - ), + ], 'CREATE DEFINER=`evil````user><\`@`work\` EVENT `rec_evn2` ON ' . 'SCHEDULE EVERY 365 DAY STARTS \'1900-01-01\' ENDS \'2050-01-01\' ' . 'ON COMPLETION PRESERVE DISABLE ON SLAVE DO SET @A=0;', 0 - ), + ], // Testing failures - array( - array( // empty request - ), + [ + [ // empty request + ], 'CREATE EVENT ON SCHEDULE ON COMPLETION NOT PRESERVE DO ', 3 - ), - array( - array( + ], + [ + [ 'item_name' => 's o m e e v e n t\\', 'item_definer' => 'someuser', // invalid definer format 'item_type' => 'ONE TIME', 'item_execute_at' => '', // no execution time 'item_definition' => 'SET @A=0;' - ), + ], 'CREATE EVENT `s o m e e v e n t\` ON SCHEDULE ON COMPLETION NOT ' . 'PRESERVE DO SET @A=0;', 2 - ), - array( - array( + ], + [ + [ 'item_name' => 'rec_``evn', 'item_type' => 'RECURRING', 'item_interval_value' => '', // no interval value 'item_interval_field' => 'DAY', 'item_status' => 'DISABLED', 'item_definition' => 'SET @A=0;' - ), + ], 'CREATE EVENT `rec_````evn` ON SCHEDULE ON COMPLETION NOT ' . 'PRESERVE DISABLE DO SET @A=0;', 1 - ), - array( - array( // simple recurring event + ], + [ + [ // simple recurring event 'item_name' => 'rec_``evn', 'item_type' => 'RECURRING', 'item_interval_value' => '365', 'item_interval_field' => 'CENTURIES', // invalid interval field 'item_status' => 'DISABLED', 'item_definition' => 'SET @A=0;' - ), + ], 'CREATE EVENT `rec_````evn` ON SCHEDULE ON COMPLETION NOT ' . 'PRESERVE DISABLE DO SET @A=0;', 1 - ), - ); + ], + ]; } } diff --git a/test/classes/Rte/RoutinesTest.php b/test/classes/Rte/RoutinesTest.php index 6ffacde19b..0e5705baa8 100644 --- a/test/classes/Rte/RoutinesTest.php +++ b/test/classes/Rte/RoutinesTest.php @@ -90,9 +90,9 @@ class RoutinesTest extends TestCase */ public function providerGetDataFromRequest() { - return array( - array( - array( + return [ + [ + [ 'item_name' => '', 'item_original_name' => '', 'item_returnlength' => '', @@ -114,8 +114,8 @@ class RoutinesTest extends TestCase 'item_isdeterministic' => '', 'item_securitytype' => '', 'item_sqldataaccess' => '' - ), - array( + ], + [ 'item_name' => '', 'item_original_name' => '', 'item_returnlength' => '', @@ -128,21 +128,21 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'FUNCTION', 'item_original_type' => 'PROCEDURE', 'item_num_params' => 0, - 'item_param_dir' => array(), - 'item_param_name' => array(), - 'item_param_type' => array(), - 'item_param_length' => array(), - 'item_param_opts_num' => array(), - 'item_param_opts_text' => array(), + 'item_param_dir' => [], + 'item_param_name' => [], + 'item_param_type' => [], + 'item_param_length' => [], + 'item_param_opts_num' => [], + 'item_param_opts_text' => [], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => '' - ) - ), - array( - array( + ] + ], + [ + [ 'item_name' => 'proc2', 'item_original_name' => 'proc', 'item_returnlength' => '', @@ -154,18 +154,18 @@ class RoutinesTest extends TestCase 'item_type' => 'PROCEDURE', 'item_type_toggle' => 'FUNCTION', 'item_original_type' => 'PROCEDURE', - 'item_param_dir' => array(0 => 'IN', 1 => 'FAIL'), - 'item_param_name' => array(0 => 'bar', 1 => 'baz'), - 'item_param_type' => array(0 => 'INT', 1 => 'FAIL'), - 'item_param_length' => array(0 => '20', 1 => ''), - 'item_param_opts_num' => array(0 => 'UNSIGNED', 1 => ''), - 'item_param_opts_text' => array(0 => '', 1 => 'latin1'), + 'item_param_dir' => [0 => 'IN', 1 => 'FAIL'], + 'item_param_name' => [0 => 'bar', 1 => 'baz'], + 'item_param_type' => [0 => 'INT', 1 => 'FAIL'], + 'item_param_length' => [0 => '20', 1 => ''], + 'item_param_opts_num' => [0 => 'UNSIGNED', 1 => ''], + 'item_param_opts_text' => [0 => '', 1 => 'latin1'], 'item_returntype' => '', 'item_isdeterministic' => 'ON', 'item_securitytype' => 'INVOKER', 'item_sqldataaccess' => 'NO SQL' - ), - array( + ], + [ 'item_name' => 'proc2', 'item_original_name' => 'proc', 'item_returnlength' => '', @@ -178,21 +178,21 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'FUNCTION', 'item_original_type' => 'PROCEDURE', 'item_num_params' => 2, - 'item_param_dir' => array(0 => 'IN', 1 => ''), - 'item_param_name' => array(0 => 'bar', 1 => 'baz'), - 'item_param_type' => array(0 => 'INT', 1 => ''), - 'item_param_length' => array(0 => '20', 1 => ''), - 'item_param_opts_num' => array(0 => 'UNSIGNED', 1 => ''), - 'item_param_opts_text' => array(0 => '', 1 => 'latin1'), + 'item_param_dir' => [0 => 'IN', 1 => ''], + 'item_param_name' => [0 => 'bar', 1 => 'baz'], + 'item_param_type' => [0 => 'INT', 1 => ''], + 'item_param_length' => [0 => '20', 1 => ''], + 'item_param_opts_num' => [0 => 'UNSIGNED', 1 => ''], + 'item_param_opts_text' => [0 => '', 1 => 'latin1'], 'item_returntype' => '', 'item_isdeterministic' => ' checked=\'checked\'', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => ' selected=\'selected\'', 'item_sqldataaccess' => 'NO SQL' - ) - ), - array( - array( + ] + ], + [ + [ 'item_name' => 'func2', 'item_original_name' => 'func', 'item_returnlength' => '20', @@ -204,21 +204,21 @@ class RoutinesTest extends TestCase 'item_type' => 'FUNCTION', 'item_type_toggle' => 'PROCEDURE', 'item_original_type' => 'FUNCTION', - 'item_param_dir' => array(0 => '', 1 => ''), - 'item_param_name' => array(0 => 'bar', 1 => 'baz'), - 'item_param_type' => array( + 'item_param_dir' => [0 => '', 1 => ''], + 'item_param_name' => [0 => 'bar', 1 => 'baz'], + 'item_param_type' => [ 0 => '<s>XSS</s>', 1 => 'TEXT' - ), - 'item_param_length' => array(0 => '10,10', 1 => ''), - 'item_param_opts_num' => array(0 => 'UNSIGNED', 1 => ''), - 'item_param_opts_text' => array(0 => '', 1 => 'utf8'), + ], + 'item_param_length' => [0 => '10,10', 1 => ''], + 'item_param_opts_num' => [0 => 'UNSIGNED', 1 => ''], + 'item_param_opts_text' => [0 => '', 1 => 'utf8'], 'item_returntype' => 'VARCHAR', 'item_isdeterministic' => '', 'item_securitytype' => 'DEFINER', 'item_sqldataaccess' => '' - ), - array( + ], + [ 'item_name' => 'func2', 'item_original_name' => 'func', 'item_returnlength' => '20', @@ -231,20 +231,20 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'PROCEDURE', 'item_original_type' => 'FUNCTION', 'item_num_params' => '2', - 'item_param_dir' => array(), - 'item_param_name' => array(0 => 'bar', 1 => 'baz'), - 'item_param_type' => array(0 => '', 1 => 'TEXT'), - 'item_param_length' => array(0 => '10,10', 1 => ''), - 'item_param_opts_num' => array(0 => 'UNSIGNED', 1 => ''), - 'item_param_opts_text' => array(0 => '', 1 => 'utf8'), + 'item_param_dir' => [], + 'item_param_name' => [0 => 'bar', 1 => 'baz'], + 'item_param_type' => [0 => '', 1 => 'TEXT'], + 'item_param_length' => [0 => '10,10', 1 => ''], + 'item_param_opts_num' => [0 => 'UNSIGNED', 1 => ''], + 'item_param_opts_text' => [0 => '', 1 => 'utf8'], 'item_returntype' => 'VARCHAR', 'item_isdeterministic' => '', 'item_securitytype_definer' => ' selected=\'selected\'', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => '' - ) - ), - ); + ] + ], + ]; } /** @@ -255,7 +255,7 @@ class RoutinesTest extends TestCase public function testGetParameterRowEmpty() { $this->routines->setGlobals(); - $this->assertEquals('', $this->routines->getParameterRow(array(), 0)); + $this->assertEquals('', $this->routines->getParameterRow([], 0)); } /** @@ -286,7 +286,7 @@ class RoutinesTest extends TestCase */ public function providerGetParameterRow() { - $data = array( + $data = [ 'item_name' => '', 'item_original_name' => '', 'item_returnlength' => '', @@ -299,46 +299,46 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'FUNCTION', 'item_original_type' => 'PROCEDURE', 'item_num_params' => 1, - 'item_param_dir' => array(0 => 'IN'), - 'item_param_name' => array(0 => 'foo'), - 'item_param_type' => array(0 => 'INT'), - 'item_param_length' => array(0 => ''), - 'item_param_opts_num' => array(0 => 'UNSIGNED'), - 'item_param_opts_text' => array(0 => ''), + 'item_param_dir' => [0 => 'IN'], + 'item_param_name' => [0 => 'foo'], + 'item_param_type' => [0 => 'INT'], + 'item_param_length' => [0 => ''], + 'item_param_opts_num' => [0 => 'UNSIGNED'], + 'item_param_opts_text' => [0 => ''], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => '' - ); + ]; - return array( - array( + return [ + [ $data, 0, "<select name='item_param_dir[0]'" - ), - array( + ], + [ $data, 0, "<input name='item_param_name[0]'" - ), - array( + ], + [ $data, 0, "<select name='item_param_type[0]'" - ), - array( + ], + [ $data, 0, "<select name='item_param_opts_num[0]'" - ), - array( + ], + [ $data, 0, "<a href='#' class='routine_param_remove_anchor'" - ), - ); + ], + ]; } /** @@ -370,7 +370,7 @@ class RoutinesTest extends TestCase */ public function providerGetParameterRowAjax() { - $data = array( + $data = [ 'item_name' => '', 'item_original_name' => '', 'item_returnlength' => '', @@ -383,41 +383,41 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'FUNCTION', 'item_original_type' => 'PROCEDURE', 'item_num_params' => 1, - 'item_param_dir' => array(0 => 'IN'), - 'item_param_name' => array(0 => 'foo'), - 'item_param_type' => array(0 => 'INT'), - 'item_param_length' => array(0 => ''), - 'item_param_opts_num' => array(0 => 'UNSIGNED'), - 'item_param_opts_text' => array(0 => ''), + 'item_param_dir' => [0 => 'IN'], + 'item_param_name' => [0 => 'foo'], + 'item_param_type' => [0 => 'INT'], + 'item_param_length' => [0 => ''], + 'item_param_opts_num' => [0 => 'UNSIGNED'], + 'item_param_opts_text' => [0 => ''], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => '' - ); + ]; - return array( - array( + return [ + [ $data, "<select name='item_param_dir[%s]'" - ), - array( + ], + [ $data, "<input name='item_param_name[%s]'" - ), - array( + ], + [ $data, "<select name='item_param_dir[%s]'" - ), - array( + ], + [ $data, "<select name='item_param_opts_num[%s]'" - ), - array( + ], + [ $data, "<a href='#' class='routine_param_remove_anchor'" - ) - ); + ] + ]; } /** @@ -447,7 +447,7 @@ class RoutinesTest extends TestCase */ public function providerGetEditorForm1() { - $data = array( + $data = [ 'item_name' => '', 'item_original_name' => '', 'item_returnlength' => '', @@ -460,85 +460,85 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'FUNCTION', 'item_original_type' => 'PROCEDURE', 'item_num_params' => 0, - 'item_param_dir' => array(), - 'item_param_name' => array(), - 'item_param_type' => array(), - 'item_param_length' => array(), - 'item_param_opts_num' => array(), - 'item_param_opts_text' => array(), + 'item_param_dir' => [], + 'item_param_name' => [], + 'item_param_type' => [], + 'item_param_length' => [], + 'item_param_opts_num' => [], + 'item_param_opts_text' => [], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => '' - ); + ]; - return array( - array( + return [ + [ $data, "<input name='add_item'" - ), - array( + ], + [ $data, "<input type='text' name='item_name'" - ), - array( + ], + [ $data, "<input name='item_type'" - ), - array( + ], + [ $data, "name='routine_changetype'" - ), - array( + ], + [ $data, "name='routine_addparameter'" - ), - array( + ], + [ $data, "name='routine_removeparameter'" - ), - array( + ], + [ $data, "select name='item_returntype'" - ), - array( + ], + [ $data, "name='item_returnlength'" - ), - array( + ], + [ $data, "select name='item_returnopts_num'" - ), - array( + ], + [ $data, "<textarea name='item_definition'" - ), - array( + ], + [ $data, "name='item_isdeterministic'" - ), - array( + ], + [ $data, "name='item_definer'" - ), - array( + ], + [ $data, "select name='item_securitytype'" - ), - array( + ], + [ $data, "select name='item_sqldataaccess'" - ), - array( + ], + [ $data, "name='item_comment'" - ), - array( + ], + [ $data, "name='editor_process_add'" - ) - ); + ] + ]; } /** @@ -568,7 +568,7 @@ class RoutinesTest extends TestCase */ public function providerGetEditorForm2() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_original_name' => 'bar', 'item_returnlength' => '', @@ -581,85 +581,85 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'FUNCTION', 'item_original_type' => 'PROCEDURE', 'item_num_params' => 1, - 'item_param_dir' => array(0 => 'IN'), - 'item_param_name' => array(0 => 'baz'), - 'item_param_type' => array(0 => 'INT'), - 'item_param_length' => array(0 => '20'), - 'item_param_opts_num' => array(0 => 'UNSIGNED'), - 'item_param_opts_text' => array(0 => ''), + 'item_param_dir' => [0 => 'IN'], + 'item_param_name' => [0 => 'baz'], + 'item_param_type' => [0 => 'INT'], + 'item_param_length' => [0 => '20'], + 'item_param_opts_num' => [0 => 'UNSIGNED'], + 'item_param_opts_text' => [0 => ''], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => 'NO SQL' - ); + ]; - return array( - array( + return [ + [ $data, "name='edit_item'" - ), - array( + ], + [ $data, "name='item_name'" - ), - array( + ], + [ $data, "<input name='item_type' type='hidden' value='FUNCTION'" - ), - array( + ], + [ $data, "name='routine_changetype'" - ), - array( + ], + [ $data, "name='routine_addparameter'" - ), - array( + ], + [ $data, "name='routine_removeparameter'" - ), - array( + ], + [ $data, "name='item_returntype'" - ), - array( + ], + [ $data, "name='item_returnlength'" - ), - array( + ], + [ $data, "name='item_returnopts_num'" - ), - array( + ], + [ $data, "<textarea name='item_definition'" - ), - array( + ], + [ $data, "name='item_isdeterministic'" - ), - array( + ], + [ $data, "name='item_definer'" - ), - array( + ], + [ $data, "<select name='item_securitytype'" - ), - array( + ], + [ $data, "<select name='item_sqldataaccess'" - ), - array( + ], + [ $data, "name='item_comment'" - ), - array( + ], + [ $data, "name='editor_process_edit'" - ) - ); + ] + ]; } /** @@ -691,7 +691,7 @@ class RoutinesTest extends TestCase */ public function providerGetEditorForm3() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_original_name' => 'bar', 'item_returnlength' => '', @@ -704,85 +704,85 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'PROCEDURE', 'item_original_type' => 'FUNCTION', 'item_num_params' => 1, - 'item_param_dir' => array(0 => ''), - 'item_param_name' => array(0 => 'baz'), - 'item_param_type' => array(0 => 'INT'), - 'item_param_length' => array(0 => '20'), - 'item_param_opts_num' => array(0 => 'UNSIGNED'), - 'item_param_opts_text' => array(0 => ''), + 'item_param_dir' => [0 => ''], + 'item_param_name' => [0 => 'baz'], + 'item_param_type' => [0 => 'INT'], + 'item_param_length' => [0 => '20'], + 'item_param_opts_num' => [0 => 'UNSIGNED'], + 'item_param_opts_text' => [0 => ''], 'item_returntype' => 'INT', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => 'NO SQL' - ); + ]; - return array( - array( + return [ + [ $data, "name='edit_item'" - ), - array( + ], + [ $data, "name='item_name'" - ), - array( + ], + [ $data, "<select name='item_type'" - ), - array( + ], + [ $data, "name='routine_addparameter'" - ), - array( + ], + [ $data, "name='routine_removeparameter'" - ), - array( + ], + [ $data, "<select name='item_returntype'" - ), - array( + ], + [ $data, "name='item_returnlength'" - ), - array( + ], + [ $data, "<select name='item_returnopts_num'" - ), - array( + ], + [ $data, "<textarea name='item_definition'" - ), - array( + ], + [ $data, "name='item_isdeterministic'" - ), - array( + ], + [ $data, "name='item_definer'" - ), - array( + ], + [ $data, "<select name='item_securitytype'" - ), - array( + ], + [ $data, "<select name='item_sqldataaccess'" - ), - array( + ], + [ $data, "name='item_comment'" - ), - array( + ], + [ $data, "name='ajax_request'" - ), - array( + ], + [ $data, "name='editor_process_edit'" - ), - ); + ], + ]; } /** @@ -812,7 +812,7 @@ class RoutinesTest extends TestCase */ public function providerGetEditorForm4() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_original_name' => 'bar', 'item_returnlength' => '', @@ -825,25 +825,25 @@ class RoutinesTest extends TestCase 'item_type_toggle' => 'PROCEDURE', 'item_original_type' => 'PROCEDURE', 'item_num_params' => 1, - 'item_param_dir' => array(0 => 'IN'), - 'item_param_name' => array(0 => 'baz'), - 'item_param_type' => array(0 => 'INT'), - 'item_param_length' => array(0 => '20'), - 'item_param_opts_num' => array(0 => 'UNSIGNED'), - 'item_param_opts_text' => array(0 => ''), + 'item_param_dir' => [0 => 'IN'], + 'item_param_name' => [0 => 'baz'], + 'item_param_type' => [0 => 'INT'], + 'item_param_length' => [0 => '20'], + 'item_param_opts_num' => [0 => 'UNSIGNED'], + 'item_param_opts_text' => [0 => ''], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => 'NO SQL' - ); + ]; - return array( - array( + return [ + [ $data, "<input name='item_type' type='hidden' value='PROCEDURE'" - ), - ); + ], + ]; } /** @@ -874,7 +874,7 @@ class RoutinesTest extends TestCase */ public function providerGetExecuteForm1() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_returnlength' => '', 'item_returnopts_num' => '', @@ -884,103 +884,103 @@ class RoutinesTest extends TestCase 'item_definer' => '', 'item_type' => 'PROCEDURE', 'item_num_params' => 6, - 'item_param_dir' => array( + 'item_param_dir' => [ 0 => 'IN', 1 => 'OUT', 2 => 'IN', 3 => 'IN', 4 => 'IN', 5 => 'IN' - ), - 'item_param_name' => array( + ], + 'item_param_name' => [ 0 => 'foo', 1 => 'foa', 2 => 'fob', 3 => 'foc', 4 => 'fod', 5 => 'foe' - ), - 'item_param_type' => array( + ], + 'item_param_type' => [ 0 => 'DATE', 1 => 'VARCHAR', 2 => 'DATETIME', 3 => 'GEOMETRY', 4 => 'ENUM', 5 => 'SET' - ), - 'item_param_length' => array( + ], + 'item_param_length' => [ 0 => '', 1 => '22', 2 => '', 3 => '', 4 => "'a','b'", 5 => "'a','b'" - ), - 'item_param_length_arr' => array( - 0 => array(), - 1 => array('22'), - 2 => array(), - 3 => array(), - 4 => array("'a'", "'b'"), - 5 => array("'a'", "'b'") - ), - 'item_param_opts_num' => array( + ], + 'item_param_length_arr' => [ + 0 => [], + 1 => ['22'], + 2 => [], + 3 => [], + 4 => ["'a'", "'b'"], + 5 => ["'a'", "'b'"] + ], + 'item_param_opts_num' => [ 0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '' - ), - 'item_param_opts_text' => array( + ], + 'item_param_opts_text' => [ 0 => '', 1 => 'utf8', 2 => '', 3 => '', 4 => '', 5 => '' - ), + ], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => '' - ); + ]; - return array( - array( + return [ + [ $data, "name='item_name'" - ), - array( + ], + [ $data, "name='funcs[foo]'" - ), - array( + ], + [ $data, "<input class='datefield' type='text' name='params[foo]' />" - ), - array( + ], + [ $data, "name='funcs[fob]'" - ), - array( + ], + [ $data, "<input class='datetimefield' type='text' name='params[fob]'" - ), - array( + ], + [ $data, "name='params[fod][]'" - ), - array( + ], + [ $data, "name='params[foe][]'" - ), - array( + ], + [ $data, "name='execute_routine'" - ), - ); + ], + ]; } /** @@ -1011,7 +1011,7 @@ class RoutinesTest extends TestCase */ public function providerGetExecuteForm2() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_returnlength' => '', 'item_returnopts_num' => '', @@ -1021,79 +1021,79 @@ class RoutinesTest extends TestCase 'item_definer' => '', 'item_type' => 'PROCEDURE', 'item_num_params' => 6, - 'item_param_dir' => array( + 'item_param_dir' => [ 0 => 'IN', 1 => 'OUT', 2 => 'IN', 3 => 'IN', 4 => 'IN', 5 => 'IN' - ), - 'item_param_name' => array( + ], + 'item_param_name' => [ 0 => 'foo', 1 => 'foa', 2 => 'fob', 3 => 'foc', 4 => 'fod', 5 => 'foe' - ), - 'item_param_type' => array( + ], + 'item_param_type' => [ 0 => 'DATE', 1 => 'VARCHAR', 2 => 'DATETIME', 3 => 'GEOMETRY', 4 => 'ENUM', 5 => 'SET' - ), - 'item_param_length' => array( + ], + 'item_param_length' => [ 0 => '', 1 => '22', 2 => '', 3 => '', 4 => "'a','b'", 5 => "'a','b'" - ), - 'item_param_length_arr' => array( - 0 => array(), - 1 => array('22'), - 2 => array(), - 3 => array(), - 4 => array("'a'", "'b'"), - 5 => array("'a'", "'b'") - ), - 'item_param_opts_num' => array( + ], + 'item_param_length_arr' => [ + 0 => [], + 1 => ['22'], + 2 => [], + 3 => [], + 4 => ["'a'", "'b'"], + 5 => ["'a'", "'b'"] + ], + 'item_param_opts_num' => [ 0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '' - ), - 'item_param_opts_text' => array( + ], + 'item_param_opts_text' => [ 0 => '', 1 => 'utf8', 2 => '', 3 => '', 4 => '', 5 => '' - ), + ], 'item_returntype' => '', 'item_isdeterministic' => '', 'item_securitytype_definer' => '', 'item_securitytype_invoker' => '', 'item_sqldataaccess' => '' - ); + ]; - return array( - array( + return [ + [ $data, "name='execute_routine'" - ), - array( + ], + [ $data, "name='ajax_request'" - ), - ); + ], + ]; } /** @@ -1113,7 +1113,7 @@ class RoutinesTest extends TestCase $cfg['ShowFunctionFields'] = false; - $errors = array(); + $errors = []; $this->routines->setGlobals(); $old_dbi = isset($GLOBALS['dbi']) ? $GLOBALS['dbi'] : null; @@ -1125,11 +1125,11 @@ class RoutinesTest extends TestCase ->method('escapeString') ->will( $this->returnValueMap( - array( - array('foo', DatabaseInterface::CONNECT_USER, 'foo'), - array("foo's bar", DatabaseInterface::CONNECT_USER, "foo\'s bar"), - array('', DatabaseInterface::CONNECT_USER, '') - ) + [ + ['foo', DatabaseInterface::CONNECT_USER, 'foo'], + ["foo's bar", DatabaseInterface::CONNECT_USER, "foo\'s bar"], + ['', DatabaseInterface::CONNECT_USER, ''] + ] ) ); $GLOBALS['dbi'] = $dbi; @@ -1150,10 +1150,10 @@ class RoutinesTest extends TestCase */ public function providerGetQueryFromRequest() { - return array( + return [ // Testing success - array( - array( + [ + [ 'item_name' => 'p r o c', 'item_returnlength' => '', 'item_returnopts_num' => '', @@ -1173,13 +1173,13 @@ class RoutinesTest extends TestCase 'item_isdeterministic' => '', 'item_securitytype' => 'INVOKER', 'item_sqldataaccess' => 'NO SQL' - ), + ], 'CREATE DEFINER=`me`@`home` PROCEDURE `p r o c`() COMMENT \'foo\' ' . 'DETERMINISTIC NO SQL SQL SECURITY INVOKER SELECT 0;', 0 - ), - array( - array( + ], + [ + [ 'item_name' => 'pr``oc', 'item_returnlength' => '', 'item_returnopts_num' => '', @@ -1189,24 +1189,24 @@ class RoutinesTest extends TestCase 'item_definer' => 'someuser@somehost', 'item_type' => 'PROCEDURE', 'item_num_params' => '2', - 'item_param_dir' => array('IN', 'INOUT'), - 'item_param_name' => array('pa`ram', 'par 2'), - 'item_param_type' => array('INT', 'ENUM'), - 'item_param_length' => array('10', '\'a\', \'b\''), - 'item_param_opts_num' => array('ZEROFILL', ''), - 'item_param_opts_text' => array('utf8', 'latin1'), + 'item_param_dir' => ['IN', 'INOUT'], + 'item_param_name' => ['pa`ram', 'par 2'], + 'item_param_type' => ['INT', 'ENUM'], + 'item_param_length' => ['10', '\'a\', \'b\''], + 'item_param_opts_num' => ['ZEROFILL', ''], + 'item_param_opts_text' => ['utf8', 'latin1'], 'item_returntype' => '', 'item_securitytype' => 'DEFINER', 'item_sqldataaccess' => 'foobar' - ), + ], 'CREATE DEFINER=`someuser`@`somehost` PROCEDURE `pr````oc`' . '(IN `pa``ram` INT(10) ZEROFILL, INOUT `par 2` ENUM(\'a\', \'b\')' . ' CHARSET latin1) NOT DETERMINISTIC SQL SECURITY DEFINER SELECT ' . '\'foobar\';', 0 - ), - array( - array( + ], + [ + [ 'item_name' => 'func\\', 'item_returnlength' => '5,5', 'item_returnopts_num' => 'UNSIGNED ZEROFILL', @@ -1217,23 +1217,23 @@ class RoutinesTest extends TestCase 'item_type' => 'FUNCTION', 'item_num_params' => '1', 'item_param_dir' => '', - 'item_param_name' => array('pa`ram'), - 'item_param_type' => array('VARCHAR'), - 'item_param_length' => array('45'), - 'item_param_opts_num' => array(''), - 'item_param_opts_text' => array('latin1'), + 'item_param_name' => ['pa`ram'], + 'item_param_type' => ['VARCHAR'], + 'item_param_length' => ['45'], + 'item_param_opts_num' => [''], + 'item_param_opts_text' => ['latin1'], 'item_returntype' => 'DECIMAL', 'item_isdeterministic' => 'ON', 'item_securitytype' => 'DEFINER', 'item_sqldataaccess' => 'READ SQL DATA' - ), + ], 'CREATE FUNCTION `func\\`(`pa``ram` VARCHAR(45) CHARSET latin1) ' . 'RETURNS DECIMAL(5,5) UNSIGNED ZEROFILL COMMENT \'foo\\\'s bar\' ' . 'DETERMINISTIC SQL SECURITY DEFINER SELECT \'foobar\';', 0 - ), - array( - array( + ], + [ + [ 'item_name' => 'func', 'item_returnlength' => '20', 'item_returnopts_num' => '', @@ -1246,20 +1246,20 @@ class RoutinesTest extends TestCase 'item_returntype' => 'VARCHAR', 'item_securitytype' => 'DEFINER', 'item_sqldataaccess' => 'READ SQL DATA' - ), + ], 'CREATE FUNCTION `func`() RETURNS VARCHAR(20) CHARSET utf8 NOT ' . 'DETERMINISTIC SQL SECURITY DEFINER SELECT 0;', 0 - ), + ], // Testing failures - array( - array( - ), + [ + [ + ], 'CREATE () NOT DETERMINISTIC ', // invalid query 3 - ), - array( - array( + ], + [ + [ 'item_name' => 'proc', 'item_returnlength' => '', 'item_returnopts_num' => '', @@ -1279,13 +1279,13 @@ class RoutinesTest extends TestCase 'item_isdeterministic' => '', 'item_securitytype' => 'INVOKER', 'item_sqldataaccess' => 'NO SQL' - ), + ], 'CREATE PROCEDURE `proc`() COMMENT \'foo\' DETERMINISTIC ' . 'NO SQL SQL SECURITY INVOKER SELECT 0;', // valid query 1 - ), - array( - array( + ], + [ + [ 'item_name' => 'proc', 'item_returnlength' => '', 'item_returnopts_num' => '', @@ -1295,23 +1295,23 @@ class RoutinesTest extends TestCase 'item_definer' => '', 'item_type' => 'PROCEDURE', 'item_num_params' => '2', - 'item_param_dir' => array('FAIL', 'INOUT'), // invalid direction - 'item_param_name' => array('pa`ram', 'goo'), - 'item_param_type' => array('INT', 'ENUM'), - 'item_param_length' => array('10', ''), // missing ENUM values - 'item_param_opts_num' => array('ZEROFILL', ''), - 'item_param_opts_text' => array('utf8', 'latin1'), + 'item_param_dir' => ['FAIL', 'INOUT'], // invalid direction + 'item_param_name' => ['pa`ram', 'goo'], + 'item_param_type' => ['INT', 'ENUM'], + 'item_param_length' => ['10', ''], // missing ENUM values + 'item_param_opts_num' => ['ZEROFILL', ''], + 'item_param_opts_text' => ['utf8', 'latin1'], 'item_returntype' => '', 'item_securitytype' => 'DEFINER', 'item_sqldataaccess' => 'foobar' // invalid, will just be ignored without throwing errors - ), + ], 'CREATE PROCEDURE `proc`((10) ZEROFILL, ' . 'INOUT `goo` ENUM CHARSET latin1) NOT DETERMINISTIC ' . 'SQL SECURITY DEFINER SELECT 0;', // invalid query 2 - ), - array( - array( + ], + [ + [ 'item_name' => 'func', 'item_returnlength' => '', // missing length for VARCHAR 'item_returnopts_num' => '', @@ -1321,22 +1321,22 @@ class RoutinesTest extends TestCase 'item_definer' => '', 'item_type' => 'FUNCTION', 'item_num_params' => '2', - 'item_param_dir' => array('IN'), - 'item_param_name' => array(''), // missing name - 'item_param_type' => array('INT'), - 'item_param_length' => array('10'), - 'item_param_opts_num' => array('ZEROFILL'), - 'item_param_opts_text' => array('latin1'), + 'item_param_dir' => ['IN'], + 'item_param_name' => [''], // missing name + 'item_param_type' => ['INT'], + 'item_param_length' => ['10'], + 'item_param_opts_num' => ['ZEROFILL'], + 'item_param_opts_text' => ['latin1'], 'item_returntype' => 'VARCHAR', 'item_securitytype' => 'DEFINER', 'item_sqldataaccess' => '' - ), + ], 'CREATE FUNCTION `func`() RETURNS VARCHAR CHARSET utf8 NOT ' . 'DETERMINISTIC SQL SECURITY DEFINER SELECT 0;', // invalid query 2 - ), - array( - array( + ], + [ + [ 'item_name' => 'func', 'item_returnlength' => '', 'item_returnopts_num' => '', @@ -1349,11 +1349,11 @@ class RoutinesTest extends TestCase 'item_returntype' => 'FAIL', // invalid return type 'item_securitytype' => 'DEFINER', 'item_sqldataaccess' => '' - ), + ], 'CREATE FUNCTION `func`() NOT DETERMINISTIC SQL ' . 'SECURITY DEFINER SELECT 0;', // invalid query 1 - ), - ); + ], + ]; } } diff --git a/test/classes/Rte/TriggersTest.php b/test/classes/Rte/TriggersTest.php index a2119dd584..12048edf98 100644 --- a/test/classes/Rte/TriggersTest.php +++ b/test/classes/Rte/TriggersTest.php @@ -81,9 +81,9 @@ class TriggersTest extends TestCase */ public function providerGetDataFromRequestEmpty() { - return array( - array( - array( + return [ + [ + [ 'item_name' => '', 'item_table' => '', 'item_original_name' => '', @@ -91,8 +91,8 @@ class TriggersTest extends TestCase 'item_event_manipulation' => '', 'item_definition' => '', 'item_definer' => '' - ), - array( + ], + [ 'item_name' => '', 'item_table' => '', 'item_original_name' => '', @@ -100,10 +100,10 @@ class TriggersTest extends TestCase 'item_event_manipulation' => '', 'item_definition' => '', 'item_definer' => '' - ) - ), - array( - array( + ] + ], + [ + [ 'item_name' => 'foo', 'item_table' => 'foo', 'item_original_name' => 'foo', @@ -111,8 +111,8 @@ class TriggersTest extends TestCase 'item_event_manipulation' => 'foo', 'item_definition' => 'foo', 'item_definer' => 'foo' - ), - array( + ], + [ 'item_name' => 'foo', 'item_table' => 'foo', 'item_original_name' => 'foo', @@ -120,9 +120,9 @@ class TriggersTest extends TestCase 'item_event_manipulation' => 'foo', 'item_definition' => 'foo', 'item_definer' => 'foo' - ) - ) - ); + ] + ] + ]; } /** @@ -153,7 +153,7 @@ class TriggersTest extends TestCase */ public function providerGetEditorFormAdd() { - $data = array( + $data = [ 'item_name' => '', 'item_table' => 'table1', 'item_original_name' => '', @@ -161,42 +161,42 @@ class TriggersTest extends TestCase 'item_event_manipulation' => '', 'item_definition' => '', 'item_definer' => '' - ); + ]; - return array( - array( + return [ + [ $data, "name='add_item'" - ), - array( + ], + [ $data, "name='item_name'" - ), - array( + ], + [ $data, "name='item_table'" - ), - array( + ], + [ $data, "name='item_timing'" - ), - array( + ], + [ $data, "name='item_event'" - ), - array( + ], + [ $data, "name='item_definition'" - ), - array( + ], + [ $data, "name='item_definer'" - ), - array( + ], + [ $data, "name='editor_process_add'" - ) - ); + ] + ]; } /** @@ -227,7 +227,7 @@ class TriggersTest extends TestCase */ public function providerGetEditorFormEdit() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_table' => 'table1', 'item_original_name' => 'bar', @@ -235,42 +235,42 @@ class TriggersTest extends TestCase 'item_event_manipulation' => 'INSERT', 'item_definition' => 'SET @A=1;', 'item_definer' => '' - ); + ]; - return array( - array( + return [ + [ $data, "name='edit_item'" - ), - array( + ], + [ $data, "name='item_name'" - ), - array( + ], + [ $data, "name='item_table'" - ), - array( + ], + [ $data, "name='item_timing'" - ), - array( + ], + [ $data, "name='item_event'" - ), - array( + ], + [ $data, "name='item_definition'" - ), - array( + ], + [ $data, "name='item_definer'" - ), - array( + ], + [ $data, "name='editor_process_edit'" - ) - ); + ] + ]; } /** @@ -302,7 +302,7 @@ class TriggersTest extends TestCase */ public function providerGetEditorFormAjax() { - $data = array( + $data = [ 'item_name' => 'foo', 'item_table' => 'table1', 'item_original_name' => 'bar', @@ -310,18 +310,18 @@ class TriggersTest extends TestCase 'item_event_manipulation' => 'INSERT', 'item_definition' => 'SET @A=1;', 'item_definer' => '' - ); + ]; - return array( - array( + return [ + [ $data, "name='editor_process_edit'" - ), - array( + ], + [ $data, "name='ajax_request'" - ) - ); + ] + ]; } /** @@ -345,7 +345,7 @@ class TriggersTest extends TestCase ) { global $_REQUEST, $errors; - $errors = array(); + $errors = []; $this->triggers->setGlobals(); $_REQUEST['item_definer'] = $definer; @@ -367,8 +367,8 @@ class TriggersTest extends TestCase */ public function providerGetQueryFromRequest() { - return array( - array('', + return [ + ['', '', '', '', @@ -376,8 +376,8 @@ class TriggersTest extends TestCase '', 'CREATE TRIGGER ON FOR EACH ROW ', 5 - ), - array( + ], + [ 'root', 'trigger', 'BEFORE', @@ -386,8 +386,8 @@ class TriggersTest extends TestCase 'SET @A=NULL', 'CREATE TRIGGER `trigger` BEFORE INSERT ON FOR EACH ROW SET @A=NULL', 2 - ), - array( + ], + [ 'foo`s@host', 'trigger`s test', 'AFTER', @@ -396,8 +396,8 @@ class TriggersTest extends TestCase 'BEGIN SET @A=1; SET @B=2; END', 'CREATE DEFINER=`foo``s`@`host` TRIGGER `trigger``s test` AFTER ON FOR EACH ROW BEGIN SET @A=1; SET @B=2; END', 2 - ), - array( + ], + [ 'root@localhost', 'trigger', 'BEFORE', @@ -406,7 +406,7 @@ class TriggersTest extends TestCase 'SET @A=NULL', 'CREATE DEFINER=`root`@`localhost` TRIGGER `trigger` BEFORE INSERT ON `table1` FOR EACH ROW SET @A=NULL', 0 - ), - ); + ], + ]; } } diff --git a/test/classes/SanitizeTest.php b/test/classes/SanitizeTest.php index b263df53b1..8373bffa31 100644 --- a/test/classes/SanitizeTest.php +++ b/test/classes/SanitizeTest.php @@ -76,12 +76,12 @@ class SanitizeTest extends TestCase */ public function docLinks() { - return array( - array('foo', 'setup.html%23foo'), - array('cfg_TitleTable', 'config.html%23cfg_TitleTable'), - array('faq3-11', 'faq.html%23faq3-11'), - array('bookmarks@', 'bookmarks.html'), - ); + return [ + ['foo', 'setup.html%23foo'], + ['cfg_TitleTable', 'config.html%23cfg_TitleTable'], + ['faq3-11', 'faq.html%23faq3-11'], + ['bookmarks@', 'bookmarks.html'], + ]; } /** @@ -190,7 +190,7 @@ class SanitizeTest extends TestCase { $this->assertEquals($expected, Sanitize::getJsValue($key, $value)); $this->assertEquals('foo = 100', Sanitize::getJsValue('foo', '100', false)); - $array = array('1','2','3'); + $array = ['1','2','3']; $this->assertEquals( "foo = [\"1\",\"2\",\"3\",];\n", Sanitize::getJsValue('foo', $array) @@ -218,15 +218,15 @@ class SanitizeTest extends TestCase */ public function variables() { - return array( - array('foo', true, "foo = true;\n"), - array('foo', false, "foo = false;\n"), - array('foo', 100, "foo = 100;\n"), - array('foo', 0, "foo = 0;\n"), - array('foo', 'text', "foo = \"text\";\n"), - array('foo', 'quote"', "foo = \"quote\\\"\";\n"), - array('foo', 'apostroph\'', "foo = \"apostroph\\'\";\n"), - ); + return [ + ['foo', true, "foo = true;\n"], + ['foo', false, "foo = false;\n"], + ['foo', 100, "foo = 100;\n"], + ['foo', 0, "foo = 0;\n"], + ['foo', 'text', "foo = \"text\";\n"], + ['foo', 'quote"', "foo = \"quote\\\"\";\n"], + ['foo', 'apostroph\'', "foo = \"apostroph\\'\";\n"], + ]; } /** @@ -251,17 +251,17 @@ class SanitizeTest extends TestCase */ public function escapeDataProvider() { - return array( - array('\\\';', '\';'), - array('\r\n\\\'<scrIpt></\' + \'script>', "\r\n'<scrIpt></sCRIPT>"), - array('\\\';[XSS]', '\';[XSS]'), - array( + return [ + ['\\\';', '\';'], + ['\r\n\\\'<scrIpt></\' + \'script>', "\r\n'<scrIpt></sCRIPT>"], + ['\\\';[XSS]', '\';[XSS]'], + [ '</\' + \'script></head><body>[HTML]', '</SCRIPT></head><body>[HTML]' - ), - array('\"\\\'\\\\\\\'\"', '"\'\\\'"'), - array("\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", "\\''''''''''''\\") - ); + ], + ['\"\\\'\\\\\\\'\"', '"\'\\\'"'], + ["\\\\\'\'\'\'\'\'\'\'\'\'\'\'\\\\", "\\''''''''''''\\"] + ]; } /** @@ -274,7 +274,7 @@ class SanitizeTest extends TestCase $_REQUEST['foo'] = 'bar'; $_REQUEST['allow'] = 'all'; $_REQUEST['second'] = 1; - $allow_list = array('allow', 'second'); + $allow_list = ['allow', 'second']; Sanitize::removeRequestVars($allow_list); $this->assertArrayNotHasKey('foo', $_REQUEST); $this->assertArrayNotHasKey('second', $_REQUEST); diff --git a/test/classes/ScriptsTest.php b/test/classes/ScriptsTest.php index a7cca57b80..751245d277 100644 --- a/test/classes/ScriptsTest.php +++ b/test/classes/ScriptsTest.php @@ -82,14 +82,14 @@ class ScriptsTest extends PmaTestCase . 'src="js/common.js?v=' . PMA_VERSION . '"></script>' . "\n", $this->_callPrivateFunction( '_includeFiles', - array( - array( - array( + [ + [ + [ 'has_onload' => false, 'filename' => 'common.js' - ) - ) - ) + ] + ] + ] ) ); } @@ -150,10 +150,10 @@ $(function() {}); $this->object->addFile('common.js'); $this->assertEquals( - array( - array('name' => 'vendor/codemirror/lib/codemirror.js', 'fire' => 0), - array('name' => 'common.js', 'fire' => 1) - ), + [ + ['name' => 'vendor/codemirror/lib/codemirror.js', 'fire' => 0], + ['name' => 'common.js', 'fire' => 1] + ], $this->object->getFiles() ); } @@ -168,7 +168,7 @@ $(function() {}); // Assert empty _files property of // Scripts $this->assertAttributeEquals( - array(), + [], '_files', $this->object ); @@ -176,13 +176,13 @@ $(function() {}); // Add one script file $file = 'common.js'; $hash = 'd7716810d825f4b55d18727c3ccb24e6'; - $_files = array( - $hash => array( + $_files = [ + $hash => [ 'has_onload' => 1, 'filename' => 'common.js', - 'params' => array(), - ) - ); + 'params' => [], + ] + ]; $this->object->addFile($file); $this->assertAttributeEquals( $_files, @@ -199,23 +199,23 @@ $(function() {}); */ public function testAddFiles() { - $filenames = array( + $filenames = [ 'common.js', 'sql.js', 'common.js', - ); - $_files = array( - 'd7716810d825f4b55d18727c3ccb24e6' => array( + ]; + $_files = [ + 'd7716810d825f4b55d18727c3ccb24e6' => [ 'has_onload' => 1, 'filename' => 'common.js', - 'params' => array(), - ), - '347a57484fcd6ea6d8a125e6e1d31f78' => array( + 'params' => [], + ], + '347a57484fcd6ea6d8a125e6e1d31f78' => [ 'has_onload' => 1, 'filename' => 'sql.js', - 'params' => array(), - ), - ); + 'params' => [], + ], + ]; $this->object->addFiles($filenames); $this->assertAttributeEquals( $_files, diff --git a/test/classes/Server/PrivilegesTest.php b/test/classes/Server/PrivilegesTest.php index 0bd603fbb2..52808b38f7 100644 --- a/test/classes/Server/PrivilegesTest.php +++ b/test/classes/Server/PrivilegesTest.php @@ -53,7 +53,7 @@ class PrivilegesTest extends TestCase $GLOBALS['cfg']['SendErrorReports'] = "never"; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; @@ -69,7 +69,7 @@ class PrivilegesTest extends TestCase $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true; $GLOBALS['cfg']['LoginCookieValidity'] = 1440; - $GLOBALS['cfgRelation'] = array(); + $GLOBALS['cfgRelation'] = []; $GLOBALS['cfgRelation']['menuswork'] = false; $GLOBALS['table'] = "table"; $GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); @@ -86,13 +86,13 @@ class PrivilegesTest extends TestCase //$_POST $_POST['pred_password'] = 'none'; //$_SESSION - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'db' => 'pmadb', 'users' => 'users', 'usergroups' => 'usergroups', 'menuswork' => true - ); + ]; $pmaconfig = $this->getMockBuilder('PhpMyAdmin\Config') ->disableOriginalConstructor() @@ -109,23 +109,23 @@ class PrivilegesTest extends TestCase ->method('fetchResult') ->will( $this->returnValue( - array( + [ 'grant user1 select', 'grant user2 delete' - ) + ] ) ); - $fetchSingleRow = array( + $fetchSingleRow = [ 'password' => 'pma_password', 'Table_priv' => 'pri1, pri2', 'Type' => 'Type', '@@old_passwords' => 0, - ); + ]; $dbi->expects($this->any())->method('fetchSingleRow') ->will($this->returnValue($fetchSingleRow)); - $fetchValue = array('key1' => 'value1'); + $fetchValue = ['key1' => 'value1']; $dbi->expects($this->any())->method('fetchValue') ->will($this->returnValue($fetchValue)); @@ -183,7 +183,7 @@ class PrivilegesTest extends TestCase //pre variable have been defined $_REQUEST['pred_tablename'] = "PMA_pred__tablename"; - $_REQUEST['pred_dbname'] = array("PMA_pred_dbname"); + $_REQUEST['pred_dbname'] = ["PMA_pred_dbname"]; list( ,, $dbname, $tablename, $routinename, $db_and_table, $dbname_is_wildcard @@ -277,19 +277,19 @@ class PrivilegesTest extends TestCase $ret = $this->serverPrivileges->getTableGrantsArray(); $this->assertEquals( - array( + [ 'Delete', 'DELETE', $GLOBALS['strPrivDescDelete'] - ), + ], $ret[0] ); $this->assertEquals( - array( + [ 'Create', 'CREATE', $GLOBALS['strPrivDescCreateTbl'] - ), + ], $ret[1] ); } @@ -303,19 +303,19 @@ class PrivilegesTest extends TestCase { $ret = $this->serverPrivileges->getGrantsArray(); $this->assertEquals( - array( + [ 'Select_priv', 'SELECT', __('Allows reading data.') - ), + ], $ret[0] ); $this->assertEquals( - array( + [ 'Insert_priv', 'INSERT', __('Allows inserting and replacing data.') - ), + ], $ret[1] ); } @@ -327,12 +327,12 @@ class PrivilegesTest extends TestCase */ public function testGetHtmlForColumnPrivileges() { - $columns = array( + $columns = [ 'row1' => 'name1' - ); - $row = array( + ]; + $row = [ 'name_for_select' => 'Y' - ); + ]; $name_for_select = 'name_for_select'; $priv_for_header = 'priv_for_header'; $name = 'name'; @@ -383,10 +383,10 @@ class PrivilegesTest extends TestCase public function testGetHtmlForRequires() { /* Assertion 1 */ - $row = array( + $row = [ 'ssl_type' => '', 'ssh_cipher' => '' - ); + ]; $html = $this->serverPrivileges->getHtmlForRequires( $row @@ -414,10 +414,10 @@ class PrivilegesTest extends TestCase ); /* Assertion 2 */ - $row = array( + $row = [ 'ssl_type' => 'ANY', 'ssh_cipher' => '' - ); + ]; $html = $this->serverPrivileges->getHtmlForRequires( $row @@ -445,10 +445,10 @@ class PrivilegesTest extends TestCase ); /* Assertion 3 */ - $row = array( + $row = [ 'ssl_type' => 'X509', 'ssh_cipher' => '' - ); + ]; $html = $this->serverPrivileges->getHtmlForRequires( $row @@ -476,10 +476,10 @@ class PrivilegesTest extends TestCase ); /* Assertion 4 */ - $row = array( + $row = [ 'ssl_type' => 'SPECIFIED', 'ssh_cipher' => '' - ); + ]; $html = $this->serverPrivileges->getHtmlForRequires( $row @@ -525,7 +525,7 @@ class PrivilegesTest extends TestCase $html ); //Url::getHiddenInputs - $params = array('username' => $username); + $params = ['username' => $username]; $html_output = Url::getHiddenInputs($params); $this->assertContains( $html_output, @@ -552,7 +552,7 @@ class PrivilegesTest extends TestCase ->will($this->returnValue(true)); $dbi->expects($this->any()) ->method('fetchRow') - ->willReturnOnConsecutiveCalls(array('userG'), null); + ->willReturnOnConsecutiveCalls(['userG'], null); $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); @@ -564,7 +564,7 @@ class PrivilegesTest extends TestCase $actualHtml ); //Url::getHiddenInputs - $params = array('username' => $username); + $params = ['username' => $username]; $html_output = Url::getHiddenInputs($params); $this->assertContains( $html_output, @@ -607,7 +607,7 @@ class PrivilegesTest extends TestCase $html ); //Url::getHiddenInputs - $params = array('username' => $username); + $params = ['username' => $username]; $html_output = Url::getHiddenInputs($params); $this->assertContains( $html_output, @@ -627,12 +627,12 @@ class PrivilegesTest extends TestCase */ public function testGetHtmlForResourceLimits() { - $row = array( + $row = [ 'max_questions' => 'max_questions', 'max_updates' => 'max_updates', 'max_connections' => 'max_connections', 'max_user_connections' => 'max_user_connections', - ); + ]; $html = $this->serverPrivileges->getHtmlForResourceLimits($row); $this->assertContains( @@ -773,7 +773,7 @@ class PrivilegesTest extends TestCase $password ); $this->assertEquals( - array(), + [], $queries ); unset($_REQUEST['change_copy']); @@ -1021,7 +1021,7 @@ class PrivilegesTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $fetchSingleRow = array( + $fetchSingleRow = [ 'password' => 'pma_password', 'max_questions' => 'max_questions', 'max_updates' => 'max_updates', @@ -1038,14 +1038,14 @@ class PrivilegesTest extends TestCase . "'Show_view','Create_routine','" . "Repl_client','Lock_tables','References','Alter_routine','" . "Create_user','Repl_slave','Repl_client','Execute','Grant','ddd", - ); + ]; $dbi->expects($this->any())->method('fetchSingleRow') ->will($this->returnValue($fetchSingleRow)); $dbi->expects($this->any())->method('tryQuery') ->will($this->returnValue(true)); - $columns = array('val1', 'replace1', 5); + $columns = ['val1', 'replace1', 5]; $dbi->expects($this->at(0)) ->method('fetchRow') ->will($this->returnValue($columns)); @@ -1221,17 +1221,17 @@ class PrivilegesTest extends TestCase $hostname = "PMA_hostname"; $db = "PMA_db"; $table = "PMA_table"; - $columns = array( + $columns = [ 'row1' => 'name1' - ); - $row = array( + ]; + $row = [ 'Select_priv' => 'Y', 'Insert_priv' => 'Y', 'Update_priv' => 'Y', 'References_priv' => 'Y', 'Create_view_priv' => 'Y', 'ShowView_priv' => 'Y', - ); + ]; $html = $this->serverPrivileges->getHtmlForTableSpecificPrivileges( $username, $hostname, $db, $table, $columns, $row @@ -1293,10 +1293,10 @@ class PrivilegesTest extends TestCase $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $fields_info = array( - array('COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80), - array('COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40), - ); + $fields_info = [ + ['COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80], + ['COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($fields_info)); $dbi->expects($this->any()) @@ -1401,10 +1401,10 @@ class PrivilegesTest extends TestCase $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $fields_info = array( - array('COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80), - array('COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40), - ); + $fields_info = [ + ['COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80], + ['COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($fields_info)); $dbi->expects($this->any()) @@ -1437,13 +1437,13 @@ class PrivilegesTest extends TestCase $item = Template::get('checkbox') ->render( - array( + [ 'html_field_name' => 'createdb-2', 'label' => __('Grant all privileges on wildcard name (username\\_%).'), 'checked' => false, 'onclick' => false, 'html_field_id' => 'createdb-2', - ) + ] ); $this->assertContains( $item, @@ -1476,10 +1476,10 @@ class PrivilegesTest extends TestCase $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $fields_info = array( - array('COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80), - array('COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40), - ); + $fields_info = [ + ['COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80], + ['COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40], + ]; $dbi->expects($this->any())->method('isSuperuser') ->will($this->returnValue(true)); $dbi->expects($this->any())->method('fetchResult') @@ -1496,7 +1496,7 @@ class PrivilegesTest extends TestCase //validate 1: Url::getCommon $this->assertContains( - Url::getCommon(array('db' => $db)), + Url::getCommon(['db' => $db]), $html ); @@ -1538,7 +1538,7 @@ class PrivilegesTest extends TestCase $html ); $this->assertContains( - Url::getCommon(array('checkprivsdb' => $db)), + Url::getCommon(['checkprivsdb' => $db]), $html ); @@ -1556,10 +1556,10 @@ class PrivilegesTest extends TestCase $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $fields_info = array( - array('COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80), - array('COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40), - ); + $fields_info = [ + ['COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80], + ['COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($fields_info)); $dbi->expects($this->any()) @@ -1583,10 +1583,10 @@ class PrivilegesTest extends TestCase //validate 2: Url::getCommon $item = Url::getCommon( - array( + [ 'db' => $db, 'table' => $table, - ) + ] ); $this->assertContains( $item, @@ -1626,7 +1626,7 @@ class PrivilegesTest extends TestCase ); $this->assertContains( Url::getCommon( - array('checkprivsdb' => $db, 'checkprivstable' => $table) + ['checkprivsdb' => $db, 'checkprivstable' => $table] ), $html ); @@ -1652,15 +1652,15 @@ class PrivilegesTest extends TestCase ); //$privMap != null - $privMap = array( - "user1" => array( - "hostname1" => array( - array('Type'=>'g', 'Grant_priv'=>'Y'), - array('Type'=>'d', 'Db'=>"dbname", 'Grant_priv'=>'Y'), - array('Type'=>'t', 'Grant_priv'=>'N'), - ) - ) - ); + $privMap = [ + "user1" => [ + "hostname1" => [ + ['Type'=>'g', 'Grant_priv'=>'Y'], + ['Type'=>'d', 'Db'=>"dbname", 'Grant_priv'=>'Y'], + ['Type'=>'t', 'Grant_priv'=>'N'], + ] + ] + ]; $html = $this->serverPrivileges->getHtmlTableBodyForSpecificDbOrTablePrivs($privMap, $db); @@ -1722,13 +1722,13 @@ class PrivilegesTest extends TestCase ); $url_html = Url::getCommon( - array( + [ 'username' => $username, 'hostname' => $hostname, 'dbname' => $dbname, 'tablename' => $tablename, 'routinename' => '', - ) + ] ); $this->assertContains( $url_html, @@ -1744,14 +1744,14 @@ class PrivilegesTest extends TestCase ); $url_html = Url::getCommon( - array( + [ 'username' => $username, 'hostname' => $hostname, 'dbname' => $dbname, 'tablename' => $tablename, 'routinename' => '', 'revokeall' => 1, - ) + ] ); $this->assertContains( $url_html, @@ -1765,12 +1765,12 @@ class PrivilegesTest extends TestCase $html = $this->serverPrivileges->getUserLink('export', $username, $hostname); $url_html = Url::getCommon( - array( + [ 'username' => $username, 'hostname' => $hostname, 'initial' => "", 'export' => 1, - ) + ] ); $this->assertContains( $url_html, @@ -1866,10 +1866,10 @@ class PrivilegesTest extends TestCase $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $fields_info = array( - array('COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80), - array('COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40), - ); + $fields_info = [ + ['COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80], + ['COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($fields_info)); @@ -1981,10 +1981,10 @@ class PrivilegesTest extends TestCase $html ); $item = Url::getCommon( - array( + [ 'db' => $url_dbname, 'reload' => 1 - ) + ] ); $this->assertContains( $item, @@ -2007,11 +2007,11 @@ class PrivilegesTest extends TestCase $html ); $item = Url::getCommon( - array( + [ 'db' => $url_dbname, 'table' => $tablename, 'reload' => 1, - ) + ] ); $this->assertContains( $item, @@ -2037,8 +2037,8 @@ class PrivilegesTest extends TestCase */ public function testGetUsersOverview() { - $result = array(); - $db_rights = array(); + $result = []; + $db_rights = []; $pmaThemeImage = "pmaThemeImage"; $text_dir = "text_dir"; $GLOBALS['cfgRelation']['menuswork'] = true; @@ -2118,8 +2118,8 @@ class PrivilegesTest extends TestCase */ public function testGetFieldsetForAddDeleteUser() { - $result = array(); - $db_rights = array(); + $result = []; + $db_rights = []; $pmaThemeImage = "pmaThemeImage"; $text_dir = "text_dir"; $GLOBALS['cfgRelation']['menuswork'] = true; @@ -2130,7 +2130,7 @@ class PrivilegesTest extends TestCase //Url::getCommon $this->assertContains( - Url::getCommon(array('adduser' => 1)), + Url::getCommon(['adduser' => 1]), $html ); @@ -2163,7 +2163,7 @@ class PrivilegesTest extends TestCase $_REQUEST['change_copy'] = "change_copy"; $_REQUEST['old_hostname'] = "old_hostname"; $_REQUEST['old_username'] = "old_username"; - $_SESSION['relation'][1] = array( + $_SESSION['relation'][1] = [ 'PMA_VERSION' => PMA_VERSION, 'bookmarkwork' => false, 'historywork' => false, @@ -2175,16 +2175,16 @@ class PrivilegesTest extends TestCase 'navwork' => false, 'savedsearcheswork' => false, 'designersettingswork' => false, - ); + ]; - $queries = array(); + $queries = []; $ret = $this->serverPrivileges->getDataForDeleteUsers($queries); - $item = array( + $item = [ "# Deleting 'old_username'@'old_hostname' ...", "DROP USER 'old_username'@'old_hostname';", - ); + ]; $this->assertEquals( $item, $ret @@ -2201,7 +2201,7 @@ class PrivilegesTest extends TestCase $html = $this->serverPrivileges->getAddUserHtmlFieldset(); $this->assertContains( - Url::getCommon(array('adduser' => 1)), + Url::getCommon(['adduser' => 1]), $html ); $this->assertContains( @@ -2246,12 +2246,12 @@ class PrivilegesTest extends TestCase //Url::getCommon $item = Url::getCommon( - array( + [ 'username' => $username, 'hostname' => $hostname, 'dbname' => '', 'tablename' => '', - ) + ] ); $this->assertContains( $item, @@ -2282,12 +2282,12 @@ class PrivilegesTest extends TestCase //Url::getCommon $item = Url::getCommon( - array( + [ 'username' => $username, 'hostname' => $hostname, 'dbname' => $url_dbname, 'tablename' => '', - ) + ] ); $this->assertContains( $item, @@ -2381,7 +2381,7 @@ class PrivilegesTest extends TestCase // Test case 2 $GLOBALS['dblist'] = new \stdClass(); - $GLOBALS['dblist']->databases = array('x', 'y', 'z'); + $GLOBALS['dblist']->databases = ['x', 'y', 'z']; $actual = $this->serverPrivileges->getHtmlForAllTableSpecificRights('pma2', 'host2', 'database', ''); $this->assertContains( '<legend data-submenu-label="Database">', @@ -2402,8 +2402,8 @@ class PrivilegesTest extends TestCase { // Setup for the test $GLOBALS['dbi']->expects($this->any())->method('fetchRow') - ->will($this->onConsecutiveCalls(array('-'))); - $actual = $this->serverPrivileges->getHtmlForInitials(array('"' => true)); + ->will($this->onConsecutiveCalls(['-'])); + $actual = $this->serverPrivileges->getHtmlForInitials(['"' => true]); $this->assertContains('<td>A</td>', $actual); $this->assertContains('<td>Z</td>', $actual); $this->assertContains( @@ -2432,15 +2432,15 @@ class PrivilegesTest extends TestCase ->getMock(); $dbi->expects($this->any()) ->method('fetchResult') - ->will($this->returnValue(array('db', 'columns_priv'))); + ->will($this->returnValue(['db', 'columns_priv'])); $dbi->expects($this->any()) ->method('fetchAssoc') ->will( $this->onConsecutiveCalls( - array( + [ 'User' => 'pmauser', 'Host' => 'local' - ) + ] ) ); $dbi->expects($this->any()) @@ -2450,17 +2450,17 @@ class PrivilegesTest extends TestCase $_GET['initial'] = 'A'; $GLOBALS['dbi'] = $dbi; - $expected = array( - 'pmauser' => array( - 'local' => array( + $expected = [ + 'pmauser' => [ + 'local' => [ 'User' => 'pmauser', 'Host' => 'local', 'Password' => '?', 'Grant_priv' => 'N', - 'privs' => array('USAGE') - ) - ) - ); + 'privs' => ['USAGE'] + ] + ] + ]; $actual = $this->serverPrivileges->getDbRightsForUserOverview(); $this->assertEquals($expected, $actual); } @@ -2482,16 +2482,16 @@ class PrivilegesTest extends TestCase ->method('query') ->will($this->onConsecutiveCalls(true, true)); - $plugins = array( - array( + $plugins = [ + [ 'PLUGIN_NAME'=>'mysql_native_password', 'PLUGIN_DESCRIPTION' => 'Native MySQL authentication' - ), - array( + ], + [ 'PLUGIN_NAME' => 'sha256_password', 'PLUGIN_DESCRIPTION' => 'SHA256 password authentication' - ) - ); + ] + ]; $dbi->expects($this->any()) ->method('fetchAssoc') ->will( @@ -2599,7 +2599,7 @@ class PrivilegesTest extends TestCase $GLOBALS['dbi'] = $dbi; // Test case 1 : empty queries - $queries = array(); + $queries = []; $actual = $this->serverPrivileges->deleteUser($queries); $this->assertArrayHasKey(0, $actual); $this->assertArrayHasKey(1, $actual); @@ -2610,7 +2610,7 @@ class PrivilegesTest extends TestCase // Test case 2 : all successful queries $_REQUEST['mode'] = 3; - $queries = array('foo'); + $queries = ['foo']; $actual = $this->serverPrivileges->deleteUser($queries); $this->assertArrayHasKey(0, $actual); $this->assertArrayHasKey(1, $actual); @@ -2625,7 +2625,7 @@ class PrivilegesTest extends TestCase // Test case 3 : failing queries $_REQUEST['mode'] = 1; - $queries = array('bar'); + $queries = ['bar']; $actual = $this->serverPrivileges->deleteUser($queries); $this->assertArrayHasKey(0, $actual); $this->assertArrayHasKey(1, $actual); diff --git a/test/classes/Server/SelectTest.php b/test/classes/Server/SelectTest.php index fe45a42160..b3723d9406 100644 --- a/test/classes/Server/SelectTest.php +++ b/test/classes/Server/SelectTest.php @@ -39,7 +39,7 @@ class SelectTest extends TestCase $GLOBALS['server'] = 1; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; @@ -62,22 +62,22 @@ class SelectTest extends TestCase $GLOBALS['cfg']['DefaultTabServer'] = "welcome"; - $GLOBALS['cfg']['Servers'] = array( - '0' => array( + $GLOBALS['cfg']['Servers'] = [ + '0' => [ 'host'=>'host0', 'port'=>'port0', 'only_db'=>'only_db0', 'user'=>'user0', 'auth_type'=>'config', - ), - '1' => array( + ], + '1' => [ 'host'=>'host1', 'port'=>'port1', 'only_db'=>'only_db1', 'user'=>'user1', 'auth_type'=>'config', - ), - ); + ], + ]; //$not_only_options=false & $omit_fieldset=false $html = Select::render($not_only_options, $omit_fieldset); diff --git a/test/classes/Server/Status/AdvisorTest.php b/test/classes/Server/Status/AdvisorTest.php index 0f22acda3d..d54bc3a478 100644 --- a/test/classes/Server/Status/AdvisorTest.php +++ b/test/classes/Server/Status/AdvisorTest.php @@ -47,7 +47,7 @@ class AdvisorTest extends TestCase $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; @@ -70,40 +70,40 @@ class AdvisorTest extends TestCase ->getMock(); //this data is needed when PhpMyAdmin\Server\Status\Data constructs - $server_status = array( + $server_status = [ "Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => "0", - ); + ]; - $server_variables= array( + $server_variables= [ "auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", - ); + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW GLOBAL STATUS", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_status - ), - array( + ], + [ "SHOW GLOBAL VARIABLES", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_variables - ), - array( + ], + [ "SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, @@ -111,8 +111,8 @@ class AdvisorTest extends TestCase DatabaseInterface::CONNECT_USER, 0, $server_status - ), - ); + ], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); diff --git a/test/classes/Server/Status/DataTest.php b/test/classes/Server/Status/DataTest.php index c005b7ec27..f35c31a928 100644 --- a/test/classes/Server/Status/DataTest.php +++ b/test/classes/Server/Status/DataTest.php @@ -37,7 +37,7 @@ class DataTest extends PmaTestCase $GLOBALS['cfg']['Server']['host'] = "::1"; $GLOBALS['replication_info']['master']['status'] = true; $GLOBALS['replication_info']['slave']['status'] = true; - $GLOBALS['replication_types'] = array(); + $GLOBALS['replication_types'] = []; //Mock DBI $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') @@ -45,7 +45,7 @@ class DataTest extends PmaTestCase ->getMock(); //this data is needed when PhpMyAdmin\Server\Status\Data constructs - $server_status = array( + $server_status = [ "Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", @@ -58,35 +58,35 @@ class DataTest extends PmaTestCase "Key_read_requests" => 1, "Threads_created" => true, "Connections" => 2, - ); + ]; - $server_variables= array( + $server_variables= [ "auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", "key_buffer_size" => 10, - ); + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW GLOBAL STATUS", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_status - ), - array( + ], + [ "SHOW GLOBAL VARIABLES", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_variables - ), - array( + ], + [ "SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, @@ -94,8 +94,8 @@ class DataTest extends PmaTestCase DatabaseInterface::CONNECT_USER, 0, $server_status - ), - ); + ], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); diff --git a/test/classes/Server/Status/MonitorTest.php b/test/classes/Server/Status/MonitorTest.php index 6ca0444ee4..097b9d10a2 100644 --- a/test/classes/Server/Status/MonitorTest.php +++ b/test/classes/Server/Status/MonitorTest.php @@ -48,7 +48,7 @@ class MonitorTest extends TestCase $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['Server']['host'] = "localhost"; @@ -68,40 +68,40 @@ class MonitorTest extends TestCase ->getMock(); //this data is needed when PhpMyAdmin\Server\Status\Data constructs - $server_status = array( + $server_status = [ "Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => "0", - ); + ]; - $server_variables = array( + $server_variables = [ "auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", - ); + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW GLOBAL STATUS", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_status - ), - array( + ], + [ "SHOW GLOBAL VARIABLES", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_variables - ), - array( + ], + [ "SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, @@ -109,8 +109,8 @@ class MonitorTest extends TestCase DatabaseInterface::CONNECT_USER, 0, $server_status - ), - ); + ], + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); @@ -238,15 +238,15 @@ class MonitorTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $value = array( + $value = [ 'sql_text' => 'insert sql_text', '#' => 11, - ); + ]; - $value2 = array( + $value2 = [ 'sql_text' => 'update sql_text', '#' => 10, - ); + ]; $dbi->expects($this->at(1))->method('fetchAssoc') ->will($this->returnValue($value)); @@ -262,11 +262,11 @@ class MonitorTest extends TestCase $end = 10; $ret = $this->statusMonitor->getJsonForLogDataTypeSlow($start, $end); - $result_rows = array( - array('sql_text' => 'insert sql_text', '#' => 11), - array('sql_text' => 'update sql_text', '#' => 10) - ); - $result_sum = array('insert' =>11, 'TOTAL' =>21, 'update' => 10); + $result_rows = [ + ['sql_text' => 'insert sql_text', '#' => 11], + ['sql_text' => 'update sql_text', '#' => 10] + ]; + $result_sum = ['insert' =>11, 'TOTAL' =>21, 'update' => 10]; $this->assertEquals( 2, $ret['numRows'] @@ -295,17 +295,17 @@ class MonitorTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $value = array( + $value = [ 'sql_text' => 'insert sql_text', '#' => 10, 'argument' => 'argument argument2', - ); + ]; - $value2 = array( + $value2 = [ 'sql_text' => 'update sql_text', '#' => 11, 'argument' => 'argument3 argument4', - ); + ]; $dbi->expects($this->at(1))->method('fetchAssoc') ->will($this->returnValue($value)); @@ -321,11 +321,11 @@ class MonitorTest extends TestCase $end = 10; $ret = $this->statusMonitor->getJsonForLogDataTypeGeneral($start, $end); - $result_rows = array( + $result_rows = [ $value, $value2, - ); - $result_sum = array('argument' =>10, 'TOTAL' =>21, 'argument3' => 11); + ]; + $result_sum = ['argument' =>10, 'TOTAL' =>21, 'argument3' => 11]; $this->assertEquals( 2, @@ -355,11 +355,11 @@ class MonitorTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $value = array( + $value = [ 'sql_text' => 'insert sql_text', '#' => 22, 'argument' => 'argument argument2', - ); + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($value)); @@ -394,11 +394,11 @@ class MonitorTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $value = array( + $value = [ 'sql_text' => 'insert sql_text', '#' => 33, 'argument' => 'argument argument2', - ); + ]; $dbi->expects($this->at(4))->method('fetchAssoc') ->will($this->returnValue($value)); @@ -415,11 +415,11 @@ class MonitorTest extends TestCase $ret['affectedRows'] ); $this->assertEquals( - array(), + [], $ret['profiling'] ); $this->assertEquals( - array($value), + [$value], $ret['explain'] ); } diff --git a/test/classes/Server/Status/ProcessesTest.php b/test/classes/Server/Status/ProcessesTest.php index 065bf9b806..ba65bbc4ca 100644 --- a/test/classes/Server/Status/ProcessesTest.php +++ b/test/classes/Server/Status/ProcessesTest.php @@ -35,7 +35,7 @@ class ProcessesTest extends TestCase $GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); $GLOBALS['replication_info']['master']['status'] = true; $GLOBALS['replication_info']['slave']['status'] = false; - $GLOBALS['replication_types'] = array(); + $GLOBALS['replication_types'] = []; $GLOBALS['pmaThemeImage'] = 'image'; @@ -100,7 +100,7 @@ class ProcessesTest extends TestCase */ public function testPMAGetHtmlForServerProcessList() { - $process = array( + $process = [ "User" => "User1", "Host" => "Host1", "Id" => "Id1", @@ -109,7 +109,7 @@ class ProcessesTest extends TestCase "Info" => "Info1", "State" => "State1", "Time" => "Time1" - ); + ]; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 12; $GLOBALS['dbi']->expects($this->any())->method('fetchAssoc') ->will($this->onConsecutiveCalls($process)); @@ -177,7 +177,7 @@ class ProcessesTest extends TestCase public function testPMAGetHtmlForServerProcessItem() { //parameters - $process = array( + $process = [ "user" => "User1", "host" => "Host1", "id" => "Id1", @@ -186,7 +186,7 @@ class ProcessesTest extends TestCase "info" => "Info1", "state" => "State1", "time" => "Time1", - ); + ]; $show_full_sql = true; $_REQUEST['sort_order'] = "desc"; @@ -197,10 +197,10 @@ class ProcessesTest extends TestCase $html = Processes::getHtmlForServerProcessItem($process, $show_full_sql); //validate 1: $kill_process - $url_params = array( + $url_params = [ 'kill' => $process['id'], 'ajax_request' => true - ); + ]; $kill_process = 'server_status_processes.php' . Url::getCommon($url_params); $this->assertContains( diff --git a/test/classes/Server/Status/QueriesTest.php b/test/classes/Server/Status/QueriesTest.php index 41f47117ed..9068023a3c 100644 --- a/test/classes/Server/Status/QueriesTest.php +++ b/test/classes/Server/Status/QueriesTest.php @@ -44,7 +44,7 @@ class QueriesTest extends TestCase $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; @@ -65,40 +65,40 @@ class QueriesTest extends TestCase ->getMock(); //this data is needed when PhpMyAdmin\Server\Status\Data constructs - $server_status = array( + $server_status = [ "Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => "0", - ); + ]; - $server_variables= array( + $server_variables= [ "auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", - ); + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW GLOBAL STATUS", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_status - ), - array( + ], + [ "SHOW GLOBAL VARIABLES", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_variables - ) - ); + ] + ]; $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); @@ -106,14 +106,14 @@ class QueriesTest extends TestCase $GLOBALS['dbi'] = $dbi; $this->serverStatusData = new Data(); $this->serverStatusData->status['Uptime'] = 36000; - $this->serverStatusData->used_queries = array( + $this->serverStatusData->used_queries = [ "Com_change_db" => "15", "Com_select" => "12", "Com_set_option" => "54", "Com_show_databases" => "16", "Com_show_status" => "14", "Com_show_tables" => "13", - ); + ]; } /** diff --git a/test/classes/Server/Status/VariablesTest.php b/test/classes/Server/Status/VariablesTest.php index 29080f0793..bedb7984f5 100644 --- a/test/classes/Server/Status/VariablesTest.php +++ b/test/classes/Server/Status/VariablesTest.php @@ -45,7 +45,7 @@ class VariablesTest extends TestCase $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; - $GLOBALS['cfg']['SQP'] = array(); + $GLOBALS['cfg']['SQP'] = []; $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; @@ -66,40 +66,40 @@ class VariablesTest extends TestCase ->getMock(); //this data is needed when PhpMyAdmin\Server\Status\Data constructs - $server_status = array( + $server_status = [ "Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => "0", - ); + ]; - $server_variables= array( + $server_variables= [ "auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", - ); + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW GLOBAL STATUS", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_status - ), - array( + ], + [ "SHOW GLOBAL VARIABLES", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_variables - ), - array( + ], + [ "SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, @@ -107,8 +107,8 @@ class VariablesTest extends TestCase DatabaseInterface::CONNECT_USER, 0, $server_status - ), - ); + ], + ]; $dbi->expects($this->at(0)) ->method('tryQuery') @@ -117,19 +117,19 @@ class VariablesTest extends TestCase $dbi->expects($this->at(1)) ->method('fetchRow') - ->will($this->returnValue(array("Aborted_clients", "0"))); + ->will($this->returnValue(["Aborted_clients", "0"])); $dbi->expects($this->at(2)) ->method('fetchRow') - ->will($this->returnValue(array("Aborted_connects", "0"))); + ->will($this->returnValue(["Aborted_connects", "0"])); $dbi->expects($this->at(3)) ->method('fetchRow') - ->will($this->returnValue(array("Com_delete_multi", "0"))); + ->will($this->returnValue(["Com_delete_multi", "0"])); $dbi->expects($this->at(4)) ->method('fetchRow') - ->will($this->returnValue(array("Com_create_function", "0"))); + ->will($this->returnValue(["Com_create_function", "0"])); $dbi->expects($this->at(5)) ->method('fetchRow') - ->will($this->returnValue(array("Com_empty_query", "0"))); + ->will($this->returnValue(["Com_empty_query", "0"])); $dbi->expects($this->at(6)) ->method('fetchRow') ->will($this->returnValue(false)); diff --git a/test/classes/Server/StatusTest.php b/test/classes/Server/StatusTest.php index 743dbc6186..2ecaa6d511 100644 --- a/test/classes/Server/StatusTest.php +++ b/test/classes/Server/StatusTest.php @@ -45,7 +45,7 @@ class StatusTest extends TestCase $GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); $GLOBALS['replication_info']['master']['status'] = true; $GLOBALS['replication_info']['slave']['status'] = false; - $GLOBALS['replication_types'] = array(); + $GLOBALS['replication_types'] = []; $GLOBALS['table'] = "table"; @@ -57,7 +57,7 @@ class StatusTest extends TestCase ->getMock(); //this data is needed when PhpMyAdmin\Server\Status\Data constructs - $server_status = array( + $server_status = [ "Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", @@ -65,34 +65,34 @@ class StatusTest extends TestCase "Com_empty_query" => "0", "Com_execute_sql" => 2, "Com_stmt_execute" => 2, - ); + ]; - $server_variables= array( + $server_variables= [ "auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", - ); + ]; - $fetchResult = array( - array( + $fetchResult = [ + [ "SHOW GLOBAL STATUS", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_status - ), - array( + ], + [ "SHOW GLOBAL VARIABLES", 0, 1, DatabaseInterface::CONNECT_USER, 0, $server_variables - ), - array( + ], + [ "SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, @@ -100,8 +100,8 @@ class StatusTest extends TestCase DatabaseInterface::CONNECT_USER, 0, $server_status - ), - ); + ], + ]; $dbi->expects($this->at(0)) ->method('tryQuery') @@ -110,19 +110,19 @@ class StatusTest extends TestCase $dbi->expects($this->at(1)) ->method('fetchRow') - ->will($this->returnValue(array("Aborted_clients", "0"))); + ->will($this->returnValue(["Aborted_clients", "0"])); $dbi->expects($this->at(2)) ->method('fetchRow') - ->will($this->returnValue(array("Aborted_connects", "0"))); + ->will($this->returnValue(["Aborted_connects", "0"])); $dbi->expects($this->at(3)) ->method('fetchRow') - ->will($this->returnValue(array("Com_delete_multi", "0"))); + ->will($this->returnValue(["Com_delete_multi", "0"])); $dbi->expects($this->at(4)) ->method('fetchRow') - ->will($this->returnValue(array("Com_create_function", "0"))); + ->will($this->returnValue(["Com_create_function", "0"])); $dbi->expects($this->at(5)) ->method('fetchRow') - ->will($this->returnValue(array("Com_empty_query", "0"))); + ->will($this->returnValue(["Com_empty_query", "0"])); $dbi->expects($this->at(6)) ->method('fetchRow') ->will($this->returnValue(false)); diff --git a/test/classes/Server/UserGroupsTest.php b/test/classes/Server/UserGroupsTest.php index 9e2501b720..f161d8233e 100644 --- a/test/classes/Server/UserGroupsTest.php +++ b/test/classes/Server/UserGroupsTest.php @@ -32,12 +32,12 @@ class UserGroupsTest extends TestCase $GLOBALS['cfg']['ActionLinksMode'] = 'both'; $GLOBALS['server'] = 1; - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'db' => 'pmadb', 'users' => 'users', 'usergroups' => 'usergroups' - ); + ]; } @@ -73,7 +73,7 @@ class UserGroupsTest extends TestCase $html ); $url_tag = '<a href="server_user_groups.php' - . Url::getCommon(array('addUserGroup' => 1)); + . Url::getCommon(['addUserGroup' => 1]); $this->assertContains( $url_tag, $html @@ -106,11 +106,11 @@ class UserGroupsTest extends TestCase ->withAnyParameters() ->will( $this->returnValue( - array( + [ 'usergroup' => 'usergroup', 'tab' => 'server_sql', 'allowed' => 'Y' - ) + ] ) ); $dbi->expects($this->at(3)) @@ -128,9 +128,9 @@ class UserGroupsTest extends TestCase ); $url_tag = '<a class="" href="server_user_groups.php' . Url::getCommon( - array( + [ 'viewUsers'=>1, 'userGroup'=>htmlspecialchars('usergroup') - ) + ] ); $this->assertContains( $url_tag, @@ -138,10 +138,10 @@ class UserGroupsTest extends TestCase ); $url_tag = '<a class="" href="server_user_groups.php' . Url::getCommon( - array( + [ 'editUserGroup'=>1, 'userGroup'=>htmlspecialchars('usergroup') - ) + ] ); $this->assertContains( $url_tag, @@ -149,10 +149,10 @@ class UserGroupsTest extends TestCase ); $url_tag = '<a class="deleteUserGroup ajax" href="server_user_groups.php' . Url::getCommon( - array( + [ 'deleteUserGroup'=> 1, 'userGroup'=>htmlspecialchars('usergroup') - ) + ] ); $this->assertContains( $url_tag, @@ -220,11 +220,11 @@ class UserGroupsTest extends TestCase $dbi->expects($this->exactly(2)) ->method('fetchAssoc') ->willReturnOnConsecutiveCalls( - array( + [ 'usergroup' => 'ug', 'tab' => 'server_sql', 'allowed' => 'Y' - ), + ], false ); $dbi->expects($this->once()) diff --git a/test/classes/Setup/ConfigGeneratorTest.php b/test/classes/Setup/ConfigGeneratorTest.php index 89f146ffa1..4d093795a9 100644 --- a/test/classes/Setup/ConfigGeneratorTest.php +++ b/test/classes/Setup/ConfigGeneratorTest.php @@ -35,12 +35,12 @@ class ConfigGeneratorTest extends PmaTestCase $GLOBALS['server'] = 0; $cf = new ConfigFile(); - $_SESSION['ConfigFile0'] = array('a', 'b', 'c'); - $_SESSION['ConfigFile0']['Servers'] = array( - array(1, 2, 3) - ); + $_SESSION['ConfigFile0'] = ['a', 'b', 'c']; + $_SESSION['ConfigFile0']['Servers'] = [ + [1, 2, 3] + ]; - $cf->setPersistKeys(array("1/", 2)); + $cf->setPersistKeys(["1/", 2]); $result = ConfigGenerator::getConfigFile($cf); @@ -90,7 +90,7 @@ class ConfigGeneratorTest extends PmaTestCase $this->assertEquals( '$cfg[\'var_name\'] = array (' . "\n);\n", - $method->invoke(null, 'var_name', array(), "\n") + $method->invoke(null, 'var_name', [], "\n") ); $this->assertEquals( @@ -98,7 +98,7 @@ class ConfigGeneratorTest extends PmaTestCase $method->invoke( null, 'var_name', - array(1, 2, 3), + [1, 2, 3], "\n" ) ); @@ -109,10 +109,10 @@ class ConfigGeneratorTest extends PmaTestCase $method->invoke( null, 'var_name', - array( + [ '1a' => 'foo', 'b' => 'bar' - ), + ], "\n" ) ); @@ -132,35 +132,35 @@ class ConfigGeneratorTest extends PmaTestCase $this->assertFalse( $method->invoke( null, - array( + [ 'a' => 1, 'b' => 2 - ) + ] ) ); $this->assertFalse( $method->invoke( null, - array( + [ 0 => 1, 1 => 2, 3 => 3, - ) + ] ) ); $this->assertTrue( $method->invoke( null, - array() + [] ) ); $this->assertTrue( $method->invoke( null, - array(1, 2, 3) + [1, 2, 3] ) ); } @@ -176,7 +176,7 @@ class ConfigGeneratorTest extends PmaTestCase $method = $reflection->getMethod('_exportZeroBasedArray'); $method->setAccessible(true); - $arr = array(1, 2, 3, 4); + $arr = [1, 2, 3, 4]; $result = $method->invoke(null, $arr, "\n"); @@ -185,7 +185,7 @@ class ConfigGeneratorTest extends PmaTestCase $result ); - $arr = array(1, 2, 3, 4, 7, 'foo'); + $arr = [1, 2, 3, 4, 7, 'foo']; $result = $method->invoke(null, $arr, "\n"); diff --git a/test/classes/Setup/FormProcessingTest.php b/test/classes/Setup/FormProcessingTest.php index f174571c40..1bded929bd 100644 --- a/test/classes/Setup/FormProcessingTest.php +++ b/test/classes/Setup/FormProcessingTest.php @@ -41,17 +41,17 @@ class FormProcessingTest extends PmaTestCase public function testProcessFormSet() { $this->mockResponse( - array( - array('status: 303 See Other'), - array('Location: index.php?lang=en'), + [ + ['status: 303 See Other'], + ['Location: index.php?lang=en'], 303 - ) + ] ); // case 1 $formDisplay = $this->getMockBuilder('PhpMyAdmin\Config\FormDisplay') ->disableOriginalConstructor() - ->setMethods(array('process', 'getDisplay')) + ->setMethods(['process', 'getDisplay']) ->getMock(); $formDisplay->expects($this->once()) @@ -68,7 +68,7 @@ class FormProcessingTest extends PmaTestCase // case 2 $formDisplay = $this->getMockBuilder('PhpMyAdmin\Config\FormDisplay') ->disableOriginalConstructor() - ->setMethods(array('process', 'hasErrors', 'displayErrors')) + ->setMethods(['process', 'hasErrors', 'displayErrors']) ->getMock(); $formDisplay->expects($this->once()) @@ -108,7 +108,7 @@ class FormProcessingTest extends PmaTestCase // case 3 $formDisplay = $this->getMockBuilder('PhpMyAdmin\Config\FormDisplay') ->disableOriginalConstructor() - ->setMethods(array('process', 'hasErrors')) + ->setMethods(['process', 'hasErrors']) ->getMock(); $formDisplay->expects($this->once()) diff --git a/test/classes/Setup/IndexTest.php b/test/classes/Setup/IndexTest.php index 44f2182a59..e51089a39b 100644 --- a/test/classes/Setup/IndexTest.php +++ b/test/classes/Setup/IndexTest.php @@ -36,30 +36,30 @@ class IndexTest extends TestCase */ public function testPMAmessagesBegin() { - $_SESSION['messages'] = array( - array( - array('foo'), - array('bar') - ) - ); + $_SESSION['messages'] = [ + [ + ['foo'], + ['bar'] + ] + ]; SetupIndex::messagesBegin(); $this->assertEquals( - array( - array( - array( + [ + [ + [ 0 => 'foo', 'fresh' => false, 'active' => false - ), - array( + ], + [ 0 => 'bar', 'fresh' => false, 'active' => false - ) - ) - ), + ] + ] + ], $_SESSION['messages'] ); @@ -68,10 +68,10 @@ class IndexTest extends TestCase unset($_SESSION['messages']); SetupIndex::messagesBegin(); $this->assertEquals( - array( - 'error' => array(), - 'notice' => array() - ), + [ + 'error' => [], + 'notice' => [] + ], $_SESSION['messages'] ); } @@ -86,12 +86,12 @@ class IndexTest extends TestCase SetupIndex::messagesSet('type', '123', 'testTitle', 'msg'); $this->assertEquals( - array( + [ 'fresh' => true, 'active' => true, 'title' => 'testTitle', 'message' => 'msg' - ), + ], $_SESSION['messages']['type']['123'] ); } @@ -103,24 +103,24 @@ class IndexTest extends TestCase */ public function testPMAmessagesEnd() { - $_SESSION['messages'] = array( - array( - array('msg' => 'foo', 'active' => false), - array('msg' => 'bar', 'active' => true), - ) - ); + $_SESSION['messages'] = [ + [ + ['msg' => 'foo', 'active' => false], + ['msg' => 'bar', 'active' => true], + ] + ]; SetupIndex::messagesEnd(); $this->assertEquals( - array( - array( - '1' => array( + [ + [ + '1' => [ 'msg' => 'bar', 'active' => 1 - ) - ) - ), + ] + ] + ], $_SESSION['messages'] ); } @@ -132,12 +132,12 @@ class IndexTest extends TestCase */ public function testPMAMessagesShowHTML() { - $_SESSION['messages'] = array( - 'type' => array( - array('title' => 'foo', 'message' => '123', 'fresh' => false), - array('title' => 'bar', 'message' => '321', 'fresh' => true), - ) - ); + $_SESSION['messages'] = [ + 'type' => [ + ['title' => 'foo', 'message' => '123', 'fresh' => false], + ['title' => 'bar', 'message' => '321', 'fresh' => true], + ] + ]; ob_start(); SetupIndex::messagesShowHtml(); diff --git a/test/classes/SqlQueryFormTest.php b/test/classes/SqlQueryFormTest.php index 27d57c20fa..9867d434c7 100644 --- a/test/classes/SqlQueryFormTest.php +++ b/test/classes/SqlQueryFormTest.php @@ -65,7 +65,7 @@ class SqlQueryFormTest extends TestCase $GLOBALS['cfg']['DefaultForeignKeyChecks'] = 'default'; //_SESSION - $_SESSION['relation'][0] = array( + $_SESSION['relation'][0] = [ 'PMA_VERSION' => PMA_VERSION, 'table_coords' => "table_name", 'displaywork' => 'displaywork', @@ -74,7 +74,7 @@ class SqlQueryFormTest extends TestCase 'relwork' => 'relwork', 'relation' => 'relation', 'bookmarkwork' => false, - ); + ]; //$GLOBALS $GLOBALS['cfg']['Server']['user'] = "user"; $GLOBALS['cfg']['Server']['pmadb'] = "pmadb"; @@ -87,17 +87,17 @@ class SqlQueryFormTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $fetchResult = array("index1"=>"table1", "index2"=>"table2"); + $fetchResult = ["index1"=>"table1", "index2"=>"table2"]; $dbi->expects($this->any()) ->method('fetchResult') ->will($this->returnValue($fetchResult)); - $getColumns = array( - array( + $getColumns = [ + [ "Field" => "field1", "Comment" => "Comment1" - ) - ); + ] + ]; $dbi->expects($this->any()) ->method('getColumns') ->will($this->returnValue($getColumns)); diff --git a/test/classes/SqlTest.php b/test/classes/SqlTest.php index 72c3865603..a971b35afa 100644 --- a/test/classes/SqlTest.php +++ b/test/classes/SqlTest.php @@ -258,18 +258,18 @@ class SqlTest extends TestCase $col3 = new stdClass; $col3->table = 'table3'; - $fields_meta = array($col1, $col2, $col3); + $fields_meta = [$col1, $col2, $col3]; $this->assertFalse( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) ); // should not matter on where the odd column occurs - $fields_meta = array($col2, $col3, $col1); + $fields_meta = [$col2, $col3, $col1]; $this->assertFalse( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) ); - $fields_meta = array($col3, $col1, $col2); + $fields_meta = [$col3, $col1, $col2]; $this->assertFalse( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) ); @@ -288,7 +288,7 @@ class SqlTest extends TestCase $col2->table = 'table1'; $col3 = new stdClass; $col3->table = 'table1'; - $fields_meta = array($col1, $col2, $col3); + $fields_meta = [$col1, $col2, $col3]; $this->assertTrue( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) @@ -310,18 +310,18 @@ class SqlTest extends TestCase $col3 = new stdClass; $col3->table = 'table1'; - $fields_meta = array($col1, $col2, $col3); + $fields_meta = [$col1, $col2, $col3]; $this->assertTrue( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) ); // should not matter on where the function column occurs - $fields_meta = array($col2, $col3, $col1); + $fields_meta = [$col2, $col3, $col1]; $this->assertTrue( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) ); - $fields_meta = array($col3, $col1, $col2); + $fields_meta = [$col3, $col1, $col2]; $this->assertTrue( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) ); @@ -341,7 +341,7 @@ class SqlTest extends TestCase $col2->table = ''; $col3 = new stdClass; $col3->table = ''; - $fields_meta = array($col1, $col2, $col3); + $fields_meta = [$col1, $col2, $col3]; $this->assertFalse( $this->callProtectedMethod('resultSetHasJustOneTable', [$fields_meta]) diff --git a/test/classes/StorageEngineTest.php b/test/classes/StorageEngineTest.php index 21420a2310..5afa44f1f1 100644 --- a/test/classes/StorageEngineTest.php +++ b/test/classes/StorageEngineTest.php @@ -34,7 +34,7 @@ class StorageEngineTest extends PmaTestCase { $GLOBALS['server'] = 1; $this->object = $this->getMockForAbstractClass( - 'PhpMyAdmin\StorageEngine', array('dummy') + 'PhpMyAdmin\StorageEngine', ['dummy'] ); } @@ -59,23 +59,23 @@ class StorageEngineTest extends PmaTestCase { $this->assertEquals( - array( - 'dummy' => array( + [ + 'dummy' => [ 'Engine' => 'dummy', 'Support' => 'YES', 'Comment' => 'dummy comment', - ), - 'dummy2' => array( + ], + 'dummy2' => [ 'Engine' => 'dummy2', 'Support' => 'NO', 'Comment' => 'dummy2 comment', - ), - 'FEDERATED' => array( + ], + 'FEDERATED' => [ 'Engine' => 'FEDERATED', 'Support' => 'NO', 'Comment' => 'Federated MySQL storage engine' - ), - ), + ], + ], $this->object->getStorageEngines() ); } @@ -121,21 +121,21 @@ class StorageEngineTest extends PmaTestCase */ public function providerGetEngine() { - return array( - array('PhpMyAdmin\StorageEngine', 'unknown engine'), - array('PhpMyAdmin\Engines\Bdb', 'Bdb'), - array('PhpMyAdmin\Engines\Berkeleydb', 'Berkeleydb'), - array('PhpMyAdmin\Engines\Binlog', 'Binlog'), - array('PhpMyAdmin\Engines\Innobase', 'Innobase'), - array('PhpMyAdmin\Engines\Innodb', 'Innodb'), - array('PhpMyAdmin\Engines\Memory', 'Memory'), - array('PhpMyAdmin\Engines\Merge', 'Merge'), - array('PhpMyAdmin\Engines\MrgMyisam', 'Mrg_Myisam'), - array('PhpMyAdmin\Engines\Myisam', 'Myisam'), - array('PhpMyAdmin\Engines\Ndbcluster', 'Ndbcluster'), - array('PhpMyAdmin\Engines\Pbxt', 'Pbxt'), - array('PhpMyAdmin\Engines\PerformanceSchema', 'Performance_Schema'), - ); + return [ + ['PhpMyAdmin\StorageEngine', 'unknown engine'], + ['PhpMyAdmin\Engines\Bdb', 'Bdb'], + ['PhpMyAdmin\Engines\Berkeleydb', 'Berkeleydb'], + ['PhpMyAdmin\Engines\Binlog', 'Binlog'], + ['PhpMyAdmin\Engines\Innobase', 'Innobase'], + ['PhpMyAdmin\Engines\Innodb', 'Innodb'], + ['PhpMyAdmin\Engines\Memory', 'Memory'], + ['PhpMyAdmin\Engines\Merge', 'Merge'], + ['PhpMyAdmin\Engines\MrgMyisam', 'Mrg_Myisam'], + ['PhpMyAdmin\Engines\Myisam', 'Myisam'], + ['PhpMyAdmin\Engines\Ndbcluster', 'Ndbcluster'], + ['PhpMyAdmin\Engines\Pbxt', 'Pbxt'], + ['PhpMyAdmin\Engines\PerformanceSchema', 'Performance_Schema'], + ]; } /** @@ -183,7 +183,7 @@ class StorageEngineTest extends PmaTestCase { $this->assertEquals( - array(), + [], $this->object->getInfoPages() ); } @@ -225,7 +225,7 @@ class StorageEngineTest extends PmaTestCase { $this->assertEquals( - array(), + [], $this->object->getVariables() ); } @@ -298,10 +298,10 @@ class StorageEngineTest extends PmaTestCase { $this->assertEquals( - array( + [ 0 => 12, 1 => 'B' - ), + ], $this->object->resolveTypeSize(12) ); } diff --git a/test/classes/Stubs/Response.php b/test/classes/Stubs/Response.php index 82eff4906c..c1a51276e9 100644 --- a/test/classes/Stubs/Response.php +++ b/test/classes/Stubs/Response.php @@ -73,7 +73,7 @@ class Response { $this->_isSuccess = true; $this->htmlString = ''; - $this->json = array(); + $this->json = []; $this->_isAjax = false; $GLOBALS['lang'] = 'en'; @@ -189,7 +189,7 @@ class Response public function clear() { $this->_isSuccess = true; - $this->json = array(); + $this->json = []; $this->htmlString = ''; } diff --git a/test/classes/SysInfoTest.php b/test/classes/SysInfoTest.php index 7a60931a38..c7ddfb6e4c 100644 --- a/test/classes/SysInfoTest.php +++ b/test/classes/SysInfoTest.php @@ -44,12 +44,12 @@ class SysInfoTest extends TestCase */ public function sysInfoOsProvider() { - return array( - array('FreeBSD', 'Linux'), - array('Linux', 'Linux'), - array('Winnt', 'Winnt'), - array('SunOS', 'SunOS'), - ); + return [ + ['FreeBSD', 'Linux'], + ['Linux', 'Linux'], + ['Winnt', 'Winnt'], + ['SunOS', 'SunOS'], + ]; } /** diff --git a/test/classes/SystemDatabaseTest.php b/test/classes/SystemDatabaseTest.php index 082a9ee8fd..6c5d52244f 100644 --- a/test/classes/SystemDatabaseTest.php +++ b/test/classes/SystemDatabaseTest.php @@ -42,7 +42,7 @@ class SystemDatabaseTest extends PmaTestCase ->will($this->returnValue('executeResult2')); //_SESSION - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'table_coords' => "table_name", 'displaywork' => 'displaywork', @@ -53,20 +53,20 @@ class SystemDatabaseTest extends PmaTestCase 'pdfwork' => 'pdfwork', 'column_info' => 'column_info', 'relation' => 'relation', - ); + ]; $dbi->expects($this->any()) ->method('fetchAssoc') ->will( $this->returnValue( - array( + [ 'table_name' => "table_name", 'column_name' => "column_name", 'comment' => "comment", 'mimetype' => "mimetype", 'transformation' => "transformation", 'transformation_options' => "transformation_options", - ) + ] ) ); @@ -100,13 +100,13 @@ class SystemDatabaseTest extends PmaTestCase public function testPMAGetNewTransformationDataSql() { $db = "PMA_db"; - $pma_transformation_data = array(); - $column_map = array( - array( + $pma_transformation_data = []; + $column_map = [ + [ "table_name" => "table_name", "refering_column" => "column_name" - ) - ); + ] + ]; $view_name = "view_name"; $ret = $this->sysDb->getNewTransformationDataSql( diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index 58de980559..90b1d567df 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -93,125 +93,125 @@ class TableTest extends PmaTestCase $getUniqueColumns_sql = "select unique column"; - $fetchResult = array( - array( + $fetchResult = [ + [ $sql_isView_true, null, null, DatabaseInterface::CONNECT_USER, 0, true - ), - array( + ], + [ $sql_copy_data, null, null, DatabaseInterface::CONNECT_USER, 0, false - ), - array( + ], + [ $sql_isView_false, null, null, DatabaseInterface::CONNECT_USER, 0, false - ), - array( + ], + [ $sql_isUpdatableView_true, null, null, DatabaseInterface::CONNECT_USER, 0, true - ), - array( + ], + [ $sql_isUpdatableView_false, null, null, DatabaseInterface::CONNECT_USER, 0, false - ), - array( + ], + [ $sql_analyzeStructure_true, null, null, DatabaseInterface::CONNECT_USER, 0, - array( - array('COLUMN_NAME'=>'COLUMN_NAME', 'DATA_TYPE'=>'DATA_TYPE') - ) - ), - array( + [ + ['COLUMN_NAME'=>'COLUMN_NAME', 'DATA_TYPE'=>'DATA_TYPE'] + ] + ], + [ $getUniqueColumns_sql, - array('Key_name', null), + ['Key_name', null], 'Column_name', DatabaseInterface::CONNECT_USER, 0, - array( - array('index1'), - array('index3'), - array('index5'), - ) - ), - array( + [ + ['index1'], + ['index3'], + ['index5'], + ] + ], + [ $getUniqueColumns_sql, 'Column_name', 'Column_name', DatabaseInterface::CONNECT_USER, 0, - array( + [ 'column1', 'column3', 'column5', 'ACCESSIBLE', 'ADD', 'ALL' - ) - ), - array( + ] + ], + [ 'SHOW COLUMNS FROM `PMA`.`PMA_BookMark`', 'Field', 'Field', DatabaseInterface::CONNECT_USER, 0, - array( + [ 'column1', 'column3', 'column5', 'ACCESSIBLE', 'ADD', 'ALL' - ) - ), - array( + ] + ], + [ 'SHOW COLUMNS FROM `PMA`.`PMA_BookMark`', null, null, DatabaseInterface::CONNECT_USER, 0, - array( - array( + [ + [ 'Field'=>'COLUMN_NAME1', 'Type'=> 'INT(10)', 'Null'=> 'NO', 'Key'=> '', 'Default'=> NULL, 'Extra'=>'' - ), - array( + ], + [ 'Field'=>'COLUMN_NAME2', 'Type'=> 'INT(10)', 'Null'=> 'YES', 'Key'=> '', 'Default'=> NULL, 'Extra'=>'STORED GENERATED' - ) - ) - ), - ); + ] + ] + ], + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -230,14 +230,14 @@ class TableTest extends PmaTestCase ) ); - $dbi->_table_cache["PMA"]["PMA_BookMark"] = array( + $dbi->_table_cache["PMA"]["PMA_BookMark"] = [ 'ENGINE' => true, 'Create_time' => true, 'TABLE_TYPE' => true, 'Comment' => true, - ); + ]; - $databases = array(); + $databases = []; $database_name = 'PMA'; $databases[$database_name]['SCHEMA_TABLES'] = 1; $databases[$database_name]['SCHEMA_TABLE_ROWS'] = 3; @@ -258,11 +258,11 @@ class TableTest extends PmaTestCase $dbi->expects($this->any())->method('tryQuery') ->will($this->returnValue(10)); - $triggers = array( - array("name" => "name1", "create"=>"crate1"), - array("name" => "name2", "create"=>"crate2"), - array("name" => "name3", "create"=>"crate3"), - ); + $triggers = [ + ["name" => "name1", "create"=>"crate1"], + ["name" => "name2", "create"=>"crate2"], + ["name" => "name3", "create"=>"crate3"], + ]; $dbi->expects($this->any())->method('getTriggers') ->will($this->returnValue($triggers)); @@ -282,7 +282,7 @@ class TableTest extends PmaTestCase $dbi->expects($this->any())->method('fetchAssoc') ->will($this->returnValue(false)); - $value = array("Auto_increment" => "Auto_increment"); + $value = ["Auto_increment" => "Auto_increment"]; $dbi->expects($this->any())->method('fetchSingleRow') ->will($this->returnValue($value)); @@ -410,18 +410,18 @@ class TableTest extends PmaTestCase */ public function dataValidateName() { - return array( - array('test', true), - array('te/st', false), - array('te.st', false), - array('te\\st', false), - array('te st', false), - array(' te st', true, true), - array('test ', false), - array('te.st', false), - array('test ', false, true), - array('te.st ', false, true), - ); + return [ + ['test', true], + ['te/st', false], + ['te.st', false], + ['te\\st', false], + ['te st', false], + [' te st', true, true], + ['test ', false], + ['te.st', false], + ['test ', false, true], + ['te.st ', false, true], + ]; } /** @@ -592,9 +592,9 @@ class TableTest extends PmaTestCase { $work = "PMA_work"; $pma_table = "pma_table"; - $get_fields = array("filed0", "field6"); - $where_fields = array("field2", "filed5"); - $new_fields = array("field3", "filed4"); + $get_fields = ["filed0", "field6"]; + $where_fields = ["field2", "filed5"]; + $new_fields = ["field3", "filed4"]; $GLOBALS['cfgRelation'][$work] = true; $GLOBALS['cfgRelation']['db'] = "PMA_db"; $GLOBALS['cfgRelation'][$pma_table] = "pma_table"; @@ -649,7 +649,7 @@ class TableTest extends PmaTestCase $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') - ->will($this->returnValue(array('table_name' => "PMA_BookMark"))); + ->will($this->returnValue(['table_name' => "PMA_BookMark"])); $tableObj = new Table('PMA_BookMark', 'PMA'); $this->assertEquals( false, @@ -664,10 +664,10 @@ class TableTest extends PmaTestCase */ public function testIsMergeCase2() { - $map = array( - array(array('PMA', 'PMA_BookMark'), null, array('ENGINE' => "MERGE")), - array(array('PMA', 'PMA_BookMark', 'ENGINE'), null, "MERGE") - ); + $map = [ + [['PMA', 'PMA_BookMark'], null, ['ENGINE' => "MERGE"]], + [['PMA', 'PMA_BookMark', 'ENGINE'], null, "MERGE"] + ]; $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') ->will($this->returnValueMap($map)); @@ -686,10 +686,10 @@ class TableTest extends PmaTestCase */ public function testIsMergeCase3() { - $map = array( - array(array('PMA', 'PMA_BookMark'), null, array('ENGINE' => "MRG_MYISAM")), - array(array('PMA', 'PMA_BookMark', 'ENGINE'), null, "MRG_MYISAM") - ); + $map = [ + [['PMA', 'PMA_BookMark'], null, ['ENGINE' => "MRG_MYISAM"]], + [['PMA', 'PMA_BookMark', 'ENGINE'], null, "MRG_MYISAM"] + ]; $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') ->will($this->returnValueMap($map)); @@ -708,10 +708,10 @@ class TableTest extends PmaTestCase */ public function testIsMergeCase4() { - $map = array( - array(array('PMA', 'PMA_BookMark'), null, array('ENGINE' => "ISDB")), - array(array('PMA', 'PMA_BookMark', 'ENGINE'), null, "ISDB") - ); + $map = [ + [['PMA', 'PMA_BookMark'], null, ['ENGINE' => "ISDB"]], + [['PMA', 'PMA_BookMark', 'ENGINE'], null, "ISDB"] + ]; $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') ->will($this->returnValueMap($map)); @@ -838,11 +838,11 @@ class TableTest extends PmaTestCase $table = new Table($table, $db); $return = $table->getUniqueColumns(); - $expect = array( + $expect = [ '`PMA`.`PMA_BookMark`.`index1`', '`PMA`.`PMA_BookMark`.`index3`', '`PMA`.`PMA_BookMark`.`index5`' - ); + ]; $this->assertEquals( $expect, $return @@ -861,14 +861,14 @@ class TableTest extends PmaTestCase $table = new Table($table, $db); $return = $table->getIndexedColumns(); - $expect = array( + $expect = [ '`PMA`.`PMA_BookMark`.`column1`', '`PMA`.`PMA_BookMark`.`column3`', '`PMA`.`PMA_BookMark`.`column5`', '`PMA`.`PMA_BookMark`.`ACCESSIBLE`', '`PMA`.`PMA_BookMark`.`ADD`', '`PMA`.`PMA_BookMark`.`ALL`', - ); + ]; $this->assertEquals( $expect, $return @@ -915,10 +915,10 @@ class TableTest extends PmaTestCase public function testGetSQLToCreateForeignKey() { $table = "PMA_table"; - $field = array("PMA_field1", "PMA_field2"); + $field = ["PMA_field1", "PMA_field2"]; $foreignDb = "foreignDb"; $foreignTable = "foreignTable"; - $foreignField = array("foreignField1", "foreignField2"); + $foreignField = ["foreignField1", "foreignField2"]; $class = new ReflectionClass(Table::class); $method = $class->getMethod('_getSQLToCreateForeignKey'); @@ -926,13 +926,13 @@ class TableTest extends PmaTestCase $tableObj = new Table('PMA_table', 'db'); $sql = $method->invokeArgs( - $tableObj, array( + $tableObj, [ $table, $field, $foreignDb, $foreignTable, $foreignField - ) + ] ); $sql_excepted = 'ALTER TABLE `PMA_table` ADD ' . 'FOREIGN KEY (`PMA_field1`, `PMA_field2`) REFERENCES ' @@ -944,13 +944,13 @@ class TableTest extends PmaTestCase // Exclude db name when relations are made between table in the same db $sql = $method->invokeArgs( - $tableObj, array( + $tableObj, [ $table, $field, 'db', $foreignTable, $foreignField - ) + ] ); $sql_excepted = 'ALTER TABLE `PMA_table` ADD ' . 'FOREIGN KEY (`PMA_field1`, `PMA_field2`) REFERENCES ' @@ -997,25 +997,25 @@ class TableTest extends PmaTestCase $table = new Table($table, $db); $return = $table->getColumns(); - $expect = array( + $expect = [ '`PMA`.`PMA_BookMark`.`column1`', '`PMA`.`PMA_BookMark`.`column3`', '`PMA`.`PMA_BookMark`.`column5`', '`PMA`.`PMA_BookMark`.`ACCESSIBLE`', '`PMA`.`PMA_BookMark`.`ADD`', '`PMA`.`PMA_BookMark`.`ALL`', - ); + ]; $this->assertEquals( $expect, $return ); $return = $table->getReservedColumnNames(); - $expect = array( + $expect = [ 'ACCESSIBLE', 'ADD', 'ALL', - ); + ]; $this->assertEquals( $expect, $return @@ -1046,13 +1046,13 @@ class TableTest extends PmaTestCase $dbi->expects($this->any()) ->method('fetchResult') ->willReturnOnConsecutiveCalls( - array(array('`one_pk`')), + [['`one_pk`']], - array(), // No Uniques found - array('`one_ind`', '`sec_ind`'), + [], // No Uniques found + ['`one_ind`', '`sec_ind`'], - array(), // No Uniques found - array() // No Indexed found + [], // No Uniques found + [] // No Indexed found ); $GLOBALS['dbi'] = $dbi; @@ -1095,14 +1095,14 @@ class TableTest extends PmaTestCase */ public function testCountRecords() { - $map = array( - array( - array('PMA', 'PMA_BookMark'), + $map = [ + [ + ['PMA', 'PMA_BookMark'], null, - array('Comment' => "Comment222", 'TABLE_TYPE' => "VIEW"), - ), - array(array('PMA', 'PMA_BookMark', 'TABLE_TYPE'), null, 'VIEW'), - ); + ['Comment' => "Comment222", 'TABLE_TYPE' => "VIEW"], + ], + [['PMA', 'PMA_BookMark', 'TABLE_TYPE'], null, 'VIEW'], + ]; $GLOBALS['dbi']->expects($this->any()) ->method('getCachedTableContent') ->will($this->returnValueMap($map)); @@ -1354,7 +1354,7 @@ class TableTest extends PmaTestCase $tbl_object->getStatusInfo(null, true); $extension = new DbiDummy(); $dbi = new DatabaseInterface($extension); - $expect = array('pack_keys' => 'DEFAULT'); + $expect = ['pack_keys' => 'DEFAULT']; $create_options = $dbi->getTable( $target_db, $target_table diff --git a/test/classes/TemplateTest.php b/test/classes/TemplateTest.php index 3543eb211e..f63402ff78 100644 --- a/test/classes/TemplateTest.php +++ b/test/classes/TemplateTest.php @@ -33,10 +33,10 @@ class TemplateTest extends PmaTestCase { $template = Template::get($data); $result = $template->render( - array( + [ 'variable1' => 'value1', 'variable2' => 'value2', - ) + ] ); $this->assertContains('value1', $result); $this->assertContains('value2', $result); diff --git a/test/classes/ThemeTest.php b/test/classes/ThemeTest.php index f0019f248f..18a9413460 100644 --- a/test/classes/ThemeTest.php +++ b/test/classes/ThemeTest.php @@ -159,10 +159,10 @@ class ThemeTest extends PmaTestCase */ public function listThemes() { - return array( - array('./themes/original'), - array('./themes/pmahomme/'), - ); + return [ + ['./themes/original'], + ['./themes/pmahomme/'], + ]; } /** @@ -351,27 +351,27 @@ class ThemeTest extends PmaTestCase */ public function providerForGetImgPath() { - return array( - array( + return [ + [ null, null, '' - ), - array( + ], + [ 'screen.png', null, './themes/pmahomme/img/screen.png' - ), - array( + ], + [ 'arrow_ltr.png', null, './themes/pmahomme/img/arrow_ltr.png' - ), - array( + ], + [ 'logo_right.png', 'pma_logo.png', './themes/pmahomme/img/pma_logo.png' - ), - ); + ], + ]; } } diff --git a/test/classes/TrackerTest.php b/test/classes/TrackerTest.php index 30a7064a1f..dd12fe7128 100644 --- a/test/classes/TrackerTest.php +++ b/test/classes/TrackerTest.php @@ -42,11 +42,11 @@ class TrackerTest extends PmaTestCase $GLOBALS['cfg']['Server']['tracking_version_auto_create'] = ''; $GLOBALS['cfg']['Server']['DisableIS'] = false; - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'db' => 'pmadb', 'tracking' => 'tracking' - ); + ]; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -88,21 +88,21 @@ class TrackerTest extends PmaTestCase Tracker::enable(); - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'trackingwork' => false - ); + ]; $this->assertFalse( Tracker::isActive() ); - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'trackingwork' => true, 'db' => 'pmadb', 'tracking' => 'tracking' - ); + ]; $this->assertTrue( Tracker::isActive() @@ -127,7 +127,7 @@ class TrackerTest extends PmaTestCase $this->assertEquals( $expected, - $method->invokeArgs(null, array($string)) + $method->invokeArgs(null, [$string]) ); } @@ -139,11 +139,11 @@ class TrackerTest extends PmaTestCase */ public function getTableNameData() { - return array( - array("`tbl`;", "tbl"), - array(" `pma.table` ", "table"), - array(" `pma.table\nfoobar` ", "table") - ); + return [ + ["`tbl`;", "tbl"], + [" `pma.table` ", "table"], + [" `pma.table\nfoobar` ", "table"] + ]; } /** @@ -221,46 +221,46 @@ class TrackerTest extends PmaTestCase * to passing $this->anything() */ - $getColumnsResult = array( - array( + $getColumnsResult = [ + [ 'Field' => 'field1', 'Type' => 'int(11)', 'Key' => 'PRI' - ), - array( + ], + [ 'Field' => 'field2', 'Type' => 'text', 'Key' => '' - ) - ); + ] + ]; $dbi->expects($this->once())->method('getColumns') ->with('pma_test', 'pma_tbl') ->will($this->returnValue($getColumnsResult)); - $getIndexesResult = array( - array( + $getIndexesResult = [ + [ 'Table' => 'pma_tbl', 'Field' => 'field1', 'Key' => 'PRIMARY' - ) - ); + ] + ]; $dbi->expects($this->once())->method('getTableIndexes') ->with('pma_test', 'pma_tbl') ->will($this->returnValue($getIndexesResult)); - $tableStatusArray = array( - array( + $tableStatusArray = [ + [ 'Name' => 'pma_tbl', 'Rows' => '1', 'Create_time' => '2013-02-22 02:04:04', 'Update_time' => '2013-02-22 21:46:48' - ) - ); + ] + ]; $dbi->expects($this->exactly(2)) ->method('tryQuery') ->withConsecutive( - array("SHOW TABLE STATUS FROM `pma_test` WHERE Name = 'pma_tbl'"), - array('SHOW CREATE TABLE `pma_test`.`pma_tbl`') + ["SHOW TABLE STATUS FROM `pma_test` WHERE Name = 'pma_tbl'"], + ['SHOW CREATE TABLE `pma_test`.`pma_tbl`'] ) ->willReturnOnConsecutiveCalls( 'res', @@ -294,15 +294,15 @@ class TrackerTest extends PmaTestCase "\n', '11' )"; - $queryResults = array( - array( + $queryResults = [ + [ $expectedMainQuery, DatabaseInterface::CONNECT_CONTROL, 0, false, 'executed' - ) - ); + ] + ]; $dbi->expects($this->any())->method('query') ->will($this->returnValueMap($queryResults)); @@ -310,7 +310,7 @@ class TrackerTest extends PmaTestCase $dbi->expects($this->any())->method('escapeString') ->will($this->returnArgument(0)); $dbi->expects($this->any())->method('getCompatibilities') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $GLOBALS['dbi'] = $dbi; $this->assertEquals( @@ -482,16 +482,16 @@ class TrackerTest extends PmaTestCase $date = Util::date('Y-m-d H:i:s'); - $new_data = array( - array( + $new_data = [ + [ 'username' => 'user1', 'statement' => 'test_statement1' - ), - array( + ], + [ 'username' => 'user2', 'statement' => 'test_statement2' - ) - ); + ] + ]; $sql_query_2 = " UPDATE `pmadb`.`tracking`" . " SET `data_sql` = '# log $date user1test_statement1\n" . @@ -503,10 +503,10 @@ class TrackerTest extends PmaTestCase $dbi->method('query') ->will( $this->returnValueMap( - array( - array($sql_query_1, DatabaseInterface::CONNECT_CONTROL, 0, false, "executed_1"), - array($sql_query_2, DatabaseInterface::CONNECT_CONTROL, 0, false, "executed_2") - ) + [ + [$sql_query_1, DatabaseInterface::CONNECT_CONTROL, 0, false, "executed_1"], + [$sql_query_2, DatabaseInterface::CONNECT_CONTROL, 0, false, "executed_2"] + ] ) ); @@ -589,11 +589,11 @@ class TrackerTest extends PmaTestCase ->method('escapeString') ->will( $this->returnValueMap( - array( - array("pma'db", "pma\'db"), - array("pma'table", "pma\'table"), - array("1.0", "1.0"), - ) + [ + ["pma'db", "pma\'db"], + ["pma'table", "pma\'table"], + ["1.0", "1.0"], + ] ) ); @@ -613,81 +613,81 @@ class TrackerTest extends PmaTestCase */ public function getTrackedDataProvider() { - $fetchArrayReturn = array( - array( + $fetchArrayReturn = [ + [ "schema_sql" => "# log 20-03-2013 23:33:58 user1\nstat1" . "# log 20-03-2013 23:39:58 user2\n", "data_sql" => "# log ", "schema_snapshot" => "dataschema", "tracking" => "SELECT, DELETE" - ) - ); + ] + ]; - $data = array( - array( + $data = [ + [ 'date_from' => '20-03-2013 23:33:58', 'date_to' => '20-03-2013 23:39:58', - 'ddlog' => array( - array( + 'ddlog' => [ + [ 'date' => '20-03-2013 23:33:58', 'username' => 'user1', 'statement' => "\nstat1" - ), - array( + ], + [ 'date' => '20-03-2013 23:39:58', 'username' => 'user2', 'statement' => "" - ) - ), - 'dmlog' => array(), + ] + ], + 'dmlog' => [], "schema_snapshot" => "dataschema", "tracking" => "SELECT, DELETE" - ) - ); + ] + ]; - $fetchArrayReturn[1] = array( + $fetchArrayReturn[1] = [ "schema_sql" => "# log 20-03-2012 23:33:58 user1\n" . "# log 20-03-2012 23:39:58 user2\n", "data_sql" => "# log 20-03-2013 23:33:58 user3\n" . "# log 20-03-2013 23:39:58 user4\n", "schema_snapshot" => "dataschema", "tracking" => "SELECT, DELETE" - ); + ]; - $data[1] = array( + $data[1] = [ 'date_from' => '20-03-2012 23:33:58', 'date_to' => '20-03-2013 23:39:58', - 'ddlog' => array( - array( + 'ddlog' => [ + [ 'date' => '20-03-2012 23:33:58', 'username' => 'user1', 'statement' => "" - ), - array( + ], + [ 'date' => '20-03-2012 23:39:58', 'username' => 'user2', 'statement' => "" - ) - ), - 'dmlog' => array( - array( + ] + ], + 'dmlog' => [ + [ 'date' => '20-03-2013 23:33:58', 'username' => 'user3', 'statement' => "" - ), - array( + ], + [ 'date' => '20-03-2013 23:39:58', 'username' => 'user4', 'statement' => "" - ) - ), + ] + ], "schema_snapshot" => "dataschema", "tracking" => "SELECT, DELETE" - ); - return array( - array($fetchArrayReturn[0], $data[0]), - array($fetchArrayReturn[1], $data[1]) - ); + ]; + return [ + [$fetchArrayReturn[0], $data[0]], + [$fetchArrayReturn[1], $data[1]] + ]; } /** @@ -747,7 +747,7 @@ class TrackerTest extends PmaTestCase */ public function parseQueryData() { - $query = array(); + $query = []; /** TODO: Should test fail when USE is in conjunction with * identifiers? $query[] = array( " - USE db1;\n- CREATE VIEW db1.v AS SELECT * FROM t;", @@ -757,130 +757,130 @@ class TrackerTest extends PmaTestCase "db1" ); */ - $query[] = array( + $query[] = [ "CREATE VIEW v AS SELECT * FROM t;", "DDL", "CREATE VIEW", "v", - ); - $query[] = array( + ]; + $query[] = [ "ALTER VIEW db1.v AS SELECT col1, col2, col3, col4 FROM t", "DDL", "ALTER VIEW", "v" - ); - $query[] = array( + ]; + $query[] = [ "DROP VIEW db1.v;", "DDL", "DROP VIEW", "v" - ); - $query[] = array( + ]; + $query[] = [ "DROP VIEW IF EXISTS db1.v;", "DDL", "DROP VIEW", "v" - ); - $query[] = array( + ]; + $query[] = [ "CREATE DATABASE db1;", "DDL", "CREATE DATABASE", "", "db1" - ); - $query[] = array( + ]; + $query[] = [ "ALTER DATABASE db1;", "DDL", "ALTER DATABASE", "" - ); - $query[] = array( + ]; + $query[] = [ "DROP DATABASE db1;", "DDL", "DROP DATABASE", "", "db1" - ); - $query[] = array( + ]; + $query[] = [ "CREATE TABLE db1.t1 (c1 INT);", "DDL", "CREATE TABLE", "t1" - ); - $query[] = array( + ]; + $query[] = [ "ALTER TABLE db1.t1 ADD c2 TEXT;", "DDL", "ALTER TABLE", "t1" - ); - $query[] = array( + ]; + $query[] = [ "DROP TABLE db1.t1", "DDL", "DROP TABLE", "t1" - ); - $query[] = array( + ]; + $query[] = [ "DROP TABLE IF EXISTS db1.t1", "DDL", "DROP TABLE", "t1" - ); - $query[] = array( + ]; + $query[] = [ "CREATE INDEX ind ON db1.t1 (c2(10));", "DDL", "CREATE INDEX", "t1" - ); - $query[] = array( + ]; + $query[] = [ "CREATE UNIQUE INDEX ind ON db1.t1 (c2(10));", "DDL", "CREATE INDEX", "t1" - ); - $query[] = array( + ]; + $query[] = [ "CREATE SPATIAL INDEX ind ON db1.t1 (c2(10));", "DDL", "CREATE INDEX", "t1" - ); - $query[] = array( + ]; + $query[] = [ "DROP INDEX ind ON db1.t1;", "DDL", "DROP INDEX", "t1" - ); - $query[] = array( + ]; + $query[] = [ "RENAME TABLE db1.t1 TO db1.t2", "DDL", "RENAME TABLE", "t1", "", "t2" - ); - $query[] = array( + ]; + $query[] = [ "UPDATE db1.t1 SET a = 2", "DML", "UPDATE", "t1" - ); - $query[] = array( + ]; + $query[] = [ "INSERT INTO db1.t1 (a, b, c) VALUES(1, 2, 3)", "DML", "INSERT", "t1" - ); - $query[] = array( + ]; + $query[] = [ "DELETE FROM db1.t1", "DML", "DELETE", "t1" - ); - $query[] = array( + ]; + $query[] = [ "TRUNCATE db1.t1", "DML", "TRUNCATE", "t1" - ); + ]; return $query; } diff --git a/test/classes/TrackingTest.php b/test/classes/TrackingTest.php index 4741318bd7..00716a8d0b 100644 --- a/test/classes/TrackingTest.php +++ b/test/classes/TrackingTest.php @@ -49,12 +49,12 @@ class TrackingTest extends TestCase $this->tracking = new Tracking(); - $_SESSION['relation'][$GLOBALS['server']] = array( + $_SESSION['relation'][$GLOBALS['server']] = [ 'PMA_VERSION' => PMA_VERSION, 'db' => 'pmadb', 'tracking' => 'tracking', 'trackingwork' => true - ); + ]; $GLOBALS['cfg']['Server']['tracking_default_statements'] = 'DELETE'; @@ -62,7 +62,7 @@ class TrackingTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $fetchArray = array('version' => "10"); + $fetchArray = ['version' => "10"]; $dbi->expects($this->any()) ->method('fetchArray') ->will($this->returnValue($fetchArray)); @@ -84,21 +84,21 @@ class TrackingTest extends TestCase */ public function testFilter() { - $data = array( - array( + $data = [ + [ "date" => "20120102", "username"=> "username1", "statement"=>"statement1" - ), - array( + ], + [ "date" => "20130102", "username"=> "username2", "statement"=>"statement2" - ), - ); + ], + ]; $filter_ts_from = 0; $filter_ts_to = 999999999999; - $filter_users = array("username1"); + $filter_users = ["username1"]; $ret = $this->tracking->filter( $data, $filter_ts_from, $filter_ts_to, $filter_users @@ -122,23 +122,23 @@ class TrackingTest extends TestCase */ public function testExtractTableNames() { - $table_list = array( - "hello_"=>array( + $table_list = [ + "hello_"=>[ "is_group"=>1, - "lovely_"=>array( + "lovely_"=>[ "is_group"=>1, - "hello_lovely_world"=>array( + "hello_lovely_world"=>[ "Name"=>"hello_lovely_world" - ), - "hello_lovely_world2"=>array( + ], + "hello_lovely_world2"=>[ "Name"=>"hello_lovely_world2" - ) - ), - "hello_world"=>array( + ] + ], + "hello_world"=>[ "Name"=>"hello_world" - ) - ) - ); + ] + ] + ]; $untracked_tables = $this->tracking->extractTableNames($table_list, 'db', true); $this->assertContains( "hello_world", @@ -165,7 +165,7 @@ class TrackingTest extends TestCase $url_query = "url_query"; $last_version = 10; $html = $this->tracking->getHtmlForDataDefinitionAndManipulationStatements( - $url_query, $last_version, $GLOBALS['db'], array($GLOBALS['table']) + $url_query, $last_version, $GLOBALS['db'], [$GLOBALS['table']] ); $this->assertContains( @@ -314,8 +314,8 @@ class TrackingTest extends TestCase */ public function testGetHtmlForColumns() { - $columns = array( - array( + $columns = [ + [ 'Field'=>'Field1', 'Type'=>'Type1', 'Collation'=>'Collation1', @@ -323,8 +323,8 @@ class TrackingTest extends TestCase 'Extra'=>'Extra1', 'Key'=>'PRI', 'Comment'=>'Comment1' - ), - array( + ], + [ 'Field'=>'Field2', 'Type'=>'Type2', 'Collation'=>'Collation2', @@ -332,8 +332,8 @@ class TrackingTest extends TestCase 'Extra'=>'Extra2', 'Key'=>'Key2', 'Comment'=>'Comment2' - ), - ); + ], + ]; $html = $this->tracking->getHtmlForColumns($columns); @@ -431,7 +431,7 @@ class TrackingTest extends TestCase { $sql_result = true; $last_version = "10"; - $url_params = array(); + $url_params = []; $url_query = "select * from PMA"; $pmaThemeImage = "themePath/img"; $text_dir = "ltr"; @@ -441,14 +441,14 @@ class TrackingTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $fetchArray = array( + $fetchArray = [ 'tracking_active' => 1, 'version' => "10", 'db_name' => 'db_name', 'table_name' => 'table_name', 'date_created' => 'date_created', 'date_updated' => 'date_updated' - ); + ]; $dbi->expects($this->at(0)) ->method('fetchArray') ->will($this->returnValue($fetchArray)); @@ -539,14 +539,14 @@ class TrackingTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $fetchArray = array( + $fetchArray = [ 'tracking_active' => 1, 'version' => "10", 'db_name' => 'db_name', 'table_name' => 'table_name', 'date_created' => 'date_created', 'date_updated' => 'date_updated' - ); + ]; $dbi->expects($this->at(0)) ->method('fetchArray') ->will($this->returnValue($fetchArray)); @@ -590,18 +590,18 @@ class TrackingTest extends TestCase $_REQUEST['users'] = "users"; $_REQUEST['logtype'] = 'logtype'; $url_query = "select * from PMA"; - $data = array( + $data = [ 'tracking'=>'tracking', - 'ddlog' => array('ddlog'), - 'dmlog' => array('dmlog') - ); - $url_params = array(); - $selection_schema = array(); - $selection_data = array(); - $selection_both = array(); - $filter_ts_to = array(); - $filter_ts_from = array(); - $filter_users = array(); + 'ddlog' => ['ddlog'], + 'dmlog' => ['dmlog'] + ]; + $url_params = []; + $selection_schema = []; + $selection_data = []; + $selection_both = []; + $filter_ts_to = []; + $filter_ts_from = []; + $filter_users = []; $html = $this->tracking->getHtmlForTrackingReport( $url_query, $data, $url_params, @@ -632,9 +632,9 @@ class TrackingTest extends TestCase $version = '<form method="post" action="tbl_tracking.php' . Url::getCommon( - $url_params + array( + $url_params + [ 'report' => 'true', 'version' => $_REQUEST['version'] - ) + ] ); $this->assertContains( @@ -687,23 +687,23 @@ class TrackingTest extends TestCase public function testGetHtmlForDataManipulationStatements() { $_REQUEST['version'] = "10"; - $data = array( + $data = [ 'tracking'=>'tracking', - 'dmlog' => array( - array( + 'dmlog' => [ + [ 'statement' => 'statement', 'date' => 'date', 'username' => 'username', - ) - ), - 'ddlog' => array('ddlog') - ); - $url_params = array(); + ] + ], + 'ddlog' => ['ddlog'] + ]; + $url_params = []; $ddlog_count = 10; $drop_image_or_text = "text"; $filter_ts_to = 9999999999; $filter_ts_from = 0; - $filter_users = array("*"); + $filter_users = ["*"]; $html = $this->tracking->getHtmlForDataManipulationStatements( $data, $filter_users, @@ -747,21 +747,21 @@ class TrackingTest extends TestCase { $_REQUEST['version'] = "10"; - $data = array( + $data = [ 'tracking'=>'tracking', - 'ddlog' => array( - array( + 'ddlog' => [ + [ 'statement' => 'statement', 'date' => 'date', 'username' => 'username', - ) - ), - 'dmlog' => array('dmlog') - ); - $filter_users = array("*"); + ] + ], + 'dmlog' => ['dmlog'] + ]; + $filter_users = ["*"]; $filter_ts_to = 9999999999; $filter_ts_from = 0; - $url_params = array(); + $url_params = []; $drop_image_or_text = "text"; list($html, $count) = $this->tracking->getHtmlForDataDefinitionStatements( @@ -810,8 +810,8 @@ class TrackingTest extends TestCase */ public function testGetHtmlForIndexes() { - $indexs = array( - array( + $indexs = [ + [ 'Non_unique' => 0, 'Packed' => '', 'Key_name' => 'Key_name1', @@ -821,8 +821,8 @@ class TrackingTest extends TestCase 'Collation' => 'Collation', 'Null' => 'Null', 'Comment' => 'Comment', - ), - ); + ], + ]; $html = $this->tracking->getHtmlForIndexes($indexs); @@ -931,24 +931,24 @@ class TrackingTest extends TestCase public function testGetEntries() { $_REQUEST['logtype'] = 'schema'; - $data = array( + $data = [ 'tracking'=>'tracking', - 'ddlog' => array( - array( + 'ddlog' => [ + [ 'statement' => 'statement1', 'date' => 'date2', 'username' => 'username3', - ) - ), - 'dmlog' => array( - array( + ] + ], + 'dmlog' => [ + [ 'statement' => 'statement1', 'date' => 'date2', 'username' => 'username3', - ) - ), - ); - $filter_users = array("*"); + ] + ], + ]; + $filter_users = ["*"]; $filter_ts_to = 9999999999; $filter_ts_from = 0; diff --git a/test/classes/TransformationsTest.php b/test/classes/TransformationsTest.php index d37f926a2b..14480e2467 100644 --- a/test/classes/TransformationsTest.php +++ b/test/classes/TransformationsTest.php @@ -34,10 +34,10 @@ class TransformationsTest extends TestCase { $GLOBALS['table'] = 'table'; $GLOBALS['db'] = 'db'; - $GLOBALS['cfg'] = array( + $GLOBALS['cfg'] = [ 'ServerDefault' => 1, 'ActionLinksMode' => 'icons', - ); + ]; $GLOBALS['server'] = 1; $GLOBALS['cfg']['Server']['pmadb'] = 'pmadb'; $GLOBALS['cfg']['Server']['user'] = 'user'; @@ -78,13 +78,13 @@ class TransformationsTest extends TestCase */ public function getOptionsData() { - return array( - array("option1 , option2 ", array('option1 ', ' option2 ')), - array("'option1' ,' option2' ", array('option1', ' option2')), - array("'2,3' ,' ,, option ,,' ", array('2,3', ' ,, option ,,')), - array("'',,", array('', '', '')), - array('', array()), - ); + return [ + ["option1 , option2 ", ['option1 ', ' option2 ']], + ["'option1' ,' option2' ", ['option1', ' option2']], + ["'2,3' ,' ,, option ,,' ", ['2,3', ' ,, option ,,']], + ["'',,", ['', '', '']], + ['', []], + ]; } /** @@ -95,15 +95,15 @@ class TransformationsTest extends TestCase public function testGetTypes() { $this->assertEquals( - array ( - 'mimetype' => array ( + [ + 'mimetype' => [ 'Application/Octetstream' => 'Application/Octetstream', 'Image/JPEG' => 'Image/JPEG', 'Image/PNG' => 'Image/PNG', 'Text/Plain' => 'Text/Plain', 'Text/Octetstream' => 'Text/Octetstream' - ), - 'transformation' => array ( + ], + 'transformation' => [ 0 => 'Application/Octetstream: Download', 1 => 'Application/Octetstream: Hex', 2 => 'Image/JPEG: Inline', @@ -123,8 +123,8 @@ class TransformationsTest extends TestCase 16 => 'Text/Plain: Longtoipv4', 17 => 'Text/Plain: PreApPend', 18 => 'Text/Plain: Substring', - ), - 'transformation_file' => array ( + ], + 'transformation_file' => [ 0 => 'Output/Application_Octetstream_Download.php', 1 => 'Output/Application_Octetstream_Hex.php', 2 => 'Output/Image_JPEG_Inline.php', @@ -144,8 +144,8 @@ class TransformationsTest extends TestCase 16 => 'Text_Plain_Longtoipv4.php', 17 => 'Text_Plain_PreApPend.php', 18 => 'Text_Plain_Substring.php', - ), - 'input_transformation' => array( + ], + 'input_transformation' => [ 'Image/JPEG: Upload', 'Text/Plain: FileUpload', 'Text/Plain: Iptobinary', @@ -157,8 +157,8 @@ class TransformationsTest extends TestCase 'Text/Plain: Longtoipv4', 'Text/Plain: PreApPend', 'Text/Plain: Substring', - ), - 'input_transformation_file' => array( + ], + 'input_transformation_file' => [ 'Input/Image_JPEG_Upload.php', 'Input/Text_Plain_FileUpload.php', 'Input/Text_Plain_Iptobinary.php', @@ -170,8 +170,8 @@ class TransformationsTest extends TestCase 'Text_Plain_Longtoipv4.php', 'Text_Plain_PreApPend.php', 'Text_Plain_Substring.php', - ), - ), + ], + ], $this->transformations->getAvailableMimeTypes() ); } @@ -189,24 +189,24 @@ class TransformationsTest extends TestCase $_SESSION['relation'][$GLOBALS['server']]['column_info'] = "column_info"; $_SESSION['relation'][$GLOBALS['server']]['trackingwork'] = false; $this->assertEquals( - array( - 'o' => array( + [ + 'o' => [ 'column_name' => 'o', 'mimetype' => 'Text/plain', 'transformation' => 'Sql', 'transformation_options' => '', 'input_transformation' => 'regex', 'input_transformation_options' => '/pma/i', - ), - 'col' => array( + ], + 'col' => [ 'column_name' => 'col', 'mimetype' => 'T', 'transformation' => 'O/P', 'transformation_options' => '', 'input_transformation' => 'i/p', 'input_transformation_options' => '', - ), - ), + ], + ], $this->transformations->getMime('pma_test', 'table1') ); } @@ -281,27 +281,27 @@ class TransformationsTest extends TestCase */ public function fixupData() { - return array( - array( + return [ + [ 'text_plain_bool2text.php', 'Text_Plain_Bool2Text.php' - ), - array( + ], + [ 'application_octetstream_download.php', 'Application_Octetstream_Download.php' - ), - array( + ], + [ 'text_plain_json.php', 'Text_Plain_Json.php' - ), - array( + ], + [ 'image_jpeg_link.php', 'Image_JPEG_Link.php' - ), - array( + ], + [ 'text_plain_dateformat.php', 'Text_Plain_Dateformat.php' - ), - ); + ], + ]; } } diff --git a/test/classes/TypesTest.php b/test/classes/TypesTest.php index 66ab31c571..13978900ed 100644 --- a/test/classes/TypesTest.php +++ b/test/classes/TypesTest.php @@ -53,12 +53,12 @@ class TypesTest extends PmaTestCase public function testGetUnaryOperators() { $this->assertEquals( - array( + [ 'IS NULL', 'IS NOT NULL', "= ''", "!= ''", - ), + ], $this->object->getUnaryOperators() ); } @@ -71,10 +71,10 @@ class TypesTest extends PmaTestCase public function testGetNullOperators() { $this->assertEquals( - array( + [ 'IS NULL', 'IS NOT NULL', - ), + ], $this->object->getNullOperators() ); } @@ -87,10 +87,10 @@ class TypesTest extends PmaTestCase public function testGetEnumOperators() { $this->assertEquals( - array( + [ '=', '!=', - ), + ], $this->object->getEnumOperators() ); } @@ -103,7 +103,7 @@ class TypesTest extends PmaTestCase public function testgetTextOperators() { $this->assertEquals( - array( + [ 'LIKE', 'LIKE %...%', 'NOT LIKE', @@ -118,7 +118,7 @@ class TypesTest extends PmaTestCase 'NOT IN (...)', 'BETWEEN', 'NOT BETWEEN', - ), + ], $this->object->getTextOperators() ); } @@ -131,7 +131,7 @@ class TypesTest extends PmaTestCase public function testGetNumberOperators() { $this->assertEquals( - array( + [ '=', '>', '>=', @@ -145,7 +145,7 @@ class TypesTest extends PmaTestCase 'NOT IN (...)', 'BETWEEN', 'NOT BETWEEN', - ), + ], $this->object->getNumberOperators() ); } @@ -176,19 +176,19 @@ class TypesTest extends PmaTestCase */ public function providerForGetTypeOperators() { - return array( - array( + return [ + [ 'enum', false, - array( + [ '=', '!=', - ) - ), - array( + ] + ], + [ 'CHAR', true, - array( + [ 'LIKE', 'LIKE %...%', 'NOT LIKE', @@ -205,17 +205,17 @@ class TypesTest extends PmaTestCase 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL', - ), - array( + ], + [ 'int', false, - array( + [ '=', '!=', - ) - ), - ) - ); + ] + ], + ] + ]; } /** @@ -246,15 +246,15 @@ class TypesTest extends PmaTestCase */ public function providerForTestGetTypeOperatorsHtml() { - return array( - array( + return [ + [ 'enum', false, '=', '<option value="=" selected="selected">=</option>' . '<option value="!=">!=</option>' - ) - ); + ] + ]; } /** @@ -294,47 +294,47 @@ class TypesTest extends PmaTestCase */ public function providerForTestGetTypeDescription() { - return array( - array('TINYINT'), - array('SMALLINT'), - array('MEDIUMINT'), - array('INT'), - array('BIGINT'), - array('DECIMAL'), - array('FLOAT'), - array('DOUBLE'), - array('REAL'), - array('BIT'), - array('BOOLEAN'), - array('SERIAL'), - array('DATE'), - array('DATETIME'), - array('TIMESTAMP'), - array('TIME'), - array('YEAR'), - array('CHAR'), - array('VARCHAR'), - array('TINYTEXT'), - array('TEXT'), - array('MEDIUMTEXT'), - array('LONGTEXT'), - array('BINARY'), - array('VARBINARY'), - array('TINYBLOB'), - array('MEDIUMBLOB'), - array('BLOB'), - array('LONGBLOB'), - array('ENUM'), - array('SET'), - array('GEOMETRY'), - array('POINT'), - array('LINESTRING'), - array('POLYGON'), - array('MULTIPOINT'), - array('MULTILINESTRING'), - array('MULTIPOLYGON'), - array('GEOMETRYCOLLECTION'), - ); + return [ + ['TINYINT'], + ['SMALLINT'], + ['MEDIUMINT'], + ['INT'], + ['BIGINT'], + ['DECIMAL'], + ['FLOAT'], + ['DOUBLE'], + ['REAL'], + ['BIT'], + ['BOOLEAN'], + ['SERIAL'], + ['DATE'], + ['DATETIME'], + ['TIMESTAMP'], + ['TIME'], + ['YEAR'], + ['CHAR'], + ['VARCHAR'], + ['TINYTEXT'], + ['TEXT'], + ['MEDIUMTEXT'], + ['LONGTEXT'], + ['BINARY'], + ['VARBINARY'], + ['TINYBLOB'], + ['MEDIUMBLOB'], + ['BLOB'], + ['LONGBLOB'], + ['ENUM'], + ['SET'], + ['GEOMETRY'], + ['POINT'], + ['LINESTRING'], + ['POLYGON'], + ['MULTIPOINT'], + ['MULTILINESTRING'], + ['MULTIPOLYGON'], + ['GEOMETRYCOLLECTION'], + ]; } /** @@ -362,10 +362,10 @@ class TypesTest extends PmaTestCase */ public function providerFortTestGetFunctionsClass() { - return array( - array( + return [ + [ 'CHAR', - array( + [ 'AES_DECRYPT', 'AES_ENCRYPT', 'BIN', @@ -400,11 +400,11 @@ class TypesTest extends PmaTestCase 'USER', 'UUID', 'VERSION', - ) - ), - array( + ] + ], + [ 'DATE', - array( + [ 'CURRENT_DATE', 'CURRENT_TIME', 'DATE', @@ -420,11 +420,11 @@ class TypesTest extends PmaTestCase 'UTC_TIME', 'UTC_TIMESTAMP', 'YEAR', - ) - ), - array( + ] + ], + [ 'SPATIAL', - array( + [ 'GeomFromText', 'GeomFromWKB', @@ -443,11 +443,11 @@ class TypesTest extends PmaTestCase 'MPointFromWKB', 'PolyFromWKB', 'MPolyFromWKB', - ) - ), - array( + ] + ], + [ 'NUMBER', - array( + [ '0' => 'ABS', '1' => 'ACOS', '2' => 'ASCII', @@ -500,13 +500,13 @@ class TypesTest extends PmaTestCase '49' => 'WEEKDAY', '50' => 'WEEKOFYEAR', '51' => 'YEARWEEK' - ) - ), - array( + ] + ], + [ 'UNKNOWN', - array() - ) - ); + [] + ] + ]; } /** @@ -517,7 +517,7 @@ class TypesTest extends PmaTestCase public function testGetFunctions() { $this->assertEquals( - array( + [ 'AES_DECRYPT', 'AES_ENCRYPT', 'BIN', @@ -552,7 +552,7 @@ class TypesTest extends PmaTestCase 'USER', 'UUID', 'VERSION', - ), + ], $this->object->getFunctions('enum') ); } @@ -565,7 +565,7 @@ class TypesTest extends PmaTestCase public function testGetAllFunctions() { $this->assertEquals( - array( + [ 'ABS', 'ACOS', 'AES_DECRYPT', @@ -667,7 +667,7 @@ class TypesTest extends PmaTestCase 'WEEKOFYEAR', 'YEAR', 'YEARWEEK', - ), + ], $this->object->getAllFunctions() ); } @@ -680,13 +680,13 @@ class TypesTest extends PmaTestCase public function testGetAttributes() { $this->assertEquals( - array( + [ '', 'BINARY', 'UNSIGNED', 'UNSIGNED ZEROFILL', 'on update CURRENT_TIMESTAMP', - ), + ], $this->object->getAttributes() ); } @@ -699,12 +699,12 @@ class TypesTest extends PmaTestCase public function testGetColumns() { $this->assertEquals( - array( + [ 0 => 'INT', 1 => 'VARCHAR', 2 => 'TEXT', 3 => 'DATE', - 'Numeric' => array ( + 'Numeric' => [ 'TINYINT', 'SMALLINT', 'MEDIUMINT', @@ -719,15 +719,15 @@ class TypesTest extends PmaTestCase 'BIT', 'BOOLEAN', 'SERIAL', - ), - 'Date and time' => array ( + ], + 'Date and time' => [ 'DATE', 'DATETIME', 'TIMESTAMP', 'TIME', 'YEAR', - ), - 'String' => array ( + ], + 'String' => [ 'CHAR', 'VARCHAR', '-', @@ -746,8 +746,8 @@ class TypesTest extends PmaTestCase '-', 'ENUM', 'SET', - ), - 'Spatial' => array ( + ], + 'Spatial' => [ 'GEOMETRY', 'POINT', 'LINESTRING', @@ -756,11 +756,11 @@ class TypesTest extends PmaTestCase 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION', - ), - 'JSON' => array( + ], + 'JSON' => [ 'JSON' - ) - ), + ] + ], $this->object->getColumns() ); } @@ -790,27 +790,27 @@ class TypesTest extends PmaTestCase */ public function providerFortTestGetTypeClass() { - return array( - array( + return [ + [ 'SERIAL', 'NUMBER' - ), - array( + ], + [ 'YEAR', 'DATE' - ), - array( + ], + [ 'GEOMETRYCOLLECTION', 'SPATIAL' - ), - array( + ], + [ 'SET', 'CHAR' - ), - array( + ], + [ 'UNKNOWN', '' - ) - ); + ] + ]; } } diff --git a/test/classes/UrlTest.php b/test/classes/UrlTest.php index 92ec62c21f..e7100de86d 100644 --- a/test/classes/UrlTest.php +++ b/test/classes/UrlTest.php @@ -47,7 +47,7 @@ class UrlTest extends TestCase $expected = '?db=db' . htmlentities($separator) . $expected; - $this->assertEquals($expected, Url::getCommon(array('db' => 'db'))); + $this->assertEquals($expected, Url::getCommon(['db' => 'db'])); } /** @@ -66,7 +66,7 @@ class UrlTest extends TestCase $expected = '?db=db' . htmlentities($separator) . 'table=table' . htmlentities($separator) . $expected; - $params = array('db' => 'db', 'table' => 'table'); + $params = ['db' => 'db', 'table' => 'table']; $this->assertEquals($expected, Url::getCommon($params)); } @@ -88,7 +88,7 @@ class UrlTest extends TestCase $this->assertEquals( $expected, Url::getCommonRaw( - array('db' => 'db', 'table' => 'table'), '#ABC#' + ['db' => 'db', 'table' => 'table'], '#ABC#' ) ); } diff --git a/test/classes/UserPreferencesTest.php b/test/classes/UserPreferencesTest.php index e9ffa8f921..a817e23739 100644 --- a/test/classes/UserPreferencesTest.php +++ b/test/classes/UserPreferencesTest.php @@ -48,23 +48,23 @@ class UserPreferencesTest extends PmaTestCase */ public function testPageInit() { - $GLOBALS['cfg'] = array( + $GLOBALS['cfg'] = [ 'Server/hide_db' => 'testval123', 'Server/port' => '213' - ); - $GLOBALS['cfg']['AvailableCharsets'] = array(); + ]; + $GLOBALS['cfg']['AvailableCharsets'] = []; $GLOBALS['cfg']['UserprefsDeveloperTab'] = null; $this->userPreferences->pageInit(new ConfigFile()); $this->assertEquals( - array( - 'Servers' => array( - 1 => array( + [ + 'Servers' => [ + 1 => [ 'hide_db' => 'testval123' - ) - ) - ), + ] + ] + ], $_SESSION['ConfigFile' . $GLOBALS['server']] ); } @@ -89,7 +89,7 @@ class UserPreferencesTest extends PmaTestCase ); $this->assertEquals( - array(), + [], $result['config_data'] ); @@ -123,10 +123,10 @@ class UserPreferencesTest extends PmaTestCase ->with($query, 'ASSOC', DatabaseInterface::CONNECT_CONTROL) ->will( $this->returnValue( - array( + [ 'ts' => '123', - 'config_data' => json_encode(array(1, 2)) - ) + 'config_data' => json_encode([1, 2]) + ] ) ); $dbi->expects($this->any()) @@ -138,11 +138,11 @@ class UserPreferencesTest extends PmaTestCase $result = $this->userPreferences->load(); $this->assertEquals( - array( - 'config_data' => array(1, 2), + [ + 'config_data' => [1, 2], 'mtime' => 123, 'type' => 'db' - ), + ], $result ); } @@ -159,7 +159,7 @@ class UserPreferencesTest extends PmaTestCase $_SESSION['relation'][2]['userconfigwork'] = null; unset($_SESSION['userconfig']); - $result = $this->userPreferences->save(array(1)); + $result = $this->userPreferences->save([1]); $this->assertTrue( $result @@ -171,7 +171,7 @@ class UserPreferencesTest extends PmaTestCase ); $this->assertEquals( - array(1), + [1], $_SESSION['userconfig']['db'] ); @@ -203,7 +203,7 @@ class UserPreferencesTest extends PmaTestCase . 'WHERE `username` = \'user\''; $query2 = 'UPDATE `pmadb`.`testconf` SET `timevalue` = NOW(), `config_data` = \'' - . json_encode(array(1)) . '\' WHERE `username` = \'user\''; + . json_encode([1]) . '\' WHERE `username` = \'user\''; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -225,7 +225,7 @@ class UserPreferencesTest extends PmaTestCase $GLOBALS['dbi'] = $dbi; $this->assertTrue( - $this->userPreferences->save(array(1)) + $this->userPreferences->save([1]) ); // case 3 @@ -234,7 +234,7 @@ class UserPreferencesTest extends PmaTestCase . 'WHERE `username` = \'user\''; $query2 = 'INSERT INTO `pmadb`.`testconf` (`username`, `timevalue`,`config_data`) ' - . 'VALUES (\'user\', NOW(), \'' . json_encode(array(1)) . '\')'; + . 'VALUES (\'user\', NOW(), \'' . json_encode([1]) . '\')'; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() @@ -260,7 +260,7 @@ class UserPreferencesTest extends PmaTestCase $GLOBALS['dbi'] = $dbi; - $result = $this->userPreferences->save(array(1)); + $result = $this->userPreferences->save([1]); $this->assertEquals( 'Could not save configuration<br /><br />err1', @@ -275,27 +275,27 @@ class UserPreferencesTest extends PmaTestCase */ public function testApply() { - $GLOBALS['cfg']['UserprefsDisallow'] = array( + $GLOBALS['cfg']['UserprefsDisallow'] = [ 'test' => 'val', 'foo' => 'bar' - ); + ]; $GLOBALS['cfg']['UserprefsDeveloperTab'] = null; $result = $this->userPreferences->apply( - array( + [ 'DBG/sql' => true, 'ErrorHandler/display' => true, 'ErrorHandler/gather' => false, 'Servers/foobar' => '123', 'Server/hide_db' => true - ) + ] ); $this->assertEquals( - array( - 'Server' => array( + [ + 'Server' => [ 'hide_db' => 1 - ) - ), + ] + ], $result ); } @@ -309,15 +309,15 @@ class UserPreferencesTest extends PmaTestCase { $GLOBALS['cfg']['UserprefsDeveloperTab'] = true; $result = $this->userPreferences->apply( - array( + [ 'DBG/sql' => true, - ) + ] ); $this->assertEquals( - array( - 'DBG' => array('sql' => true), - ), + [ + 'DBG' => ['sql' => true], + ], $result ); } @@ -331,12 +331,12 @@ class UserPreferencesTest extends PmaTestCase { $_SESSION['relation'][$GLOBALS['server']]['PMA_VERSION'] = PMA_VERSION; $_SESSION['relation'][$GLOBALS['server']]['userconfigwork'] = null; - $_SESSION['userconfig'] = array(); + $_SESSION['userconfig'] = []; $_SESSION['userconfig']['ts'] = "123"; - $_SESSION['userconfig']['db'] = array( + $_SESSION['userconfig']['db'] = [ 'Server/hide_db' => true, 'Server/only_db' => true, - ); + ]; $GLOBALS['server'] = 2; $_SESSION['relation'][2]['userconfigwork'] = null; @@ -372,7 +372,7 @@ class UserPreferencesTest extends PmaTestCase $this->userPreferences->redirect( 'file.html', - array('a' => 'b'), + ['a' => 'b'], 'h ash' ); } diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php index 4f91c5ea99..08d3e806a0 100644 --- a/test/classes/UtilTest.php +++ b/test/classes/UtilTest.php @@ -129,11 +129,11 @@ class UtilTest extends PmaTestCase */ public function charsetQueryData() { - return array( - array("a_b_c_d", " CHARSET=a COLLATE a_b_c_d"), - array("a_", " CHARSET=a COLLATE a_"), - array("a", " CHARSET=a"), - ); + return [ + ["a_b_c_d", " CHARSET=a COLLATE a_b_c_d"], + ["a_", " CHARSET=a COLLATE a_"], + ["a", " CHARSET=a"], + ]; } /** @@ -182,15 +182,15 @@ class UtilTest extends PmaTestCase */ public function providerGetBrowseUploadFileBlock() { - return array( - array(10, __('B'), "10"), - array(100, __('B'), "100"), - array(1024, __('B'), "1,024"), - array(102400, __('KiB'), "100"), - array(10240000, __('MiB'), "10"), - array(2147483648, __('MiB'), "2,048"), - array(21474836480, __('GiB'), "20") - ); + return [ + [10, __('B'), "10"], + [100, __('B'), "100"], + [1024, __('B'), "1,024"], + [102400, __('KiB'), "100"], + [10240000, __('MiB'), "10"], + [2147483648, __('MiB'), "2,048"], + [21474836480, __('GiB'), "20"] + ]; } /** @@ -202,9 +202,9 @@ class UtilTest extends PmaTestCase */ function testBuildActionTitles() { - $GLOBALS['cfg'] = array('ActionLinksMode' => 'both'); + $GLOBALS['cfg'] = ['ActionLinksMode' => 'both']; - $titles = array(); + $titles = []; $titles['Browse'] = Util::getIcon('b_browse', __('Browse')); $titles['NoBrowse'] = Util::getIcon('bd_browse', __('Browse')); $titles['Search'] = Util::getIcon('b_select', __('Search')); @@ -352,7 +352,7 @@ class UtilTest extends PmaTestCase $this->expectOutputRegex("/Missing parameter: field/"); Util::checkParameters( - array('db', 'table', 'field') + ['db', 'table', 'field'] ); } @@ -366,7 +366,7 @@ class UtilTest extends PmaTestCase function testCheckParameter() { $GLOBALS['PMA_Config'] = new Config(); - $GLOBALS['cfg'] = array('ServerDefault' => 1); + $GLOBALS['cfg'] = ['ServerDefault' => 1]; $GLOBALS['text_dir'] = 'ltr'; $GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); $GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath(); @@ -377,7 +377,7 @@ class UtilTest extends PmaTestCase $this->expectOutputString(""); Util::checkParameters( - array('db', 'table', 'field', 'sql_query') + ['db', 'table', 'field', 'sql_query'] ); } @@ -406,13 +406,13 @@ class UtilTest extends PmaTestCase */ public function providerContainsNonPrintableAscii() { - return array( - array("normal string", 0), - array("new\nline", 1), - array("tab\tspace", 1), - array("escape" . chr(27) . "char", 1), - array("chars%$\r\n", 1), - ); + return [ + ["normal string", 0], + ["new\nline", 1], + ["tab\tspace", 1], + ["escape" . chr(27) . "char", 1], + ["chars%$\r\n", 1], + ]; } /** @@ -440,11 +440,11 @@ class UtilTest extends PmaTestCase */ public function providerConvertBitDefaultValue() { - return array( - array("b'",""), - array("b'01'","01"), - array("b'010111010'","010111010") - ); + return [ + ["b'",""], + ["b'01'","01"], + ["b'010111010'","010111010"] + ]; } /** @@ -454,16 +454,16 @@ class UtilTest extends PmaTestCase */ public function providerUnEscapeMysqlWildcards() { - return array( - array('\_test', '_test'), - array('\_\\', '_\\'), - array('\\_\%', '_%'), - array('\\\_', '\_'), - array('\\\_\\\%', '\_\%'), - array('\_\\%\_\_\%', '_%__%'), - array('\%\_', '%_'), - array('\\\%\\\_', '\%\_') - ); + return [ + ['\_test', '_test'], + ['\_\\', '_\\'], + ['\\_\%', '_%'], + ['\\\_', '\_'], + ['\\\_\\\%', '\_\%'], + ['\_\\%\_\_\%', '_%__%'], + ['\%\_', '%_'], + ['\\\%\\\_', '\%\_'] + ]; } /** @@ -517,12 +517,12 @@ class UtilTest extends PmaTestCase { $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); - $GLOBALS['cfg'] = array( - 'Server' => array( + $GLOBALS['cfg'] = [ + 'Server' => [ 'host' => 'host&', 'verbose' => 'verbose', - ) - ); + ] + ]; $GLOBALS['db'] = 'database'; $GLOBALS['table'] = 'table'; @@ -547,14 +547,14 @@ class UtilTest extends PmaTestCase */ public function providerExpandUserString() { - return array( - array('@SERVER@', 'host&'), - array('@VSERVER@', 'verbose'), - array('@DATABASE@', 'database'), - array('@TABLE@', 'table'), - array('@IGNORE@', '@IGNORE@'), - array('@PHPMYADMIN@', 'phpMyAdmin PMA_VERSION'), - ); + return [ + ['@SERVER@', 'host&'], + ['@VSERVER@', 'verbose'], + ['@DATABASE@', 'database'], + ['@TABLE@', 'table'], + ['@IGNORE@', '@IGNORE@'], + ['@PHPMYADMIN@', 'phpMyAdmin PMA_VERSION'], + ]; } /** @@ -584,113 +584,113 @@ class UtilTest extends PmaTestCase */ public function providerExtractColumnSpec() { - return array( - array( + return [ + [ "SET('a','b')", - array( + [ 'type' => 'set', 'print_type' => "set('a', 'b')", 'binary' => false, 'unsigned' => false, 'zerofill' => false, 'spec_in_brackets' => "'a','b'", - 'enum_set_values' => array('a', 'b'), + 'enum_set_values' => ['a', 'b'], 'attribute' => ' ', 'can_contain_collation' => true, 'displayed_type' => "set('a', 'b')" - ), - ), - array( + ], + ], + [ "SET('\'a','b')", - array( + [ 'type' => 'set', 'print_type' => "set('\'a', 'b')", 'binary' => false, 'unsigned' => false, 'zerofill' => false, 'spec_in_brackets' => "'\'a','b'", - 'enum_set_values' => array("'a", 'b'), + 'enum_set_values' => ["'a", 'b'], 'attribute' => ' ', 'can_contain_collation' => true, 'displayed_type' => "set('\'a', 'b')" - ), - ), - array( + ], + ], + [ "SET('''a','b')", - array( + [ 'type' => 'set', 'print_type' => "set('''a', 'b')", 'binary' => false, 'unsigned' => false, 'zerofill' => false, 'spec_in_brackets' => "'''a','b'", - 'enum_set_values' => array("'a", 'b'), + 'enum_set_values' => ["'a", 'b'], 'attribute' => ' ', 'can_contain_collation' => true, 'displayed_type' => "set('''a', 'b')" - ), - ), - array( + ], + ], + [ "ENUM('a&b', 'b''c\\'d', 'e\\\\f')", - array( + [ 'type' => 'enum', 'print_type' => "enum('a&b', 'b''c\\'d', 'e\\\\f')", 'binary' => false, 'unsigned' => false, 'zerofill' => false, 'spec_in_brackets' => "'a&b', 'b''c\\'d', 'e\\\\f'", - 'enum_set_values' => array('a&b', 'b\'c\'d', 'e\\f'), + 'enum_set_values' => ['a&b', 'b\'c\'d', 'e\\f'], 'attribute' => ' ', 'can_contain_collation' => true, 'displayed_type' => "enum('a&b', 'b''c\\'d', 'e\\\\f')" - ), - ), - array( + ], + ], + [ "INT UNSIGNED zerofill", - array( + [ 'type' => 'int', 'print_type' => 'int', 'binary' => false, 'unsigned' => true, 'zerofill' => true, 'spec_in_brackets' => '', - 'enum_set_values' => array(), + 'enum_set_values' => [], 'attribute' => 'UNSIGNED ZEROFILL', 'can_contain_collation' => false, 'displayed_type' => "int" - ), - ), - array( + ], + ], + [ "VARCHAR(255)", - array( + [ 'type' => 'varchar', 'print_type' => 'varchar(255)', 'binary' => false, 'unsigned' => false, 'zerofill' => false, 'spec_in_brackets' => '255', - 'enum_set_values' => array(), + 'enum_set_values' => [], 'attribute' => ' ', 'can_contain_collation' => true, 'displayed_type' => "varchar(255)" - ), - ), - array( + ], + ], + [ "VARBINARY(255)", - array( + [ 'type' => 'varbinary', 'print_type' => 'varbinary(255)', 'binary' => false, 'unsigned' => false, 'zerofill' => false, 'spec_in_brackets' => '255', - 'enum_set_values' => array(), + 'enum_set_values' => [], 'attribute' => ' ', 'can_contain_collation' => false, 'displayed_type' => "varbinary(255)" - ), - ), - ); + ], + ], + ]; } /** @@ -719,12 +719,12 @@ class UtilTest extends PmaTestCase */ public function providerExtractValueFromFormattedSize() { - return array( - array(100, -1), - array("10GB", 10737418240), - array("15MB", 15728640), - array("256K", 262144) - ); + return [ + [100, -1], + ["10GB", 10737418240], + ["15MB", 15728640], + ["256K", 262144] + ]; } /** @@ -754,12 +754,12 @@ class UtilTest extends PmaTestCase */ public function providerIsForeignKeySupported() { - return array( - array('MyISAM', false), - array('innodb', true), - array('pBxT', true), - array('ndb', true) - ); + return [ + ['MyISAM', false], + ['innodb', true], + ['pBxT', true], + ['ndb', true] + ]; } /** @@ -815,17 +815,17 @@ class UtilTest extends PmaTestCase */ public function providerFormatByteDown() { - return array( - array(10, 2, 2, array('10', __('B'))), - array(100, 2, 0, array('0', __('KiB'))), - array(100, 3, 0, array('100', __('B'))), - array(100, 2, 2, array('0.10', __('KiB'))), - array(1034, 3, 2, array('1.01', __('KiB'))), - array(100233, 3, 3, array('97.884', __('KiB'))), - array(2206451, 1, 2, array('2.10', __('MiB'))), - array(21474836480, 4, 0, array('20', __('GiB'))), - array(doubleval(52) + doubleval(2048), 3, 1, array('2.1', 'KiB')), - ); + return [ + [10, 2, 2, ['10', __('B')]], + [100, 2, 0, ['0', __('KiB')]], + [100, 3, 0, ['100', __('B')]], + [100, 2, 2, ['0.10', __('KiB')]], + [1034, 3, 2, ['1.01', __('KiB')]], + [100233, 3, 3, ['97.884', __('KiB')]], + [2206451, 1, 2, ['2.10', __('MiB')]], + [21474836480, 4, 0, ['20', __('GiB')]], + [doubleval(52) + doubleval(2048), 3, 1, ['2.1', 'KiB']], + ]; } /** @@ -911,23 +911,23 @@ class UtilTest extends PmaTestCase */ public function providerFormatNumber() { - return array( - array(10, 2, 2, '10 '), - array(100, 2, 0, '100 '), - array(100, 2, 2, '100 '), - array(-1000.454, 4, 2, '-1,000.45 '), - array(0.00003, 3, 2, '30 µ'), - array(0.003, 3, 3, '3 m'), - array(-0.003, 6, 0, '-3,000 µ'), - array(100.98, 0, 2, '100.98'), - array(21010101, 0, 2, '21,010,101.00'), - array(1100000000, 5, 0, '1,100 M'), - array(20000, 2, 2, '20 k'), - array(20011, 2, 2, '20.01 k'), - array(123456789, 6, 0, '123,457 k'), - array(-123456789, 4, 2, '-123.46 M'), - array(0, 6, 0, '0') - ); + return [ + [10, 2, 2, '10 '], + [100, 2, 0, '100 '], + [100, 2, 2, '100 '], + [-1000.454, 4, 2, '-1,000.45 '], + [0.00003, 3, 2, '30 µ'], + [0.003, 3, 3, '3 m'], + [-0.003, 6, 0, '-3,000 µ'], + [100.98, 0, 2, '100.98'], + [21010101, 0, 2, '21,010,101.00'], + [1100000000, 5, 0, '1,100 M'], + [20000, 2, 2, '20 k'], + [20011, 2, 2, '20.01 k'], + [123456789, 6, 0, '123,457 k'], + [-123456789, 4, 2, '-123.46 M'], + [0, 6, 0, '0'] + ]; } /** @@ -955,14 +955,14 @@ class UtilTest extends PmaTestCase */ public function providerGenerateHiddenMaxFileSize() { - return array( - array(10), - array("100"), - array(1024), - array("1024Mb"), - array(2147483648), - array("some_string") - ); + return [ + [10], + ["100"], + [1024], + ["1024Mb"], + [2147483648], + ["some_string"] + ]; } /** @@ -1133,7 +1133,7 @@ class UtilTest extends PmaTestCase public function testGetDropdownEmpty() { $name = "test_dropdown_name"; - $choices = array(); + $choices = []; $active_choice = null; $id = "test_<dropdown>_name"; @@ -1158,7 +1158,7 @@ class UtilTest extends PmaTestCase public function testGetDropdown() { $name = "&test_dropdown_name"; - $choices = array("value_1" => "label_1", "value&_2\"" => "label_2"); + $choices = ["value_1" => "label_1", "value&_2\"" => "label_2"]; $active_choice = null; $id = "test_<dropdown>_name"; @@ -1191,7 +1191,7 @@ class UtilTest extends PmaTestCase public function testGetDropdownWithActive() { $name = "&test_dropdown_name"; - $choices = array("value_1" => "label_1", "value&_2\"" => "label_2"); + $choices = ["value_1" => "label_1", "value&_2\"" => "label_2"]; $active_choice = "value&_2\""; $id = "test_<dropdown>_name"; @@ -1243,15 +1243,15 @@ class UtilTest extends PmaTestCase */ public function providerGetFormattedMaximumUploadSize() { - return array( - array(10, __('B'), "10"), - array(100, __('B'), "100"), - array(1024, __('B'), "1,024"), - array(102400, __('KiB'), "100"), - array(10240000, __('MiB'), "10"), - array(2147483648, __('MiB'), "2,048"), - array(21474836480, __('GiB'), "20") - ); + return [ + [10, __('B'), "10"], + [100, __('B'), "100"], + [1024, __('B'), "1,024"], + [102400, __('KiB'), "100"], + [10240000, __('MiB'), "10"], + [2147483648, __('MiB'), "2,048"], + [21474836480, __('GiB'), "20"] + ]; } /** @@ -1340,7 +1340,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFieldsEmpty() { $name = "test_display_radio"; - $choices = array(); + $choices = []; $this->assertEquals( Util::getRadioFields($name, $choices), @@ -1358,7 +1358,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFields() { $name = "test_display_radio"; - $choices = array('value_1'=>'choice_1', 'value_2'=>'choice_2'); + $choices = ['value_1'=>'choice_1', 'value_2'=>'choice_2']; $out = ""; foreach ($choices as $choice_value => $choice_label) { @@ -1389,7 +1389,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFieldsWithChecked() { $name = "test_display_radio"; - $choices = array('value_1'=>'choice_1', 'value_2'=>'choice_2'); + $choices = ['value_1'=>'choice_1', 'value_2'=>'choice_2']; $checked_choice = "value_2"; $out = ""; @@ -1426,7 +1426,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFieldsWithCheckedWithClass() { $name = "test_display_radio"; - $choices = array('value_1'=>'choice_1', 'value_2'=>'choice_2'); + $choices = ['value_1'=>'choice_1', 'value_2'=>'choice_2']; $checked_choice = "value_2"; $class = "test_class"; @@ -1468,7 +1468,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFieldsWithoutBR() { $name = "test_display_radio"; - $choices = array('value_1'=>'choice_1', 'value&_<2>'=>'choice_2'); + $choices = ['value_1'=>'choice_1', 'value&_<2>'=>'choice_2']; $checked_choice = "choice_2"; $out = ""; @@ -1503,7 +1503,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFieldsEscapeLabelEscapeLabel() { $name = "test_display_radio"; - $choices = array('value_1'=>'choice_1', 'value_&2'=>'choice&_<2>'); + $choices = ['value_1'=>'choice_1', 'value_&2'=>'choice&_<2>']; $checked_choice = "value_2"; $out = ""; @@ -1540,7 +1540,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFieldsEscapeLabelNotEscapeLabel() { $name = "test_display_radio"; - $choices = array('value_1'=>'choice_1', 'value_&2'=>'choice&_<2>'); + $choices = ['value_1'=>'choice_1', 'value_&2'=>'choice&_<2>']; $checked_choice = "value_2"; $out = ""; @@ -1577,7 +1577,7 @@ class UtilTest extends PmaTestCase public function testGetRadioFieldsEscapeLabelEscapeLabelWithClass() { $name = "test_display_radio"; - $choices = array('value_1'=>'choice_1', 'value_&2'=>'choice&_<2>'); + $choices = ['value_1'=>'choice_1', 'value_&2'=>'choice&_<2>']; $checked_choice = "value_2"; $class = "test_class"; @@ -1634,17 +1634,17 @@ class UtilTest extends PmaTestCase */ public function providerGetTitleForTarget() { - return array( - array('tbl_structure.php', __('Structure')), - array('tbl_sql.php', __('SQL'),), - array('tbl_select.php', __('Search'),), - array('tbl_change.php', __('Insert')), - array('sql.php', __('Browse')), - array('db_structure.php', __('Structure')), - array('db_sql.php', __('SQL')), - array('db_search.php', __('Search')), - array('db_operations.php', __('Operations')), - ); + return [ + ['tbl_structure.php', __('Structure')], + ['tbl_sql.php', __('SQL'),], + ['tbl_select.php', __('Search'),], + ['tbl_change.php', __('Insert')], + ['sql.php', __('Browse')], + ['db_structure.php', __('Structure')], + ['db_sql.php', __('SQL')], + ['db_search.php', __('Search')], + ['db_operations.php', __('Operations')], + ]; } /** @@ -1678,10 +1678,10 @@ class UtilTest extends PmaTestCase */ public function providerLocalisedDate() { - return array( - array(1227455558, '', 'Nov 23, 2008 at 03:52 PM'), - array(1227455558, '%Y-%m-%d %H:%M:%S %a', '2008-11-23 15:52:38 Sun') - ); + return [ + [1227455558, '', 'Nov 23, 2008 at 03:52 PM'], + [1227455558, '%Y-%m-%d %H:%M:%S %a', '2008-11-23 15:52:38 Sun'] + ]; } /** @@ -1715,10 +1715,10 @@ class UtilTest extends PmaTestCase */ public function providerTimespanFormat() { - return array( - array(1258, '0 days, 0 hours, 20 minutes and 58 seconds'), - array(821958, '9 days, 12 hours, 19 minutes and 18 seconds') - ); + return [ + [1258, '0 days, 0 hours, 20 minutes and 58 seconds'], + [821958, '9 days, 12 hours, 19 minutes and 18 seconds'] + ]; } /** @@ -1747,14 +1747,14 @@ class UtilTest extends PmaTestCase */ public function providerPrintableBitValue() { - return array( - array( + return [ + [ '20131009', 64, '0000000000000000000000000000000000000001001100110010110011000001' - ), - array('5', 32, '00000000000000000000000000000101') - ); + ], + ['5', 32, '00000000000000000000000000000101'] + ]; } /** @@ -1782,12 +1782,12 @@ class UtilTest extends PmaTestCase */ public function providerUnQuote() { - return array( - array('"test\'"', "test'"), - array("'test''", "test'"), - array("`test'`", "test'"), - array("'test'test", "'test'test") - ); + return [ + ['"test\'"', "test'"], + ["'test''", "test'"], + ["`test'`", "test'"], + ["'test'test", "'test'test"] + ]; } /** @@ -1815,12 +1815,12 @@ class UtilTest extends PmaTestCase */ public function providerUnQuoteSelectedChar() { - return array( - array('"test\'"', "test'"), - array("'test''", "'test''"), - array("`test'`", "`test'`"), - array("'test'test", "'test'test") - ); + return [ + ['"test\'"', "test'"], + ["'test''", "'test''"], + ["`test'`", "`test'`"], + ["'test'test", "'test'test"] + ]; } /** @@ -1850,15 +1850,15 @@ class UtilTest extends PmaTestCase */ public function providerBackquote() { - return array( - array('0', '`0`'), - array('test', '`test`'), - array('te`st', '`te``st`'), - array( - array('test', 'te`st', '', '*'), - array('`test`', '`te``st`', '', '*') - ) - ); + return [ + ['0', '`0`'], + ['test', '`test`'], + ['te`st', '`te``st`'], + [ + ['test', 'te`st', '', '*'], + ['`test`', '`te``st`', '', '*'] + ] + ]; } /** @@ -1892,15 +1892,15 @@ class UtilTest extends PmaTestCase */ public function providerBackquoteCompat() { - return array( - array('0', '"0"'), - array('test', '"test"'), - array('te`st', '"te`st"'), - array( - array('test', 'te`st', '', '*'), - array('"test"', '"te`st"', '', '*') - ) - ); + return [ + ['0', '"0"'], + ['test', '"test"'], + ['te`st', '"te`st"'], + [ + ['test', 'te`st', '', '*'], + ['"test"', '"te`st"', '', '*'] + ] + ]; } /** @@ -1994,10 +1994,10 @@ class UtilTest extends PmaTestCase */ public function providerUserDir() { - return array( - array('/var/pma_tmp/%u/', "/var/pma_tmp/root/"), - array('/home/%u/pma', "/home/root/pma/") - ); + return [ + ['/var/pma_tmp/%u/', "/var/pma_tmp/root/"], + ['/home/%u/pma', "/home/root/pma/"] + ]; } /** @@ -2025,12 +2025,12 @@ class UtilTest extends PmaTestCase */ public function providerDuplicateFirstNewline() { - return array( - array('test', 'test'), - array("\r\ntest", "\n\r\ntest"), - array("\ntest", "\ntest"), - array("\n\r\ntest", "\n\r\ntest") - ); + return [ + ['test', 'test'], + ["\r\ntest", "\n\r\ntest"], + ["\ntest", "\ntest"], + ["\n\r\ntest", "\n\r\ntest"] + ]; } /** @@ -2042,7 +2042,7 @@ class UtilTest extends PmaTestCase */ function testUnsupportedDatatypes() { - $no_support_types = array(); + $no_support_types = []; $this->assertEquals( $no_support_types, Util::unsupportedDatatypes() ); @@ -2065,7 +2065,7 @@ class UtilTest extends PmaTestCase $GLOBALS['cfg']['LinkLengthLimit'] = $limit; try { $result = call_user_func_array( - array('PhpMyAdmin\Util', 'linkOrButton'), + ['PhpMyAdmin\Util', 'linkOrButton'], $params ); $this->assertEquals($match, $result); diff --git a/test/classes/Utils/HttpRequestTest.php b/test/classes/Utils/HttpRequestTest.php index 1623d8e8b7..e114a2be4e 100644 --- a/test/classes/Utils/HttpRequestTest.php +++ b/test/classes/Utils/HttpRequestTest.php @@ -241,12 +241,12 @@ class HttpRequestTest extends PmaTestCase */ public function httpRequests() { - return array( - array("https://www.phpmyadmin.net/test/data", "GET", true, true), - array("https://www.phpmyadmin.net/test/data", "POST", true, null), - array("https://nonexisting.phpmyadmin.net/test/data", "GET", true, null), - array("https://www.phpmyadmin.net/test/data","GET", false, "TEST DATA"), - array("https://www.phpmyadmin.net/test/nothing","GET", true, false), - ); + return [ + ["https://www.phpmyadmin.net/test/data", "GET", true, true], + ["https://www.phpmyadmin.net/test/data", "POST", true, null], + ["https://nonexisting.phpmyadmin.net/test/data", "GET", true, null], + ["https://www.phpmyadmin.net/test/data","GET", false, "TEST DATA"], + ["https://www.phpmyadmin.net/test/nothing","GET", true, false], + ]; } } diff --git a/test/classes/VersionInformationTest.php b/test/classes/VersionInformationTest.php index e807f51697..aea6c86615 100644 --- a/test/classes/VersionInformationTest.php +++ b/test/classes/VersionInformationTest.php @@ -30,7 +30,7 @@ class VersionInformationTest extends PmaTestCase */ protected function setUp() { - $this->_releases = array(); + $this->_releases = []; $release = new stdClass(); $release->date = "2015-09-08"; @@ -101,27 +101,27 @@ class VersionInformationTest extends PmaTestCase */ public function dataVersions() { - return array( - array('1.0.0', 1000050), - array('2.0.0.2-dev', 2000002), - array('3.4.2.1', 3040251), - array('3.4.2-dev3', 3040203), - array('3.4.2-dev', 3040200), - array('3.4.2-pl', 3040260), - array('3.4.2-pl3', 3040263), - array('4.4.2-rc22', 4040252), - array('4.4.2-rc', 4040230), - array('4.4.22-beta22', 4042242), - array('4.4.22-beta', 4042220), - array('4.4.21-alpha22', 4042132), - array('4.4.20-alpha', 4042010), - array('4.40.20-alpha-dev', 4402010), - array('4.4a', 4000050), - array('4.4.4-test', 4040400), - array('4.1.0', 4010050), - array('4.0.1.3', 4000153), - array('4.1-dev', 4010000), - ); + return [ + ['1.0.0', 1000050], + ['2.0.0.2-dev', 2000002], + ['3.4.2.1', 3040251], + ['3.4.2-dev3', 3040203], + ['3.4.2-dev', 3040200], + ['3.4.2-pl', 3040260], + ['3.4.2-pl3', 3040263], + ['4.4.2-rc22', 4040252], + ['4.4.2-rc', 4040230], + ['4.4.22-beta22', 4042242], + ['4.4.22-beta', 4042220], + ['4.4.21-alpha22', 4042132], + ['4.4.20-alpha', 4042010], + ['4.40.20-alpha-dev', 4402010], + ['4.4a', 4000050], + ['4.4.4-test', 4040400], + ['4.1.0', 4010050], + ['4.0.1.3', 4000153], + ['4.1-dev', 4010000], + ]; } /** @@ -131,12 +131,12 @@ class VersionInformationTest extends PmaTestCase */ public function testGetLatestCompatibleVersionWithSingleServer() { - $GLOBALS['cfg']['Servers'] = array( - array() - ); + $GLOBALS['cfg']['Servers'] = [ + [] + ]; $mockVersionInfo = $this->getMockBuilder('PhpMyAdmin\VersionInformation') - ->setMethods(array('evaluateVersionCondition')) + ->setMethods(['evaluateVersionCondition']) ->getMock(); $mockVersionInfo->expects($this->at(0)) @@ -167,13 +167,13 @@ class VersionInformationTest extends PmaTestCase */ public function testGetLaestCompatibleVersionWithMultipleServers() { - $GLOBALS['cfg']['Servers'] = array( - array(), - array() - ); + $GLOBALS['cfg']['Servers'] = [ + [], + [] + ]; $mockVersionInfo = $this->getMockBuilder('PhpMyAdmin\VersionInformation') - ->setMethods(array('evaluateVersionCondition')) + ->setMethods(['evaluateVersionCondition']) ->getMock(); $mockVersionInfo->expects($this->at(0)) @@ -198,13 +198,13 @@ class VersionInformationTest extends PmaTestCase */ public function testGetLaestCompatibleVersionWithOldPHPVersion() { - $GLOBALS['cfg']['Servers'] = array( - array(), - array() - ); + $GLOBALS['cfg']['Servers'] = [ + [], + [] + ]; $mockVersionInfo = $this->getMockBuilder('PhpMyAdmin\VersionInformation') - ->setMethods(array('evaluateVersionCondition')) + ->setMethods(['evaluateVersionCondition']) ->getMock(); $mockVersionInfo->expects($this->at(0)) @@ -240,7 +240,7 @@ class VersionInformationTest extends PmaTestCase public function testEvaluateVersionCondition() { $mockVersionInfo = $this->getMockBuilder('PhpMyAdmin\VersionInformation') - ->setMethods(array('getPHPVersion')) + ->setMethods(['getPHPVersion']) ->getMock(); $mockVersionInfo->expects($this->any()) diff --git a/test/classes/ZipExtensionTest.php b/test/classes/ZipExtensionTest.php index afc6d47c8d..2b10188561 100644 --- a/test/classes/ZipExtensionTest.php +++ b/test/classes/ZipExtensionTest.php @@ -57,24 +57,24 @@ class ZipExtensionTest extends PmaTestCase */ public function provideTestGetContents() { - return array( - array( + return [ + [ './test/test_data/test.zip', null, - array( + [ 'error' => '', 'data' => 'TEST FILE' . "\n" - ) - ), - array( + ] + ], + [ './test/test_data/test.zip', 'test', - array( + [ 'error' => 'Error in ZIP archive: Could not find "test"', 'data' => '' - ) - ) - ); + ] + ] + ]; } /** @@ -102,13 +102,13 @@ class ZipExtensionTest extends PmaTestCase */ public function provideTestFindFile() { - return array( - array( + return [ + [ './test/test_data/test.zip', '/test/', 'test.file' - ) - ); + ] + ]; } /** @@ -195,7 +195,7 @@ class ZipExtensionTest extends PmaTestCase false, $this->zipExtension->createFile( "Content", - array("name1.txt", "name2.txt") + ["name1.txt", "name2.txt"] ) ); } @@ -208,8 +208,8 @@ class ZipExtensionTest extends PmaTestCase public function testCreateMultiFile() { $file = $this->zipExtension->createFile( - array("Content", 'Content2'), - array("name1.txt", "name2.txt") + ["Content", 'Content2'], + ["name1.txt", "name2.txt"] ); $this->assertNotEmpty($file); $zip = $this->getZip($file); diff --git a/test/libraries/FilesTest.php b/test/libraries/FilesTest.php index bf08ef21da..71fdab648f 100644 --- a/test/libraries/FilesTest.php +++ b/test/libraries/FilesTest.php @@ -31,14 +31,14 @@ class FilesTest extends TestCase public function testDynamicJs($name, $expected) { $GLOBALS['pmaThemeImage'] = ''; - $GLOBALS['goto_whitelist'] = array('x'); + $GLOBALS['goto_whitelist'] = ['x']; $_GET['scripts'] = '["ajax.js"]'; - $cfg = array( + $cfg = [ 'AllowUserDropDatabase' => true, 'GridEditing' => 'click', 'OBGzip' => false, 'ServerDefault' => 1, - ); + ]; $GLOBALS['cfg'] = $cfg; require $name; $buffer->stop(); @@ -53,9 +53,9 @@ class FilesTest extends TestCase */ public function listScripts() { - return array( - array('js/whitelist.php', 'var PMA_gotoWhitelist'), - array('js/messages.php', 'var PMA_messages = new Array();'), - ); + return [ + ['js/whitelist.php', 'var PMA_gotoWhitelist'], + ['js/messages.php', 'var PMA_messages = new Array();'], + ]; } } diff --git a/test/libraries/common/GetCheckboxTest.php b/test/libraries/common/GetCheckboxTest.php index 5e67f6ad5b..669584ac3d 100644 --- a/test/libraries/common/GetCheckboxTest.php +++ b/test/libraries/common/GetCheckboxTest.php @@ -36,13 +36,13 @@ class GetCheckboxTest extends TestCase $this->assertXmlStringEqualsXmlString( '<root> ' . Template::get('checkbox') ->render( - array( + [ 'html_field_name' => $name, 'label' => $label, 'checked' => false, 'onclick' => false, 'html_field_id' => $name, - ) + ] ) . ' </root>', '<root> <input type="checkbox" name="' . $name . '" id="' . $name . '" /><label for="' . $name . '">' . $label @@ -63,13 +63,13 @@ class GetCheckboxTest extends TestCase $this->assertXmlStringEqualsXmlString( '<root>' . Template::get('checkbox') ->render( - array( + [ 'html_field_name' => $name, 'label' => $label, 'checked' => true, 'onclick' => false, 'html_field_id' => $name, - ) + ] ) . '</root>', '<root> <input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" /><label for="' . $name . '">' . $label @@ -90,13 +90,13 @@ class GetCheckboxTest extends TestCase $this->assertXmlStringEqualsXmlString( '<root>' . Template::get('checkbox') ->render( - array( + [ 'html_field_name' => $name, 'label' => $label, 'checked' => false, 'onclick' => true, 'html_field_id' => $name, - ) + ] ) . '</root>', '<root> <input type="checkbox" name="' . $name . '" id="' . $name . '" class="autosubmit" /><label for="' . $name . '">' . $label @@ -117,13 +117,13 @@ class GetCheckboxTest extends TestCase $this->assertXmlStringEqualsXmlString( '<root>' . Template::get('checkbox') ->render( - array( + [ 'html_field_name' => $name, 'label' => $label, 'checked' => true, 'onclick' => true, 'html_field_id' => $name, - ) + ] ) . '</root>', '<root> <input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" class="autosubmit" /><label for="' . $name diff --git a/test/selenium/ExportTest.php b/test/selenium/ExportTest.php index 31e64578a4..1bfc8ea1d0 100644 --- a/test/selenium/ExportTest.php +++ b/test/selenium/ExportTest.php @@ -125,24 +125,24 @@ class ExportTest extends TestBase */ public function exportDataProvider() { - return array( - array( + return [ + [ 'CSV', - array('"1","2"') - ), - array( + ['"1","2"'] + ], + [ 'SQL', - array( + [ "CREATE TABLE IF NOT EXISTS `test_table`", "INSERT INTO `test_table` (`id`, `val`) VALUES", "(1, 2)", - ) - ), - array( + ] + ], + [ 'JSON', - array('{"id":"1","val":"2"}') - ) - ); + ['{"id":"1","val":"2"}'] + ] + ]; } /** diff --git a/test/selenium/TableCreateTest.php b/test/selenium/TableCreateTest.php index 33587bbed5..2e947ddb90 100644 --- a/test/selenium/TableCreateTest.php +++ b/test/selenium/TableCreateTest.php @@ -66,25 +66,25 @@ class TableCreateTest extends TestBase $this->waitForElement('byXPath', '//button[contains(text(), \'Go\')]')->click(); // column details - $column_text_details = array( + $column_text_details = [ "field_0_1" => "test_id", "field_0_3" => "14", "field_0_10" => "comm1", "field_1_1" => "test_column", "field_1_3" => "10", "field_1_10" => "comm2", - ); + ]; foreach ($column_text_details as $field => $val) { $this->byId($field)->value($val); } - $column_dropdown_details = array( + $column_dropdown_details = [ "field_0_6" => "UNSIGNED", "field_1_2" => "VARCHAR", "field_1_5" => "utf8_general_ci", "field_1_4" => "As defined:" - ); + ]; foreach ($column_dropdown_details as $selector => $value) { $this->waitForElement( diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php index 9fc95db956..feb194ef6a 100644 --- a/test/selenium/TestBase.php +++ b/test/selenium/TestBase.php @@ -80,13 +80,13 @@ abstract class TestBase extends Selenium2TestCase $project_name = 'phpMyAdmin (Travis)'; } - $capabilities = array( + $capabilities = [ 'browserstack.user' => $GLOBALS['TESTSUITE_BROWSERSTACK_USER'], 'browserstack.key' => $GLOBALS['TESTSUITE_BROWSERSTACK_KEY'], 'browserstack.debug' => false, 'project' => $project_name, 'build' => $build_id, - ); + ]; if ($build_local) { $capabilities['browserstack.local'] = $build_local; @@ -94,8 +94,8 @@ abstract class TestBase extends Selenium2TestCase $capabilities['browserstack.debug'] = true; } - $result = array(); - $result[] = array( + $result = []; + $result[] = [ 'browserName' => 'chrome', 'host' => 'hub.browserstack.com', 'port' => 80, @@ -103,11 +103,11 @@ abstract class TestBase extends Selenium2TestCase 'sessionStrategy' => $strategy, 'desiredCapabilities' => array_merge( $capabilities, - array( + [ 'os' => 'Windows', - ) + ] ) - ); + ]; /* Only one browser for continuous integration for speed */ if (empty($GLOBALS['TESTSUITE_FULL'])) { @@ -130,14 +130,14 @@ abstract class TestBase extends Selenium2TestCase ) ); */ - $result[] = array( + $result[] = [ 'browserName' => 'firefox', 'host' => 'hub.browserstack.com', 'port' => 80, 'timeout' => 30000, 'sessionStrategy' => $strategy, 'desiredCapabilities' => $capabilities, - ); + ]; /* TODO: testing is MSIE is currently broken, so disabled $result[] = array( 'browserName' => 'internet explorer', @@ -157,15 +157,15 @@ abstract class TestBase extends Selenium2TestCase return $result; } elseif (! empty($GLOBALS['TESTSUITE_SELENIUM_HOST'])) { self::$_selenium_enabled = true; - return array( - array( + return [ + [ 'browserName' => $GLOBALS['TESTSUITE_SELENIUM_BROWSER'], 'host' => $GLOBALS['TESTSUITE_SELENIUM_HOST'], 'port' => intval($GLOBALS['TESTSUITE_SELENIUM_PORT']), - ) - ); + ] + ]; } else { - return array(); + return []; } } @@ -186,7 +186,7 @@ abstract class TestBase extends Selenium2TestCase $this->setDesiredCapabilities( array_merge( $caps, - array('name' => get_class($this) . '__' . $this->getName()) + ['name' => get_class($this) . '__' . $this->getName()] ) ); @@ -392,14 +392,14 @@ abstract class TestBase extends Selenium2TestCase { try { return call_user_func_array( - array($this, $func), array($arg) + [$this, $func], [$arg] ); } catch(\Exception $e) { // Element not present, fall back to waiting } $this->timeouts()->implicitWait(10000); $element = call_user_func_array( - array($this, $func), array($arg) + [$this, $func], [$arg] ); $this->timeouts()->implicitWait(0); return $element; @@ -435,7 +435,7 @@ abstract class TestBase extends Selenium2TestCase { try { $element = call_user_func_array( - array($this, $func), array($arg) + [$this, $func], [$arg] ); } catch (WebDriverException $e) { // Element not present @@ -560,10 +560,10 @@ abstract class TestBase extends Selenium2TestCase { $this->waitForElement('byCssSelector', 'div.cm-s-default'); $this->execute( - array( + [ 'script' => "$('.cm-s-default')[$index].CodeMirror.setValue('" . $text . "');", - 'args' => array() - ) + 'args' => [] + ] ); } @@ -661,12 +661,12 @@ abstract class TestBase extends Selenium2TestCase { // 70pt offset by-default so that the topmenu does not cover the element $this->execute( - array( + [ 'script' => 'var position = document.getElementById("' . $element_id . '").getBoundingClientRect();' . 'window.scrollBy(0, position.top-(' . $offset . '));', - 'args' => array() - ) + 'args' => [] + ] ); } @@ -678,10 +678,10 @@ abstract class TestBase extends Selenium2TestCase public function scrollToBottom() { $this->execute( - array( + [ 'script' => 'window.scrollTo(0,document.body.scrollHeight);', - 'args' => array() - ) + 'args' => [] + ] ); } @@ -693,7 +693,7 @@ abstract class TestBase extends Selenium2TestCase public function waitAjax() { /* Wait while code is loading */ - while ($this->execute(array('script' => 'return AJAX.active;', 'args' => array()))) { + while ($this->execute(['script' => 'return AJAX.active;', 'args' => []])) { usleep(5000); } } @@ -707,10 +707,10 @@ abstract class TestBase extends Selenium2TestCase { /* Get current message count */ $ajax_message_count = $this->execute( - array( + [ 'script' => 'return ajax_message_count;', - 'args' => array() - ) + 'args' => [] + ] ); /* Ensure the popup is gone */ $this->waitForElementNotPresent( @@ -738,10 +738,10 @@ abstract class TestBase extends Selenium2TestCase $SESSION_REST_URL = 'https://www.browserstack.com/automate/sessions/'; $sessionId = $this->getSessionId(); $payload = json_encode( - array( + [ 'status' => 'failed', 'reason' => $e->getMessage() - ) + ] ); $ch = curl_init(); @@ -760,7 +760,7 @@ abstract class TestBase extends Selenium2TestCase . ":" . $GLOBALS['TESTSUITE_BROWSERSTACK_KEY'] ); - $headers = array(); + $headers = []; $headers[] = "Content-Type: application/json"; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |