Fixed upgrading test database
This commit is contained in:
parent
bf8e6e9e00
commit
894457363e
3 changed files with 7 additions and 9 deletions
|
@ -13,11 +13,9 @@ final class PropertyModel implements IModel
|
||||||
|
|
||||||
static $allProperties;
|
static $allProperties;
|
||||||
static $loaded;
|
static $loaded;
|
||||||
static $database;
|
|
||||||
|
|
||||||
public static function init()
|
public static function init()
|
||||||
{
|
{
|
||||||
self::$database = Core::getDatabase();
|
|
||||||
self::$allProperties = null;
|
self::$allProperties = null;
|
||||||
self::$loaded = false;
|
self::$loaded = false;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +35,7 @@ final class PropertyModel implements IModel
|
||||||
$stmt = Sql\Statements::select();
|
$stmt = Sql\Statements::select();
|
||||||
$stmt ->setColumn('*');
|
$stmt ->setColumn('*');
|
||||||
$stmt ->setTable('property');
|
$stmt ->setTable('property');
|
||||||
foreach (self::$database->fetchAll($stmt) as $row)
|
foreach (Core::getDatabase()->fetchAll($stmt) as $row)
|
||||||
self::$allProperties[$row['prop_id']] = $row['value'];
|
self::$allProperties[$row['prop_id']] = $row['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,13 +50,13 @@ final class PropertyModel implements IModel
|
||||||
public static function set($propertyId, $value)
|
public static function set($propertyId, $value)
|
||||||
{
|
{
|
||||||
self::loadIfNecessary();
|
self::loadIfNecessary();
|
||||||
self::$database->transaction(function() use ($propertyId, $value)
|
Core::getDatabase()->transaction(function() use ($propertyId, $value)
|
||||||
{
|
{
|
||||||
$stmt = Sql\Statements::select();
|
$stmt = Sql\Statements::select();
|
||||||
$stmt->setColumn('id');
|
$stmt->setColumn('id');
|
||||||
$stmt->setTable('property');
|
$stmt->setTable('property');
|
||||||
$stmt->setCriterion(Sql\Functors::equals('prop_id', new Sql\Binding($propertyId)));
|
$stmt->setCriterion(Sql\Functors::equals('prop_id', new Sql\Binding($propertyId)));
|
||||||
$row = self::$database->fetchOne($stmt);
|
$row = Core::getDatabase()->fetchOne($stmt);
|
||||||
|
|
||||||
if ($row)
|
if ($row)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +71,7 @@ final class PropertyModel implements IModel
|
||||||
$stmt->setTable('property');
|
$stmt->setTable('property');
|
||||||
$stmt->setColumn('value', new Sql\Binding($value));
|
$stmt->setColumn('value', new Sql\Binding($value));
|
||||||
|
|
||||||
self::$database->execute($stmt);
|
Core::getDatabase()->execute($stmt);
|
||||||
|
|
||||||
self::$allProperties[$propertyId] = $value;
|
self::$allProperties[$propertyId] = $value;
|
||||||
});
|
});
|
||||||
|
|
|
@ -168,7 +168,7 @@ final class Core
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Core::getDatabase()->executeUnprepared(new \Chibi\Sql\RawStatement($query));
|
Core::getDatabase()->executeUnprepared(\Chibi\Sql\Statements::raw($query));
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,9 +103,9 @@ class SzurubooruTestRunner implements ITestRunner
|
||||||
private function cleanMysqlDatabase()
|
private function cleanMysqlDatabase()
|
||||||
{
|
{
|
||||||
$stmt = \Chibi\Sql\Statements::raw('DROP DATABASE IF EXISTS ' . $this->getMysqlDatabaseName());
|
$stmt = \Chibi\Sql\Statements::raw('DROP DATABASE IF EXISTS ' . $this->getMysqlDatabaseName());
|
||||||
Core::getDatabase()->exec($stmt);
|
Core::getDatabase()->executeUnprepared($stmt);
|
||||||
$stmt = \Chibi\Sql\Statements::raw('CREATE DATABASE ' . $this->getMysqlDatabaseName());
|
$stmt = \Chibi\Sql\Statements::raw('CREATE DATABASE ' . $this->getMysqlDatabaseName());
|
||||||
Core::getDatabase()->exec($stmt);
|
Core::getDatabase()->executeUnprepared($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function removeTestFolders()
|
private function removeTestFolders()
|
||||||
|
|
Loading…
Reference in a new issue