Fix PDO boolean handling
This commit is contained in:
parent
0e79e907b5
commit
3fd5171e2b
@ -42,7 +42,7 @@ class MigrateTest extends UloggerDatabaseTestCase {
|
|||||||
$this->setOutputCallback(static function() {});
|
$this->setOutputCallback(static function() {});
|
||||||
$ret = updateSchemas();
|
$ret = updateSchemas();
|
||||||
$this->resetConnection();
|
$this->resetConnection();
|
||||||
$this->assertEquals(true, $ret, "Function updateSchemas() failed");
|
$this->assertTrue($ret, "Function updateSchemas() failed");
|
||||||
$this->assertEquals(1, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
$this->assertEquals(1, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||||
$this->assertEquals(1, $this->getConnection()->getRowCount("tracks"), "Wrong row count");
|
$this->assertEquals(1, $this->getConnection()->getRowCount("tracks"), "Wrong row count");
|
||||||
$this->assertEquals(1, $this->getConnection()->getRowCount("positions"), "Wrong row count");
|
$this->assertEquals(1, $this->getConnection()->getRowCount("positions"), "Wrong row count");
|
||||||
@ -56,14 +56,10 @@ class MigrateTest extends UloggerDatabaseTestCase {
|
|||||||
$this->loadDataSet("fixture_non_admin.xml");
|
$this->loadDataSet("fixture_non_admin.xml");
|
||||||
$this->setOutputCallback(static function() {});
|
$this->setOutputCallback(static function() {});
|
||||||
$ret = updateConfig(dirname(__DIR__) . "/fixtures/config_0_6.php");
|
$ret = updateConfig(dirname(__DIR__) . "/fixtures/config_0_6.php");
|
||||||
$this->assertEquals(true, $ret, "Function updateConfig() failed");
|
$this->assertTrue($ret, "Function updateConfig() failed");
|
||||||
// admin user imported from config file
|
// admin user imported from config file
|
||||||
$expected = [ "admin" => 1 ];
|
$this->assertEquals(1, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||||
$actual = $this->getConnection()->createQueryTable(
|
$this->assertTrue((bool) $this->pdoGetColumn("SELECT admin FROM users WHERE login = 'admin'"), "User should be admin");
|
||||||
"admin",
|
|
||||||
"SELECT admin FROM users WHERE login = 'admin'"
|
|
||||||
);
|
|
||||||
$this->assertTableContains($expected, $actual, "Wrong actual table data");
|
|
||||||
// settings imported from config file
|
// settings imported from config file
|
||||||
$expected = [ "config" => [
|
$expected = [ "config" => [
|
||||||
["name" => "color_extra", "value" => "s:7:\"#cccccc\";"], // default
|
["name" => "color_extra", "value" => "s:7:\"#cccccc\";"], // default
|
||||||
@ -108,13 +104,13 @@ class MigrateTest extends UloggerDatabaseTestCase {
|
|||||||
fwrite($yes, "yes");
|
fwrite($yes, "yes");
|
||||||
$ret = waitForUser(stream_get_meta_data($yes)['uri']);
|
$ret = waitForUser(stream_get_meta_data($yes)['uri']);
|
||||||
fclose($yes);
|
fclose($yes);
|
||||||
$this->assertEquals(true, $ret, "Wrong return status");
|
$this->assertTrue($ret, "Wrong return status");
|
||||||
|
|
||||||
$no = tmpfile();
|
$no = tmpfile();
|
||||||
fwrite($no, "no");
|
fwrite($no, "no");
|
||||||
$ret = waitForUser(stream_get_meta_data($no)['uri']);
|
$ret = waitForUser(stream_get_meta_data($no)['uri']);
|
||||||
fclose($no);
|
fclose($no);
|
||||||
$this->assertEquals(false, $ret, "Wrong return status");
|
$this->assertFalse($ret, "Wrong return status");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,9 +113,9 @@ function updateConfig($path = ROOT_DIR . "/config.php") {
|
|||||||
if (isset($admin_user) && !empty($admin_user)) {
|
if (isset($admin_user) && !empty($admin_user)) {
|
||||||
try {
|
try {
|
||||||
echo "Setting user $admin_user as admin" . PHP_EOL;
|
echo "Setting user $admin_user as admin" . PHP_EOL;
|
||||||
$query = "UPDATE " . uDb::getInstance()->table('users') . " SET admin = TRUE WHERE login = ?";
|
$query = "UPDATE " . uDb::getInstance()->table('users') . " SET admin = ? WHERE login = ?";
|
||||||
$stmt = uDb::getInstance()->prepare($query);
|
$stmt = uDb::getInstance()->prepare($query);
|
||||||
$stmt->execute([ $admin_user ]);
|
$stmt->execute([ 1, $admin_user ]);
|
||||||
if ($stmt->rowCount() === 0) {
|
if ($stmt->rowCount() === 0) {
|
||||||
echo "User $admin_user not found in database table" . PHP_EOL;
|
echo "User $admin_user not found in database table" . PHP_EOL;
|
||||||
echo "Set your admin user manually in users table" . PHP_EOL;
|
echo "Set your admin user manually in users table" . PHP_EOL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user