From 3602924fbb0ec3273af3711491587bd2e7e9d75b Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 19 Sep 2014 07:23:29 +0000 Subject: [PATCH] dblayer : add more unit tests git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1830 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- Tests/dblayerComplet.php | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Tests/dblayerComplet.php b/Tests/dblayerComplet.php index af277d0..8a1436a 100644 --- a/Tests/dblayerComplet.php +++ b/Tests/dblayerComplet.php @@ -119,6 +119,7 @@ class test_dblayer_{ENGINE} extends PHPUnit_Framework_TestCase "with space"=>array ("varchar", "255", "not null")); $db->unique = array (); $db->primary = "group"; + // Don't update primary key $res = $db->update ("gr ou\"p", array ("object"=>"%éàoppp", "with space"=>"WITH SPACE")); $this->assertSame (1, $res); @@ -144,4 +145,45 @@ class test_dblayer_{ENGINE} extends PHPUnit_Framework_TestCase "where"=>"\$'\"", "with space"=>"WITH SPACE")), $res); } + + public function test_update2 () + { + $dbconfig = $this->confs["{ENGINE}"]; + $db = new dblayer ($dbconfig["dsn"], $dbconfig["username"], + $dbconfig["password"], $dbconfig["driver_options"]); + $db->table = "grouped"; + $db->fields = array ("group"=>array ("varchar", "255", "not null"), + "object"=>array ("varchar", "255", "not null"), + "where"=>array ("varchar", "255", "not null"), + "with space"=>array ("varchar", "255", "not null")); + $db->unique = array (array ("group","object")); + $db->primary = "group"; + // Update primary key + $res = $db->update ("gr ou\"p", array ("group"=>"NEW GROUP", + "object"=>"%éàoppp", + "with space"=>"WITH SPACE")); + $this->assertSame (1, $res); + } + + public function test_read3 () + { + $dbconfig = $this->confs["{ENGINE}"]; + $db = new dblayer ($dbconfig["dsn"], $dbconfig["username"], + $dbconfig["password"], $dbconfig["driver_options"]); + $db->table = "grouped"; + $db->fields = array ("group"=>array ("varchar", "255", "not null"), + "object"=>array ("varchar", "255", "not null"), + "where"=>array ("varchar", "255", "not null"), + "with space"=>array ("varchar", "255", "not null")); + $db->unique = array (); + $res = $db->read (array (array ("group", "NEW GROUP"), + array ("object","%éàoppp"), + array ("where","\$'\""), + array ("with space","WITH SPACE"))); + $this->assertSame (array (0=>array ("group"=>"NEW GROUP", + "object"=>"%éàoppp", + "where"=>"\$'\"", + "with space"=>"WITH SPACE")), $res); + } + }