diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-11-10 22:18:26 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-11-10 22:18:26 +0300 |
commit | 5df50f6a1140b6490710b8acf51a6c6f6669ec55 (patch) | |
tree | 855e99210668adb49ad145c0feb28ceec1aa2bf5 /test | |
parent | 7b723d63185632d556242f72a4676472ee32d55f (diff) |
Refactor Tracking export download to remove `exit`
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test')
-rw-r--r-- | test/classes/TrackingTest.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/classes/TrackingTest.php b/test/classes/TrackingTest.php index 3238241344..6a00ba318e 100644 --- a/test/classes/TrackingTest.php +++ b/test/classes/TrackingTest.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests; use DateTimeImmutable; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\ConfigStorage\RelationParameters; +use PhpMyAdmin\DatabaseInterface; use PhpMyAdmin\SqlQueryForm; use PhpMyAdmin\Template; use PhpMyAdmin\Tracking; @@ -14,7 +15,11 @@ use PhpMyAdmin\Url; use function __; use function _pgettext; +use function date; use function htmlspecialchars; +use function ini_get; +use function ini_restore; +use function ini_set; use function sprintf; /** @@ -584,4 +589,24 @@ class TrackingTest extends AbstractTestCase $this->assertEquals('username3', $entries[0]['username']); $this->assertEquals('statement1', $entries[0]['statement']); } + + public function testGetDownloadInfoForExport(): void + { + $tracking = new Tracking( + $this->createStub(SqlQueryForm::class), + $this->createStub(Template::class), + $this->createStub(Relation::class), + $this->createStub(DatabaseInterface::class) + ); + ini_set('url_rewriter.tags', 'a=href,area=href,frame=src,form=,fieldset='); + $entries = [['statement' => 'first statement'], ['statement' => 'second statement']]; + $expectedDump = '# Tracking report for table `test> table`' . "\n" + . '# ' . date('Y-m-d H:i:s') . "\n" + . 'first statementsecond statement'; + $actual = $tracking->getDownloadInfoForExport('test> table', $entries); + $this->assertSame('log_test> table.sql', $actual['filename']); + $this->assertSame($expectedDump, $actual['dump']); + $this->assertSame('', ini_get('url_rewriter.tags')); + ini_restore('url_rewriter.tags'); + } } |