aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal/sql_affected_rows_test.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2014-05-26 23:09:51 +0200
committerAndreas Fischer <bantu@phpbb.com>2014-05-26 23:09:51 +0200
commitef96f8aa2ca7a2bb7ef97d9dd73b40c6a33aa552 (patch)
treeea64137ba7428d756c232fdb4178375cb9efb2fc /tests/dbal/sql_affected_rows_test.php
parentcfa9d239886d3fca33d7942c0ce5aa36858c014f (diff)
parentd646354b0e8f2d14d48c51c11d4462c7087f94c8 (diff)
downloadforums-ef96f8aa2ca7a2bb7ef97d9dd73b40c6a33aa552.tar
forums-ef96f8aa2ca7a2bb7ef97d9dd73b40c6a33aa552.tar.gz
forums-ef96f8aa2ca7a2bb7ef97d9dd73b40c6a33aa552.tar.bz2
forums-ef96f8aa2ca7a2bb7ef97d9dd73b40c6a33aa552.tar.xz
forums-ef96f8aa2ca7a2bb7ef97d9dd73b40c6a33aa552.zip
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/12570] Keep MySQLi procedural [ticket/12570] Remove test for affected rows after SELECT [ticket/12570] Add a test for set_array() and updating with the same value [ticket/12570] Fix MySQL affectedrows [ticket/12570] Fix MySQLi affectedrows by specifying MYSQLI_CLIENT_FOUND_ROWS [ticket/12570] Add a unit test to show broken sql_affectedrows() [ticket/12570] Add test for updating a config with the same value
Diffstat (limited to 'tests/dbal/sql_affected_rows_test.php')
-rw-r--r--tests/dbal/sql_affected_rows_test.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/dbal/sql_affected_rows_test.php b/tests/dbal/sql_affected_rows_test.php
new file mode 100644
index 0000000000..860b8bf237
--- /dev/null
+++ b/tests/dbal/sql_affected_rows_test.php
@@ -0,0 +1,64 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_dbal_sql_affected_rows_test extends phpbb_database_test_case
+{
+ /** @var \phpbb\db\driver\driver_interface */
+ protected $db;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->db = $this->new_dbal();
+ }
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
+ public function test_update()
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = 'bertie'";
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(2, $this->db->sql_affectedrows());
+ }
+
+ public function test_update_all_matched_unequal_updated()
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = 'foo'";
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(2, $this->db->sql_affectedrows());
+ }
+
+ public function test_update_same_value_matched_unequal_updated()
+ {
+ $sql = 'UPDATE ' . CONFIG_TABLE . "
+ SET config_value = 'foo'
+ WHERE config_value = 'foo'";
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(1, $this->db->sql_affectedrows());
+ }
+
+ public function test_insert()
+ {
+ $sql = 'INSERT INTO ' . CONFIG_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
+ 'config_name' => 'bertie',
+ 'config_value' => 'rules',
+ ));
+ $this->db->sql_query($sql);
+
+ $this->assertEquals(1, $this->db->sql_affectedrows());
+ }
+}