diff options
author | Yuriy Rusko <github@rusko.net> | 2014-05-27 21:55:40 +0200 |
---|---|---|
committer | Yuriy Rusko <github@rusko.net> | 2014-05-27 21:55:40 +0200 |
commit | 1d61bcedfd1882f84d102c523a354a8c4ae69336 (patch) | |
tree | cbc3aead2546002d82fa0503eaab7f1520c515b8 /tests/dbal | |
parent | 27f787e5e4e118b77a3e16879d6c684bdaafc303 (diff) | |
parent | 0acaa7722956635b8f17e19cddc6f02a602b7352 (diff) | |
download | forums-1d61bcedfd1882f84d102c523a354a8c4ae69336.tar forums-1d61bcedfd1882f84d102c523a354a8c4ae69336.tar.gz forums-1d61bcedfd1882f84d102c523a354a8c4ae69336.tar.bz2 forums-1d61bcedfd1882f84d102c523a354a8c4ae69336.tar.xz forums-1d61bcedfd1882f84d102c523a354a8c4ae69336.zip |
Merge remote-tracking branch 'upstream/develop-ascraeus' into ticket/12594
Conflicts:
phpBB/docs/hook_system.html
Diffstat (limited to 'tests/dbal')
-rw-r--r-- | tests/dbal/sql_affected_rows_test.php | 64 |
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()); + } +} |