Improve test suite to make it 32bit compatible and more flexible

Ref: #14906
- Fixes the case where you have FilterLanguages in the local config file
- Fixes the case where the php zip or php bz2 extension is not installed

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2019-11-05 21:32:02 +01:00
parent 89f311b588
commit f6272067a7
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
4 changed files with 60 additions and 11 deletions

View File

@ -74,14 +74,31 @@ class EncodingTest extends TestCase
$this->markTestSkipped('iconv extension missing');
}
$GLOBALS['cfg']['IconvExtraParams'] = '//TRANSLIT';
Encoding::setEngine(Encoding::ENGINE_ICONV);
$this->assertEquals(
"This is the Euro symbol 'EUR'.",
Encoding::convertString(
'UTF-8', 'ISO-8859-1', "This is the Euro symbol '€'."
)
);
if (PHP_INT_SIZE === 8) {
$GLOBALS['cfg']['IconvExtraParams'] = '//TRANSLIT';
Encoding::setEngine(Encoding::ENGINE_ICONV);
$this->assertEquals(
"This is the Euro symbol 'EUR'.",
Encoding::convertString(
'UTF-8',
'ISO-8859-1',
"This is the Euro symbol '€'."
)
);
} elseif (PHP_INT_SIZE === 4) {
// NOTE: this does not work on 32bit systems and requires "//IGNORE"
// NOTE: or it will throw "iconv(): Detected an illegal character in input string"
$GLOBALS['cfg']['IconvExtraParams'] = '//TRANSLIT//IGNORE';
Encoding::setEngine(Encoding::ENGINE_ICONV);
$this->assertEquals(
"This is the Euro symbol ''.",
Encoding::convertString(
'UTF-8',
'ISO-8859-1',
"This is the Euro symbol '€'."
)
);
}
}
public function testMbstring()

View File

@ -64,6 +64,8 @@ class FileTest extends PmaTestCase
*
* @return void
* @dataProvider compressedFiles
* @requires extension bz2 1
* @requires extension zip 1
*/
public function testReadCompressed($file)
{

View File

@ -303,7 +303,7 @@ class ImportTest extends TestCase
*/
function provDetectType()
{
return array(
$data = array(
array(Import::NONE, null, 'NULL'),
array(Import::NONE, Import::NONE, 'NULL'),
array(Import::INT, Import::INT, 'NULL'),
@ -313,11 +313,37 @@ class ImportTest extends TestCase
array(Import::INT, Import::INT, '10'),
array(Import::DECIMAL, Import::DECIMAL, '10.2'),
array(Import::DECIMAL, Import::INT, '10.2'),
array(Import::BIGINT, Import::BIGINT, '2147483648'),
array(Import::BIGINT, Import::INT, '2147483648'),
array(Import::VARCHAR, Import::VARCHAR, 'test'),
array(Import::VARCHAR, Import::INT, 'test'),
);
if (PHP_INT_MAX > 2147483647) {
$data[] = [
Import::BIGINT,
Import::BIGINT,
'2147483648',
];
$data[] = [
Import::BIGINT,
Import::INT,
'2147483648',
];
} else {
// To be fixed ?
// Can not detect a BIGINT since the value is over PHP_INT_MAX
$data[] = [
Import::VARCHAR,
Import::BIGINT,
'2147483648',
];
$data[] = [
Import::VARCHAR,
Import::INT,
'2147483648',
];
}
return $data;
}
/**

View File

@ -105,6 +105,7 @@ class LanguageTest extends PmaTestCase
*/
public function testMySQLLocale()
{
$GLOBALS['PMA_Config']->set('FilterLanguages', '');
$czech = $this->manager->getLanguage('cs');
$this->assertNotFalse($czech);
$this->assertEquals('cs_CZ', $czech->getMySQLLocale());
@ -132,6 +133,7 @@ class LanguageTest extends PmaTestCase
*/
public function testGet()
{
$GLOBALS['PMA_Config']->set('FilterLanguages', '');
$lang = $this->manager->getLanguage('cs');
$this->assertNotEquals(false, $lang);
$this->assertEquals('Czech', $lang->getEnglishName());
@ -158,6 +160,7 @@ class LanguageTest extends PmaTestCase
*/
public function testSelect($lang, $post, $get, $cookie, $accept, $agent, $default, $expect)
{
$GLOBALS['PMA_Config']->set('FilterLanguages', '');
$GLOBALS['PMA_Config']->set('Lang', $lang);
$GLOBALS['PMA_Config']->set('is_https', false);
$_POST['lang'] = $post;
@ -216,6 +219,7 @@ class LanguageTest extends PmaTestCase
*/
public function testGettext($locale)
{
$GLOBALS['PMA_Config']->set('FilterLanguages', '');
/* We should be able to set the language */
$this->manager->getLanguage($locale)->activate();