aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dbal
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
commitd646354b0e8f2d14d48c51c11d4462c7087f94c8 (patch)
treecbaffc8574a99b9022e4d3c731d1388c1ebf410e /tests/dbal
parent502cbad5a7f8896311a616553cff9d83ccc87497 (diff)
parentfcdf1101cba7999081f12bca2f5f96ef7769539c (diff)
downloadforums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar
forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar.gz
forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar.bz2
forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.tar.xz
forums-d646354b0e8f2d14d48c51c11d4462c7087f94c8.zip
Merge pull request #2492 from nickvergessen/ticket/12570
[ticket/12570] Fix updating a config with the same value * nickvergessen/ticket/12570: [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')
-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());
+ }
+}