Commit 5a776a61 authored by Carsten  Rose's avatar Carsten Rose

Update PhpDoc, add phpstorm SQL suggestion to quote 'groups'

parent 75ddccee
Pipeline #3102 passed with stages
in 1 minute and 50 seconds
......@@ -71,7 +71,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check read rows
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person ORDER BY id LIMIT 2');
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person ORDER BY id LIMIT 2');
// Check count
$this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
......@@ -80,7 +80,7 @@ class DatabaseTest extends AbstractDatabaseTest {
// Check rows
// Same as above, but specify 'ROW_REGULAR'
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person ORDER BY id LIMIT 2', ROW_REGULAR);
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person ORDER BY id LIMIT 2', ROW_REGULAR);
$this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows
$this->assertEquals($expected, $dataArray);
......@@ -92,13 +92,13 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(array(), $dataArray);
// ROW_EXPECT_1
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person WHERE id=1', ROW_EXPECT_1);
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person WHERE id=1', ROW_EXPECT_1);
$this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows
$this->assertEquals($expected[0], $dataArray);
// ROW_EXPECT_0_1: 1
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person WHERE id=1', ROW_EXPECT_0_1);
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person WHERE id=1', ROW_EXPECT_0_1);
$this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows
$this->assertEquals($expected[0], $dataArray);
......@@ -110,23 +110,23 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(array(), $dataArray);
//ROW_EXPECT_GE_1 - one record
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person WHERE id=1', ROW_EXPECT_GE_1);
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person WHERE id=1', ROW_EXPECT_GE_1);
$this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows
$this->assertEquals([$expected[0]], $dataArray);
// ROW_EXPECT_GE_1 - two records
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person ORDER BY id LIMIT 2', ROW_EXPECT_GE_1);
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person ORDER BY id LIMIT 2', ROW_EXPECT_GE_1);
$this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows
$this->assertEquals($expected, $dataArray);
// Check Implode: 2 records
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person ORDER BY id LIMIT 2', ROW_IMPLODE_ALL);
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person ORDER BY id LIMIT 2', ROW_IMPLODE_ALL);
$this->assertEquals(implode($expected[0]) . implode($expected[1]), $data);
// Check Implode: 1 record
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,groups FROM Person ORDER BY id LIMIT 1', ROW_IMPLODE_ALL);
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id,name,firstName,adrId,gender,`groups` FROM Person ORDER BY id LIMIT 1', ROW_IMPLODE_ALL);
$this->assertEquals(implode($expected[0]), $data);
// Check Implode 0 record
......@@ -160,7 +160,7 @@ class DatabaseTest extends AbstractDatabaseTest {
// Check count
$this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('UPDATE Person SET groups = ?', ROW_REGULAR, ['a,b,c']);
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('UPDATE Person SET `groups` = ?', ROW_REGULAR, ['a,b,c']);
$this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
$dataArray = $this->dbArray[DB_INDEX_DEFAULT]->sql('INSERT INTO Person (`name`, `firstname`, `groups`) VALUES ( ?, ? ,? )', ROW_REGULAR, ['Meier', 'John', 'a'], 'fake', $dummy, $stat);
......@@ -178,6 +178,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/**
* @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
public function testSqlExceptionExpect0() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id LIMIT 1', ROW_EXPECT_0);
......@@ -185,6 +189,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/**
* @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
public function testSqlExceptionExpect1_0() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id LIMIT 0', ROW_EXPECT_1);
......@@ -192,6 +200,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/**
* @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
public function testSqlExceptionExpect1_2() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id ', ROW_EXPECT_1);
......@@ -199,6 +211,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/**
* @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
public function testSqlExceptionExpect01() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id ', ROW_EXPECT_0_1);
......@@ -206,6 +222,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/**
* @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
public function testSqlExceptionExpectGE1() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id LIMIT 0', ROW_EXPECT_GE_1);
......@@ -213,6 +233,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/**
* @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
public function testSanitizeException() {
$this->dbArray[DB_INDEX_DEFAULT]->sql('some garbage');
......@@ -314,7 +338,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$dummy = array();
$stat = array();
$sql = "INSERT INTO Person (id, name, firstname, gender, groups) VALUES (NULL, 'Doe', 'Jonni', 'male','')";
$sql = "INSERT INTO Person (id, name, firstname, gender, `groups`) VALUES (NULL, 'Doe', 'Jonni', 'male','')";
$rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
// DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
......@@ -333,7 +357,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$dummy = array();
$stat = array();
$sql = "UPDATE Person SET groups = 'a'";
$sql = "UPDATE Person SET `groups` = 'a'";
$rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
......@@ -373,7 +397,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
$sql = "REPLACE INTO Person (id, name, firstname, gender, groups) VALUES (1, 'Doe', 'John', 'male','')";
$sql = "REPLACE INTO Person (id, name, firstname, gender, `groups`) VALUES (1, 'Doe', 'John', 'male','')";
$rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
// DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
......@@ -383,7 +407,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(1, $rc);
$sql = "REPLACE INTO Person (id, name, firstname, gender, groups) VALUES (100, 'Lincoln', 'Abraham', 'male','')";
$sql = "REPLACE INTO Person (id, name, firstname, gender, `groups`) VALUES (100, 'Lincoln', 'Abraham', 'male','')";
$rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
// DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment