1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-25 06:39:48 +03:00
Files
phpmyadmin/test/classes/ExportTest.php
Maurício Meneghini Fauth 86fb10e688 Fix coding standard issues
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.com.br>
2026-07-31 13:32:49 -03:00

126 lines
3.5 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\Export\ExportPhparray;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Large;
/**
* @covers \PhpMyAdmin\Export
* @large
*/
#[Large]
#[CoversClass(Export::class)]
class ExportTest extends AbstractTestCase
{
/** @var Export */
private $export;
/**
* Sets up the fixture
*/
protected function setUp(): void
{
parent::setUp();
$this->export = new Export($GLOBALS['dbi']);
}
/**
* Test for mergeAliases
*/
public function testMergeAliases(): void
{
$aliases1 = [
'test_db' => [
'alias' => 'aliastest',
'tables' => [
'foo' => [
'alias' => 'foobar',
'columns' => [
'bar' => 'foo',
'baz' => 'barbaz',
],
],
'bar' => [
'alias' => 'foobaz',
'columns' => [
'a' => 'a_alias',
'b' => 'b',
],
],
],
],
];
$aliases2 = [
'test_db' => [
'alias' => 'test',
'tables' => [
'foo' => [
'columns' => ['bar' => 'foobar'],
],
'baz' => [
'columns' => ['a' => 'x'],
],
],
],
];
$expected = [
'test_db' => [
'alias' => 'test',
'tables' => [
'foo' => [
'alias' => 'foobar',
'columns' => [
'bar' => 'foobar',
'baz' => 'barbaz',
],
],
'bar' => [
'alias' => 'foobaz',
'columns' => [
'a' => 'a_alias',
'b' => 'b',
],
],
'baz' => [
'columns' => ['a' => 'x'],
],
],
],
];
$actual = $this->export->mergeAliases($aliases1, $aliases2);
self::assertSame($expected, $actual);
}
/**
* Test for getFinalFilenameAndMimetypeForFilename
*/
public function testGetFinalFilenameAndMimetypeForFilename(): void
{
$exportPlugin = new ExportPhparray();
$finalFileName = $this->export->getFinalFilenameAndMimetypeForFilename($exportPlugin, 'zip', 'myfilename');
self::assertSame([
'myfilename.php.zip',
'application/zip',
], $finalFileName);
$finalFileName = $this->export->getFinalFilenameAndMimetypeForFilename($exportPlugin, 'gzip', 'myfilename');
self::assertSame([
'myfilename.php.gz',
'application/x-gzip',
], $finalFileName);
$finalFileName = $this->export->getFinalFilenameAndMimetypeForFilename(
$exportPlugin,
'gzip',
'export.db1.table1.file'
);
self::assertSame([
'export.db1.table1.file.php.gz',
'application/x-gzip',
], $finalFileName);
}
}