diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-05-23 16:10:07 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-05-26 21:43:37 +0200 |
commit | 15516bd07853cbda585f1716ce1b614d43cf9d9a (patch) | |
tree | 506d877f1db0c5244d5ff972f6f4f5881c1cdd87 /tests | |
parent | ce5258d801859fe38bdcd61531e3a4c14a7b3f03 (diff) | |
download | forums-15516bd07853cbda585f1716ce1b614d43cf9d9a.tar forums-15516bd07853cbda585f1716ce1b614d43cf9d9a.tar.gz forums-15516bd07853cbda585f1716ce1b614d43cf9d9a.tar.bz2 forums-15516bd07853cbda585f1716ce1b614d43cf9d9a.tar.xz forums-15516bd07853cbda585f1716ce1b614d43cf9d9a.zip |
[ticket/12570] Add a unit test to show broken sql_affectedrows()
PHPBB3-12570
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dbal/sql_affected_rows_test.php | 73 |
1 files changed, 73 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..df008bab9a --- /dev/null +++ b/tests/dbal/sql_affected_rows_test.php @@ -0,0 +1,73 @@ +<?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_select() + { + $sql = 'SELECT * + FROM ' . CONFIG_TABLE; + $this->db->sql_query($sql); + + $this->assertEquals(2, $this->db->sql_affectedrows()); + } + + 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_some_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()); + } +} |