Unit test fixes

This commit is contained in:
Dennis Eichhorn 2016-01-29 19:08:14 +01:00
parent 9350e90e0c
commit cef8d11e10
5 changed files with 77 additions and 20 deletions

View File

@ -39,6 +39,8 @@ class Autoloader
* *
* @return void * @return void
* *
* @throws
*
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
@ -47,6 +49,8 @@ class Autoloader
if (($class = self::exists($class)) !== false) { if (($class = self::exists($class)) !== false) {
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
include __DIR__ . '/../' . $class . '.php'; include __DIR__ . '/../' . $class . '.php';
} else {
throw new \Exception();
} }
} }

View File

@ -586,11 +586,11 @@ abstract class DataMapperAbstract implements DataMapperInterface
$sth = $this->db->con->prepare($query->toSql()); $sth = $this->db->con->prepare($query->toSql());
$sth->execute(); $sth->execute();
$results = $sth->fetch(\PDO::FETCH_ASSOC); $results = $sth->fetchAll(\PDO::FETCH_ASSOC);
/* todo: if limit get's used this has to call populateIterable */ /* todo: if limit get's used this has to call populateIterable */
return $this->populate(is_bool($results) ? [] : $results); return $this->populateIterable(is_bool($results) ? [] : $results);
} }

View File

@ -55,6 +55,22 @@ abstract class ModuleAbstract
*/ */
const MODULE_NAME = ''; const MODULE_NAME = '';
/**
* Module path.
*
* @var string
* @since 1.0.0
*/
const MODULE_PATH = __DIR__;
/**
* Module version.
*
* @var string
* @since 1.0.0
*/
const MODULE_VERSION = '1.0.0';
/** /**
* Localization files. * Localization files.
* *

View File

@ -16,6 +16,7 @@
namespace phpOMS\Module; namespace phpOMS\Module;
use phpOMS\ApplicationAbstract; use phpOMS\ApplicationAbstract;
use phpOMS\Module\NullModule;
/** /**
@ -76,6 +77,7 @@ class ModuleFactory
public static function getInstance(string $module, ApplicationAbstract $app) : ModuleAbstract public static function getInstance(string $module, ApplicationAbstract $app) : ModuleAbstract
{ {
if (!isset(self::$loaded[$module])) { if (!isset(self::$loaded[$module])) {
try {
$class = '\\Modules\\' . $module . '\\Controller'; $class = '\\Modules\\' . $module . '\\Controller';
/** /**
@ -100,6 +102,9 @@ class ModuleFactory
self::$loaded[$name]->addReceiving($providing); self::$loaded[$name]->addReceiving($providing);
} }
} }
} catch(\Exception $e) {
self::$loaded[$module] = new NullModule($app);
}
} }
return self::$loaded[$module]; return self::$loaded[$module];

32
Module/NullModule.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Module;
/**
* Module abstraction class.
*
* @category Framework
* @package phpOMS\Module
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class NullModule extends ModuleAbstract
{
}