mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
implement tests
This commit is contained in:
parent
0be02d40c2
commit
4f081aaa71
|
|
@ -73,10 +73,6 @@ final class Header extends HeaderAbstract
|
|||
return false;
|
||||
}
|
||||
|
||||
if (self::isSecurityHeader($key) && isset($this->header[$key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$key = \strtolower($key);
|
||||
|
||||
if (!$overwrite && isset($this->header[$key])) {
|
||||
|
|
@ -94,25 +90,6 @@ final class Header extends HeaderAbstract
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is security header.
|
||||
*
|
||||
* @param string $key Header key
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function isSecurityHeader(string $key) : bool
|
||||
{
|
||||
$key = \strtolower($key);
|
||||
|
||||
return $key === 'content-security-policy'
|
||||
|| $key === 'x-xss-protection'
|
||||
|| $key === 'x-content-type-options'
|
||||
|| $key === 'x-frame-options';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -121,48 +98,6 @@ final class Header extends HeaderAbstract
|
|||
return self::VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status code.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getStatusCode() : int
|
||||
{
|
||||
if ($this->status === 0) {
|
||||
$this->status = (int) \http_response_code();
|
||||
}
|
||||
|
||||
return parent::getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all headers for apache and nginx
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getAllHeaders() : array
|
||||
{
|
||||
if (\function_exists('getallheaders')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
return getallheaders();
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
$headers = [];
|
||||
foreach ($_SERVER as $name => $value) {
|
||||
$part = \substr($name, 5);
|
||||
if ($part === 'HTTP_') {
|
||||
$headers[\str_replace(' ', '-', \ucwords(\strtolower(\str_replace('_', ' ', $part))))] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove header by ID.
|
||||
*
|
||||
|
|
@ -225,27 +160,6 @@ final class Header extends HeaderAbstract
|
|||
return isset($this->header[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push all headers.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function push() : void
|
||||
{
|
||||
if (self::$isLocked) {
|
||||
throw new \Exception('Already locked');
|
||||
}
|
||||
|
||||
foreach ($this->header as $name => $arr) {
|
||||
foreach ($arr as $ele => $value) {
|
||||
\header($name . ': ' . $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use phpOMS\Message\RequestAbstract;
|
|||
use phpOMS\Message\RequestSource;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Router\RouteVerb;
|
||||
use phpOMS\Uri\Argument;
|
||||
use phpOMS\Uri\UriInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -49,12 +50,12 @@ final class Request extends RequestAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(UriInterface $uri, Localization $l11n = null)
|
||||
public function __construct(UriInterface $uri = null, Localization $l11n = null)
|
||||
{
|
||||
$this->header = new Header();
|
||||
$this->header->setL11n($l11n ?? new Localization());
|
||||
|
||||
$this->uri = $uri;
|
||||
$this->uri = $uri ?? new Argument();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
|
|
@ -71,20 +72,6 @@ final class Request extends RequestAbstract
|
|||
{
|
||||
$lang = \explode('_', $_SERVER['LANG'] ?? '');
|
||||
$this->header->getL11n()->setLanguage($lang[0] ?? 'en');
|
||||
|
||||
$this->cleanupGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up globals that musn't be used any longer
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function cleanupGlobals() : void
|
||||
{
|
||||
unset($_SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -123,18 +110,31 @@ final class Request extends RequestAbstract
|
|||
public function getOS() : string
|
||||
{
|
||||
if ($this->os === null) {
|
||||
$this->os = PHP_OS;
|
||||
$this->os = \strtolower(PHP_OS);
|
||||
}
|
||||
|
||||
return $this->os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set OS type
|
||||
*
|
||||
* @param string $os OS type
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setOS(string $os) : void
|
||||
{
|
||||
$this->os = $os;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOrigin() : string
|
||||
{
|
||||
// todo: maybe return execution path?
|
||||
return '127.0.0.1';
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +159,6 @@ final class Request extends RequestAbstract
|
|||
*/
|
||||
public function getBody() : string
|
||||
{
|
||||
// todo: implement
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
|||
34
Message/Mail/ContentEncoding.php
Normal file
34
Message/Mail/ContentEncoding.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package phpOMS\Message\Mail
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Message\Mail;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* OS type enum.
|
||||
*
|
||||
* OS Types which could be useful in order to create statistics or deliver OS specific content.
|
||||
*
|
||||
* @package phpOMS\Message\Mail
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class ContentEncoding extends Enum
|
||||
{
|
||||
public const BASE64 = 1;
|
||||
public const EIGHTBIT = 2;
|
||||
public const QPRINT = 3;
|
||||
}
|
||||
|
|
@ -64,6 +64,14 @@ class EmailAbstract
|
|||
*/
|
||||
protected $timeout = 30;
|
||||
|
||||
/**
|
||||
* Connection.
|
||||
*
|
||||
* @var mixed
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $con = null;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
|
|
@ -81,10 +89,10 @@ class EmailAbstract
|
|||
$this->timeout = $timeout;
|
||||
$this->ssl = $ssl;
|
||||
|
||||
imap_timeout(IMAP_OPENTIMEOUT, $timeout);
|
||||
imap_timeout(IMAP_READTIMEOUT, $timeout);
|
||||
imap_timeout(IMAP_WRITETIMEOUT, $timeout);
|
||||
imap_timeout(IMAP_CLOSETIMEOUT, $timeout);
|
||||
\imap_timeout(IMAP_OPENTIMEOUT, $timeout);
|
||||
\imap_timeout(IMAP_READTIMEOUT, $timeout);
|
||||
\imap_timeout(IMAP_WRITETIMEOUT, $timeout);
|
||||
\imap_timeout(IMAP_CLOSETIMEOUT, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -99,13 +107,13 @@ class EmailAbstract
|
|||
*/
|
||||
public static function decode(string $content, int $encoding)
|
||||
{
|
||||
if ($encoding == 3) {
|
||||
return imap_base64($content);
|
||||
} elseif ($encoding == 1) {
|
||||
return imap_8bit($content);
|
||||
} else {
|
||||
return imap_qprint($content);
|
||||
if ($encoding === ContentEncoding::BASE64) {
|
||||
return \imap_base64($content);
|
||||
} elseif ($encoding === ContentEncoding::EIGHTBIT) {
|
||||
return \imap_8bit($content);
|
||||
}
|
||||
|
||||
return \imap_qprint($content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -127,8 +135,8 @@ class EmailAbstract
|
|||
*/
|
||||
public function disconnect() : void
|
||||
{
|
||||
if ($this->con === null) {
|
||||
imap_close($this->con);
|
||||
if ($this->con !== null) {
|
||||
\imap_close($this->con);
|
||||
$this->con = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -139,17 +147,22 @@ class EmailAbstract
|
|||
* @param string $user Username
|
||||
* @param string $pass Password
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function connect(string $user = '', string $pass = '') : void
|
||||
public function connect(string $user = '', string $pass = '') : bool
|
||||
{
|
||||
$this->mailbox = \substr($this->mailbox, 0, -1) . ($this->ssl ? '/ssl/validate-cert' : '/novalidate-cert') . '}';
|
||||
|
||||
// /novalidate-cert
|
||||
if ($this->con === null) {
|
||||
$this->con = imap_open($this->mailbox . 'INBOX', $user, $pass);
|
||||
try {
|
||||
$this->con = \imap_open($this->mailbox . 'INBOX', $user, $pass);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $t) {
|
||||
$this->con = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +175,7 @@ class EmailAbstract
|
|||
*/
|
||||
public function isConnected() : bool
|
||||
{
|
||||
return imap_ping($this->con);
|
||||
return $this->con === null ? false : \imap_ping($this->con);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -176,36 +189,49 @@ class EmailAbstract
|
|||
*/
|
||||
public function getBoxes(string $pattern = '*') : array
|
||||
{
|
||||
return imap_list($this->con, $this->host, $pattern);
|
||||
$list = \imap_list($this->con, $this->host, $pattern);
|
||||
|
||||
return $list === false ? [] : $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get inbox quota.
|
||||
*
|
||||
* @return mixed
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getQuota()
|
||||
public function getQuota() : array
|
||||
{
|
||||
return imap_get_quotaroot($this->con, "INBOX");
|
||||
$quota = [];
|
||||
|
||||
try {
|
||||
$quota = \imap_get_quotaroot($this->con, "INBOX");
|
||||
} finally {
|
||||
return $quota === false ? [] : $quota;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email.
|
||||
*
|
||||
* @param mixed $id mail id
|
||||
* @param string $id mail id
|
||||
*
|
||||
* @return Mail
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getEmail($id) : Mail
|
||||
public function getEmail(string $id) : Mail
|
||||
{
|
||||
$mail = new Mail($id);
|
||||
$mail->setOverview(imap_fetch_overview($this->con, $id));
|
||||
$mail->setBody(imap_fetchbody($this->con, $id, 2));
|
||||
$mail->setEncoding(imap_fetchstructure($this->con, $id));
|
||||
|
||||
if ((int) $id > $this->countMessages()) {
|
||||
return $mail;
|
||||
}
|
||||
|
||||
$mail->setOverview(\imap_fetch_overview($this->con, $id));
|
||||
$mail->setBody(\imap_fetchbody($this->con, (int) $id, '1.1'));
|
||||
//$mail->setEncoding(\imap_fetchstructure($this->con, (int) $id));
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
|
@ -233,9 +259,9 @@ class EmailAbstract
|
|||
*/
|
||||
public function getInboxOverview(string $option = 'ALL') : array
|
||||
{
|
||||
$ids = imap_search($this->con, $option, SE_FREE, 'UTF-8');
|
||||
$ids = \imap_search($this->con, $option, SE_FREE, 'UTF-8');
|
||||
|
||||
return is_array($ids) ? imap_fetch_overview($this->con, \implode(',', $ids)) : [];
|
||||
return \is_array($ids) ? \imap_fetch_overview($this->con, \implode(',', $ids)) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -396,18 +422,6 @@ class EmailAbstract
|
|||
return $this->getInboxOverview('TEXT "' . $text . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* List mailboxes
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function listMailbox() : array
|
||||
{
|
||||
return imap_listmailbox($this->con, $this->mailbox, '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create mailbox
|
||||
*
|
||||
|
|
@ -419,7 +433,7 @@ class EmailAbstract
|
|||
*/
|
||||
public function createMailbox(string $mailbox) : bool
|
||||
{
|
||||
return imap_createmailbox($this->con, $mailbox);
|
||||
return \imap_createmailbox($this->con, $mailbox);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -434,7 +448,7 @@ class EmailAbstract
|
|||
*/
|
||||
public function renameMailbox(string $old, string $new) : bool
|
||||
{
|
||||
return imap_renamemailbox($this->con, $old, $new);
|
||||
return \imap_renamemailbox($this->con, $old, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -448,7 +462,7 @@ class EmailAbstract
|
|||
*/
|
||||
public function deleteMailbox(string $mailbox) : bool
|
||||
{
|
||||
return imap_deletemailbox($this->con, $mailbox);
|
||||
return \imap_deletemailbox($this->con, $mailbox);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -462,7 +476,7 @@ class EmailAbstract
|
|||
*/
|
||||
public function deleteMessage(int $id) : bool
|
||||
{
|
||||
return imap_delete($this->con, $id);
|
||||
return \imap_delete($this->con, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -474,7 +488,7 @@ class EmailAbstract
|
|||
*/
|
||||
public function deleteMarkedMessages() : bool
|
||||
{
|
||||
return imap_expunge($this->con);
|
||||
return \imap_expunge($this->con);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -490,11 +504,11 @@ class EmailAbstract
|
|||
public function getMessageOverview(int $length = 0, int $start = 1) : array
|
||||
{
|
||||
if ($length === 0) {
|
||||
$info = imap_check($this->con);
|
||||
$info = \imap_check($this->con);
|
||||
$length = $info->Nmsgs;
|
||||
}
|
||||
|
||||
return imap_fetch_overview($mbox, $start . ':' . ($length + $start), 0);
|
||||
return \imap_fetch_overview($this->con, $start . ':' . ($length - 1 + $start), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -506,7 +520,7 @@ class EmailAbstract
|
|||
*/
|
||||
public function countMessages() : int
|
||||
{
|
||||
return imap_num_msg($this->con);
|
||||
return \imap_num_msg($this->con);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -520,6 +534,10 @@ class EmailAbstract
|
|||
*/
|
||||
public function getMessageHeader(int $id) : string
|
||||
{
|
||||
return imap_fetchheader($this->con, $id);
|
||||
if ($id > $this->countMessages()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return \imap_fetchheader($this->con, $id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class Imap extends EmailAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $host = 'localhost', int $port = 25, int $timeout = 30, bool $ssl = false)
|
||||
public function __construct(string $host = 'localhost', int $port = 143, int $timeout = 30, bool $ssl = false)
|
||||
{
|
||||
parent::__construct($host, $port, $timeout, $ssl);
|
||||
}
|
||||
|
|
@ -45,13 +45,14 @@ class Imap extends EmailAbstract
|
|||
* @param string $user Username
|
||||
* @param string $pass Password
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function connect(string $user = '', string $pass = '') : void
|
||||
public function connect(string $user = '', string $pass = '') : bool
|
||||
{
|
||||
$this->mailbox = '{' . $this->host . ':' . $this->port . '/imap}';
|
||||
parent::connect();
|
||||
|
||||
return parent::connect($user, $pass);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,13 +197,13 @@ class Mail
|
|||
/**
|
||||
* Set body.
|
||||
*
|
||||
* @param string $overview Mail overview
|
||||
* @param array $overview Mail overview
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setOverview(string $overview) : void
|
||||
public function setOverview(array $overview) : void
|
||||
{
|
||||
$this->overview = $overview;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package phpOMS\Message\Mail
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Message\Mail;
|
||||
|
||||
/**
|
||||
* Imap mail class.
|
||||
*
|
||||
* @package phpOMS\Message\Mail
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Nntp extends EmailAbstract
|
||||
{
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param string $host Host
|
||||
* @param int $port Host port
|
||||
* @param int $timeout Timeout
|
||||
* @param bool $ssl Use ssl
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $host = 'localhost', int $port = 25, int $timeout = 30, bool $ssl = false)
|
||||
{
|
||||
parent::__construct($host, $port, $timeout, $ssl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
*
|
||||
* @param string $user Username
|
||||
* @param string $pass Password
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function connect(string $user = '', string $pass = '') : void
|
||||
{
|
||||
$this->mailbox = '{' . $this->host . ':' . $this->port . '/nntp}';
|
||||
parent::connect();
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,11 @@ class Tar implements ArchiveInterface
|
|||
|
||||
/** @var array $sources */
|
||||
foreach ($sources as $source => $relative) {
|
||||
if (\is_numeric($source) && \realpath($relative) !== false) {
|
||||
$source = $relative;
|
||||
$relative = '';
|
||||
}
|
||||
|
||||
$source = \realpath($source);
|
||||
|
||||
if ($source === false) {
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package phpOMS\Utils\JobQueue
|
||||
* }
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Utils\JobQueue;
|
||||
|
||||
/**
|
||||
* Array utils.
|
||||
*
|
||||
* @package phpOMS\Utils\JobQueue
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Job
|
||||
{
|
||||
private $priority = 0.0;
|
||||
private $callback = null;
|
||||
|
||||
public function __construct($callback, float $priority = 0.0)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$this->callback();
|
||||
}
|
||||
|
||||
public function getPriority() : float
|
||||
{
|
||||
return $this->priority;
|
||||
}
|
||||
|
||||
public function setPriority(float $priority) : void
|
||||
{
|
||||
$this->priority = $priority;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package phpOMS\Utils\JobQueue
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpOMS\Utils\JobQueue;
|
||||
|
||||
use phpOMS\Stdlib\Queue\PriorityQueue;
|
||||
|
||||
/**
|
||||
* Array utils.
|
||||
*
|
||||
* @package phpOMS\Utils\JobQueue
|
||||
* @license OMS License 1.0
|
||||
* @link http://website.orange-management.de
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class JobQueue
|
||||
{
|
||||
private $queue = null;
|
||||
|
||||
private $run = true;
|
||||
|
||||
private $suspended = false;
|
||||
|
||||
private $isTerminating = true;
|
||||
|
||||
private $isDeamonized;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->queue = new PriorityQueue();
|
||||
}
|
||||
|
||||
public function dispatch(Job $job)
|
||||
{
|
||||
$this->queue->insert($job, $job->getPriority());
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->run = true;
|
||||
$this->suspended = false;
|
||||
|
||||
if ($this->isDeamonized) {
|
||||
if ($pid = pcntl_fork()) {
|
||||
return $pid;
|
||||
}
|
||||
|
||||
$this->runAsDeamon();
|
||||
|
||||
if (posix_setsid() < 0 || $pid = pcntl_fork()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
while ($this->run) {
|
||||
while (!$this->suspended) {
|
||||
if ($this->deamonized) {
|
||||
// todo: see if still unsuspended and still running (db, file etc)
|
||||
}
|
||||
}
|
||||
|
||||
$job = $this->queue->pop();
|
||||
|
||||
$this->queue->increaseAll();
|
||||
$job['job']->execute();
|
||||
|
||||
if ($this->isTerminating && $this->queue->count() < 1) {
|
||||
$this->suspended = true;
|
||||
$this->run = false;
|
||||
}
|
||||
|
||||
\sleep(1);
|
||||
}
|
||||
|
||||
\sleep(1);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private function runAsDeamon()
|
||||
{
|
||||
\ob_end_clean();
|
||||
\fclose(STDIN);
|
||||
\fclose(STDOUT);
|
||||
\fclose(STDERR);
|
||||
|
||||
\register_shutdown_function(function() { \posix_kill(\posix_getpid(), SIGHUP); });
|
||||
}
|
||||
|
||||
public function setRunning(bool $run = true) : void
|
||||
{
|
||||
$this->run = $run;
|
||||
$this->suspended = $run;
|
||||
}
|
||||
|
||||
public function isRunning() : bool
|
||||
{
|
||||
return $this->run;
|
||||
}
|
||||
|
||||
public function isSuspended() : bool
|
||||
{
|
||||
return $this->suspended;
|
||||
}
|
||||
|
||||
public function setSuspended(bool $suspended = true) : void
|
||||
{
|
||||
$this->suspended = $suspended;
|
||||
}
|
||||
|
||||
public function isTerminating() : bool
|
||||
{
|
||||
return $this->isTerminating;
|
||||
}
|
||||
|
||||
public function setTerminating(bool $terminating = true) : void
|
||||
{
|
||||
$this->isTerminating = $terminating;
|
||||
}
|
||||
|
||||
public function isDeamonized() : bool
|
||||
{
|
||||
return $this->isDeamonized;
|
||||
}
|
||||
|
||||
public function setDeamonized(bool $deamonized) : void
|
||||
{
|
||||
$this->isDeamonized = $deamonized;
|
||||
}
|
||||
|
||||
private function savePid()
|
||||
{
|
||||
// todo: save pid somewhere for kill
|
||||
}
|
||||
}
|
||||
|
|
@ -254,6 +254,22 @@ $CONFIG = [
|
|||
'port' => 11211,
|
||||
],
|
||||
],
|
||||
'mail' => [
|
||||
'imap' => [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 143,
|
||||
'ssl' => false,
|
||||
'user' => 'testuser',
|
||||
'password' => 'testuser',
|
||||
],
|
||||
'pop3' => [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 25,
|
||||
'ssl' => false,
|
||||
'user' => 'testuser',
|
||||
'password' => 'testuser',
|
||||
],
|
||||
],
|
||||
'log' => [
|
||||
'file' => [
|
||||
'path' => __DIR__ . '/Logs',
|
||||
|
|
|
|||
78
tests/Message/Console/HeaderTest.php
Normal file
78
tests/Message/Console/HeaderTest.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Message\Console;
|
||||
|
||||
use phpOMS\Message\Console\Header;
|
||||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\DataStorage\LockException;
|
||||
use phpOMS\Utils\TestUtils;
|
||||
|
||||
class HeaderTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefaults()
|
||||
{
|
||||
$header = new Header();
|
||||
self::assertFalse($header->isLocked());
|
||||
self::assertEquals(0, $header->getStatusCode());
|
||||
self::assertEquals('1.0', $header->getProtocolVersion());
|
||||
self::assertEquals('', $header->getReasonPhrase());
|
||||
self::assertEquals([], $header->get('key'));
|
||||
self::assertFalse($header->has('key'));
|
||||
self::assertInstanceOf(Localization::class, $header->getL11n());
|
||||
self::assertEquals(0, $header->getAccount());
|
||||
}
|
||||
|
||||
public function testGetSet()
|
||||
{
|
||||
$header = new Header();
|
||||
|
||||
self::assertTrue($header->set('key', 'header'));
|
||||
self::assertEquals(['header'], $header->get('key'));
|
||||
self::assertTrue($header->has('key'));
|
||||
|
||||
self::assertFalse($header->set('key', 'header2'));
|
||||
self::assertEquals(['header'], $header->get('key'));
|
||||
|
||||
self::assertTrue($header->set('key', 'header3', true));
|
||||
self::assertEquals(['header3'], $header->get('key'));
|
||||
|
||||
self::assertTrue($header->remove('key'));
|
||||
self::assertFalse($header->has('key'));
|
||||
self::assertFalse($header->remove('key'));
|
||||
|
||||
$header->setAccount(2);
|
||||
self::AssertEquals(2, $header->getAccount(2));
|
||||
}
|
||||
|
||||
public function testLockedHeaderSet()
|
||||
{
|
||||
$header = new Header();
|
||||
Header::lock();
|
||||
self::assertTrue(Header::isLocked());
|
||||
self::assertFalse($header->set('key', 'value'));
|
||||
|
||||
TestUtils::setMember('phpOMS\Message\Console\Header', 'isLocked', false);
|
||||
}
|
||||
|
||||
public function testLockedHeaderRemove()
|
||||
{
|
||||
$header = new Header();
|
||||
Header::lock();
|
||||
self::assertTrue(Header::isLocked());
|
||||
self::assertFalse($header->remove('key'));
|
||||
|
||||
TestUtils::setMember('phpOMS\Message\Console\Header', 'isLocked', false);
|
||||
}
|
||||
}
|
||||
108
tests/Message/Console/RequestTest.php
Normal file
108
tests/Message/Console/RequestTest.php
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Message\Console;
|
||||
|
||||
use phpOMS\Message\Console\Request;
|
||||
use phpOMS\Message\Console\Header;
|
||||
use phpOMS\Message\Http\OSType;
|
||||
use phpOMS\Message\Http\RequestMethod;
|
||||
use phpOMS\Message\RequestSource;
|
||||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\Router\RouteVerb;
|
||||
use phpOMS\Uri\Console;
|
||||
use phpOMS\Uri\Argument;
|
||||
|
||||
class RequestTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault()
|
||||
{
|
||||
$request = new Request();
|
||||
|
||||
self::assertEquals('en', $request->getHeader()->getL11n()->getLanguage());
|
||||
self::assertEquals(OSType::LINUX, $request->getOS());
|
||||
self::assertEquals('127.0.0.1', $request->getOrigin());
|
||||
self::assertEquals([], $request->getHash());
|
||||
self::assertEmpty($request->getBody());
|
||||
self::assertEquals(RouteVerb::GET, $request->getRouteVerb());
|
||||
self::assertEquals(RequestMethod::GET, $request->getMethod());
|
||||
self::assertInstanceOf('\phpOMS\Message\Console\Header', $request->getHeader());
|
||||
self::assertEquals('', $request->__toString());
|
||||
self::assertFalse($request->hasData('key'));
|
||||
self::assertEquals(null, $request->getData('key'));
|
||||
}
|
||||
|
||||
public function testSetGet()
|
||||
{
|
||||
$request = new Request(new Argument('get:some/test/path'), $l11n = new Localization());
|
||||
|
||||
$request->setOS(OSType::WINDOWS_XP);
|
||||
self::assertEquals(OSType::WINDOWS_XP, $request->getOS());
|
||||
|
||||
$request->setMethod(RequestMethod::PUT);
|
||||
self::assertEquals(RequestMethod::PUT, $request->getMethod());
|
||||
self::assertEquals(RouteVerb::PUT, $request->getRouteVerb());
|
||||
|
||||
$request->setMethod(RequestMethod::DELETE);
|
||||
self::assertEquals(RequestMethod::DELETE, $request->getMethod());
|
||||
self::assertEquals(RouteVerb::DELETE, $request->getRouteVerb());
|
||||
|
||||
$request->setMethod(RequestMethod::POST);
|
||||
self::assertEquals(RequestMethod::POST, $request->getMethod());
|
||||
self::assertEquals(RouteVerb::SET, $request->getRouteVerb());
|
||||
|
||||
self::assertEquals('get:some/test/path', $request->getUri()->__toString());
|
||||
|
||||
$request->createRequestHashs(0);
|
||||
self::assertEquals([
|
||||
'eb875812858d27b22cb2b75f992dffadc1b05c66',
|
||||
'fa423b369272e7e19b2a5fa4eeba560e74c0d457',
|
||||
'3e353695aa5bfa63bc373702a75865b3619c4c96',
|
||||
], $request->getHash());
|
||||
self::assertEquals($l11n, $request->getHeader()->getL11n());
|
||||
|
||||
self::assertTrue($request->setData('key', 'value'));
|
||||
self::assertFalse($request->setData('key', 'value2', false));
|
||||
self::assertEquals('value', $request->getData('key'));
|
||||
self::assertTrue($request->hasData('key'));
|
||||
self::assertEquals(['key' => 'value'], $request->getData());
|
||||
|
||||
$request->setUri(new Argument('get:some/test/path2'));
|
||||
$request->createRequestHashs(0);
|
||||
|
||||
self::assertEquals('get:some/test/path2', $request->__toString());
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$request = new Request(new Argument('get:some/test/path'));
|
||||
self::assertEquals('get:some/test/path', $request->__toString());
|
||||
|
||||
$request->setData('test', 'data');
|
||||
$request->setData('test2', 3);
|
||||
self::assertEquals('get:some/test/path', $request->__toString());
|
||||
|
||||
$request = new Request(new Argument('get:some/test/path?test=var'));
|
||||
self::assertEquals('get:some/test/path?test=var', $request->__toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testInvalidRouteVerb()
|
||||
{
|
||||
$request = new Request(new Argument('get:some/test/path'));
|
||||
$request->setMethod('failure');
|
||||
$request->getRouteVerb();
|
||||
}
|
||||
}
|
||||
39
tests/Message/Console/ResponseTest.php
Normal file
39
tests/Message/Console/ResponseTest.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Message\Console;
|
||||
|
||||
use phpOMS\Message\Console\Response;
|
||||
use phpOMS\Localization\Localization;
|
||||
|
||||
class ResponseTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault()
|
||||
{
|
||||
$response = new Response(new Localization());
|
||||
self::assertEquals('', $response->getBody());
|
||||
self::assertEquals('', $response->render());
|
||||
self::assertEquals([], $response->toArray());
|
||||
self::assertInstanceOf('\phpOMS\Localization\Localization', $response->getHeader()->getL11n());
|
||||
self::assertInstanceOf('\phpOMS\Message\Console\Header', $response->getHeader());
|
||||
}
|
||||
|
||||
public function testSetGet()
|
||||
{
|
||||
$response = new Response(new Localization());
|
||||
|
||||
$response->setResponse(['a' => 1]);
|
||||
self::assertTrue($response->remove('a'));
|
||||
self::assertFalse($response->remove('a'));
|
||||
}
|
||||
}
|
||||
|
|
@ -17,8 +17,41 @@ use phpOMS\Message\Mail\Imap;
|
|||
|
||||
class ImapTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testPlaceholder()
|
||||
public function testDefault()
|
||||
{
|
||||
self::markTestIncomplete();
|
||||
$email = new Imap(
|
||||
$GLOBALS['CONFIG']['mail']['imap']['host'],
|
||||
$GLOBALS['CONFIG']['mail']['imap']['port'],
|
||||
30,
|
||||
$GLOBALS['CONFIG']['mail']['imap']['ssl']
|
||||
);
|
||||
|
||||
self::assertFalse($email->isConnected());
|
||||
self::assertTrue($email->connect(
|
||||
$GLOBALS['CONFIG']['mail']['imap']['user'],
|
||||
$GLOBALS['CONFIG']['mail']['imap']['password']
|
||||
));
|
||||
|
||||
self::assertTrue($email->isConnected());
|
||||
self::assertEquals([], $email->getBoxes());
|
||||
self::assertEquals([], $email->getQuota());
|
||||
self::assertInstanceOf('\phpOMS\Message\Mail\Mail', $email->getEmail('1'));
|
||||
self::assertEquals([], $email->getInboxAll());
|
||||
self::assertEquals([], $email->getInboxOverview());
|
||||
self::assertEquals([], $email->getInboxNew());
|
||||
self::assertEquals([], $email->getInboxFrom(''));
|
||||
self::assertEquals([], $email->getInboxTo(''));
|
||||
self::assertEquals([], $email->getInboxCc(''));
|
||||
self::assertEquals([], $email->getInboxBcc(''));
|
||||
self::assertEquals([], $email->getInboxAnswered());
|
||||
self::assertEquals([], $email->getInboxSubject(''));
|
||||
self::assertEquals([], $email->getInboxSince(new \DateTime('now')));
|
||||
self::assertEquals([], $email->getInboxUnseen());
|
||||
self::assertEquals([], $email->getInboxSeen());
|
||||
self::assertEquals([], $email->getInboxDeleted());
|
||||
self::assertEquals([], $email->getInboxText(''));
|
||||
self::assertEquals([], $email->getMessageOverview(1, 1));
|
||||
self::assertEquals(0, $email->countMessages());
|
||||
self::assertEquals('', $email->getMessageHeader(1));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,32 @@
|
|||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Utils\IO\Zip;
|
||||
namespace phpOMS\tests\Utils\IO\Gz;
|
||||
|
||||
use phpOMS\Utils\IO\Zip\Gz;
|
||||
|
||||
class GzTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testPlaceholder()
|
||||
public function testGz()
|
||||
{
|
||||
self::markTestIncomplete();
|
||||
self::assertTrue(Gz::pack(
|
||||
'test a.txt',
|
||||
__DIR__ . '/test.gz'
|
||||
));
|
||||
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test.gz'));
|
||||
|
||||
$a = \file_get_contents(__DIR__ . '/test a.txt');
|
||||
|
||||
\unlink(__DIR__ . '/test a.txt');
|
||||
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertTrue(Gz::unpack(__DIR__ . '/test.gz', __DIR__));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertEquals($a, \file_get_contents(__DIR__ . '/test a.txt'));
|
||||
|
||||
\unlink(__DIR__ . '/test.gz');
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test.gz'));
|
||||
self::assertFalse(Gz::unpack(__DIR__ . '/test.gz', __DIR__));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,83 @@
|
|||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Utils\IO\Zip;
|
||||
namespace phpOMS\tests\Utils\IO\TarGz;
|
||||
|
||||
use phpOMS\Utils\IO\Zip\TarGz;
|
||||
|
||||
class TarGzTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testPlaceholder()
|
||||
protected function setUp()
|
||||
{
|
||||
self::markTestIncomplete();
|
||||
if (!extension_loaded('phar')) {
|
||||
$this->markTestSkipped(
|
||||
'The Phar extension is not available.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testTarGz()
|
||||
{
|
||||
self::assertTrue(TarGz::pack(
|
||||
[
|
||||
__DIR__ . '/test a.txt' => 'test a.txt',
|
||||
__DIR__ . '/test b.md' => 'test b.md',
|
||||
__DIR__ . '/test' => 'test',
|
||||
],
|
||||
__DIR__ . '/test.tar.gz'
|
||||
));
|
||||
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test.tar.gz'));
|
||||
|
||||
self::assertFalse(TarGz::pack(
|
||||
[
|
||||
__DIR__ . '/test a.txt' => 'test a.txt',
|
||||
__DIR__ . '/test b.txt' => 'test b.txt',
|
||||
],
|
||||
__DIR__ . '/test.tar.gz',
|
||||
false
|
||||
));
|
||||
|
||||
$a = \file_get_contents(__DIR__ . '/test a.txt');
|
||||
$b = \file_get_contents(__DIR__ . '/test b.md');
|
||||
$c = \file_get_contents(__DIR__ . '/test/test c.txt');
|
||||
$d = \file_get_contents(__DIR__ . '/test/test d.txt');
|
||||
$e = \file_get_contents(__DIR__ . '/test/sub/test e.txt');
|
||||
|
||||
\unlink(__DIR__ . '/test a.txt');
|
||||
\unlink(__DIR__ . '/test b.md');
|
||||
\unlink(__DIR__ . '/test/test c.txt');
|
||||
\unlink(__DIR__ . '/test/test d.txt');
|
||||
\unlink(__DIR__ . '/test/sub/test e.txt');
|
||||
\rmdir(__DIR__ . '/test/sub');
|
||||
\rmdir(__DIR__ . '/test');
|
||||
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test'));
|
||||
|
||||
self::assertTrue(TarGz::unpack(__DIR__ . '/test.tar.gz', __DIR__));
|
||||
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test'));
|
||||
|
||||
self::assertEquals($a, \file_get_contents(__DIR__ . '/test a.txt'));
|
||||
self::assertEquals($b, \file_get_contents(__DIR__ . '/test b.md'));
|
||||
self::assertEquals($c, \file_get_contents(__DIR__ . '/test/test c.txt'));
|
||||
self::assertEquals($d, \file_get_contents(__DIR__ . '/test/test d.txt'));
|
||||
self::assertEquals($e, \file_get_contents(__DIR__ . '/test/sub/test e.txt'));
|
||||
|
||||
\unlink(__DIR__ . '/test.tar.gz');
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test.tar.gz'));
|
||||
self::assertFalse(TarGz::unpack(__DIR__ . '/test.tar.gz', __DIR__));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,14 +11,83 @@
|
|||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Utils\IO\Zip;
|
||||
namespace phpOMS\tests\Utils\IO\Tar;
|
||||
|
||||
use phpOMS\Utils\IO\Zip\Tar;
|
||||
|
||||
class TarTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testPlaceholder()
|
||||
protected function setUp()
|
||||
{
|
||||
self::markTestIncomplete();
|
||||
if (!extension_loaded('phar')) {
|
||||
$this->markTestSkipped(
|
||||
'The Phar extension is not available.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testTar()
|
||||
{
|
||||
self::assertTrue(Tar::pack(
|
||||
[
|
||||
__DIR__ . '/test a.txt' => 'test a.txt',
|
||||
__DIR__ . '/test b.md' => 'test b.md',
|
||||
__DIR__ . '/test' => 'test',
|
||||
],
|
||||
__DIR__ . '/test.tar'
|
||||
));
|
||||
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test.tar'));
|
||||
|
||||
self::assertFalse(Tar::pack(
|
||||
[
|
||||
__DIR__ . '/test a.txt' => 'test a.txt',
|
||||
__DIR__ . '/test b.txt' => 'test b.txt',
|
||||
],
|
||||
__DIR__ . '/test.tar',
|
||||
false
|
||||
));
|
||||
|
||||
$a = \file_get_contents(__DIR__ . '/test a.txt');
|
||||
$b = \file_get_contents(__DIR__ . '/test b.md');
|
||||
$c = \file_get_contents(__DIR__ . '/test/test c.txt');
|
||||
$d = \file_get_contents(__DIR__ . '/test/test d.txt');
|
||||
$e = \file_get_contents(__DIR__ . '/test/sub/test e.txt');
|
||||
|
||||
\unlink(__DIR__ . '/test a.txt');
|
||||
\unlink(__DIR__ . '/test b.md');
|
||||
\unlink(__DIR__ . '/test/test c.txt');
|
||||
\unlink(__DIR__ . '/test/test d.txt');
|
||||
\unlink(__DIR__ . '/test/sub/test e.txt');
|
||||
\rmdir(__DIR__ . '/test/sub');
|
||||
\rmdir(__DIR__ . '/test');
|
||||
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test'));
|
||||
|
||||
self::assertTrue(Tar::unpack(__DIR__ . '/test.tar', __DIR__));
|
||||
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test a.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test b.md'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/test c.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/test d.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/sub/test e.txt'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test/sub'));
|
||||
self::assertTrue(\file_exists(__DIR__ . '/test'));
|
||||
|
||||
self::assertEquals($a, \file_get_contents(__DIR__ . '/test a.txt'));
|
||||
self::assertEquals($b, \file_get_contents(__DIR__ . '/test b.md'));
|
||||
self::assertEquals($c, \file_get_contents(__DIR__ . '/test/test c.txt'));
|
||||
self::assertEquals($d, \file_get_contents(__DIR__ . '/test/test d.txt'));
|
||||
self::assertEquals($e, \file_get_contents(__DIR__ . '/test/sub/test e.txt'));
|
||||
|
||||
\unlink(__DIR__ . '/test.tar');
|
||||
self::assertFalse(\file_exists(__DIR__ . '/test.tar'));
|
||||
self::assertFalse(Tar::unpack(__DIR__ . '/test.tar', __DIR__));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Utils\JobQueue;
|
||||
|
||||
use phpOMS\Utils\JobQueue\JobQueue;
|
||||
|
||||
class JobQueueTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testPlaceholder()
|
||||
{
|
||||
self::markTestIncomplete();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.2
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Utils\JobQueue;
|
||||
|
||||
use phpOMS\Utils\JobQueue\Job;
|
||||
|
||||
class JobTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testPlaceholder()
|
||||
{
|
||||
self::markTestIncomplete();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user