Files
DomFramework/Tests/dblayerooComplet.php

894 lines
27 KiB
PHP

<?php
/** DomFramework - Tests
@package domframework
@author Dominique Fournier <dominique@fournier38.fr> */
class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
{
// Test with column name 'group', 'object', 'where', 'with space'
// Test with table name 'group', 'object', 'where', 'with space'
// For the 3 DB engines
public $engine="{ENGINE}";
public $confs = array (
"sqlite" => array (
"dsn" => "sqlite:/tmp/databaseDBLayeroo.db",
"username" => null,
"password" => null,
"driver_options" => null,
"tableprefix" => "",
),
"mysql" => array (
"dsn" => "mysql:host=127.0.0.1;port=3306;dbname=test",
"username" => "root",
"password" => "lqsym",
"driver_options" => null,
"tableprefix" => "",
),
"pgsql" => array (
"dsn" => "pgsql:host=127.0.0.1;port=5432;dbname=dbname",
"username" => "root",
"password" => "root",
"driver_options" => null,
"tableprefix" => "",
),
);
private function tbl1 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl1 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$tbl1->table ("groupedoo");
$tbl1->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)")));
$tbl1->unique (array ());
$tbl1->primary ("group");
return $tbl1;
}
private function tbl2 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl2 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$tbl2->table ("usersoo");
$tbl2->fields (array ("uid"=>array ("integer", "not null", "autoincrement"),
"gecos"=>array ("varchar(255)", "not null"),
"password"=>array ("varchar(255)", "not null"),
"group" => array ("varchar(255)", "not null"),
));
$tbl2->unique (array ("gecos","password"));
$tbl2->primary ("uid");
$tbl2->foreign (array ("group" => array ("groupedoo", "group",
"ON DELETE CASCADE")));
return $tbl2;
}
private function tbl3 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl3 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
return $tbl3;
}
private function tbl4 ()
{
$dbconfig = $this->confs["{ENGINE}"];
$tbl4 = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
$tbl4->table ("rightsoo");
$tbl4->fields (array ("id"=>array ("integer", "not null", "autoincrement"),
"name"=>array ("varchar(255)", "not null"),
"group" => array ("varchar(255)", "not null"),
));
$tbl4->unique (array ("name"));
$tbl4->primary ("id");
$tbl4->foreign (array ("group" => array ("groupedoo", "group",
"ON DELETE CASCADE")));
return $tbl4;
}
public function test_dropTable ()
{
$dbconfig = $this->confs["{ENGINE}"];
$db = new dblayeroo ($dbconfig["dsn"], $dbconfig["username"],
$dbconfig["password"], $dbconfig["driver_options"]);
foreach (array ("rightsoo", "usersoo", "groupedoo",
"multipleoo", "multiple2oo", "users3oo",
"readORoo") as
$table)
{
$db->table ($table);
try
{
$res = $db->dropTable();
}
catch (Exception $e)
{
}
}
$db->disconnect ();
// Never generate an error, just drop the table if it exists, and do noting
// if it doesn't exists
}
public function test_createTable1 ()
{
// Create a table named groupedoo
$tbl1 = $this->tbl1 ();
$res = $tbl1->createTable ();
$tbl1->disconnect ();
$this->assertSame (0, $res);
}
public function test_createTable2 ()
{
// Create a table named usersoo
$tbl2 = $this->tbl2 ();
$res = $tbl2->createTable ();
$tbl2->disconnect ();
$this->assertSame (0, $res);
}
public function test_createTable4 ()
{
// Create a table named rightsoo
$tbl4 = $this->tbl4 ();
$res = $tbl4->createTable ();
$tbl4->disconnect ();
$this->assertSame (0, $res);
}
public function test_select1 ()
{
// Select all on the table : nothing
$tbl1 = $this->tbl1 ();
$res = $tbl1->select()->execute ();
$tbl1->disconnect ();
$this->assertSame (array (), $res);
}
public function test_insert1 ()
{
// Insert without value : raise an exception
$this->setExpectedException ("Exception");
$tbl1 = $this->tbl1 ();
$res = $tbl1->insert()->execute ();
$tbl1->disconnect ();
}
public function test_insert2 ()
{
// Insert : missing not null field : exception
$this->setExpectedException ("Exception");
$tbl1 = $this->tbl1 ();
$res = $tbl1->insert()
->setValues(array ("group"=>"group1", "where"=>"where"))
->execute ();
$tbl1->disconnect ();
}
public function test_insert3 ()
{
// Insert : first row inserted
$tbl1 = $this->tbl1 ();
$res = $tbl1->insert()->setValues(array ("group"=>"group1",
"where"=>"where",
"object"=>"object"))->execute ();
$tbl1->disconnect ();
// As the key is not an autoincrement, the lastInsertID can be 0 or 1
$this->assertGreaterThanOrEqual ($res, "0");
}
public function test_select2 ()
{
// Select all on the table : nothing
$tbl1 = $this->tbl1 ();
$res = $tbl1->select()->execute ();
$tbl1->disconnect ();
$this->assertSame (array (array ("group"=>"group1", "object"=>"object",
"where"=>"where", "with space"=>null)),
$res);
}
public function test_update1 ()
{
// update the all the rows of the table (without WHERE)
$tbl1 = $this->tbl1 ();
$res = $tbl1->update()->setValues(array ("group"=>"group2",
"where"=>"where",
"object"=>"object"))->execute ();
$tbl1->disconnect ();
$this->assertSame (1, $res);
}
public function test_select3 ()
{
// Select all on the table after update
$tbl1 = $this->tbl1 ();
$res = $tbl1->select()->execute ();
$tbl1->disconnect ();
$this->assertSame (array (array ("group"=>"group2", "object"=>"object",
"where"=>"where", "with space"=>null)),
$res);
}
public function test_update2 ()
{
// update the all the rows of the table (with inexisting WHERE)
$tbl1 = $this->tbl1 ();
$res = $tbl1->update()
->setValues(array ("group"=>"group2", "where"=>"where",
"object"=>"object"))
->whereAdd ("group", "=", "group1")
->execute ();
$tbl1->disconnect ();
$this->assertSame (0, $res);
}
public function test_update3 ()
{
// update the all the rows of the table (with existing WHERE)
$tbl1 = $this->tbl1 ();
$res = $tbl1->update()
->setValues(array ("group"=>"group1", "where"=>"where",
"object"=>"object"))
->whereAdd ("group", "=", "group2")
->execute ();
$tbl1->disconnect ();
$this->assertSame (1, $res);
}
public function test_update4 ()
{
// update the all the rows of the table : NOT NULL value not provided
// (already existing in the table)
$tbl1 = $this->tbl1 ();
$res = $tbl1->update()
->setValues(array ("group"=>"group1"))
->execute ();
$tbl1->disconnect ();
$this->assertSame (1, $res);
}
public function test_delete1 ()
{
// Delete : WHERE return nothing
$tbl1 = $this->tbl1 ();
$res = $tbl1->delete ()
->whereAdd ("group", "=", "group2")
->execute ();
$tbl1->disconnect ();
$this->assertSame (0, $res);
}
public function test_delete2 ()
{
// Delete all
$tbl1 = $this->tbl1 ();
$res = $tbl1->delete ()
->execute ();
$tbl1->disconnect ();
$this->assertSame (1, $res);
}
public function test_select4 ()
{
// Select all on the table : nothing
$tbl1 = $this->tbl1 ();
$res = $tbl1->select()->execute ();
$tbl1->disconnect ();
$this->assertSame (array (), $res);
}
public function test_insert5 ()
{
// Insert : first row inserted for TABLE 2 tests
$tbl1 = $this->tbl1 ();
$res = $tbl1->insert()->setValues(array ("group"=>"group1",
"where"=>"where",
"object"=>"object"))->execute ();
$tbl1->disconnect ();
// As the key is not an autoincrement, the lastInsertID can be 0 or 1
$this->assertGreaterThanOrEqual ($res, "0");
}
///////////////////
/// TABLE 2 ///
///////////////////
public function test_insertAutoincrement1 ()
{
// Test autoincrement
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->setForeignObj ($tbl1);
$res = $tbl2->insert()->setValues(array ("gecos"=>"name",
"password"=>"toto",
"group"=>"group1"))->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame ("1", $res);
}
public function test_insertAutoincrement2 ()
{
// Test autoincrement
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->setForeignObj ($tbl1);
$res = $tbl2->insert()->setValues(array ("gecos"=>"firstname2",
"password"=>"toto2",
"group"=>"group1"))->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame ("2", $res);
}
public function test_insertAutoincrement3 ()
{
// Test autoincrement
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->setForeignObj ($tbl1);
$res = $tbl2->insert()->setValues(array ("gecos"=>"firstname3",
"password"=>"toto3",
"group"=>"group1"))->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame ("3", $res);
}
public function test_delete3 ()
{
// Delete with WHERE clause
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->setForeignObj ($tbl1);
$res = $tbl2->delete ()
->whereAdd ("gecos", "LIKE", "firstname%")
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame (2, $res);
}
public function test_select5 ()
{
// Select all on the table : one entry "gecos"=>"name"
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->setForeignObj ($tbl1);
$res = $tbl2->select()->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame (array (array ("uid"=>1,
"gecos"=>"name",
"password"=>"toto",
"group"=>"group1")), $res);
}
/// SCHEMA MANAGEMENT ///
public function test_getTableSchema1 ()
{
$tbl3 = $this->tbl3 ();
$res = $tbl3->getTableSchema ("usersoo");
$tbl3->disconnect ();
$this->assertSame (
array ("fields"=>array (
"uid"=>array ("integer", "not null", "autoincrement"),
"gecos"=>array ("varchar(255)", "not null"),
"password"=>array ("varchar(255)", "not null"),
"group" => array ("varchar(255)", "not null"),
),
"primary"=>"uid",
"unique"=>array ("gecos","password"),
"foreign" => array (
"group" => array ('groupedoo', 'group', 'ON DELETE CASCADE'),
),
), $res);
}
// JOINS
public function test_insertJoin1 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->insert()
->setValues(array ("group"=>"group2",
"object"=>"object",
"where"=>"where"))
->execute ();
$tbl2 = $this->tbl2 ();
$tbl2->setForeignObj ($tbl1);
$res = $tbl2->insert()
->setValues(array ("gecos"=>"name2",
"password"=>"pwd2",
"group"=>"group1"))
->execute ();
$res = $tbl2->insert()
->setValues(array ("gecos"=>"name3",
"password"=>"pwd3",
"group"=>"group1"))
->execute ();
$res = $tbl2->insert()
->setValues(array ("gecos"=>"name4",
"password"=>"pwd4",
"group"=>"group1"))
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
}
public function test_innerJoin1 ()
{
// No filter
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$res = $tbl2->select ()
->joinInner ($tbl1, array ("group"=>"group"))
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame (array (
array (
'usersoo.uid' => 1,
'usersoo.gecos' => 'name',
'usersoo.password' => 'toto',
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
),
array (
'usersoo.uid' => 4,
'usersoo.gecos' => 'name2',
'usersoo.password' => 'pwd2',
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
),
array (
'usersoo.uid' => 5,
'usersoo.gecos' => 'name3',
'usersoo.password' => 'pwd3',
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
),
array (
'usersoo.uid' => 6,
'usersoo.gecos' => 'name4',
'usersoo.password' => 'pwd4',
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
),
), $res);
}
public function test_leftJoin2 ()
{
// No filter
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$res = $tbl1->select ()
->joinLeft ($tbl2, array ("group"=>"group"))
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame (array (
array (
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
'usersoo.uid' => 1,
'usersoo.gecos' => 'name',
'usersoo.password' => 'toto',
'usersoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
'usersoo.uid' => 4,
'usersoo.gecos' => 'name2',
'usersoo.password' => 'pwd2',
'usersoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
'usersoo.uid' => 5,
'usersoo.gecos' => 'name3',
'usersoo.password' => 'pwd3',
'usersoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group1',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
'usersoo.uid' => 6,
'usersoo.gecos' => 'name4',
'usersoo.password' => 'pwd4',
'usersoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group2',
'groupedoo.object' => 'object',
'groupedoo.where' => 'where',
'groupedoo.with space' => NULL,
'usersoo.uid' => 0,
'usersoo.gecos' => NULL,
'usersoo.password' => NULL,
'usersoo.group' => NULL,
),
), $res);
}
public function test_leftJoin3 ()
{
// Filter on the tbl1, do not display tbl2
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->displayAdd ();
$res = $tbl1->select ()
->displayAdd ("group")
->joinLeft ($tbl2, array ("group"=>"group"))
->orderAdd ("group", "ASC")
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame (array (
array (
'groupedoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group1',
),
array (
'groupedoo.group' => 'group2',
),
), $res);
}
public function test_leftJoin4 ()
{
// Filter on the tbl1, display one column in tbl2
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->displayAdd ("group");
$res = $tbl1->select ()
->displayAdd ("group")
->joinLeft ($tbl2, array ("group"=>"group"))
->orderAdd ("group", "DESC")
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame (array (
array (
'usersoo.group' => NULL,
'groupedoo.group' => 'group2',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
), $res);
}
public function test_leftJoin5 ()
{
// Filter on the tbl1 and add order in full mode
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl2->displayAdd ("group");
$res = $tbl1->select ()
->displayAdd ("group")
->joinLeft ($tbl2, array ("group"=>"group"))
->orderAdd ("group", "DESC")
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame (array (
array (
'usersoo.group' => NULL,
'groupedoo.group' => 'group2',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
array (
'usersoo.group' => 'group1',
'groupedoo.group' => 'group1',
),
), $res);
}
/// THREE TABLES ///
public function test_insert6 ()
{
$tbl1 = $this->tbl1 ();
$tbl4 = $this->tbl4 ();
$tbl4->setForeignObj ($tbl1);
$res = $tbl4->insert ()
->setValues(array ("name"=>"RO",
"group"=>"group1"))
->execute ();
$tbl4->disconnect ();
// As the key is not an autoincrement, the lastInsertID can be 0 or 1
$this->assertGreaterThanOrEqual ($res, "0");
}
public function test_leftJoin6 ()
{
// Two joins tables in left join
$tbl1 = $this->tbl1 (); // Do not display anything from groupedoo
$tbl1->displayAdd ("group")
->orderAdd ("group", "DESC");
$tbl2 = $this->tbl2 (); // Display the gecos and group from usersoo
$tbl2->displayAdd ("gecos")
->orderAdd ("gecos", "ASC");
$tbl4 = $this->tbl4 (); // Display the name in rightsoo
$tbl4->displayAdd ("name");
$tbl1->joinLeft ($tbl4, array ("group"=>"group"));
$res = $tbl1->select ()
->joinLeft ($tbl2, array ("group"=>"group"))
->execute ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$tbl4->disconnect ();
$this->assertSame (array (
array (
'groupedoo.group' => 'group2',
'usersoo.gecos' => NULL,
'rightsoo.name' => NULL,
),
array (
'groupedoo.group' => 'group1',
'usersoo.gecos' => 'name',
'rightsoo.name' => 'RO',
),
array (
'groupedoo.group' => 'group1',
'usersoo.gecos' => 'name2',
'rightsoo.name' => 'RO',
),
array (
'groupedoo.group' => 'group1',
'usersoo.gecos' => 'name3',
'rightsoo.name' => 'RO',
),
array (
'groupedoo.group' => 'group1',
'usersoo.gecos' => 'name4',
'rightsoo.name' => 'RO',
),
), $res);
}
public function test_sortOrder1 ()
{
$tbl1 = $this->tbl1 ();
$res = $tbl1->getSortOrder ();
$tbl1->disconnect ();
$this->assertSame ("order1", $res);
}
public function test_sortOrder2 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->getSortOrder ();
$res = $tbl1->getSortOrder ();
$tbl1->disconnect ();
$this->assertSame ("order2", $res);
}
public function test_sortOrder3 ()
{
$tbl1 = $this->tbl1 ();
$tbl2 = $this->tbl2 ();
$tbl1->getSortOrder ();
$tbl1->getSortOrder ();
$res = $tbl2->getSortOrder ();
$tbl1->disconnect ();
$tbl2->disconnect ();
$this->assertSame ("order3", $res);
}
public function test_displayAdd_NotFull1 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group");
$res = $tbl1->displayGet ();
$tbl1->disconnect ();
$this->assertSame (array ("order1" => $tbl1->sep()."group".$tbl1->sep()),
$res);
}
public function test_displayAdd_NotFull2 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("distinct group");
$res = $tbl1->displayGet ();
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "DISTINCT ".$tbl1->sep()."group".$tbl1->sep()), $res);
}
public function test_displayAdd_NotFull3 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group_concat ( group ) ");
$res = $tbl1->displayGet ();
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "GROUP_CONCAT(".$tbl1->sep()."group".$tbl1->sep().")"), $res);
}
public function test_displayAdd_NotFull4 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group_concat (distinct group ) ");
$res = $tbl1->displayGet ();
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "GROUP_CONCAT(DISTINCT ".
$tbl1->sep()."group".$tbl1->sep().")"), $res);
}
public function test_displayAdd_NotFull5 ()
{
// With alias
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group_concat (distinct group ) ", "Group Alias");
$res = $tbl1->displayGet ();
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "GROUP_CONCAT(DISTINCT ".
$tbl1->sep()."group".$tbl1->sep().") AS ".
$tbl1->sep()."Group Alias".$tbl1->sep()), $res);
}
public function test_displayAdd_Full1 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group");
$res = $tbl1->displayGet (true);
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => $tbl1->sep()."groupedoo".$tbl1->sep().".".
$tbl1->sep()."group".$tbl1->sep()),
$res);
}
public function test_displayAdd_Full2 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("distinct group");
$res = $tbl1->displayGet (true);
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "DISTINCT ".$tbl1->sep()."groupedoo".$tbl1->sep().".".
$tbl1->sep()."group".$tbl1->sep()), $res);
}
public function test_displayAdd_Full3 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group_concat ( group ) ");
$res = $tbl1->displayGet (true);
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "GROUP_CONCAT(".$tbl1->sep()."groupedoo".$tbl1->sep().".".
$tbl1->sep()."group".$tbl1->sep().")"), $res);
}
public function test_displayAdd_Full4 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group_concat (distinct group ) ");
$res = $tbl1->displayGet (true);
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "GROUP_CONCAT(DISTINCT ".
$tbl1->sep()."groupedoo".$tbl1->sep().".".
$tbl1->sep()."group".$tbl1->sep().")"), $res);
}
public function test_displayAdd_Full5 ()
{
// With alias
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group_concat (distinct group ) ", "Group Alias");
$res = $tbl1->displayGet (true);
$tbl1->disconnect ();
$this->assertSame (array (
"order1" => "GROUP_CONCAT(DISTINCT ".
$tbl1->sep()."groupedoo".$tbl1->sep().".".
$tbl1->sep()."group".$tbl1->sep().") AS ".
$tbl1->sep()."Group Alias".$tbl1->sep()), $res);
}
public function test_displayAdd_Multiple1 ()
{
$tbl1 = $this->tbl1 ();
$tbl1->displayAdd ("group");
$tbl1->displayAdd ("where");
$res = $tbl1->displayGet ();
$tbl1->disconnect ();
$this->assertSame (array ("order1" => $tbl1->sep()."group".$tbl1->sep(),
"order2" => $tbl1->sep()."where".$tbl1->sep(),),
$res);
}
public function test_update5 ()
{
// Manage to update the non unique fields
// the "where" column is not unique, so it allow to have twice the same
// value
$tbl1 = $this->tbl1 ();
$res = $tbl1->update()
->setValues(array ("where"=>"where2"))
->execute ();
$tbl1->disconnect ();
$this->assertSame (2, $res);
}
public function test_update6 ()
{
// Manage to update the primary / unique fields
// There is 2 lines in the DB, so the unique key "group" can not be updated
// with the same value twice (the result can not be unique)
$tbl1 = $this->tbl1 ();
$this->setExpectedException ("Exception");
$res = $tbl1->update()
->setValues(array ("group"=>"group3"))
->execute ();
$tbl1->disconnect ();
}
}