mirror of
https://github.com/nextcloud/tables.git
synced 2026-01-14 03:17:18 +00:00
fix(CI): make unit tests PHP 8.5 compatibly
... and do not swallow exceptions Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
@ -194,7 +194,6 @@ class EntityVirtualPropertiesTest extends DatabaseTestCase {
|
||||
* Get database table fields for Entity class
|
||||
*/
|
||||
private function getDatabaseTableFields(string $className): array {
|
||||
try {
|
||||
// Try to get table name from class
|
||||
$tableName = $this->getTableNameFromClass($className);
|
||||
if (!$tableName) {
|
||||
@ -217,23 +216,20 @@ class EntityVirtualPropertiesTest extends DatabaseTestCase {
|
||||
}
|
||||
|
||||
return $fields;
|
||||
} catch (\Exception $e) {
|
||||
// If we can't get table fields, return empty array
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get table name from Entity class
|
||||
*/
|
||||
private function getTableNameFromClass(string $className): ?string {
|
||||
try {
|
||||
$reflection = new ReflectionClass($className);
|
||||
|
||||
// Try to get table name from protected property
|
||||
if ($reflection->hasProperty('table')) {
|
||||
$tableProperty = $reflection->getProperty('table');
|
||||
if (PHP_VERSION_ID < 80200) {
|
||||
$tableProperty->setAccessible(true);
|
||||
}
|
||||
|
||||
// Create instance to get table name
|
||||
$instance = $reflection->newInstanceWithoutConstructor();
|
||||
@ -250,7 +246,9 @@ class EntityVirtualPropertiesTest extends DatabaseTestCase {
|
||||
$mapperReflection = new ReflectionClass($mapperClassName);
|
||||
if ($mapperReflection->hasProperty('table')) {
|
||||
$tableProperty = $mapperReflection->getProperty('table');
|
||||
if (PHP_VERSION_ID < 80200) {
|
||||
$tableProperty->setAccessible(true);
|
||||
}
|
||||
|
||||
// Create mapper instance to get table name
|
||||
$mapperInstance = $mapperReflection->newInstanceWithoutConstructor();
|
||||
@ -274,10 +272,6 @@ class EntityVirtualPropertiesTest extends DatabaseTestCase {
|
||||
return $tableName;
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// If we can't get table name, return null
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user