|
8 | 8 | use PhpMyAdmin\Core;
|
9 | 9 | use PhpMyAdmin\Current;
|
10 | 10 | use PhpMyAdmin\Html\Generator;
|
| 11 | +use PhpMyAdmin\Http\Factory\ServerRequestFactory; |
11 | 12 | use PhpMyAdmin\Import\SimulateDml;
|
12 | 13 | use PhpMyAdmin\SqlParser\Parser;
|
13 | 14 | use PhpMyAdmin\SqlParser\Statements\DeleteStatement;
|
|
19 | 20 | use PHPUnit\Framework\Attributes\DataProvider;
|
20 | 21 |
|
21 | 22 | use function count;
|
| 23 | +use function json_decode; |
22 | 24 |
|
23 | 25 | #[CoversClass(SimulateDmlController::class)]
|
24 | 26 | final class SimulateDmlControllerTest extends AbstractTestCase
|
@@ -276,4 +278,31 @@ public static function providerForTestGetMatchedRows(): array
|
276 | 278 | ],
|
277 | 279 | ];
|
278 | 280 | }
|
| 281 | + |
| 282 | + public function testStatementWithParsingError(): void |
| 283 | + { |
| 284 | + Current::$sqlQuery = 'UPDATE actor SET'; |
| 285 | + |
| 286 | + $request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/') |
| 287 | + ->withParsedBody(['sql_delimiter' => ';']); |
| 288 | + |
| 289 | + $responseRenderer = new ResponseRenderer(); |
| 290 | + $responseRenderer->setAjax(true); |
| 291 | + $controller = new SimulateDmlController($responseRenderer, new SimulateDml($this->createDatabaseInterface())); |
| 292 | + $response = $controller($request); |
| 293 | + |
| 294 | + $expectedMessage = <<<'HTML' |
| 295 | + <div class="alert alert-danger" role="alert"> |
| 296 | + <img src="themes/dot.gif" title="" alt="" class="icon ic_s_error"> Missing assignment in SET operation. |
| 297 | + </div> |
| 298 | + |
| 299 | + HTML; |
| 300 | + |
| 301 | + $body = (string) $response->getBody(); |
| 302 | + self::assertJson($body); |
| 303 | + self::assertSame( |
| 304 | + ['message' => $expectedMessage, 'sql_data' => false, 'success' => true], |
| 305 | + json_decode($body, true), |
| 306 | + ); |
| 307 | + } |
279 | 308 | }
|
0 commit comments