Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2022-09-11 23:32:44 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2022-09-11 23:32:44 +0300
commite96fab654df405595b9f42c5a4eba04f80344cc1 (patch)
tree983c3c570d2e6ea5114d84123dc4fca20ec0b38c /test
parent7975f5fb05befd63e10408a9c34a3ffff56a2515 (diff)
Move DBI's getProceduresOrFunctions into Routines class
Splits the method into Routines::getFunctionNames and Routines::getProcedureNames and adds tests. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test')
-rw-r--r--test/classes/Database/RoutinesTest.php80
-rw-r--r--test/classes/Plugins/Export/ExportXmlTest.php13
2 files changed, 84 insertions, 9 deletions
diff --git a/test/classes/Database/RoutinesTest.php b/test/classes/Database/RoutinesTest.php
index 9b166c7837..aac3f5997e 100644
--- a/test/classes/Database/RoutinesTest.php
+++ b/test/classes/Database/RoutinesTest.php
@@ -1433,4 +1433,84 @@ class RoutinesTest extends AbstractTestCase
],
];
}
+
+ public function testGetFunctionNames(): void
+ {
+ $dbiDummy = $this->createDbiDummy();
+ $dbiDummy->addResult(
+ 'SHOW FUNCTION STATUS;',
+ [
+ ['db_test', 'test_func', 'FUNCTION'],
+ ['test_db', 'test_func1', 'FUNCTION'],
+ ['test_db', '', 'FUNCTION'],
+ ['test_db', 'test_func2', 'FUNCTION'],
+ ['test_db', 'test_func', 'PROCEDURE'],
+ ],
+ ['Db', 'Name', 'Type']
+ );
+
+ $names = Routines::getFunctionNames($this->createDatabaseInterface($dbiDummy), 'test_db');
+ $this->assertSame(['test_func1', 'test_func2'], $names);
+
+ $dbiDummy->assertAllQueriesConsumed();
+ }
+
+ public function testGetFunctionNamesWithEmptyReturn(): void
+ {
+ $dbiDummy = $this->createDbiDummy();
+ $dbiDummy->addResult(
+ 'SHOW FUNCTION STATUS;',
+ [
+ ['db_test', 'test_func', 'FUNCTION'],
+ ['test_db', '', 'FUNCTION'],
+ ['test_db', 'test_func', 'PROCEDURE'],
+ ],
+ ['Db', 'Name', 'Type']
+ );
+
+ $names = Routines::getFunctionNames($this->createDatabaseInterface($dbiDummy), 'test_db');
+ $this->assertSame([], $names);
+
+ $dbiDummy->assertAllQueriesConsumed();
+ }
+
+ public function testGetProcedureNames(): void
+ {
+ $dbiDummy = $this->createDbiDummy();
+ $dbiDummy->addResult(
+ 'SHOW PROCEDURE STATUS;',
+ [
+ ['db_test', 'test_proc', 'PROCEDURE'],
+ ['test_db', 'test_proc1', 'PROCEDURE'],
+ ['test_db', '', 'PROCEDURE'],
+ ['test_db', 'test_proc2', 'PROCEDURE'],
+ ['test_db', 'test_proc', 'FUNCTION'],
+ ],
+ ['Db', 'Name', 'Type']
+ );
+
+ $names = Routines::getProcedureNames($this->createDatabaseInterface($dbiDummy), 'test_db');
+ $this->assertSame(['test_proc1', 'test_proc2'], $names);
+
+ $dbiDummy->assertAllQueriesConsumed();
+ }
+
+ public function testGetProcedureNamesWithEmptyReturn(): void
+ {
+ $dbiDummy = $this->createDbiDummy();
+ $dbiDummy->addResult(
+ 'SHOW PROCEDURE STATUS;',
+ [
+ ['db_test', 'test_proc', 'PROCEDURE'],
+ ['test_db', '', 'PROCEDURE'],
+ ['test_db', 'test_proc', 'FUNCTION'],
+ ],
+ ['Db', 'Name', 'Type']
+ );
+
+ $names = Routines::getProcedureNames($this->createDatabaseInterface($dbiDummy), 'test_db');
+ $this->assertSame([], $names);
+
+ $dbiDummy->assertAllQueriesConsumed();
+ }
}
diff --git a/test/classes/Plugins/Export/ExportXmlTest.php b/test/classes/Plugins/Export/ExportXmlTest.php
index a2bff35a19..d5b66a9072 100644
--- a/test/classes/Plugins/Export/ExportXmlTest.php
+++ b/test/classes/Plugins/Export/ExportXmlTest.php
@@ -215,17 +215,12 @@ class ExportXmlTest extends AbstractTestCase
'DEFINER' => 'test_user@localhost',
],
];
+ $functions = [['Db' => 'd<"b', 'Name' => 'fn', 'Type' => 'FUNCTION']];
+ $procedures = [['Db' => 'd<"b', 'Name' => 'pr', 'Type' => 'PROCEDURE']];
- $dbi->expects($this->exactly(4))
+ $dbi->expects($this->exactly(6))
->method('fetchResult')
- ->willReturnOnConsecutiveCalls($result, $result, [], $triggers);
-
- $dbi->expects($this->exactly(2))
- ->method('getProceduresOrFunctions')
- ->willReturnOnConsecutiveCalls(
- ['fn'],
- ['pr']
- );
+ ->willReturnOnConsecutiveCalls($result, $result, [], $triggers, $functions, $procedures);
$dbi->expects($this->exactly(2))
->method('fetchValue')