|
6 | 6 |
|
7 | 7 | use PhpMyAdmin\ConfigStorage\Relation; |
8 | 8 | use PhpMyAdmin\Export\Export; |
| 9 | +use PhpMyAdmin\FlashMessages; |
9 | 10 | use PhpMyAdmin\Identifiers\DatabaseName; |
| 11 | +use PhpMyAdmin\Message; |
10 | 12 | use PhpMyAdmin\Plugins\Export\ExportPhparray; |
11 | 13 | use PhpMyAdmin\Plugins\Export\ExportSql; |
12 | 14 | use PhpMyAdmin\Tests\AbstractTestCase; |
@@ -225,4 +227,88 @@ public function testExportServer(): void |
225 | 227 |
|
226 | 228 | $this->assertSame(htmlspecialchars($expected, ENT_COMPAT), $this->getActualOutputForAssertion()); |
227 | 229 | } |
| 230 | + |
| 231 | + public function testGetPageLocationAndSaveMessageForServerExportWithError(): void |
| 232 | + { |
| 233 | + $GLOBALS['lang'] = 'en'; |
| 234 | + $GLOBALS['server'] = 2; |
| 235 | + $_SESSION = []; |
| 236 | + $dbi = $this->createDatabaseInterface(); |
| 237 | + $export = new Export($dbi); |
| 238 | + $location = $export->getPageLocationAndSaveMessage('server', Message::error('Error message!')); |
| 239 | + $this->assertSame('index.php?route=/server/export&server=2&lang=en', $location); |
| 240 | + $this->assertSame(['danger' => ['Error message!']], (new FlashMessages())->getMessages()); |
| 241 | + } |
| 242 | + |
| 243 | + public function testGetPageLocationAndSaveMessageForServerExportWithSuccess(): void |
| 244 | + { |
| 245 | + $GLOBALS['lang'] = 'en'; |
| 246 | + $GLOBALS['server'] = 2; |
| 247 | + $_SESSION = []; |
| 248 | + $dbi = $this->createDatabaseInterface(); |
| 249 | + $export = new Export($dbi); |
| 250 | + $location = $export->getPageLocationAndSaveMessage('server', Message::success('Success message!')); |
| 251 | + $this->assertSame('index.php?route=/server/export&server=2&lang=en', $location); |
| 252 | + $this->assertSame(['success' => ['Success message!']], (new FlashMessages())->getMessages()); |
| 253 | + } |
| 254 | + |
| 255 | + public function testGetPageLocationAndSaveMessageForDatabaseExportWithError(): void |
| 256 | + { |
| 257 | + $GLOBALS['lang'] = 'en'; |
| 258 | + $GLOBALS['server'] = 2; |
| 259 | + $GLOBALS['db'] = 'test_db'; |
| 260 | + $_SESSION = []; |
| 261 | + $dbi = $this->createDatabaseInterface(); |
| 262 | + $export = new Export($dbi); |
| 263 | + $location = $export->getPageLocationAndSaveMessage('database', Message::error('Error message!')); |
| 264 | + $this->assertSame('index.php?route=/database/export&db=test_db&server=2&lang=en', $location); |
| 265 | + $this->assertSame(['danger' => ['Error message!']], (new FlashMessages())->getMessages()); |
| 266 | + } |
| 267 | + |
| 268 | + public function testGetPageLocationAndSaveMessageForDatabaseExportWithSuccess(): void |
| 269 | + { |
| 270 | + $GLOBALS['lang'] = 'en'; |
| 271 | + $GLOBALS['server'] = 2; |
| 272 | + $GLOBALS['db'] = 'test_db'; |
| 273 | + $_SESSION = []; |
| 274 | + $dbi = $this->createDatabaseInterface(); |
| 275 | + $export = new Export($dbi); |
| 276 | + $location = $export->getPageLocationAndSaveMessage('database', Message::success('Success message!')); |
| 277 | + $this->assertSame('index.php?route=/database/export&db=test_db&server=2&lang=en', $location); |
| 278 | + $this->assertSame(['success' => ['Success message!']], (new FlashMessages())->getMessages()); |
| 279 | + } |
| 280 | + |
| 281 | + public function testGetPageLocationAndSaveMessageForTableExportWithError(): void |
| 282 | + { |
| 283 | + $GLOBALS['lang'] = 'en'; |
| 284 | + $GLOBALS['server'] = 2; |
| 285 | + $GLOBALS['db'] = 'test_db'; |
| 286 | + $GLOBALS['table'] = 'test_table'; |
| 287 | + $_SESSION = []; |
| 288 | + $dbi = $this->createDatabaseInterface(); |
| 289 | + $export = new Export($dbi); |
| 290 | + $location = $export->getPageLocationAndSaveMessage('table', Message::error('Error message!')); |
| 291 | + $this->assertSame( |
| 292 | + 'index.php?route=/table/export&db=test_db&table=test_table&single_table=true&server=2&lang=en', |
| 293 | + $location, |
| 294 | + ); |
| 295 | + $this->assertSame(['danger' => ['Error message!']], (new FlashMessages())->getMessages()); |
| 296 | + } |
| 297 | + |
| 298 | + public function testGetPageLocationAndSaveMessageForTableExportWithSuccess(): void |
| 299 | + { |
| 300 | + $GLOBALS['lang'] = 'en'; |
| 301 | + $GLOBALS['server'] = 2; |
| 302 | + $GLOBALS['db'] = 'test_db'; |
| 303 | + $GLOBALS['table'] = 'test_table'; |
| 304 | + $_SESSION = []; |
| 305 | + $dbi = $this->createDatabaseInterface(); |
| 306 | + $export = new Export($dbi); |
| 307 | + $location = $export->getPageLocationAndSaveMessage('table', Message::success('Success message!')); |
| 308 | + $this->assertSame( |
| 309 | + 'index.php?route=/table/export&db=test_db&table=test_table&single_table=true&server=2&lang=en', |
| 310 | + $location, |
| 311 | + ); |
| 312 | + $this->assertSame(['success' => ['Success message!']], (new FlashMessages())->getMessages()); |
| 313 | + } |
228 | 314 | } |
0 commit comments