phpmyadmin/test/classes
Kamil Tekiela 56a832948c
Refactor DatabaseInterface.php (#17209)
* Use str_starts_with()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant !empty()

!empty() on a declared variable is redundant.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Replace loop with array_column()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Simpify assignment by removing temporary variable

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant if statements and array_merge

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove temporary variable

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Unindent code

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Add helper method fetchByMode()

This is done to avoid calling methods through variables. It is the same
in terms of performance.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Move if statements to where they are relevant

I had a choice to either move the while loop out of the if statements
or move the if statements inside. I decided it made more sense to move
them inside.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Add NULL to phpdoc for the two parameters that can be null

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Simplify return statement

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Improve performance and simplify code

Since we are always using STORE mode then we can use data_seek() method.
This will allow us to get rid of the loop and use fetchByMode() method.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Inline value defaulting

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant check

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* [bugfix] getColumnNames() should return an array of strings

There were multiple issues here. If we are selecting only a certain
column from the SQL then let's use the handy function instead of
array_keys. We will never get anything other than an array so checking
if it is not an array makes no sense. Returning null only to cast it to
an array is pointless. If really necessary, we could still check for an
empty array. The ColumnController returned the value without even
casting it to an array. I am not sure how jQuery/JavaScript dealt with it.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getColumnMapFromSql and add type hint

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Refactor getVirtualTables

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant loop

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove redundant usage of freeResult()

If there was no chance for the object to leak the scope and it is the
end of the scope then there's no reason to call this method.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Replace dynamic variable with declare one

It's always the same name. If we were creating more than one, we could
use associative array, but in this case there seems to be absolutely no
need for any of this. Dynamic variables make it harder to debug the code.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Update psalm-baseline.xml

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Widen the condition per williamdes suggestion

This will allow value such as '' and '0' to pass through. Previously
`if(! empty($database))` and `if($database)` dissallowed them.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* fetchResult() should return only arrays

Tests fixed to return arrays. Non-empty in case of true, empty in case
of false.
Fixed a lot of Psalm issues where the condition was always true.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-26 20:17:46 -03:00
..
_data Remove two symfony dev deps 2021-06-26 19:05:28 +02:00
Charsets Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
Command Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Config Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
Controllers Refactor destroy controller (#17194) 2021-11-19 14:26:04 -03:00
Database Redesign the export/import pages to use Bootstrap components 2021-11-25 13:37:47 -03:00
Dbal Merge branch 'QA_5_1' 2021-10-28 14:10:04 -03:00
Display Remove printview.css theme files 2021-10-31 17:35:55 -03:00
Engines Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
Export Refactor PhpMyAdmin\Plugins::getChoice method 2021-08-27 13:38:01 -03:00
Gis Use @requires annotation for required extensions 2021-10-07 13:40:50 -03:00
Html Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
Import Add some test classes 2021-06-07 16:59:34 -03:00
Navigation Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Partitioning Move partition classes to the Partitioning namespace 2021-08-21 14:01:25 -03:00
Plugins Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
Properties Remove useless whitespaces 2021-09-15 17:05:40 -03:00
Query Add support for account locking 2021-08-21 00:55:33 -03:00
Server Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
Setup Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
Stubs Fix tryMultiQuery signature 2021-11-25 13:45:56 +00:00
Table Add Table\Maintenance\Message value object 2021-10-06 14:06:03 -03:00
Utils Fix SessionCacheTest's failing test 2021-11-09 15:31:02 -03:00
AbstractNetworkTestCase.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
AbstractTestCase.php Fix some issues found by PHPStan 2021-11-16 15:11:57 -03:00
AdvisorTest.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
BookmarkTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
BrowseForeignersTest.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
CacheTest.php Create a simple Cache class 2021-06-17 16:35:53 +02:00
CharsetsTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
CheckUserPrivilegesTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
CommonTest.php Move some Core methods to Common class 2021-07-06 16:52:54 -03:00
ConfigTest.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
ConsoleTest.php Add some test classes 2021-06-07 16:59:34 -03:00
CoreTest.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
CreateAddFieldTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
DatabaseInterfaceTest.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
EncodingTest.php Use @requires annotation for required extensions 2021-10-07 13:40:50 -03:00
EnvironmentTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
ErrorHandlerTest.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
ErrorReportTest.php Remove PhpMyAdmin\Config::enableBc method 2021-07-09 13:59:04 -03:00
ErrorTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
ExportTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
FieldMetadataTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
FileListingTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
FileTest.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
FlashMessagesTest.php Remove non used variables 2021-07-16 02:13:27 +02:00
FontTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
FooterTest.php Remove PhpMyAdmin\Config::enableBc method 2021-07-09 13:59:04 -03:00
GitTest.php Replace rand functions with random_int 2021-09-27 19:05:42 -03:00
HeaderTest.php Remove print view mode 2021-10-31 13:22:07 -03:00
ImportTest.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
IndexColumnTest.php Add some test classes 2021-06-07 16:59:34 -03:00
IndexTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
InsertEditTest.php Merge pull request #17204 from kamil-tekiela/Refactor-DatabaseInterface-getColumns() 2021-11-26 15:07:20 -03:00
InternalRelationsTest.php Add some test classes 2021-06-07 16:59:34 -03:00
IpAllowDenyTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
LanguageTest.php Fix some errors found by PHPStan and Psalm 2021-06-24 18:03:14 -03:00
LinterTest.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
ListDatabaseTest.php Add some test classes 2021-06-07 16:59:34 -03:00
LoggingTest.php Add some test classes 2021-06-07 16:59:34 -03:00
MenuTest.php Get default config values from Config\Settings classes 2021-09-30 12:04:47 -03:00
MessageTest.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
MimeTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
NormalizationTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
OperationsTest.php Fix some tests with PHP 8.1 2021-06-11 18:14:40 -03:00
PdfTest.php Fix types and signatures after tcpdf upgrade 2021-07-21 00:26:11 +02:00
PluginsTest.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
ProfilingTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
RelationCleanupTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
RelationParametersTest.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
RelationTest.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
ReplicationGuiTest.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
ResponseTest.php Remove PhpMyAdmin\Config::enableBc method 2021-07-09 13:59:04 -03:00
RoutingTest.php Extract controllers from HomeController 2021-09-05 00:40:18 -03:00
SanitizeTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
ScriptsTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
SqlQueryFormTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
SqlTest.php Add test for Sql::executeQueryAndSendQueryResponse 2021-11-15 19:51:16 -03:00
StorageEngineTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
SystemDatabaseTest.php Create the RelationParameters value object 2021-11-14 18:22:36 -03:00
TableTest.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
TemplateTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
ThemeManagerTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
ThemeTest.php Remove PhpMyAdmin\Config::enableBc method 2021-07-09 13:59:04 -03:00
TrackerTest.php Fix some issues found by PHPStan 2021-11-16 15:11:57 -03:00
TrackingTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
TransformationsTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
TwoFactorTest.php Use @requires annotation for required extensions 2021-10-07 13:40:50 -03:00
TypesTest.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
UrlTest.php Remove useless string concatenations 2021-09-27 21:40:22 -03:00
UserPasswordTest.php Add tests for UserPassword and TablePartitionDefinition 2021-06-09 19:32:55 -03:00
UserPreferencesTest.php Refactor DatabaseInterface.php (#17209) 2021-11-26 20:17:46 -03:00
UtilTest.php Remove array support from Util::backquote 2021-11-10 19:33:09 -03:00
VersionInformationTest.php Remove useless whitespaces 2021-09-15 17:05:40 -03:00
VersionTest.php Add PHPUnit's Covers annotation on test classes 2021-06-04 23:39:26 -03:00
ZipExtensionTest.php Replace fopen, fwrite and fclose with file_put_contents 2021-07-13 11:51:57 -03:00