Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed May 18, 2024
1 parent 0cb183c commit e780319
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
8 changes: 7 additions & 1 deletion tests/Account/PermissionAbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ public function testAbstractDefault() : void
'from' => null,
'element' => null,
'component' => null,
'permission' => PermissionType::NONE,
'category' => null,
'hasRead' => false,
'hasModify' => false,
'hasCreate' => false,
'hasDelete' => false,
'hasPermission' => false,
'defaultCPermissions' => null,
'defaultPPermissions' => null,
],
$perm->jsonSerialize()
);
Expand Down
4 changes: 2 additions & 2 deletions tests/DataStorage/Cache/Connection/ConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testCreateMemCached() : void

self::assertInstanceOf(
\phpOMS\DataStorage\Cache\Connection\MemCached::class,
ConnectionFactory::create(['type' => CacheType::MEMCACHED, 'data' => $GLOBALS['CONFIG']['cache']['memcached']])
ConnectionFactory::create(\array_merge(['type' => CacheType::MEMCACHED], $GLOBALS['CONFIG']['cache']['memcached']))
);
}

Expand All @@ -61,7 +61,7 @@ public function testCreateRedisCache() : void

self::assertInstanceOf(
\phpOMS\DataStorage\Cache\Connection\RedisCache::class,
ConnectionFactory::create(['type' => CacheType::REDIS, 'data' => $GLOBALS['CONFIG']['cache']['redis']])
ConnectionFactory::create(\array_merge(['type' => CacheType::REDIS], $GLOBALS['CONFIG']['cache']['redis']))
);
}

Expand Down
22 changes: 11 additions & 11 deletions tests/DataStorage/Database/Schema/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public function testShowTables($con) : void

$sql = '';
if ($con instanceof MysqlConnection) {
$sql = 'SELECT [table_name] FROM [information_schema].[tables] WHERE [table_schema] = \'' . $GLOBALS['CONFIG']['db']['core']['masters']['admin']['database']. '\';';
$sql = 'SELECT [table_name] FROM [information_schema].[tables] WHERE [table_schema] = ?;';
} elseif ($con instanceof PostgresConnection) {
$sql = 'SELECT [table_name] FROM [information_schema].[tables] WHERE [table_schema] = \'' . $GLOBALS['CONFIG']['db']['core']['masters']['admin']['database']. '\';';
$sql = 'SELECT [table_name] FROM [information_schema].[tables] WHERE [table_schema] = ?;';
} elseif ($con instanceof SqlServerConnection) {
$sql = 'SELECT [table_name] FROM [sys].[tables] INNER JOIN [sys].[schemas] ON [sys].[tables.schema_id] = [sys].[schemas.schema_id];';
} elseif ($con instanceof SQLiteConnection) {
Expand Down Expand Up @@ -133,13 +133,13 @@ public function testShowFields($con) : void

$sql = '';
if ($con instanceof MysqlConnection) {
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = \'' . $GLOBALS['CONFIG']['db']['core']['masters']['admin']['database']. '\' AND [table_name] = \'test\';';
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = ? AND [table_name] = ?;';
} elseif ($con instanceof PostgresConnection) {
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = \'' . $GLOBALS['CONFIG']['db']['core']['masters']['admin']['database']. '\' AND [table_name] = \'test\';';
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = ? AND [table_name] = ?;';
} elseif ($con instanceof SqlServerConnection) {
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = \'' . $GLOBALS['CONFIG']['db']['core']['masters']['admin']['database']. '\' AND [table_name] = \'test\';';
$sql = 'SELECT * FROM [information_schema].[columns] WHERE [table_schema] = ? AND [table_name] = ?;';
} elseif ($con instanceof SQLiteConnection) {
$sql = 'SELECT * FROM pragma_table_info(\'test\') WHERE pragma_table_info(\'test\') = \'test\';';
$sql = 'SELECT * FROM pragma_table_info(?) WHERE pragma_table_info(?) = ?;';
}

$sql = \strtr($sql, '[]', $iS . $iE);
Expand All @@ -164,13 +164,13 @@ public function testCreateTable($con) : void

$sql = '';
if ($con instanceof MysqlConnection) {
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id])) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT ? NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id])) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
} elseif ($con instanceof PostgresConnection) {
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT ? NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
} elseif ($con instanceof SqlServerConnection) {
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT ? NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
} elseif ($con instanceof SQLiteConnection) {
$sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER AUTOINCREMENT PRIMARY KEY, [role_id] TEXT DEFAULT \'1\' NULL, FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
$sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER AUTOINCREMENT PRIMARY KEY, [role_id] TEXT DEFAULT ? NULL, FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
}

$sql = \strtr($sql, '[]', $iS . $iE);
Expand All @@ -196,7 +196,7 @@ public function testAlter($con) : void
$iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con);
$sql = 'CREATE TABLE IF NOT EXISTS user_roles (user_id INT NOT NULL AUTO_INCREMENT, role_id VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY (user_id), FOREIGN KEY (user_id) REFERENCES users (ext1_id), FOREIGN KEY (role_id) REFERENCES roles (ext2_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
$sql = 'CREATE TABLE IF NOT EXISTS user_roles (user_id INT NOT NULL AUTO_INCREMENT, role_id VARCHAR(10) DEFAULT ? NULL, PRIMARY KEY (user_id), FOREIGN KEY (user_id) REFERENCES users (ext1_id), FOREIGN KEY (role_id) REFERENCES roles (ext2_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;';
$sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals(
$sql,
Expand Down
8 changes: 8 additions & 0 deletions tests/Stdlib/Base/LocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function testDefault() : void
'state' => '',
'lat' => 0.0,
'lon' => 0.0,
'id' => 0,
'type' => 2,
];

self::assertEquals('', $this->location->postal);
Expand Down Expand Up @@ -111,6 +113,8 @@ public function testArray() : void
'state' => 'This is a state 123',
'lat' => 12.1,
'lon' => 11.2,
'id' => 0,
'type' => 2,
];

$this->location->postal = '0123456789';
Expand All @@ -137,6 +141,8 @@ public function testJsonSerialize() : void
'state' => 'This is a state 123',
'lat' => 12.1,
'lon' => 11.2,
'id' => 0,
'type' => 2,
];

$this->location->postal = '0123456789';
Expand Down Expand Up @@ -164,6 +170,8 @@ public function testUnserialize() : void
'state' => 'This is a state 123',
'lat' => 12.1,
'lon' => 11.2,
'id' => 0,
'type' => 2,
];

$this->location->unserialize(\json_encode($expected));
Expand Down

0 comments on commit e780319

Please sign in to comment.