phpmyadmin/test/classes/CharsetsTest.php
Maurício Meneghini Fauth 172ffd871b Fix case when collation name can be null
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2019-06-30 18:23:21 -03:00

65 lines
1.4 KiB
PHP

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for MySQL Charsets
*
* @package PhpMyAdmin-test
*/
declare(strict_types=1);
namespace PhpMyAdmin\Tests;
use PhpMyAdmin\Charsets;
use PHPUnit\Framework\TestCase;
/**
* Tests for MySQL Charsets
*
* @package PhpMyAdmin-test
*/
class CharsetsTest extends TestCase
{
/**
* @return void
*/
protected function setUp(): void
{
$GLOBALS['cfg']['DBG']['sql'] = false;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
}
/**
* @return void
*/
public function testFindCollationByName(): void
{
$this->assertNull(Charsets::findCollationByName(
$GLOBALS['dbi'],
$GLOBALS['cfg']['Server']['DisableIS'],
null
));
$this->assertNull(Charsets::findCollationByName(
$GLOBALS['dbi'],
$GLOBALS['cfg']['Server']['DisableIS'],
''
));
$this->assertNull(Charsets::findCollationByName(
$GLOBALS['dbi'],
$GLOBALS['cfg']['Server']['DisableIS'],
'invalid'
));
$actual = Charsets::findCollationByName(
$GLOBALS['dbi'],
$GLOBALS['cfg']['Server']['DisableIS'],
'utf8_general_ci'
);
$this->assertInstanceOf(Charsets\Collation::class, $actual);
$this->assertSame('utf8_general_ci', $actual->getName());
}
}