Test adjustments

This commit is contained in:
Dennis Eichhorn 2017-10-14 18:03:25 +02:00
parent ef0f4624e4
commit 1b8481ad06
32 changed files with 106 additions and 86 deletions

View File

@ -215,6 +215,20 @@ class Account implements ArrayableInterface, \JsonSerializable
return $this->groups;
}
/**
* Add group.
*
* @param mixed $group Group to add
*
* @return void
*
* @since 1.0.0
*/
public function addGroup($group) /* : void */
{
$this->groups[] = $group;
}
/**
* Set localization.
*
@ -258,7 +272,7 @@ class Account implements ArrayableInterface, \JsonSerializable
*/
public function addPermissions(array $permissions) /* : void */
{
$this->permissions += $permissions;
$this->permissions = array_merge($this->permissions, $permissions);
}
/**
@ -277,6 +291,18 @@ class Account implements ArrayableInterface, \JsonSerializable
$this->permissions[] = $permission;
}
/**
* Get permissions.
*
* @return array
*
* @since 1.0.0
*/
public function getPermissions() : array
{
return $this->permissions;
}
/**
* Has permissions.
*

View File

@ -62,11 +62,7 @@ class Auth
{
$uid = $this->session->get('UID');
if (empty($uid)) {
return 0;
}
return $uid;
return empty($uid) ? 0 : $uid;
}
/**

View File

@ -127,9 +127,13 @@ class CookieJar
throw new LockException('CookieJar');
}
setcookie($id, '', time() - 3600);
if(!headers_sent()) {
setcookie($id, '', time() - 3600);
return true;
return true;
}
return false;
}
return false;

View File

@ -174,6 +174,7 @@ class DataMapperAbstract implements DataMapperInterface
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
@ -185,6 +186,7 @@ class DataMapperAbstract implements DataMapperInterface
* @return void
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __clone()
{

View File

@ -171,6 +171,7 @@ class DataMapperBaseAbstract
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
@ -182,6 +183,7 @@ class DataMapperBaseAbstract
* @return void
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __clone()
{

View File

@ -545,14 +545,9 @@ class Builder extends BuilderAbstract
*
* @since 1.0.0
*/
public function andWhere(Where $where) : Builder
public function andWhere($where, $operator = null, $values = null) : Builder
{
$this->wheres[][] = [
'column' => $where,
'boolean' => 'and',
];
return $this;
return $this->where($where, $operator, $values, 'and');
}
/**
@ -564,14 +559,9 @@ class Builder extends BuilderAbstract
*
* @since 1.0.0
*/
public function orWhere(Where $where) : Builder
public function orWhere($where, $operator = null, $values = null) : Builder
{
$this->wheres[][] = [
'column' => $where,
'boolean' => 'or',
];
return $this;
return $this->where($where, $operator, $values, 'or');
}
/**
@ -693,10 +683,14 @@ class Builder extends BuilderAbstract
public function orderBy($columns, $order = 'DESC') : Builder
{
if (is_string($columns) || $columns instanceof \Closure) {
$this->orders[] = ['column' => $columns, 'order' => $order];
if(!isset($this->orders[$order])) {
$this->orders[$order] = [];
}
$this->orders[$order][] = $columns;
} elseif (is_array($columns)) {
foreach ($columns as $key => $column) {
$this->orders[] = ['column' => $column, 'order' => $order[$key]];
$this->orders[is_string($order) ? $order : $order[$key]][] = $column;
}
} else {
throw new \InvalidArgumentException();

View File

@ -288,6 +288,9 @@ class Grammar extends GrammarAbstract
if (isset($element['value'])) {
$expression .= ' ' . strtoupper($element['operator']) . ' ' . $this->compileValue($element['value'], $query->getPrefix());
} else {
$operator = strtoupper($element['operator']) === '=' ? 'IS' : 'IS NOT';
$expression .= ' ' . $operator . ' ' . $this->compileValue($element['value'], $query->getPrefix());
}
return $expression;
@ -416,8 +419,13 @@ class Grammar extends GrammarAbstract
{
$expression = '';
foreach ($orders as $order) {
$expression .= $this->compileSystem($order['column'], $query->getPrefix()) . ' ' . $order['order'] . ', ';
foreach ($orders as $key => $order) {
foreach($order as $column) {
$expression .= $this->compileSystem($column, $query->getPrefix()) . ', ';
}
$expression = rtrim($expression, ', ');
$expression .= ' ' . $key . ', ';
}
if ($expression === '') {

View File

@ -86,8 +86,10 @@ class HttpSession implements SessionInterface
$this->inactivityInterval = $inactivityInterval;
session_set_cookie_params($liftetime, '/', '', false, true);
session_start();
if(session_status() !== PHP_SESSION_ACTIVE && !headers_sent()) {
session_set_cookie_params($liftetime, '/', '', false, true);
session_start();
}
if($this->inactivityInterval > 0 && ($this->inactivityInterval + ($_SESSION['lastActivity'] ?? 0) < time())) {
$this->destroy();

View File

@ -150,6 +150,7 @@ class FileLogger implements LoggerInterface
* Closes the logging file
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function __destruct()
{
@ -162,6 +163,7 @@ class FileLogger implements LoggerInterface
* Protect instance from getting copied from outside.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __clone()
{

View File

@ -67,12 +67,12 @@ class Request extends RequestAbstract
/**
* Constructor.
*
* @param Localization $l11n Localization
* @param UriInterface $uri Uri
* @param Localization $l11n Localization
*
* @since 1.0.0
*/
public function __construct(Localization $l11n = null, UriInterface $uri = null)
public function __construct(UriInterface $uri = null, Localization $l11n = null)
{
$this->header = new Header();
$this->header->setL11n($l11n ?? new Localization());
@ -193,15 +193,13 @@ class Request extends RequestAbstract
/**
* Create request from super globals.
*
* @param Localization $l11n Localization
*
* @return Request
*
* @since 1.0.0
*/
public static function createFromSuperglobals(Localization $l11n = null) : Request
public static function createFromSuperglobals() : Request
{
return new self($l11n);
return new self();
}
/**

View File

@ -47,10 +47,10 @@ class Response extends ResponseAbstract implements RenderableInterface
*
* @since 1.0.0
*/
public function __construct(Localization $l11n)
public function __construct(Localization $l11n = null)
{
$this->header = new Header();
$this->header->setL11n($l11n);
$this->header->setL11n($l11n ?? new Localization());
}
/**

View File

@ -107,15 +107,6 @@ abstract class ModuleAbstract
$this->app = $app;
}
/**
* Install external.
*
* @since 1.0.0
*/
public static function installExternal() /* : void */
{
}
/**
* Get language files.
*
@ -171,16 +162,4 @@ abstract class ModuleAbstract
/** @noinspection PhpUndefinedFieldInspection */
return static::$dependencies;
}
/**
* Get event id prefix.
*
* @return string
*
* @since 1.0.0
*/
public function getEventId() : string
{
return static::class;
}
}

View File

@ -54,6 +54,7 @@ class ModuleFactory
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -40,6 +40,7 @@ class FileUtils
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -40,6 +40,7 @@ final class Storage
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -40,6 +40,7 @@ abstract class StorageAbstract
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -31,6 +31,7 @@ class SystemUtils
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -35,6 +35,7 @@ final class UnhandledHandler
* @return void
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public static function exceptionHandler(\Throwable $e) /* : void */
{
@ -92,6 +93,7 @@ final class UnhandledHandler
* @return void
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public static function shutdownHandler() /* : void */
{

View File

@ -41,6 +41,7 @@ class UriFactory
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -31,6 +31,7 @@ class ArrayUtils
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -46,6 +46,7 @@ class Currency
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
@ -97,7 +98,7 @@ class Currency
public static function getEcbEuroRates() : array
{
if (!isset(self::$ecbCurrencies)) {
$request = new Request(new Localization(), new Http('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'));
$request = new Request(new Http('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'));
$request->setMethod(RequestMethod::GET);
$xml = new \SimpleXMLElement(Rest::request($request));

View File

@ -31,6 +31,7 @@ class File
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -28,6 +28,12 @@ class Ip
{
/* public */ const IP_TABLE_ITERATIONS = 100;
/**
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
}

View File

@ -59,7 +59,7 @@ final class Dictionary
*/
public function __construct(string $source = '')
{
if (isset($source)) {
if (!empty($source)) {
$this->generate($source);
}
}
@ -139,15 +139,15 @@ final class Dictionary
public function set(string $entry, string $value) /* : void */
{
if (strlen($entry) !== 1) {
throw new \Exception('Must be a character.');
throw new \InvalidArgumentException('Must be a character.');
}
if (isset($this->dictionary[$entry])) {
throw new \Exception('Character already exists');
throw new \InvalidArgumentException('Character already exists');
}
if (strlen(str_replace('0', '', str_replace('1', '', $value))) !== 0) {
throw new \Exception('Bad formatting.');
throw new \InvalidArgumentException('Bad formatting.');
}
$length = strlen($value);
@ -177,11 +177,11 @@ final class Dictionary
public function get(string $entry) : string
{
if (strlen($entry) !== 1) {
throw new \Exception('Must be a character.');
throw new \InvalidArgumentException('Must be a character.');
}
if (!isset($this->dictionary[$entry])) {
throw new \Exception('Character does not exist');
throw new \InvalidArgumentException('Character does not exist');
}
return $this->dictionary[$entry];

View File

@ -51,7 +51,7 @@ final class Huffman
*
* @since 1.0.0
*/
public function getDictionary() : Dictionary
public function getDictionary() /* : ?Dictionary */
{
return $this->dictionary;
}

View File

@ -35,6 +35,7 @@ class StringUtils
* This class is purely static and is preventing any initialization
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -33,6 +33,7 @@ abstract class Iban extends ValidatorAbstract
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -33,6 +33,7 @@ class Email extends ValidatorAbstract
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -33,8 +33,9 @@ abstract class Hostname extends ValidatorAbstract
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function __construct()
private function __construct()
{
}

View File

@ -33,6 +33,7 @@ class Ip extends ValidatorAbstract
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -33,6 +33,7 @@ class Version
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{

View File

@ -145,22 +145,6 @@ abstract class ViewAbstract implements \Serializable
return false;
}
/**
* Edit view.
*
* @param string $id View ID
* @param View $view
* @param null|int $order Order of view
*
* @return void
*
* @since 1.0.0 <d.eichhorn@oms.com>
*/
public function editView(string $id, View $view, $order = null) /* : void */
{
$this->addView($id, $view, $order, true);
}
/**
* Add view.
*
@ -247,11 +231,11 @@ abstract class ViewAbstract implements \Serializable
try {
ob_start();
/** @noinspection PhpIncludeInspection */
$data = include $path;
$includeData = include $path;
$ob = ob_get_clean();
if (is_array($data)) {
return $data;
if (is_array($includeData)) {
return $includeData;
}
} catch(\Throwable $e) {
$ob = '';
@ -268,10 +252,10 @@ abstract class ViewAbstract implements \Serializable
* @return void
*
* @since 1.0.0 <d.eichhorn@oms.com>
* @codeCoverageIgnore
*/
public function unserialize($raw)
{
// todo: implement
}
}