phpmyadmin/tests/unit/Plugins/Schema/SchemaSvgTest.php
Kamil Tekiela 71483428a2 Drop Countable contract
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2026-02-26 00:23:31 +00:00

68 lines
2.9 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Plugins\Schema;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Plugins\Schema\SchemaSvg;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
use PhpMyAdmin\Tests\AbstractTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(SchemaSvg::class)]
final class SchemaSvgTest extends AbstractTestCase
{
public function testGetName(): void
{
self::assertSame('svg', (new SchemaSvg())->getName());
}
public function testSetProperties(): void
{
$properties = (new SchemaSvg())->getProperties();
self::assertSame('SVG', $properties->getText());
self::assertSame('svg', $properties->getExtension());
self::assertSame('application/svg', $properties->getMimeType());
$options = $properties->getOptions();
self::assertNotNull($options);
self::assertSame('Format Specific Options', $options->getName());
$specificOptions = $options->getProperties();
self::assertCount(1, $specificOptions);
$specificOption = $specificOptions->current();
self::assertInstanceOf(OptionsPropertyMainGroup::class, $specificOption);
self::assertSame('svg_general_opts', $specificOption->getName());
$specificOptionProperties = $specificOption->getProperties();
self::assertCount(3, $specificOptionProperties);
$specificOptionProperty = $specificOptionProperties->current();
self::assertInstanceOf(BoolPropertyItem::class, $specificOptionProperty);
self::assertSame('svg_show_color', $specificOptionProperty->getName());
self::assertSame('Show color', $specificOptionProperty->getText());
$specificOptionProperties->next();
$specificOptionProperty = $specificOptionProperties->current();
self::assertInstanceOf(BoolPropertyItem::class, $specificOptionProperty);
self::assertSame('svg_show_keys', $specificOptionProperty->getName());
self::assertSame('Only show keys', $specificOptionProperty->getText());
$specificOptionProperties->next();
$specificOptionProperty = $specificOptionProperties->current();
self::assertInstanceOf(BoolPropertyItem::class, $specificOptionProperty);
self::assertSame('svg_all_tables_same_width', $specificOptionProperty->getName());
self::assertSame('Same width for all tables', $specificOptionProperty->getText());
}
public function testGetExportInfo(): void
{
$_REQUEST['page_number'] = '0';
$actual = (new SchemaSvg())->getExportInfo(DatabaseName::from('test_db'));
self::assertSame('test_db.svg', $actual['fileName']);
self::assertSame('image/svg+xml', $actual['mediaType']);
self::assertStringStartsWith('<?xml version="1.0" encoding="UTF-8"?>', $actual['fileData']);
}
}