aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dbal/select_test.php24
-rw-r--r--tests/random/mt_rand.php46
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php
index 533416f14b..e0d08d9306 100644
--- a/tests/dbal/select_test.php
+++ b/tests/dbal/select_test.php
@@ -8,6 +8,7 @@
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_dbal_select_test extends phpbb_database_test_case
{
@@ -317,4 +318,27 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
+
+ function test_nested_transactions()
+ {
+ $db = $this->new_dbal();
+
+ // nested transactions should work on systems that do not require
+ // buffering of nested transactions, so ignore the ones that need
+ // buffering
+ if ($db->sql_buffer_nested_transactions())
+ {
+ return;
+ }
+
+ $sql = 'SELECT user_id FROM phpbb_users ORDER BY user_id ASC';
+ $result1 = $db->sql_query($sql);
+
+ $db->sql_transaction('begin');
+ $result2 = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result2);
+ $db->sql_transaction('commit');
+
+ $this->assertEquals('1', $row['user_id']);
+ }
}
diff --git a/tests/random/mt_rand.php b/tests/random/mt_rand.php
new file mode 100644
index 0000000000..d6502c4e80
--- /dev/null
+++ b/tests/random/mt_rand.php
@@ -0,0 +1,46 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_random_mt_rand_test extends phpbb_test_case
+{
+ public function test_max_equals_min()
+ {
+ $result = phpbb_mt_rand(42, 42);
+ $this->assertEquals(42, $result);
+ }
+
+ public function test_max_equals_min_negative()
+ {
+ $result = phpbb_mt_rand(-42, -42);
+ $this->assertEquals(-42, $result);
+ }
+
+ public function test_max_greater_min()
+ {
+ $result = phpbb_mt_rand(3, 4);
+ $this->assertGreaterThanOrEqual(3, $result);
+ $this->assertLessThanOrEqual(4, $result);
+ }
+
+ public function test_min_greater_max()
+ {
+ $result = phpbb_mt_rand(4, 3);
+ $this->assertGreaterThanOrEqual(3, $result);
+ $this->assertLessThanOrEqual(4, $result);
+ }
+
+ public function test_min_greater_max_negative()
+ {
+ $result = phpbb_mt_rand(-3, -4);
+ $this->assertGreaterThanOrEqual(-4, $result);
+ $this->assertLessThanOrEqual(-3, $result);
+ }
+}