Compare commits
3 Commits
84e2b419c8
...
a2e103c32f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2e103c32f | ||
|
|
2f4461f8d9 | ||
|
|
5b56197aaa |
@@ -16,11 +16,17 @@ use Domframework\Dbjson;
|
||||
*/
|
||||
class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $DBFILE;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->DBFILE = "/tmp/dbjson-" . time();
|
||||
}
|
||||
|
||||
public function testInsertOne1()
|
||||
{
|
||||
// Document #0
|
||||
define("dbfile", "/tmp/dbjson-" . time());
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->insertOne(
|
||||
"collection",
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
@@ -31,7 +37,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
public function testInsertOne2()
|
||||
{
|
||||
// Document #1
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->insertOne(
|
||||
"collection",
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
@@ -43,7 +49,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// Error : Invalid array provided (not array of array)
|
||||
$this->setExpectedException("Exception");
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->insertMany(
|
||||
"collection",
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
@@ -53,7 +59,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
public function testInsertMany2()
|
||||
{
|
||||
// Document #2 and #3
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->insertMany(
|
||||
"collection",
|
||||
[["key1" => "val3", "key2" => "val2"],
|
||||
@@ -65,21 +71,21 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
public function testFilter1()
|
||||
{
|
||||
// Return all the keys (filter = array ())
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->filter("collection", []);
|
||||
$this->assertSame(array_keys($res), [0,1,2,3]);
|
||||
}
|
||||
public function testFilter2()
|
||||
{
|
||||
// Return the keys where filter = array ("key2"=>"val2"))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->filter("collection", ["key2" => "val2"]);
|
||||
$this->assertSame(array_keys($res), [0,1,2]);
|
||||
}
|
||||
public function testFilter3()
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>"val3","key2"=>"val2"))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->filter("collection", ["key1" => "val3",
|
||||
"key2" => "val2"]);
|
||||
$this->assertSame(count($res), 1);
|
||||
@@ -88,7 +94,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "=="),
|
||||
// "key2"=>array ("val2", "=="))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->filter("collection", ["key1" => ["val3", "=="],
|
||||
"key2" => ["val2", "=="]]);
|
||||
$this->assertSame(count($res), 1);
|
||||
@@ -97,7 +103,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||
// "key2"=>array ("val2", "=="))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->filter("collection", ["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", "=="]]);
|
||||
$this->assertSame(array_keys($res), [0,1,2]);
|
||||
@@ -106,7 +112,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
|
||||
// "key2"=>array ("val2", ">"))
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->filter("collection", ["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]]);
|
||||
$this->assertSame(count($res), 1);
|
||||
@@ -114,7 +120,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testFind1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find("collection", ["key1" => ["val3", "<="],
|
||||
"key2" => ["val2", ">"]]);
|
||||
$res = array_values($res);
|
||||
@@ -125,7 +131,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind2()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -142,7 +148,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// Exception : fields not an array
|
||||
$this->setExpectedException("Exception");
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -152,7 +158,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind4()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -166,7 +172,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind5()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -181,7 +187,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind6()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -202,7 +208,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind7()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -220,7 +226,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind8()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -236,7 +242,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDeleteOne1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->deleteOne(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -247,7 +253,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind9()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -264,7 +270,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDeleteMany1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->deleteMany(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -275,7 +281,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind10()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->find(
|
||||
"collection",
|
||||
["key1" => ["val3", "<="],
|
||||
@@ -290,7 +296,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testFind11()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
@@ -299,13 +305,13 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testReplace1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->replace("collection", [], ["key2" => "val5"]);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
public function testFind12()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
@@ -314,14 +320,14 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdate1()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->update("collection", [], ["key2" => "val6",
|
||||
"key5" => "val5"]);
|
||||
$this->assertSame($res, 1);
|
||||
}
|
||||
public function testFind13()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
@@ -331,7 +337,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
public function testInsertOne3()
|
||||
{
|
||||
// Document #4
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->insertOne(
|
||||
"collection",
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
@@ -340,7 +346,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind14()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
@@ -353,14 +359,14 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdate2()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->update("collection", [], ["key2" => "val7",
|
||||
"key5" => "val8"]);
|
||||
$this->assertSame($res, 2);
|
||||
}
|
||||
public function testFind15()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
@@ -374,7 +380,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdate3()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = $dbjson->update(
|
||||
"collection",
|
||||
[],
|
||||
@@ -386,7 +392,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
public function testFind16()
|
||||
{
|
||||
$dbjson = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$res = array_values($dbjson->find("collection"));
|
||||
// ["_id"] is random : skip the test
|
||||
unset($res[0]["_id"]);
|
||||
@@ -399,8 +405,8 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
|
||||
// Concurrency tests
|
||||
public function testConcurrency1()
|
||||
{
|
||||
$dbjson1 = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson2 = new Dbjson("dbjson://" . dbfile);
|
||||
$dbjson1 = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$dbjson2 = new Dbjson("dbjson://" . $this->DBFILE);
|
||||
$dbjson1->insertOne(
|
||||
"collection",
|
||||
["key1" => "val1", "key2" => "val2"]
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Domframework\Tests;
|
||||
|
||||
use Domframework\Dblayer;
|
||||
|
||||
class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
class DblayerTestENGINE 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 $engine = "ENGINE";
|
||||
public $confs = [
|
||||
"sqlite" => [
|
||||
"dsn" => "sqlite:/tmp/databaseDBLayer.db",
|
||||
@@ -47,7 +47,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDropTable()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -75,7 +75,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
public function testCreateTable1()
|
||||
{
|
||||
// Create a table named grouped
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -99,7 +99,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testInsert1()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -123,7 +123,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRead1()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -148,7 +148,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdate1()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -170,7 +170,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRead2()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -195,7 +195,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdate2()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -218,7 +218,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testRead3()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -243,7 +243,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUpdate3()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -277,7 +277,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
public function testCreateTable2()
|
||||
{
|
||||
// Create a table named group
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -306,7 +306,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testInsert2()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -335,7 +335,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
// Test the unique feature
|
||||
public function testInsert3()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -362,7 +362,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testInsert4()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -395,7 +395,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
// Create a table named group
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -432,7 +432,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
public function testCreateTable3()
|
||||
{
|
||||
// Create a table named group
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -454,7 +454,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testReadOR1()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayer(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Domframework\Tests;
|
||||
|
||||
use Domframework\Dblayeroo;
|
||||
|
||||
class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
class DblayerooTestENGINE 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 $engine = "ENGINE";
|
||||
public $confs = [
|
||||
"sqlite" => [
|
||||
"dsn" => "sqlite:/tmp/databaseDBLayeroo.db",
|
||||
@@ -44,7 +44,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function tbl1()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$tbl1 = new Dblayeroo(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -64,7 +64,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function tbl2()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$tbl2 = new Dblayeroo(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -86,7 +86,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function tbl3()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$tbl3 = new Dblayeroo(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -98,7 +98,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function tbl4()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$tbl4 = new Dblayeroo(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -119,7 +119,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testDropTable()
|
||||
{
|
||||
$dbconfig = $this->confs["{ENGINE}"];
|
||||
$dbconfig = $this->confs["ENGINE"];
|
||||
$db = new Dblayeroo(
|
||||
$dbconfig["dsn"],
|
||||
$dbconfig["username"],
|
||||
@@ -1250,7 +1250,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_integerPositive",
|
||||
"checkRealTypeIntegerPositive",
|
||||
"1",
|
||||
""
|
||||
);
|
||||
@@ -1261,7 +1261,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_integerPositive",
|
||||
"checkRealTypeIntegerPositive",
|
||||
"-1",
|
||||
""
|
||||
);
|
||||
@@ -1273,7 +1273,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_integerPositive",
|
||||
"checkRealTypeIntegerPositive",
|
||||
"0777",
|
||||
""
|
||||
);
|
||||
@@ -1285,7 +1285,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_integerPositive",
|
||||
"checkRealTypeIntegerPositive",
|
||||
"07a7",
|
||||
""
|
||||
);
|
||||
@@ -1298,7 +1298,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_allowedchars",
|
||||
"checkRealTypeAllowedchars",
|
||||
"1111",
|
||||
"allowedchars(123)"
|
||||
);
|
||||
@@ -1309,7 +1309,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_allowedchars",
|
||||
"checkRealTypeAllowedchars",
|
||||
"-1",
|
||||
"allowedchars(123)"
|
||||
);
|
||||
@@ -1321,7 +1321,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_array",
|
||||
"checkRealTypeArray",
|
||||
"235",
|
||||
"array('123','235','256')"
|
||||
);
|
||||
@@ -1332,7 +1332,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_array",
|
||||
"checkRealTypeArray",
|
||||
"777",
|
||||
"array('123','235','256')"
|
||||
);
|
||||
@@ -1344,7 +1344,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_regex",
|
||||
"checkRealTypeRegex",
|
||||
"235",
|
||||
"regex(/^\\d+$/)"
|
||||
);
|
||||
@@ -1355,7 +1355,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_regex",
|
||||
"checkRealTypeRegex",
|
||||
"235",
|
||||
"regex(/^\\d{3}$/)"
|
||||
);
|
||||
@@ -1366,7 +1366,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_regex",
|
||||
"checkRealTypeRegex",
|
||||
"235",
|
||||
"regex(/^\\d{4}$/)"
|
||||
);
|
||||
@@ -1377,7 +1377,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_regex",
|
||||
"checkRealTypeRegex",
|
||||
"abcdef",
|
||||
"regex(/^[a-z]+$/)"
|
||||
);
|
||||
@@ -1388,7 +1388,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_regex",
|
||||
"checkRealTypeRegex",
|
||||
"Abcdef",
|
||||
"regex(/^[a-z]+$/)"
|
||||
);
|
||||
@@ -1400,7 +1400,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_mail",
|
||||
"checkRealTypeMail",
|
||||
"toto@example.com",
|
||||
""
|
||||
);
|
||||
@@ -1411,7 +1411,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_mail",
|
||||
"checkRealTypeMail",
|
||||
"toto@",
|
||||
""
|
||||
);
|
||||
@@ -1423,7 +1423,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_uuid",
|
||||
"checkRealTypeUuid",
|
||||
"4e799e3f-f376-46e5-a5db-85200949987e",
|
||||
""
|
||||
);
|
||||
@@ -1434,7 +1434,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_uuid",
|
||||
"checkRealTypeUuid",
|
||||
"4E799E3F-F376-46E5-A5DB-85200949987E",
|
||||
""
|
||||
);
|
||||
@@ -1445,7 +1445,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_uuid",
|
||||
"checkRealTypeUuid",
|
||||
"4E799E3F-F376-46E5+A5DB+85200949987E",
|
||||
""
|
||||
);
|
||||
@@ -1456,7 +1456,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_uuid",
|
||||
"checkRealTypeUuid",
|
||||
"4E799E3F5F376546E55A5DB585200949987E",
|
||||
""
|
||||
);
|
||||
@@ -1468,7 +1468,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqldate",
|
||||
"checkRealTypeSqldate",
|
||||
"2018-10-24",
|
||||
""
|
||||
);
|
||||
@@ -1479,7 +1479,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqldate",
|
||||
"checkRealTypeSqldate",
|
||||
"2018/10/24",
|
||||
""
|
||||
);
|
||||
@@ -1490,7 +1490,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqldate",
|
||||
"checkRealTypeSqldate",
|
||||
"2018-10-32",
|
||||
""
|
||||
);
|
||||
@@ -1502,7 +1502,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqltime",
|
||||
"checkRealTypeSqltime",
|
||||
"12:34:56",
|
||||
""
|
||||
);
|
||||
@@ -1513,7 +1513,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqltime",
|
||||
"checkRealTypeSqltime",
|
||||
"12;22;22",
|
||||
""
|
||||
);
|
||||
@@ -1524,7 +1524,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqltime",
|
||||
"checkRealTypeSqltime",
|
||||
"32:34:56",
|
||||
""
|
||||
);
|
||||
@@ -1536,7 +1536,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqldatetime",
|
||||
"checkRealTypeSqldatetime",
|
||||
"2018-10-24 22:23:24",
|
||||
""
|
||||
);
|
||||
@@ -1547,7 +1547,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqldatetime",
|
||||
"checkRealTypeSqldatetime",
|
||||
"2018/10/24",
|
||||
""
|
||||
);
|
||||
@@ -1558,7 +1558,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
|
||||
$tbl1 = $this->tbl1();
|
||||
$res = $this->invokeMethod(
|
||||
$tbl1,
|
||||
"checkRealType_sqldatetime",
|
||||
"checkRealTypeSqldatetime",
|
||||
"2018-10-24 25:12:25",
|
||||
""
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ define("PHPUNIT", "ON-GOING");
|
||||
file_put_contents(
|
||||
"Tests/DblayerooSqliteTest.php",
|
||||
str_replace(
|
||||
"{ENGINE}",
|
||||
"ENGINE",
|
||||
"sqlite",
|
||||
file_get_contents("Tests/DblayerooComplet.php")
|
||||
)
|
||||
@@ -33,7 +33,7 @@ file_put_contents(
|
||||
file_put_contents(
|
||||
"Tests/DblayerooMySQLTest.php",
|
||||
str_replace(
|
||||
"{ENGINE}",
|
||||
"ENGINE",
|
||||
"mysql",
|
||||
file_get_contents("Tests/DblayerooComplet.php")
|
||||
)
|
||||
@@ -41,7 +41,7 @@ file_put_contents(
|
||||
file_put_contents(
|
||||
"Tests/DblayerooPostgreSQLTest.php",
|
||||
str_replace(
|
||||
"{ENGINE}",
|
||||
"ENGINE",
|
||||
"pgsql",
|
||||
file_get_contents("Tests/DblayerooComplet.php")
|
||||
)
|
||||
@@ -49,7 +49,7 @@ file_put_contents(
|
||||
file_put_contents(
|
||||
"Tests/DblayerSqliteTest.php",
|
||||
str_replace(
|
||||
"{ENGINE}",
|
||||
"ENGINE",
|
||||
"sqlite",
|
||||
file_get_contents("Tests/DblayerComplet.php")
|
||||
)
|
||||
@@ -57,7 +57,7 @@ file_put_contents(
|
||||
file_put_contents(
|
||||
"Tests/DblayerMySQLTest.php",
|
||||
str_replace(
|
||||
"{ENGINE}",
|
||||
"ENGINE",
|
||||
"mysql",
|
||||
file_get_contents("Tests/DblayerComplet.php")
|
||||
)
|
||||
@@ -65,7 +65,7 @@ file_put_contents(
|
||||
file_put_contents(
|
||||
"Tests/DblayerPostgreSQLTest.php",
|
||||
str_replace(
|
||||
"{ENGINE}",
|
||||
"ENGINE",
|
||||
"pgsql",
|
||||
file_get_contents("Tests/DblayerComplet.php")
|
||||
)
|
||||
|
||||
@@ -214,7 +214,7 @@ class Authldap extends Auth
|
||||
"email" => $vals["mail"][0]];
|
||||
}
|
||||
|
||||
unset($data[$key]["mail"]["count"]);
|
||||
unset($data[$key]["email"]["count"]);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
@@ -490,10 +490,10 @@ class Authorizationdb extends Authorization
|
||||
* Change mode bits for an object
|
||||
* Need to be the owner of the object or the root administrator
|
||||
* @param string $object Object path to change
|
||||
* @param integer $mod Bits of authorization
|
||||
* @param integer $modbits Bits of authorization
|
||||
* @return boolean TRUE or an exception with the error message
|
||||
*/
|
||||
public function chmod($object, $mod)
|
||||
public function chmod($object, $modbits)
|
||||
{
|
||||
if ($this->db === null) {
|
||||
throw new \Exception(dgettext(
|
||||
@@ -743,6 +743,7 @@ class Authorizationdb extends Authorization
|
||||
|
||||
foreach ($parents as $i => $p) {
|
||||
$found = false;
|
||||
$r = [];
|
||||
foreach ($res as $r) {
|
||||
if ($r["object"] === $p) {
|
||||
$found = true;
|
||||
|
||||
@@ -41,7 +41,7 @@ class Authshibboleth extends Auth
|
||||
/**
|
||||
* The optional URL to change the user password
|
||||
*/
|
||||
public $urlPasswd = "";
|
||||
public $urlPasswdChange = "";
|
||||
|
||||
/**
|
||||
* No connection to shibboleth
|
||||
|
||||
@@ -91,6 +91,7 @@ class Cli
|
||||
// This error code is not included in error_reporting
|
||||
return;
|
||||
}
|
||||
$severity = "ERROR";
|
||||
switch ($errno) {
|
||||
case E_ERROR:
|
||||
$severity = "ERROR";
|
||||
@@ -217,6 +218,7 @@ class Cli
|
||||
}
|
||||
die("No controllers/models available in " . getcwd() . "\n");
|
||||
}
|
||||
$classes = [];
|
||||
foreach ($files as $file) {
|
||||
if (strpos($file, "_")) {
|
||||
$classes[substr(strstr($file, "_"), 1, -4)] = $file;
|
||||
@@ -415,17 +417,22 @@ class Cli
|
||||
|
||||
if (in_array("-?", $argv, true)) {
|
||||
// Question mark display the PHPDoc of the method
|
||||
$comment = "";
|
||||
if (isset($r1)) {
|
||||
$comment = trim(substr($r1->getDocComment(), 3, -2));
|
||||
if ($comment !== "") {
|
||||
$comment .= "\n";
|
||||
}
|
||||
}
|
||||
$comment .= trim(substr($r2->getDocComment(), 3, -2));
|
||||
$comment = preg_replace("#^\s*\*\s*#m", "", $comment);
|
||||
$comment = preg_replace("#@param .+ \\$(\w+) #U", "<\\1> ", $comment);
|
||||
$params = "";
|
||||
if (isset($r1)) {
|
||||
foreach ($r1->getParameters() as $param) {
|
||||
$params .= "<" . $param->name . "> ";
|
||||
}
|
||||
}
|
||||
foreach ($r2->getParameters() as $param) {
|
||||
$params .= "<" . $param->name . "> ";
|
||||
}
|
||||
@@ -449,7 +456,7 @@ class Cli
|
||||
// (Array management in CLI)
|
||||
foreach ($argv as $key => $arg) {
|
||||
// Don't modify the stdin
|
||||
if (isset($keyStdIn) && $key === $keyStdIn) {
|
||||
if ($key === $keyStdIn) {
|
||||
continue;
|
||||
}
|
||||
$pairs = explode('&', $arg);
|
||||
|
||||
@@ -694,7 +694,7 @@ class Console
|
||||
*/
|
||||
public function completeFunction($completionKeys, $completionFunction)
|
||||
{
|
||||
if (! is_string($completionKeys) && ! is_boolean($completionKeys)) {
|
||||
if (! is_string($completionKeys) && ! is_bool($completionKeys)) {
|
||||
$this->consoleException("Can not set the completionKeys : not a string");
|
||||
}
|
||||
if ($completionKeys === true) {
|
||||
|
||||
@@ -351,12 +351,12 @@ class Dblayeroo
|
||||
if ($this->sep === "") {
|
||||
$this->DBException(dgettext("domframework", "Database not connected"));
|
||||
}
|
||||
$res = [];
|
||||
switch (self::$instance[$this->dsn]->getAttribute(\PDO::ATTR_DRIVER_NAME)) {
|
||||
case "sqlite":
|
||||
$req = "SELECT name FROM sqlite_master WHERE type='table'";
|
||||
$st = self::$instance[$this->dsn]->prepare($req);
|
||||
$st->execute();
|
||||
$res = [];
|
||||
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
|
||||
if ($d["name"] !== "sqlite_sequence") {
|
||||
$res[] = $d["name"];
|
||||
@@ -369,7 +369,6 @@ class Dblayeroo
|
||||
WHERE TABLE_SCHEMA='" . $this->databasename() . "'";
|
||||
$st = self::$instance[$this->dsn]->prepare($req);
|
||||
$st->execute();
|
||||
$res = [];
|
||||
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$res[] = $d["TABLE_NAME"];
|
||||
}
|
||||
@@ -380,7 +379,6 @@ class Dblayeroo
|
||||
WHERE schemaname = 'public'";
|
||||
$st = self::$instance[$this->dsn]->prepare($req);
|
||||
$st->execute();
|
||||
$res = [];
|
||||
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$res[] = $d["tablename"];
|
||||
}
|
||||
@@ -430,6 +428,7 @@ class Dblayeroo
|
||||
"No table name defined to create the table"
|
||||
), 500);
|
||||
}
|
||||
$sql = "";
|
||||
switch (self::$instance[$this->dsn]->getAttribute(\PDO::ATTR_DRIVER_NAME)) {
|
||||
case "sqlite":
|
||||
$sql = "CREATE TABLE IF NOT EXISTS " .
|
||||
@@ -1684,7 +1683,7 @@ class Dblayeroo
|
||||
}
|
||||
@list($func, $param) = explode("(", $realType);
|
||||
$func = trim($func);
|
||||
$method = "checkRealType_" . $func;
|
||||
$method = "checkRealType" . ucfirst($func);
|
||||
if (! method_exists($this, $method)) {
|
||||
$this->DBException("Invalid setRealType provided : " .
|
||||
"field '$field' : unknown realType provided '$func'");
|
||||
@@ -2008,10 +2007,10 @@ class Dblayeroo
|
||||
}
|
||||
$display = $name = trim($display);
|
||||
$pos = strpos($display, "(");
|
||||
$separator = "";
|
||||
if ($pos !== false) {
|
||||
$func = strtoupper(trim(substr($name, 0, $pos)));
|
||||
$name = trim(substr($name, $pos + 1, -1));
|
||||
$separator = "";
|
||||
if (
|
||||
in_array($func, ["AVG", "COUNT", "GROUP_CONCAT", "MAX",
|
||||
"MIN","SUM"], true)
|
||||
@@ -2848,6 +2847,7 @@ class Dblayeroo
|
||||
"The unique configuration is not an array"
|
||||
));
|
||||
}
|
||||
$sql = "";
|
||||
switch ($this->command) {
|
||||
case "SELECT":
|
||||
$sql = "SELECT";
|
||||
@@ -2980,7 +2980,7 @@ class Dblayeroo
|
||||
try {
|
||||
$st = self::$instance[$this->dsn]->prepare($sql);
|
||||
} catch (\Exception $e) {
|
||||
$this->DBException($e->getMessage());
|
||||
throw $this->DBException($e->getMessage());
|
||||
}
|
||||
}
|
||||
foreach ($this->whereGetValues() as $hash => $val) {
|
||||
@@ -3053,7 +3053,7 @@ class Dblayeroo
|
||||
$text .= "(date)\n";
|
||||
} else {
|
||||
$text .= "(UNKNOWN)\n";
|
||||
$this->DBException("TO BE DEVELOPPED : " . $fields[$field][0]);
|
||||
$this->DBException("TO BE DEVELOPPED : Unknown type : " . $type);
|
||||
}
|
||||
if (!$textForm) {
|
||||
if ($value === null) {
|
||||
@@ -3306,6 +3306,7 @@ class Dblayeroo
|
||||
}
|
||||
$setValues = $values;
|
||||
$foundImpactedLines = 0;
|
||||
$resUpdate = [];
|
||||
foreach ($uniques as $k => $columns) {
|
||||
if ($update) {
|
||||
// Can not update multiple UNIQUE rows with the same value
|
||||
@@ -3314,7 +3315,7 @@ class Dblayeroo
|
||||
} elseif (is_array($columns)) {
|
||||
$cols = $columns;
|
||||
} else {
|
||||
$this->DBException(dgettext(
|
||||
throw $this->DBException(dgettext(
|
||||
"domframework",
|
||||
"Unique def is not a string or an array"
|
||||
));
|
||||
@@ -3592,7 +3593,7 @@ class Dblayeroo
|
||||
$val = trim($values[$field]);
|
||||
@list($func, $param) = explode("(", $this->realTypes[$field]);
|
||||
$func = trim($func);
|
||||
$method = "checkRealType_" . $func;
|
||||
$method = "checkRealType" . ucfirst($func);
|
||||
$res = $this->$method($val, $this->realTypes[$field]);
|
||||
if (is_string($res)) {
|
||||
$errors[$field] = $res;
|
||||
@@ -3796,7 +3797,7 @@ class Dblayeroo
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($autoInc !== null) {
|
||||
if ($autoInc !== null && isset($col)) {
|
||||
$autoInc = $this->table . "_{$col}_seq";
|
||||
}
|
||||
}
|
||||
@@ -3912,7 +3913,7 @@ class Dblayeroo
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
*/
|
||||
private function checkRealType_integerPositive($val, $definition)
|
||||
private function checkRealTypeIntegerPositive($val, $definition)
|
||||
{
|
||||
if (substr($val, 0, 1) === "-") {
|
||||
return dgettext("domframework", "Invalid positive integer : " .
|
||||
@@ -3935,7 +3936,7 @@ class Dblayeroo
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
*/
|
||||
private function checkRealType_integer($val, $definition)
|
||||
private function checkRealTypeInteger($val, $definition)
|
||||
{
|
||||
if (strspn($val, "0123456789-") !== strlen($val)) {
|
||||
return dgettext("domframework", "Invalid integer : " .
|
||||
@@ -3959,7 +3960,7 @@ class Dblayeroo
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
*/
|
||||
private function checkRealType_allowedchars($val, $definition)
|
||||
private function checkRealTypeAllowedchars($val, $definition)
|
||||
{
|
||||
list($func, $param) = explode("(", $definition);
|
||||
if ($param === null) {
|
||||
@@ -3988,7 +3989,7 @@ class Dblayeroo
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
*/
|
||||
private function checkRealType_array($val, $definition)
|
||||
private function checkRealTypeArray($val, $definition)
|
||||
{
|
||||
list($func, $param) = explode("(", $definition);
|
||||
if ($param === null) {
|
||||
@@ -4018,7 +4019,7 @@ class Dblayeroo
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
*/
|
||||
private function checkRealType_regex($val, $definition)
|
||||
private function checkRealTypeRegex($val, $definition)
|
||||
{
|
||||
list($func, $param) = explode("(", $definition);
|
||||
if ($param === null) {
|
||||
@@ -4047,7 +4048,7 @@ class Dblayeroo
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
*/
|
||||
private function checkRealType_mail($val, $definition)
|
||||
private function checkRealTypeMail($val, $definition)
|
||||
{
|
||||
if (!! filter_var($val, FILTER_VALIDATE_EMAIL)) {
|
||||
return;
|
||||
@@ -4059,9 +4060,9 @@ class Dblayeroo
|
||||
* Check the type "uuid"
|
||||
* @param string $val The value to check
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
* @return string|null
|
||||
*/
|
||||
private function checkRealType_uuid($val, $definition)
|
||||
private function checkRealTypeUuid($val, $definition)
|
||||
{
|
||||
if (strlen($val) !== 36) {
|
||||
return dgettext("domframework", "Invalid UUID provided : " .
|
||||
@@ -4082,9 +4083,9 @@ class Dblayeroo
|
||||
* Check the type "sqldate"
|
||||
* @param string $val The value to check
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
* @return string|null
|
||||
*/
|
||||
private function checkRealType_sqldate($val, $definition)
|
||||
private function checkRealTypeSqldate($val, $definition)
|
||||
{
|
||||
if (strlen($val) !== 10) {
|
||||
return dgettext("domframework", "Invalid date provided : " .
|
||||
@@ -4117,9 +4118,9 @@ class Dblayeroo
|
||||
* Check the type "sqltime"
|
||||
* @param string $val The value to check
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
* @return string|null
|
||||
*/
|
||||
private function checkRealType_sqltime($val, $definition)
|
||||
private function checkRealTypeSqltime($val, $definition)
|
||||
{
|
||||
if (strlen($val) !== 8) {
|
||||
return dgettext("domframework", "Invalid time provided : " .
|
||||
@@ -4152,9 +4153,9 @@ class Dblayeroo
|
||||
* Check the type "sqldatetime"
|
||||
* @param string $val The value to check
|
||||
* @param string $definition The definition of the type
|
||||
* @return string or null
|
||||
* @return string|null
|
||||
*/
|
||||
private function checkRealType_sqldatetime($val, $definition)
|
||||
private function checkRealTypeSqldatetime($val, $definition)
|
||||
{
|
||||
if (strlen($val) !== 19) {
|
||||
return dgettext("domframework", "Invalid date and time provided : " .
|
||||
|
||||
@@ -691,6 +691,7 @@ class File
|
||||
$newname = $this->realpath($newname);
|
||||
$this->checkPathRO(dirname($oldname));
|
||||
$this->checkPathRW(dirname($newname));
|
||||
$rc = "";
|
||||
if (is_dir($oldname)) {
|
||||
// Copy directory structure
|
||||
if (! $this->file_exists($newname)) {
|
||||
|
||||
@@ -471,7 +471,8 @@ class Form
|
||||
public function getToken()
|
||||
{
|
||||
if ($this->csrfToken === "") {
|
||||
$this->createToken();
|
||||
$csrf = new Csrf();
|
||||
$this->csrfToken = $csrf->newToken();
|
||||
}
|
||||
return $this->csrfToken;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ class Formfield
|
||||
* The Bootstrap width of the column of fields
|
||||
*/
|
||||
public $fieldwidth = 10;
|
||||
/**
|
||||
* Form template (Bootstrap3 by default)
|
||||
*/
|
||||
private $formTemplate = "Bootstrap3";
|
||||
|
||||
/**
|
||||
* When adding a field, the name and the label are the minimum mandatory
|
||||
|
||||
@@ -42,6 +42,12 @@ class Graph
|
||||
*/
|
||||
public $title = null;
|
||||
|
||||
/**
|
||||
* The graph title position
|
||||
* @var string
|
||||
*/
|
||||
private $titlePosition = null;
|
||||
|
||||
/**
|
||||
* The height of the graph (150px by default)
|
||||
*/
|
||||
|
||||
@@ -73,6 +73,7 @@ class GraphAxisHorizontal extends GraphAxisGeneral
|
||||
*/
|
||||
public function positionMin($value)
|
||||
{
|
||||
$posCenter = $this->position($value);
|
||||
if ($this->numerical) {
|
||||
return $posCenter;
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ class GraphAxisVertical extends GraphAxisGeneral
|
||||
*/
|
||||
public function positionMin($value)
|
||||
{
|
||||
$posCenter = $this->position($value);
|
||||
if ($this->numerical) {
|
||||
return $posCenter;
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ class GraphSerie
|
||||
"Invalid style provided to serie"
|
||||
), 406);
|
||||
}
|
||||
$styleClass = "GraphStyle" . $style;
|
||||
$styleClass = "GraphStyle" . ucfirst($style);
|
||||
if ($this->style === null) {
|
||||
$this->style = new $styleClass();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user