Skip to content

Commit cf7fa38

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents b29afef + 5f6966a commit cf7fa38

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

libraries/classes/Core.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,6 @@ public static function downloadHeader(
491491
$headers['Content-Length'] = (string) $length;
492492
}
493493

494-
if (defined('TESTSUITE')) {
495-
return;
496-
}
497-
498494
foreach ($headers as $name => $value) {
499495
header(sprintf('%s: %s', $name, $value));
500496
}

test/classes/Controllers/Table/GetFieldControllerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
*/
1818
class GetFieldControllerTest extends AbstractTestCase
1919
{
20+
/**
21+
* @runInSeparateProcess
22+
* @preserveGlobalState disabled
23+
*/
2024
public function testGetFieldController(): void
2125
{
2226
$GLOBALS['db'] = 'test_db';

test/classes/CoreTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use function __;
1515
use function _pgettext;
1616
use function hash;
17+
use function header;
1718
use function htmlspecialchars;
1819
use function mb_strpos;
1920
use function ob_end_clean;
@@ -993,4 +994,56 @@ public function providerForTestPopulateRequestWithEncryptedQueryParamsWithInvali
993994
[['eq' => 'invalid'], []],
994995
];
995996
}
997+
998+
/**
999+
* @runInSeparateProcess
1000+
* @preserveGlobalState disabled
1001+
* @requires extension xdebug
1002+
*/
1003+
public function testDownloadHeader(): void
1004+
{
1005+
$GLOBALS['config']->set('PMA_USR_BROWSER_AGENT', 'FIREFOX');
1006+
1007+
header('Cache-Control: private, max-age=10800');
1008+
1009+
Core::downloadHeader('test.sql', 'text/x-sql', 100, false);
1010+
1011+
// phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
1012+
$headersList = \xdebug_get_headers();
1013+
// phpcs:enable
1014+
1015+
$this->assertContains('Cache-Control: private, max-age=10800', $headersList);
1016+
$this->assertContains('Content-Description: File Transfer', $headersList);
1017+
$this->assertContains('Content-Disposition: attachment; filename="test.sql"', $headersList);
1018+
$this->assertContains('Content-type: text/x-sql;charset=UTF-8', $headersList);
1019+
$this->assertContains('Content-Transfer-Encoding: binary', $headersList);
1020+
$this->assertContains('Content-Length: 100', $headersList);
1021+
$this->assertNotContains('Content-Encoding: gzip', $headersList);
1022+
}
1023+
1024+
/**
1025+
* @runInSeparateProcess
1026+
* @preserveGlobalState disabled
1027+
* @requires extension xdebug
1028+
*/
1029+
public function testDownloadHeader2(): void
1030+
{
1031+
$GLOBALS['config']->set('PMA_USR_BROWSER_AGENT', 'FIREFOX');
1032+
1033+
header('Cache-Control: private, max-age=10800');
1034+
1035+
Core::downloadHeader('test.sql.gz', 'application/x-gzip', 0, false);
1036+
1037+
// phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
1038+
$headersList = \xdebug_get_headers();
1039+
// phpcs:enable
1040+
1041+
$this->assertContains('Cache-Control: private, max-age=10800', $headersList);
1042+
$this->assertContains('Content-Description: File Transfer', $headersList);
1043+
$this->assertContains('Content-Disposition: attachment; filename="test.sql.gz"', $headersList);
1044+
$this->assertContains('Content-Type: application/x-gzip', $headersList);
1045+
$this->assertContains('Content-Encoding: gzip', $headersList);
1046+
$this->assertContains('Content-Transfer-Encoding: binary', $headersList);
1047+
$this->assertNotContains('Content-Length: 0', $headersList);
1048+
}
9961049
}

0 commit comments

Comments
 (0)