mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-19 04:58:41 +00:00
PhpUnit fixes
This commit is contained in:
parent
aa483c2eb8
commit
20a48cc1fe
|
|
@ -332,7 +332,13 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
{
|
||||
self::extend(__CLASS__);
|
||||
|
||||
$reflectionClass = new \ReflectionClass(get_class($obj));
|
||||
if($obj === null ||
|
||||
(is_object($obj) && strpos($className = get_class($obj), '\Null') !== false)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$reflectionClass = new \ReflectionClass($className);
|
||||
$objId = self::createModel($obj, $reflectionClass);
|
||||
self::setObjectId($reflectionClass, $obj, $objId);
|
||||
|
||||
|
|
@ -378,6 +384,8 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$value = self::parseValue($column['type'], $id);
|
||||
|
||||
$query->insert($column['name'])->value($value, $column['type']);
|
||||
$temp = $query->toSql();
|
||||
$test = 1;
|
||||
break;
|
||||
} elseif (isset(static::$belongsTo[$propertyName]) && $column['internal'] === $propertyName) {
|
||||
$id = self::createBelongsTo($propertyName, $property->getValue($obj));
|
||||
|
|
@ -658,7 +666,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
return $value->serialize();
|
||||
} elseif ($value instanceof \JsonSerializable) {
|
||||
return json_encode($value->jsonSerialize());
|
||||
} elseif (is_object($value)) {
|
||||
} elseif (is_object($value) && method_exists($value, 'getId')) {
|
||||
return $value->getId();
|
||||
} elseif ($type === 'int') {
|
||||
return (int) $value;
|
||||
|
|
@ -1266,7 +1274,7 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
$reflectionClass = new \ReflectionClass(get_class($obj));
|
||||
|
||||
foreach ($result as $member => $values) {
|
||||
if ($reflectionClass->hasProperty($member)) {
|
||||
if (!empty($values) && $reflectionClass->hasProperty($member)) {
|
||||
/** @var DataMapperAbstract $mapper */
|
||||
$mapper = static::$hasMany[$member]['mapper'];
|
||||
$reflectionProperty = $reflectionClass->getProperty($member);
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ class Request extends RequestAbstract
|
|||
$this->hash = [];
|
||||
foreach ($this->path as $key => $path) {
|
||||
$paths = [];
|
||||
for ($i = 1; $i < $key + 1; $i++) {
|
||||
for ($i = 0; $i < $key + 1; $i++) {
|
||||
$paths[] = $this->path[$i];
|
||||
}
|
||||
|
||||
|
|
@ -383,10 +383,10 @@ class Request extends RequestAbstract
|
|||
}
|
||||
|
||||
return
|
||||
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
||||
|| (empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
|
||||
|| (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')
|
||||
|| $_SERVER['SERVER_PORT'] == $port;
|
||||
(!empty($_SERVER['HTTPS'] ?? '') && ($_SERVER['HTTPS'] ?? '') !== 'off')
|
||||
|| (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https')
|
||||
|| (($_SERVER['HTTP_X_FORWARDED_SSL'] ?? '') === 'on')
|
||||
|| ($_SERVER['SERVER_PORT'] ?? '') == $port;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -248,34 +248,6 @@ abstract class RequestAbstract implements MessageInterface
|
|||
return $this->path[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set request type.
|
||||
*
|
||||
* E.g. M_JSON
|
||||
*
|
||||
* @param string $type Request type
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setType(string $type) /* : void */
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get request type.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getType() : string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -148,6 +148,6 @@ class Router
|
|||
*/
|
||||
private function match(string $route, int $routeVerb, string $uri, int $remoteVerb = RouteVerb::GET) : bool
|
||||
{
|
||||
return (bool) preg_match('~^' . $route . '$~', $uri) && ($routeVerb == RouteVerb::ANY || ($remoteVerb & $routeVerb) === $remoteVerb);
|
||||
return (bool) preg_match('~^' . $route . '$~', $uri) && ($routeVerb === RouteVerb::ANY || $remoteVerb === RouteVerb::ANY || ($remoteVerb & $routeVerb) === $remoteVerb);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user