mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-11 14:38:39 +00:00
fix tests
This commit is contained in:
parent
1ed4f3f5e2
commit
6443ab6c14
|
|
@ -761,12 +761,13 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$values = $property->getValue($obj);
|
$values = $property->getValue($obj);
|
||||||
|
|
||||||
/** @var self $mapper */
|
/** @var self $mapper */
|
||||||
$mapper = static::$hasMany[$propertyName]['mapper'];
|
$mapper = static::$hasMany[$propertyName]['mapper'];
|
||||||
|
$internalName = isset($mapper::$columns[static::$hasMany[$propertyName]['self']]) ? $mapper::$columns[static::$hasMany[$propertyName]['self']]['internal'] : 'ERROR';
|
||||||
|
|
||||||
if (\is_object($values)) {
|
if (\is_object($values)) {
|
||||||
// conditionals
|
// conditionals
|
||||||
$relReflectionClass = new \ReflectionClass($values);
|
$relReflectionClass = new \ReflectionClass($values);
|
||||||
$relProperty = $relReflectionClass->getProperty($mapper::$columns[static::$hasMany[$propertyName]['self']]['internal']);
|
$relProperty = $relReflectionClass->getProperty($internalName);
|
||||||
|
|
||||||
if (!($isPublicRel = $relProperty->isPublic())) {
|
if (!($isPublicRel = $relProperty->isPublic())) {
|
||||||
$relProperty->setAccessible(true);
|
$relProperty->setAccessible(true);
|
||||||
|
|
@ -779,10 +780,17 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$mapper::create($values);
|
$mapper::create($values);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\is_array($values)) {
|
if (!$isPublic) {
|
||||||
|
$property->setAccessible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
} elseif (!\is_array($values)) {
|
||||||
|
if (!$isPublic) {
|
||||||
|
$property->setAccessible(false);
|
||||||
|
}
|
||||||
|
|
||||||
// conditionals
|
// conditionals
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -814,13 +822,20 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
|
|
||||||
// Setting relation value (id) for relation (since the relation is not stored in an extra relation table)
|
// Setting relation value (id) for relation (since the relation is not stored in an extra relation table)
|
||||||
if (!isset(static::$hasMany[$propertyName]['external'])) {
|
if (!isset(static::$hasMany[$propertyName]['external'])) {
|
||||||
$relProperty = $relReflectionClass->getProperty($mapper::$columns[static::$hasMany[$propertyName]['self']]['internal']);
|
$relProperty = $relReflectionClass->getProperty($internalName);
|
||||||
|
|
||||||
if (!$isPublic) {
|
if (!$isPublic) {
|
||||||
$relProperty->setAccessible(true);
|
$relProperty->setAccessible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$relProperty->setValue($value, $objId);
|
// todo maybe consider to just set the column type to object, and then check for that (might be faster)
|
||||||
|
if (isset($mapper::$belongsTo[$internalName])
|
||||||
|
|| isset($mapper::$ownsOne[$internalName])
|
||||||
|
) {
|
||||||
|
$relProperty->setValue($value, self::createNullModel($objId));
|
||||||
|
} else {
|
||||||
|
$relProperty->setValue($value, $objId);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$isPublic) {
|
if (!$isPublic) {
|
||||||
$relProperty->setAccessible(false);
|
$relProperty->setAccessible(false);
|
||||||
|
|
@ -3464,14 +3479,7 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
$parts[$c] = 'Null' . $name;
|
$parts[$c] = 'Null' . $name;
|
||||||
$class = \implode('\\', $parts);
|
$class = \implode('\\', $parts);
|
||||||
|
|
||||||
$obj = new $class();
|
return $id !== null ? new $class($id) : new $class();
|
||||||
|
|
||||||
if ($id !== null) {
|
|
||||||
$refClass = new \ReflectionClass($obj);
|
|
||||||
self::setObjectId($refClass, $obj, $id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ class Localization implements \JsonSerializable
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileContent = \file_get_contents(DEFINITIONS_PATH . 'en_US.json');
|
$fileContent = \file_get_contents(self::DEFINITIONS_PATH . 'en_US.json');
|
||||||
if ($fileContent === false) {
|
if ($fileContent === false) {
|
||||||
return; // @codeCoverageIgnore
|
return; // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ final class ModuleManager
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param ApplicationAbstract $app Application
|
* @param ApplicationAbstract $app Application
|
||||||
* @param string $modulePath Path to modules
|
* @param string $modulePath Path to modules (must end with '/')
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -673,7 +673,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function current()
|
public function current() : FileAbstract
|
||||||
{
|
{
|
||||||
$current = \current($this->nodes);
|
$current = \current($this->nodes);
|
||||||
|
|
||||||
|
|
@ -695,7 +695,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function next() : FileAbstract
|
public function next()
|
||||||
{
|
{
|
||||||
$next = \next($this->nodes);
|
$next = \next($this->nodes);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -496,7 +496,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function current() : self
|
public function current() : FileAbstract
|
||||||
{
|
{
|
||||||
$current = \current($this->nodes);
|
$current = \current($this->nodes);
|
||||||
|
|
||||||
|
|
@ -518,7 +518,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function next() : FileAbstract
|
public function next()
|
||||||
{
|
{
|
||||||
$next = \next($this->nodes);
|
$next = \next($this->nodes);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class ApplicationManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
$app->router = new WebRouter();
|
$app->router = new WebRouter();
|
||||||
$app->dispatcher = new Dispatcher($app);
|
$app->dispatcher = new Dispatcher($app);
|
||||||
$app->appSettings = new CoreSettings($app->dbPool->get('admin'));
|
$app->appSettings = new CoreSettings($app->dbPool->get('admin'));
|
||||||
$app->moduleManager = new ModuleManager($app, __DIR__ . '/../../../Modules');
|
$app->moduleManager = new ModuleManager($app, __DIR__ . '/../../../Modules/');
|
||||||
|
|
||||||
$this->appManager = new ApplicationManager($app->moduleManager);
|
$this->appManager = new ApplicationManager($app->moduleManager);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -375,16 +375,4 @@ class LocalizationTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->localization->loadFromLanguage(ISO639x1Enum::_AA);
|
$this->localization->loadFromLanguage(ISO639x1Enum::_AA);
|
||||||
self::assertEquals(ISO4217CharEnum::_USD, $this->localization->getCurrency());
|
self::assertEquals(ISO4217CharEnum::_USD, $this->localization->getCurrency());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @testdox Loading localization data from a file with invalid language throws InvalidEnumValue
|
|
||||||
* @covers phpOMS\Localization\Localization
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testInvalidLocalizationLoading() : void
|
|
||||||
{
|
|
||||||
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
|
|
||||||
|
|
||||||
$this->localization->loadFromLanguage('INVALID');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->app->router = new WebRouter();
|
$this->app->router = new WebRouter();
|
||||||
$this->app->dispatcher = new Dispatcher($this->app);
|
$this->app->dispatcher = new Dispatcher($this->app);
|
||||||
$this->app->appSettings = new CoreSettings($this->app->dbPool->get('admin'));
|
$this->app->appSettings = new CoreSettings($this->app->dbPool->get('admin'));
|
||||||
$this->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules');
|
$this->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -251,7 +251,7 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testInvalidModulePath() : void
|
public function testInvalidModulePath() : void
|
||||||
{
|
{
|
||||||
$moduleManager = new ModuleManager($this->app, __DIR__ . '/Testmodule');
|
$moduleManager = new ModuleManager($this->app, __DIR__ . '/Testmodule/');
|
||||||
|
|
||||||
self::assertEquals([], $moduleManager->getAllModules());
|
self::assertEquals([], $moduleManager->getAllModules());
|
||||||
self::assertEquals([], $moduleManager->getInstalledModules());
|
self::assertEquals([], $moduleManager->getInstalledModules());
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class ClientTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->app->cachePool = new CachePool($this->app->dbPool);
|
$this->app->cachePool = new CachePool($this->app->dbPool);
|
||||||
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
||||||
$this->app->appSettings = new CoreSettings($this->app->dbPool->get());
|
$this->app->appSettings = new CoreSettings($this->app->dbPool->get());
|
||||||
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules');
|
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');
|
||||||
$this->app->dispatcher = new Dispatcher($this->app);
|
$this->app->dispatcher = new Dispatcher($this->app);
|
||||||
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
||||||
$this->app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php');
|
$this->app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php');
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ $app->orgId = 1;
|
||||||
$app->cachePool = new CachePool($app->dbPool);
|
$app->cachePool = new CachePool($app->dbPool);
|
||||||
$app->accountManager = new AccountManager($GLOBALS['session']);
|
$app->accountManager = new AccountManager($GLOBALS['session']);
|
||||||
$app->appSettings = new CoreSettings($app->dbPool->get());
|
$app->appSettings = new CoreSettings($app->dbPool->get());
|
||||||
$app->moduleManager = new ModuleManager($app, __DIR__ . '/../../../../Modules');
|
$app->moduleManager = new ModuleManager($app, __DIR__ . '/../../../../Modules/');
|
||||||
$app->dispatcher = new Dispatcher($app);
|
$app->dispatcher = new Dispatcher($app);
|
||||||
$app->eventManager = new EventManager($app->dispatcher);
|
$app->eventManager = new EventManager($app->dispatcher);
|
||||||
$app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php');
|
$app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php');
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class ServerTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->app->cachePool = new CachePool($this->app->dbPool);
|
$this->app->cachePool = new CachePool($this->app->dbPool);
|
||||||
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
||||||
$this->app->appSettings = new CoreSettings($this->app->dbPool->get());
|
$this->app->appSettings = new CoreSettings($this->app->dbPool->get());
|
||||||
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules');
|
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/');
|
||||||
$this->app->dispatcher = new Dispatcher($this->app);
|
$this->app->dispatcher = new Dispatcher($this->app);
|
||||||
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
$this->app->eventManager = new EventManager($this->app->dispatcher);
|
||||||
$this->app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php');
|
$this->app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user