|
6 | 6 |
|
7 | 7 | use PhpMyAdmin\ConfigStorage\Relation; |
8 | 8 | use PhpMyAdmin\Database\DatabaseList; |
| 9 | +use PhpMyAdmin\DatabaseInterface; |
9 | 10 | use PhpMyAdmin\Dbal\ResultInterface; |
10 | 11 | use PhpMyAdmin\Query\Utilities; |
11 | 12 | use PhpMyAdmin\SystemDatabase; |
12 | 13 | use PhpMyAdmin\Utils\SessionCache; |
| 14 | +use stdClass; |
13 | 15 |
|
14 | 16 | /** |
15 | 17 | * @covers \PhpMyAdmin\DatabaseInterface |
@@ -501,4 +503,203 @@ public function testQueryAsControlUser(): void |
501 | 503 | ); |
502 | 504 | $this->assertFalse($this->dbi->tryQueryAsControlUser('Invalid query')); |
503 | 505 | } |
| 506 | + |
| 507 | + public function testGetDatabasesFullDisabledISAndSortIntColumn(): void |
| 508 | + { |
| 509 | + parent::setGlobalDbi(); |
| 510 | + |
| 511 | + $GLOBALS['db'] = ''; |
| 512 | + $GLOBALS['table'] = ''; |
| 513 | + $GLOBALS['server'] = 1; |
| 514 | + $GLOBALS['cfg']['Server']['DisableIS'] = true; |
| 515 | + $GLOBALS['cfg']['NaturalOrder'] = true; |
| 516 | + $GLOBALS['dblist'] = new stdClass(); |
| 517 | + $GLOBALS['dblist']->databases = [ |
| 518 | + 'db1', |
| 519 | + 'db2', |
| 520 | + ]; |
| 521 | + $this->dummyDbi->removeDefaultResults(); |
| 522 | + $this->dummyDbi->addResult( |
| 523 | + 'SELECT @@collation_database', |
| 524 | + [ |
| 525 | + ['utf8_general_ci'], |
| 526 | + ], |
| 527 | + ['@@collation_database'] |
| 528 | + ); |
| 529 | + $this->dummyDbi->addResult( |
| 530 | + 'SELECT @@collation_database', |
| 531 | + [ |
| 532 | + ['utf8_general_ci'], |
| 533 | + ], |
| 534 | + ['@@collation_database'] |
| 535 | + ); |
| 536 | + $this->dummyDbi->addResult( |
| 537 | + 'SHOW TABLE STATUS FROM `db1`;', |
| 538 | + [ |
| 539 | + [ |
| 540 | + 'pma__bookmark', |
| 541 | + 'InnoDB', |
| 542 | + 10, |
| 543 | + 'Dynamic', |
| 544 | + 0, |
| 545 | + 0, |
| 546 | + 16384, |
| 547 | + 0, |
| 548 | + 0, |
| 549 | + 0, |
| 550 | + 1, |
| 551 | + '2021-08-27 14:11:52', |
| 552 | + null, |
| 553 | + null, |
| 554 | + 'utf8_bin', |
| 555 | + null, |
| 556 | + 'Bookmarks', |
| 557 | + ], |
| 558 | + [ |
| 559 | + 'pma__central_columns', |
| 560 | + 'InnoDB', |
| 561 | + 10, |
| 562 | + 'Dynamic', |
| 563 | + 0, |
| 564 | + 0, |
| 565 | + 16384, |
| 566 | + 0, |
| 567 | + 0, |
| 568 | + 0, |
| 569 | + null, |
| 570 | + '2021-08-27 14:11:52', |
| 571 | + null, |
| 572 | + null, |
| 573 | + 'utf8_bin', |
| 574 | + null, |
| 575 | + 'Central list of columns', |
| 576 | + ], |
| 577 | + ], |
| 578 | + [ |
| 579 | + 'Name', |
| 580 | + 'Engine', |
| 581 | + 'Version', |
| 582 | + 'Row_format', |
| 583 | + 'Rows', |
| 584 | + 'Avg_row_length', |
| 585 | + 'Data_length', |
| 586 | + 'Max_data_length', |
| 587 | + 'Index_length', |
| 588 | + 'Data_free', |
| 589 | + 'Auto_increment', |
| 590 | + 'Create_time', |
| 591 | + 'Update_time', |
| 592 | + 'Check_time', |
| 593 | + 'Collation', |
| 594 | + 'Checksum', |
| 595 | + 'Create_options', |
| 596 | + 'Comment', |
| 597 | + ] |
| 598 | + ); |
| 599 | + |
| 600 | + $this->dummyDbi->addResult( |
| 601 | + 'SHOW TABLE STATUS FROM `db2`;', |
| 602 | + [ |
| 603 | + [ |
| 604 | + 'pma__bookmark', |
| 605 | + 'InnoDB', |
| 606 | + 10, |
| 607 | + 'Dynamic', |
| 608 | + 0, |
| 609 | + 0, |
| 610 | + 16324, |
| 611 | + 0, |
| 612 | + 0, |
| 613 | + 0, |
| 614 | + 1, |
| 615 | + '2021-08-27 14:11:52', |
| 616 | + null, |
| 617 | + null, |
| 618 | + 'utf8_bin', |
| 619 | + null, |
| 620 | + 'Bookmarks', |
| 621 | + ], |
| 622 | + [ |
| 623 | + 'pma__central_columns', |
| 624 | + 'InnoDB', |
| 625 | + 10, |
| 626 | + 'Dynamic', |
| 627 | + 0, |
| 628 | + 0, |
| 629 | + 14384, |
| 630 | + 0, |
| 631 | + 0, |
| 632 | + 0, |
| 633 | + null, |
| 634 | + '2021-08-27 14:11:52', |
| 635 | + null, |
| 636 | + null, |
| 637 | + 'utf8_bin', |
| 638 | + null, |
| 639 | + 'Central list of columns', |
| 640 | + ], |
| 641 | + ], |
| 642 | + [ |
| 643 | + 'Name', |
| 644 | + 'Engine', |
| 645 | + 'Version', |
| 646 | + 'Row_format', |
| 647 | + 'Rows', |
| 648 | + 'Avg_row_length', |
| 649 | + 'Data_length', |
| 650 | + 'Max_data_length', |
| 651 | + 'Index_length', |
| 652 | + 'Data_free', |
| 653 | + 'Auto_increment', |
| 654 | + 'Create_time', |
| 655 | + 'Update_time', |
| 656 | + 'Check_time', |
| 657 | + 'Collation', |
| 658 | + 'Checksum', |
| 659 | + 'Create_options', |
| 660 | + 'Comment', |
| 661 | + ] |
| 662 | + ); |
| 663 | + $this->dummyDbi->addSelectDb(''); |
| 664 | + $this->dummyDbi->addSelectDb(''); |
| 665 | + $this->dummyDbi->addSelectDb('db1'); |
| 666 | + $this->dummyDbi->addSelectDb('db2'); |
| 667 | + |
| 668 | + $databaseList = $this->dbi->getDatabasesFull( |
| 669 | + null, |
| 670 | + true, |
| 671 | + DatabaseInterface::CONNECT_USER, |
| 672 | + 'SCHEMA_DATA_LENGTH', |
| 673 | + 'ASC', |
| 674 | + 0, |
| 675 | + 100 |
| 676 | + ); |
| 677 | + |
| 678 | + $this->assertSame([ |
| 679 | + [ |
| 680 | + 'SCHEMA_NAME' => 'db2', |
| 681 | + 'DEFAULT_COLLATION_NAME' => 'utf8_general_ci', |
| 682 | + 'SCHEMA_TABLES' => 2, |
| 683 | + 'SCHEMA_TABLE_ROWS' => 0, |
| 684 | + 'SCHEMA_DATA_LENGTH' => 30708, |
| 685 | + 'SCHEMA_MAX_DATA_LENGTH' => 0, |
| 686 | + 'SCHEMA_INDEX_LENGTH' => 0, |
| 687 | + 'SCHEMA_LENGTH' => 30708, |
| 688 | + 'SCHEMA_DATA_FREE' => 0, |
| 689 | + ], |
| 690 | + [ |
| 691 | + 'SCHEMA_NAME' => 'db1', |
| 692 | + 'DEFAULT_COLLATION_NAME' => 'utf8_general_ci', |
| 693 | + 'SCHEMA_TABLES' => 2, |
| 694 | + 'SCHEMA_TABLE_ROWS' => 0, |
| 695 | + 'SCHEMA_DATA_LENGTH' => 32768, |
| 696 | + 'SCHEMA_MAX_DATA_LENGTH' => 0, |
| 697 | + 'SCHEMA_INDEX_LENGTH' => 0, |
| 698 | + 'SCHEMA_LENGTH' => 32768, |
| 699 | + 'SCHEMA_DATA_FREE' => 0, |
| 700 | + ], |
| 701 | + ], $databaseList); |
| 702 | + |
| 703 | + $this->assertAllQueriesConsumed(); |
| 704 | + } |
504 | 705 | } |
0 commit comments