chore(ci): Updated checks for Medoo version 1.4.2

Closed #196Signed-off-by: Stuart McCulloch Anderson's avatarStuart McCulloch Anderson <stuart@nxfifteen.me.uk>
parent 28f60ec5
Pipeline #186 failed with stages
in 6 minutes and 23 seconds
<?php
/*******************************************************************************
* This file is part of NxFIFTEEN Fitness Core.
* https://nxfifteen.me.uk
*
* Copyright (c) 2017, Stuart McCulloch Anderson
*
* Released under the MIT license
* Copyright (c) 2017. Stuart McCulloch Anderson
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
......@@ -244,13 +241,23 @@
$this->settings[$key] = $value;
if ($query_db) {
if ($this->database->has($this->get("db_prefix", false) . "settings", array("var" => $key))) {
return $this->database->update($this->get("db_prefix", false) . "settings", array("data" => $value),
$dbAction = $this->database->update($this->get("db_prefix", false) . "settings", array("data" => $value),
array("var" => $key));
if ($this->wasMySQLError($dbAction->errorInfo())) {
return false;
} else {
return true;
}
} else {
return $this->database->insert($this->get("db_prefix", false) . "settings", array(
$dbAction = $this->database->insert($this->get("db_prefix", false) . "settings", array(
"data" => $value,
"var" => $key
));
if ($this->wasMySQLError($dbAction->errorInfo())) {
return false;
} else {
return true;
}
}
} else {
return true;
......@@ -274,7 +281,12 @@
if ($query_db) {
if ($this->database->has($this->get("db_prefix", false) . "settings", array("var" => $key))) {
return $this->database->delete($this->get("db_prefix", false) . "settings", array("var" => $key));
$dbAction = $this->database->delete($this->get("db_prefix", false) . "settings", array("var" => $key));
if ($this->wasMySQLError($dbAction->errorInfo())) {
return false;
} else {
return true;
}
}
}
......@@ -342,19 +354,29 @@
)
))
) {
return $this->database->update($this->get("db_prefix", false) . "settings_users",
$dbAction = $this->database->update($this->get("db_prefix", false) . "settings_users",
array("data" => $value), array(
"AND" => array(
"fuid" => $fuid,
"var" => $key
)
));
if ($this->wasMySQLError($dbAction->errorInfo())) {
return false;
} else {
return true;
}
} else {
return $this->database->insert($this->get("db_prefix", false) . "settings_users", array(
$dbAction = $this->database->insert($this->get("db_prefix", false) . "settings_users", array(
"fuid" => $fuid,
"data" => $value,
"var" => $key
));
if ($this->wasMySQLError($dbAction->errorInfo())) {
return false;
} else {
return true;
}
}
}
......@@ -381,8 +403,13 @@
)
))
) {
return $this->database->delete($this->get("db_prefix", false) . "settings_users",
$dbAction = $this->database->delete($this->get("db_prefix", false) . "settings_users",
array("fuid" => $fuid, "var" => $key));
if ($this->wasMySQLError($dbAction->errorInfo())) {
return false;
} else {
return true;
}
}
return true;
......@@ -398,4 +425,20 @@
{
$this->database = $database;
}
/**
* @param array $error
*
* @return bool
*/
private function wasMySQLError($error)
{
if (is_null($error[2])) {
return false;
} else {
print_r($error);
return true;
}
}
}
......@@ -10,13 +10,6 @@
namespace Core\Tests;
if (!function_exists('autoloader')) {
require_once(dirname(__FILE__) . "/../lib/autoloader.php");
require_once(dirname(__FILE__) . "/../bundle/vendor/autoload.php");
}
require_once(dirname(__FILE__) . "/../lib/functions.php");
use Core\Config;
use Medoo\Medoo;
use PHPUnit\Framework\TestCase;
......@@ -223,7 +216,7 @@
public function testSetNoDB()
{
$storeValue = rand(0, 1000);
$this->assertTrue($this->configClass->set('test' . __METHOD__ . 'DB' . $storeValue, $storeValue, false));
$this->assertTrue($this->configClass->set('test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue, false));
}
/**
......@@ -232,9 +225,9 @@
public function testDelNoDB()
{
$storeValue = rand(0, 1000);
$this->configClass->set('test' . __METHOD__ . 'DB' . $storeValue, $storeValue, false);
$this->configClass->set('test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue, false);
$dbAction = $this->convertNumberToBool($this->configClass->del('test' . __METHOD__ . 'DB' . $storeValue,
$dbAction = $this->convertNumberToBool($this->configClass->del('test_' . __METHOD__ . '_DB:' . $storeValue,
false));
$this->assertTrue($dbAction);
}
......@@ -245,8 +238,8 @@
public function testGetNoDB()
{
$storeValue = rand(0, 1000);
$this->configClass->set('test' . __METHOD__ . 'DB' . $storeValue, $storeValue, false);
$settingsValue = $this->configClass->get('test' . __METHOD__ . 'DB' . $storeValue, 'Not Stored', false);
$this->configClass->set('test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue, false);
$settingsValue = $this->configClass->get('test_' . __METHOD__ . '_DB:' . $storeValue, 'Not Stored', false);
$this->assertSame($storeValue, $settingsValue);
}
......@@ -258,11 +251,9 @@
$this->configClass->setDatabase($this->setUpDatabase());
$storeValue = rand(0, 1000);
$dbAction = $this->convertNumberToBool($this->configClass->set('test' . __METHOD__ . 'DB' . $storeValue,
$storeValue, true));
$this->assertTrue($dbAction);
$this->assertTrue($this->configClass->set('test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue, true));
$this->configClass->del('test' . __METHOD__ . 'DB' . $storeValue, true);
$this->configClass->del('test_' . __METHOD__ . '_DB:' . $storeValue, true);
}
/**
......@@ -273,13 +264,13 @@
$this->configClass->setDatabase($this->setUpDatabase());
$storeValue = rand(0, 1000);
$this->configClass->set('test' . __METHOD__ . 'DB' . $storeValue, $storeValue, true);
$this->configClass->set('test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue, true);
$settingsValue = $this->configClass->get('test' . __METHOD__ . 'DB' . $storeValue, 'Not Stored', true);
$settingsValue = $this->configClass->get('test_' . __METHOD__ . '_DB:' . $storeValue, 'Not Stored', true);
$this->assertSame($storeValue, $settingsValue);
$this->configClass->del('test' . __METHOD__ . 'DB' . $storeValue, true);
$this->configClass->del('test_' . __METHOD__ . '_DB:' . $storeValue, true);
}
/**
......@@ -290,11 +281,9 @@
$this->configClass->setDatabase($this->setUpDatabase());
$storeValue = rand(0, 1000);
$this->configClass->set('test' . __METHOD__ . 'DB' . $storeValue, $storeValue, true);
$this->configClass->set('test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue, true);
$dbAction = $this->convertNumberToBool($this->configClass->del('test' . __METHOD__ . 'DB' . $storeValue,
true));
$this->assertTrue($dbAction);
$this->assertTrue($this->configClass->del('test_' . __METHOD__ . '_DB:' . $storeValue,true));
}
/**
......@@ -307,11 +296,9 @@
$this->configClass->setDatabase($this->setUpDatabase());
$storeValue = rand(0, 1000);
$dbAction = $this->convertNumberToBool($this->configClass->setUser($ownerFuid,
'test' . __METHOD__ . 'DB' . $storeValue, $storeValue));
$this->assertTrue($dbAction);
$this->assertTrue($this->configClass->setUser($ownerFuid,'test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue));
$this->configClass->delUser($ownerFuid, 'test' . __METHOD__ . 'DB' . $storeValue);
$this->configClass->delUser($ownerFuid, 'test_' . __METHOD__ . '_DB:' . $storeValue);
}
/**
......@@ -324,11 +311,9 @@
$this->configClass->setDatabase($this->setUpDatabase());
$storeValue = rand(0, 1000);
$this->configClass->setUser($ownerFuid, 'test' . __METHOD__ . 'DB' . $storeValue, $storeValue);
$this->configClass->setUser($ownerFuid, 'test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue);
$dbAction = $this->convertNumberToBool($this->configClass->delUser($ownerFuid,
'test' . __METHOD__ . 'DB' . $storeValue));
$this->assertTrue($dbAction);
$this->assertTrue($this->configClass->delUser($ownerFuid,'test_' . __METHOD__ . '_DB:' . $storeValue));
}
/**
......@@ -341,13 +326,13 @@
$this->configClass->setDatabase($this->setUpDatabase());
$storeValue = rand(0, 1000);
$this->configClass->setUser($ownerFuid, 'test' . __METHOD__ . 'DB' . $storeValue, $storeValue);
$this->configClass->setUser($ownerFuid, 'test_' . __METHOD__ . '_DB:' . $storeValue, $storeValue);
$settingsValue = $this->configClass->getUser($ownerFuid, 'test' . __METHOD__ . 'DB' . $storeValue,
$settingsValue = $this->configClass->getUser($ownerFuid, 'test_' . __METHOD__ . '_DB:' . $storeValue,
'Not Stored');
$this->assertSame($storeValue, $settingsValue);
$this->configClass->delUser($ownerFuid, 'test' . __METHOD__ . 'DB' . $storeValue);
$this->configClass->delUser($ownerFuid, 'test_' . __METHOD__ . '_DB:' . $storeValue);
}
}
......@@ -10,3 +10,7 @@
define('TEST_SUITE', true);
require_once(dirname(__FILE__) . "/../lib/autoloader.php");
require_once(dirname(__FILE__) . "/../bundle/vendor/autoload.php");
require_once(dirname(__FILE__) . "/../lib/functions.php");
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