phpmyadmin/test/classes/Controllers/SchemaExportControllerTest.php
Maurício Meneghini Fauth f23ab54ca9
Move the Export class to the Export namespace
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-06-28 12:28:38 -03:00

42 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers;
use PhpMyAdmin\Controllers\SchemaExportController;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
#[CoversClass(SchemaExportController::class)]
class SchemaExportControllerTest extends AbstractTestCase
{
#[RunInSeparateProcess]
public function testExport(): void
{
$GLOBALS['dbi'] = $this->createDatabaseInterface();
$request = $this->createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['db', null, 'test_db'], ['export_type', null, 'svg']]);
$export = $this->createStub(Export::class);
$export->method('getExportSchemaInfo')->willReturn([
'fileName' => 'file.svg',
'mediaType' => 'image/svg+xml',
'fileData' => 'file data',
]);
$response = new ResponseRenderer();
$controller = new SchemaExportController($export, $response);
$controller($request);
$output = $this->getActualOutputForAssertion();
$this->assertSame('file data', $output);
$this->assertTrue($response->isDisabled());
$this->assertSame('', $response->getHTMLResult());
$this->assertSame([], $response->getJSONResult());
}
}