mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 03:54:10 +01:00
[feature/dbal-tests] Added tests for dbal fetchrow and fetchfield.
This commit is contained in:
parent
94bc65e203
commit
af654814f6
@ -22,6 +22,7 @@ require_once 'request/all_tests.php';
|
||||
require_once 'security/all_tests.php';
|
||||
require_once 'template/all_tests.php';
|
||||
require_once 'text_processing/all_tests.php';
|
||||
require_once 'dbal/all_tests.php';
|
||||
|
||||
// exclude the test directory from code coverage reports
|
||||
PHPUnit_Util_Filter::addDirectoryToFilter('./');
|
||||
@ -42,6 +43,7 @@ class phpbb_all_tests
|
||||
$suite->addTest(phpbb_security_all_tests::suite());
|
||||
$suite->addTest(phpbb_template_all_tests::suite());
|
||||
$suite->addTest(phpbb_text_processing_all_tests::suite());
|
||||
$suite->addTest(phpbb_dbal_all_tests::suite());
|
||||
|
||||
return $suite;
|
||||
}
|
||||
|
40
tests/dbal/all_tests.php
Normal file
40
tests/dbal/all_tests.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2008 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD'))
|
||||
{
|
||||
define('PHPUnit_MAIN_METHOD', 'phpbb_dbal_all_tests::main');
|
||||
}
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
|
||||
require_once 'dbal/dbal.php';
|
||||
|
||||
class phpbb_dbal_all_tests
|
||||
{
|
||||
public static function main()
|
||||
{
|
||||
PHPUnit_TextUI_TestRunner::run(self::suite());
|
||||
}
|
||||
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new PHPUnit_Framework_TestSuite('phpBB Database Abstraction Layer');
|
||||
|
||||
$suite->addTestSuite('phpbb_dbal_test');
|
||||
|
||||
return $suite;
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'phpbb_dbal_all_tests::main')
|
||||
{
|
||||
phpbb_dbal_all_tests::main();
|
||||
}
|
43
tests/dbal/dbal.php
Normal file
43
tests/dbal/dbal.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2008 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'test_framework/framework.php';
|
||||
require_once '../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_dbal_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/two_users.xml');
|
||||
}
|
||||
|
||||
public function test_select_row()
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
$result = $db->sql_query('SELECT username_clean
|
||||
FROM phpbb_users
|
||||
WHERE user_id = 2');
|
||||
$row = $db->sql_fetchrow($result);
|
||||
|
||||
$this->assertEquals(array('username_clean' => 'foobar'), $row);
|
||||
}
|
||||
|
||||
public function test_select_field()
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
$result = $db->sql_query('SELECT username_clean
|
||||
FROM phpbb_users
|
||||
WHERE user_id = 2');
|
||||
|
||||
$this->assertEquals('foobar', $db->sql_fetchfield('username_clean'));
|
||||
}
|
||||
}
|
||||
|
15
tests/dbal/fixtures/two_users.xml
Normal file
15
tests/dbal/fixtures/two_users.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>username_clean</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>barfoo</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>foobar</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
Loading…
x
Reference in New Issue
Block a user