mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/10942] Avoid possible conflicts with magic words in unit tests
PHPBB3-10942
This commit is contained in:
parent
6776feb0de
commit
1b826842aa
1 changed files with 12 additions and 12 deletions
|
@ -18,52 +18,52 @@ class phpbb_dbal_case_test extends phpbb_database_test_case
|
||||||
{
|
{
|
||||||
$db = $this->new_dbal();
|
$db = $this->new_dbal();
|
||||||
|
|
||||||
$sql = 'SELECT ' . $db->sql_case('1 = 1', '1', '2') . ' AS num
|
$sql = 'SELECT ' . $db->sql_case('1 = 1', '1', '2') . ' AS test_num
|
||||||
FROM phpbb_config';
|
FROM phpbb_config';
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
$this->assertEquals(1, (int) $db->sql_fetchfield('num'));
|
$this->assertEquals(1, (int) $db->sql_fetchfield('test_num'));
|
||||||
|
|
||||||
$sql = 'SELECT ' . $db->sql_case('1 = 0', '1', '2') . ' AS num
|
$sql = 'SELECT ' . $db->sql_case('1 = 0', '1', '2') . ' AS test_num
|
||||||
FROM phpbb_config';
|
FROM phpbb_config';
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
$this->assertEquals(2, (int) $db->sql_fetchfield('num'));
|
$this->assertEquals(2, (int) $db->sql_fetchfield('test_num'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_case_string()
|
public function test_case_string()
|
||||||
{
|
{
|
||||||
$db = $this->new_dbal();
|
$db = $this->new_dbal();
|
||||||
|
|
||||||
$sql = 'SELECT ' . $db->sql_case('1 = 1', "'foo'", "'bar'") . ' AS string
|
$sql = 'SELECT ' . $db->sql_case('1 = 1', "'foo'", "'bar'") . ' AS test_string
|
||||||
FROM phpbb_config';
|
FROM phpbb_config';
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
$this->assertEquals('foo', $db->sql_fetchfield('string'));
|
$this->assertEquals('foo', $db->sql_fetchfield('test_string'));
|
||||||
|
|
||||||
$sql = 'SELECT ' . $db->sql_case('1 = 0', "'foo'", "'bar'") . ' AS string
|
$sql = 'SELECT ' . $db->sql_case('1 = 0', "'foo'", "'bar'") . ' AS test_string
|
||||||
FROM phpbb_config';
|
FROM phpbb_config';
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
$this->assertEquals('bar', $db->sql_fetchfield('string'));
|
$this->assertEquals('bar', $db->sql_fetchfield('test_string'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_case_column()
|
public function test_case_column()
|
||||||
{
|
{
|
||||||
$db = $this->new_dbal();
|
$db = $this->new_dbal();
|
||||||
|
|
||||||
$sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS string
|
$sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS test_string
|
||||||
FROM phpbb_config
|
FROM phpbb_config
|
||||||
WHERE config_name = 'config1'";
|
WHERE config_name = 'config1'";
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
$this->assertEquals('config1', $db->sql_fetchfield('string'));
|
$this->assertEquals('config1', $db->sql_fetchfield('test_string'));
|
||||||
|
|
||||||
$sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS string
|
$sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS test_string
|
||||||
FROM phpbb_config
|
FROM phpbb_config
|
||||||
WHERE config_value = 'bar'";
|
WHERE config_value = 'bar'";
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
|
||||||
$this->assertEquals('bar', $db->sql_fetchfield('string'));
|
$this->assertEquals('bar', $db->sql_fetchfield('test_string'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue