aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/dbal/auto_increment_test.php100
-rw-r--r--tests/dbal/db_tools_test.php47
-rw-r--r--travis/phpunit-mysql-travis.xml4
-rw-r--r--travis/phpunit-postgres-travis.xml4
4 files changed, 109 insertions, 46 deletions
diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php
new file mode 100644
index 0000000000..e87fc1c6bd
--- /dev/null
+++ b/tests/dbal/auto_increment_test.php
@@ -0,0 +1,100 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
+
+class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
+{
+ protected $db;
+ protected $tools;
+ protected $table_exists;
+ protected $table_data;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->db = $this->new_dbal();
+ $this->tools = new phpbb_db_tools($this->db);
+
+ $this->table_data = array(
+ 'COLUMNS' => array(
+ 'c_id' => array('UINT', NULL, 'auto_increment'),
+ 'c_uint' => array('UINT', 4),
+ ),
+ 'PRIMARY_KEY' => 'c_id',
+ );
+ $this->tools->sql_create_table('prefix_table_name', $this->table_data);
+ $this->table_exists = true;
+ }
+
+ protected function tearDown()
+ {
+ if ($this->table_exists)
+ {
+ $this->tools->sql_table_drop('prefix_table_name');
+ }
+
+ parent::tearDown();
+ }
+
+ static protected function get_default_values()
+ {
+ return array(
+ 'c_uint' => 0,
+ );
+ }
+
+ public function test_auto_increment()
+ {
+ $sql = 'DELETE FROM prefix_table_name';
+ $result = $this->db->sql_query($sql);
+
+ $row1 = array_merge(self::get_default_values(), array(
+ 'c_uint' => 1,
+ ));
+ $row2 = array_merge(self::get_default_values(), array(
+ 'c_uint' => 2,
+ ));
+
+ $sql = 'INSERT INTO prefix_table_name ' . $this->db->sql_build_array('INSERT', $row1);
+ $result = $this->db->sql_query($sql);
+ $id1 = $this->db->sql_nextid();
+
+ $sql = 'INSERT INTO prefix_table_name ' . $this->db->sql_build_array('INSERT', $row2);
+ $result = $this->db->sql_query($sql);
+ $id2 = $this->db->sql_nextid();
+
+ $this->assertGreaterThan($id1, $id2, 'Auto increment should increase the id value');
+
+ $sql = "SELECT *
+ FROM prefix_table_name WHERE c_id = $id1";
+ $result = $this->db->sql_query($sql);
+ $row_actual = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $row1['c_id'] = $id1;
+ $this->assertEquals($row1, $row_actual);
+
+ $sql = "SELECT *
+ FROM prefix_table_name WHERE c_id = $id2";
+ $result = $this->db->sql_query($sql);
+ $row_actual = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $row2['c_id'] = $id2;
+ $this->assertEquals($row2, $row_actual);
+ }
+}
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index c7ddb88ce8..9bed0648cd 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -106,7 +106,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
'c_bool' => 0,
'c_vchar' => '',
'c_vchar_size' => '',
- 'c_char_size' => '',
+ 'c_char_size' => 'abcd',
'c_xstext' => '',
'c_stext' => '',
'c_text' => '',
@@ -189,51 +189,6 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertEquals($row_expect[$column_name], $row_actual[$column_name], "Column $column_name of type $type should have equal return and input value.");
}
- public function test_auto_increment()
- {
- $sql = 'DELETE FROM prefix_table_name';
- $result = $this->db->sql_query($sql);
-
- $row1 = array_merge(self::get_default_values(), array(
- 'c_uint' => 1,
- 'c_vchar' => '1', // these values are necessary to avoid unique index issues
- 'c_vchar_size' => '1',
- ));
- $row2 = array_merge(self::get_default_values(), array(
- 'c_uint' => 2,
- 'c_vchar' => '2',
- 'c_vchar_size' => '2',
- ));
-
- $sql = 'INSERT INTO prefix_table_name ' . $this->db->sql_build_array('INSERT', $row1);
- $result = $this->db->sql_query($sql);
- $id1 = $this->db->sql_nextid();
-
- $sql = 'INSERT INTO prefix_table_name ' . $this->db->sql_build_array('INSERT', $row2);
- $result = $this->db->sql_query($sql);
- $id2 = $this->db->sql_nextid();
-
- $this->assertGreaterThan($id1, $id2, 'Auto increment should increase the id value');
-
- $sql = "SELECT *
- FROM prefix_table_name WHERE c_id = $id1";
- $result = $this->db->sql_query($sql);
- $row_actual = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- $row1['c_id'] = $id1;
- $this->assertEquals($row1, $row_actual);
-
- $sql = "SELECT *
- FROM prefix_table_name WHERE c_id = $id2";
- $result = $this->db->sql_query($sql);
- $row_actual = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
-
- $row2['c_id'] = $id2;
- $this->assertEquals($row2, $row_actual);
- }
-
public function test_list_columns()
{
$this->assertEquals(
diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml
index 36845a7f71..e54b2bb77b 100644
--- a/travis/phpunit-mysql-travis.xml
+++ b/travis/phpunit-mysql-travis.xml
@@ -13,6 +13,10 @@
<testsuites>
<testsuite name="phpBB Test Suite">
<directory suffix="_test.php">../tests/</directory>
+ <exclude>tests/functional</exclude>
+ </testsuite>
+ <testsuite name="phpBB Functional Tests">
+ <directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
</testsuites>
diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml
index 461a53bcb1..55ba996548 100644
--- a/travis/phpunit-postgres-travis.xml
+++ b/travis/phpunit-postgres-travis.xml
@@ -13,6 +13,10 @@
<testsuites>
<testsuite name="phpBB Test Suite">
<directory suffix="_test.php">../tests/</directory>
+ <exclude>tests/functional</exclude>
+ </testsuite>
+ <testsuite name="phpBB Functional Tests">
+ <directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
</testsuites>