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

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 { ...@@ -71,7 +71,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM)); $this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check read rows // 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 // Check count
$this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM)); $this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
...@@ -80,7 +80,7 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -80,7 +80,7 @@ class DatabaseTest extends AbstractDatabaseTest {
// Check rows // Check rows
// Same as above, but specify 'ROW_REGULAR' // 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)); $this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows // Check rows
$this->assertEquals($expected, $dataArray); $this->assertEquals($expected, $dataArray);
...@@ -92,13 +92,13 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -92,13 +92,13 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(array(), $dataArray); $this->assertEquals(array(), $dataArray);
// ROW_EXPECT_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); $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)); $this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows // Check rows
$this->assertEquals($expected[0], $dataArray); $this->assertEquals($expected[0], $dataArray);
// ROW_EXPECT_0_1: 1 // 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)); $this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows // Check rows
$this->assertEquals($expected[0], $dataArray); $this->assertEquals($expected[0], $dataArray);
...@@ -110,23 +110,23 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -110,23 +110,23 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(array(), $dataArray); $this->assertEquals(array(), $dataArray);
//ROW_EXPECT_GE_1 - one record //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)); $this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows // Check rows
$this->assertEquals([$expected[0]], $dataArray); $this->assertEquals([$expected[0]], $dataArray);
// ROW_EXPECT_GE_1 - two records // 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)); $this->assertEquals(2, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM));
// Check rows // Check rows
$this->assertEquals($expected, $dataArray); $this->assertEquals($expected, $dataArray);
// Check Implode: 2 records // 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); $this->assertEquals(implode($expected[0]) . implode($expected[1]), $data);
// Check Implode: 1 record // 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); $this->assertEquals(implode($expected[0]), $data);
// Check Implode 0 record // Check Implode 0 record
...@@ -160,7 +160,7 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -160,7 +160,7 @@ class DatabaseTest extends AbstractDatabaseTest {
// Check count // Check count
$this->assertEquals(1, $this->store->getVar(SYSTEM_SQL_COUNT, STORE_SYSTEM)); $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)); $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); $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 { ...@@ -178,6 +178,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/** /**
* @expectedException DbException * @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/ */
public function testSqlExceptionExpect0() { public function testSqlExceptionExpect0() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id LIMIT 1', ROW_EXPECT_0); $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 { ...@@ -185,6 +189,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/** /**
* @expectedException DbException * @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/ */
public function testSqlExceptionExpect1_0() { public function testSqlExceptionExpect1_0() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id LIMIT 0', ROW_EXPECT_1); $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 { ...@@ -192,6 +200,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/** /**
* @expectedException DbException * @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/ */
public function testSqlExceptionExpect1_2() { public function testSqlExceptionExpect1_2() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id ', ROW_EXPECT_1); $data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id ', ROW_EXPECT_1);
...@@ -199,6 +211,10 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -199,6 +211,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/** /**
* @expectedException DbException * @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/ */
public function testSqlExceptionExpect01() { public function testSqlExceptionExpect01() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id ', ROW_EXPECT_0_1); $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 { ...@@ -206,6 +222,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/** /**
* @expectedException DbException * @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/ */
public function testSqlExceptionExpectGE1() { public function testSqlExceptionExpectGE1() {
$data = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT * FROM Person ORDER BY id LIMIT 0', ROW_EXPECT_GE_1); $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 { ...@@ -213,6 +233,10 @@ class DatabaseTest extends AbstractDatabaseTest {
/** /**
* @expectedException DbException * @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/ */
public function testSanitizeException() { public function testSanitizeException() {
$this->dbArray[DB_INDEX_DEFAULT]->sql('some garbage'); $this->dbArray[DB_INDEX_DEFAULT]->sql('some garbage');
...@@ -314,7 +338,7 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -314,7 +338,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$dummy = array(); $dummy = array();
$stat = 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); $rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
// DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS // DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
...@@ -333,7 +357,7 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -333,7 +357,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$dummy = array(); $dummy = array();
$stat = 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); $rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
...@@ -373,7 +397,7 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -373,7 +397,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true); $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); $rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
// DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS // DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
...@@ -383,7 +407,7 @@ class DatabaseTest extends AbstractDatabaseTest { ...@@ -383,7 +407,7 @@ class DatabaseTest extends AbstractDatabaseTest {
$this->assertEquals(1, $rc); $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); $rc = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, $dummy, 'fake', $dummy, $stat);
// DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS // 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