phpmyadmin/test/classes/Dbal/DatabaseNameTest.php
Maurício Meneghini Fauth f3b79d83c0
Add PHPUnit's Covers annotation on test classes
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-06-04 23:39:26 -03:00

49 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Dbal;
use InvalidArgumentException;
use PhpMyAdmin\Dbal\DatabaseName;
use PHPUnit\Framework\TestCase;
use function str_repeat;
/**
* @covers \PhpMyAdmin\Dbal\DatabaseName
*/
class DatabaseNameTest extends TestCase
{
public function testEmptyName(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Expected a different value than "".');
new DatabaseName('');
}
public function testNameWithTrailingWhitespace(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Expected a value not to end with " ". Got: "a "');
new DatabaseName('a ');
}
public function testLongName(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
'Expected a value to contain at most 64 characters. Got: '
. '"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"'
);
new DatabaseName(str_repeat('a', 65));
}
public function testValidName(): void
{
$name = new DatabaseName('name');
$this->assertEquals('name', $name->getName());
$this->assertEquals('name', (string) $name);
}
}