diff options
author | Kamil Tekiela <tekiela246@gmail.com> | 2021-11-19 20:26:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 20:26:04 +0300 |
commit | 51f4017b32ef686aeefd037cb9456705658d075a (patch) | |
tree | d3989483b38101a22f3a9a3ec09d74582d4e4e2a /test | |
parent | e91d25803590c50cafb672f48864fa76e0526d12 (diff) |
Refactor destroy controller (#17194)
* Remove redundant conditions
They were always true. First, the variable is set to -1.
If the variable is -1, then set it to Message.
If the variable is Message then set the JSON array. All of this is
redundant.
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* $sqlQuery is not used anywhere
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* Enforce $selected to be an array
I can't remove it as it is a global. Previously, it was set to a POST
variable. Since we validate that the variable is set and is not null,
we can use the value from $params. If we validate that it's also an
array we can replace for loop with foreach.
There is no passing by reference, so this change should be safe.
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* Replace $rebuildDatabaseList with input validation
The validation message says 'No databases selected.' so I assume that
we should check that we actually got at least one entry in the list.
If that is true, then the $rebuildDatabaseList is not needed and the
condition redundant.
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* drop_selected_dbs is always set and is redundant
I am not sure if this is necessary. The AJAX request sends a value of "1"
but the code doesn't really do anything with it other than checking if
it is actually set. Is there some other path possible?
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* Flatten the array with a single element
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* Remove redundant isset
The variable is set, so !isset === is_null. Why check for null if we can
check just for !is_array.
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* Update psalm-baseline.xml
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
* Adhere to the coding standard
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/classes/Controllers/Server/Databases/DestroyControllerTest.php | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/test/classes/Controllers/Server/Databases/DestroyControllerTest.php b/test/classes/Controllers/Server/Databases/DestroyControllerTest.php index 377d84dc24..4c193a5fb3 100644 --- a/test/classes/Controllers/Server/Databases/DestroyControllerTest.php +++ b/test/classes/Controllers/Server/Databases/DestroyControllerTest.php @@ -46,8 +46,6 @@ class DestroyControllerTest extends AbstractTestCase new RelationCleanup($dbi, new Relation($dbi, $template)) ); - $_POST['drop_selected_dbs'] = '1'; - $controller(); $actual = $response->getJSONResult(); |