BUG : dblayer : don't raise an exception when re-inserting unique record
dblayer : add more unit tests git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1850 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -259,4 +259,50 @@ class test_dblayer_{ENGINE} extends PHPUnit_Framework_TestCase
|
||||
$this->assertThat($res, $this->lessThanOrEqual(2));
|
||||
}
|
||||
|
||||
// Test the unique feature
|
||||
public function test_insert3 ()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||
$db->table = "users";
|
||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
||||
"groupmember"=>array ("varchar", "255", "not null"),
|
||||
"where"=>array ("varchar", "255", "not null"),
|
||||
"with space"=>array ("varchar", "255", "not null"));
|
||||
// Unique simple in insert
|
||||
$db->unique = array ("user");
|
||||
$db->primary = "user";
|
||||
$db->foreign = array (
|
||||
"groupmember"=>array ("grouped", "group", "ON UPDATE CASCADE ON DELETE CASCADE"),
|
||||
);
|
||||
$this->setExpectedException ("Exception");
|
||||
$res = $db->insert (array ("user"=>"Us ou\"r",
|
||||
"groupmember"=>"NEW GROUP",
|
||||
"where"=>"\$'\"",
|
||||
"with space"=>"with space"));
|
||||
}
|
||||
|
||||
public function test_insert4 ()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$db = new dblayer ($dbconfig["dsn"], $dbconfig["username"],
|
||||
$dbconfig["password"], $dbconfig["driver_options"]);
|
||||
$db->table = "users";
|
||||
$db->fields = array ("user"=>array ("varchar", "255", "not null"),
|
||||
"groupmember"=>array ("varchar", "255", "not null"),
|
||||
"where"=>array ("varchar", "255", "not null"),
|
||||
"with space"=>array ("varchar", "255", "not null"));
|
||||
// Unique multiple in insert
|
||||
$db->unique = array (array ("user", "groupmember"));
|
||||
$db->primary = "user";
|
||||
$db->foreign = array (
|
||||
"groupmember"=>array ("grouped", "group", "ON UPDATE CASCADE ON DELETE CASCADE"),
|
||||
);
|
||||
$this->setExpectedException ("Exception");
|
||||
$res = $db->insert (array ("user"=>"Us ou\"r",
|
||||
"groupmember"=>"NEW GROUP",
|
||||
"where"=>"\$'\"",
|
||||
"with space"=>"with space"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user