Use global namespace+minor fixes

This commit is contained in:
Dennis Eichhorn 2019-02-04 22:30:05 +01:00
parent 60685547b6
commit 0d55e17842
36 changed files with 90 additions and 54 deletions

View File

@ -213,6 +213,9 @@ class Group implements ArrayableInterface, \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
/**
* {@inheritdoc}
*/
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();

View File

@ -89,6 +89,11 @@ class DataMapperAbstract implements DataMapperInterface
* *
* @var string[] * @var string[]
* @since 1.0.0 * @since 1.0.0
*/ /**
* Has many relation.
*
* @var array<string, array<string, string>>
* @since 1.0.0
*/ */
protected static $hasMany = []; protected static $hasMany = [];
@ -109,6 +114,11 @@ class DataMapperAbstract implements DataMapperInterface
* *
* @var string[] * @var string[]
* @since 1.0.0 * @since 1.0.0
*/ /**
* Belongs to.
*
* @var array<string, array<string, string>>
* @since 1.0.0
*/ */
protected static $belongsTo = []; protected static $belongsTo = [];

View File

@ -86,7 +86,7 @@ final class Money implements \Serializable
*/ */
public function __construct($value = 0, string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0) public function __construct($value = 0, string $thousands = ',', string $decimal = '.', string $symbol = '', int $position = 0)
{ {
$this->value = is_int($value) ? $value : self::toInt((string) $value); $this->value = \is_int($value) ? $value : self::toInt((string) $value);
$this->thousands = $thousands; $this->thousands = $thousands;
$this->decimal = $decimal; $this->decimal = $decimal;
$this->symbol = $symbol; $this->symbol = $symbol;
@ -273,7 +273,7 @@ final class Money implements \Serializable
*/ */
public function mult($value) : self public function mult($value) : self
{ {
if (\is_float($value) || is_int($value)) { if (\is_float($value) || \is_int($value)) {
$this->value = (int) ($this->value * $value); $this->value = (int) ($this->value * $value);
} }
@ -291,7 +291,7 @@ final class Money implements \Serializable
*/ */
public function div($value) : self public function div($value) : self
{ {
if (\is_float($value) || is_int($value)) { if (\is_float($value) || \is_int($value)) {
$this->value = (int) ($this->value / $value); $this->value = (int) ($this->value / $value);
} }
@ -323,7 +323,7 @@ final class Money implements \Serializable
*/ */
public function pow($value) : self public function pow($value) : self
{ {
if (\is_float($value) || is_int($value)) { if (\is_float($value) || \is_int($value)) {
$this->value = (int) ($this->value ** $value); $this->value = (int) ($this->value ** $value);
} }

View File

@ -402,7 +402,7 @@ class Matrix implements \ArrayAccess, \Iterator
{ {
if ($value instanceof self) { if ($value instanceof self) {
return $this->add($value->mult(-1)); return $this->add($value->mult(-1));
} elseif (!is_string($value) && is_numeric($value)) { } elseif (!\is_string($value) && is_numeric($value)) {
return $this->add(-$value); return $this->add(-$value);
} }
@ -424,7 +424,7 @@ class Matrix implements \ArrayAccess, \Iterator
{ {
if ($value instanceof self) { if ($value instanceof self) {
return $this->addMatrix($value); return $this->addMatrix($value);
} elseif (!is_string($value) && is_numeric($value)) { } elseif (!\is_string($value) && is_numeric($value)) {
return $this->addScalar($value); return $this->addScalar($value);
} }
@ -529,7 +529,7 @@ class Matrix implements \ArrayAccess, \Iterator
{ {
if ($value instanceof self) { if ($value instanceof self) {
return $this->multMatrix($value); return $this->multMatrix($value);
} elseif (!is_string($value) && is_numeric($value)) { } elseif (!\is_string($value) && is_numeric($value)) {
return $this->multScalar($value); return $this->multScalar($value);
} }

View File

@ -122,8 +122,6 @@ final class Request extends RequestAbstract
$this->header->getL11n()->setLanguage($this->loadRequestLanguage()); $this->header->getL11n()->setLanguage($this->loadRequestLanguage());
$this->initNonGetData(); $this->initNonGetData();
$this->uri = $this->uri ?? new Http(Http::getCurrent());
} }
/** /**
@ -483,7 +481,7 @@ final class Request extends RequestAbstract
if ($this->getMethod() === RequestMethod::GET && !empty($this->data)) { if ($this->getMethod() === RequestMethod::GET && !empty($this->data)) {
return $this->uri->__toString() return $this->uri->__toString()
. (\parse_url($this->uri->__toString(), PHP_URL_QUERY) ? '&' : '?') . (\parse_url($this->uri->__toString(), PHP_URL_QUERY) ? '&' : '?')
. http_build_query($this->data); . \http_build_query($this->data);
} }
return parent::__toString(); return parent::__toString();

View File

@ -67,7 +67,7 @@ abstract class ResponseAbstract implements MessageInterface, \JsonSerializable
*/ */
public function set($key, $response, bool $overwrite = true) : void public function set($key, $response, bool $overwrite = true) : void
{ {
// This is not working since the key kontains :: from http:// // This is not working since the key contains :: from http://
//$this->response = ArrayUtils::setArray((string) $key, $this->response, $response, ':', $overwrite); //$this->response = ArrayUtils::setArray((string) $key, $this->response, $response, ':', $overwrite);
$this->response[$key] = $response; $this->response[$key] = $response;
} }

View File

@ -74,6 +74,9 @@ class FormValidation implements \Serializable, ArrayableInterface, \JsonSerializ
* *
* @since 1.0.0 * @since 1.0.0
*/ */
/**
* {@inheritdoc}
*/
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();

View File

@ -178,6 +178,9 @@ class Notify implements \Serializable, ArrayableInterface, \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
/**
* {@inheritdoc}
*/
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();

View File

@ -120,6 +120,9 @@ class Redirect implements \Serializable, ArrayableInterface, \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
/**
* {@inheritdoc}
*/
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();

View File

@ -125,6 +125,9 @@ class Reload implements \Serializable, ArrayableInterface, \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
/**
* {@inheritdoc}
*/
public function jsonSerialize() public function jsonSerialize()
{ {
return $this->toArray(); return $this->toArray();

View File

@ -132,8 +132,8 @@ final class FileUtils
{ {
$content = \file_get_contents($file); $content = \file_get_contents($file);
if ($content !== false && preg_match('!!u', $content)) { if ($content !== false && \preg_match('!!u', $content)) {
\file_put_contents($file, \mb_convert_encoding($content, 'UTF-8', mb_list_encodings())); \file_put_contents($file, \mb_convert_encoding($content, 'UTF-8', \mb_list_encodings()));
} }
} }
} }

View File

@ -48,7 +48,7 @@ class FtpStorage extends StorageAbstract
protected static function getClassType(string $path) : string protected static function getClassType(string $path) : string
{ {
return \is_dir($path) || (!is_file($path) && \stripos($path, '.') === false) ? Directory::class : File::class; return \is_dir($path) || (!\is_file($path) && \stripos($path, '.') === false) ? Directory::class : File::class;
} }
/** /**

View File

@ -329,7 +329,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
*/ */
public static function copy(string $from, string $to, bool $overwrite = false) : bool public static function copy(string $from, string $to, bool $overwrite = false) : bool
{ {
if (!is_dir($from)) { if (!\is_dir($from)) {
throw new PathException($from); throw new PathException($from);
} }
@ -360,7 +360,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
*/ */
public static function move(string $from, string $to, bool $overwrite = false) : bool public static function move(string $from, string $to, bool $overwrite = false) : bool
{ {
if (!is_dir($from)) { if (!\is_dir($from)) {
throw new PathException($from); throw new PathException($from);
} }

View File

@ -343,7 +343,7 @@ final class File extends FileAbstract implements FileInterface
*/ */
public function getDirPath() : string public function getDirPath() : string
{ {
return dirname($this->path); return \dirname($this->path);
} }
/** /**
@ -364,7 +364,7 @@ final class File extends FileAbstract implements FileInterface
Directory::create(\dirname($path), 0755, true); Directory::create(\dirname($path), 0755, true);
} }
if (!is_writable(\dirname($path))) { if (!\is_writable(\dirname($path))) {
return false; return false;
} }

View File

@ -58,7 +58,7 @@ class LocalStorage extends StorageAbstract
*/ */
protected static function getClassType(string $path) : string protected static function getClassType(string $path) : string
{ {
return \is_dir($path) || (!is_file($path) && \stripos($path, '.') === false) ? Directory::class : File::class; return \is_dir($path) || (!\is_file($path) && \stripos($path, '.') === false) ? Directory::class : File::class;
} }
/** /**

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace phpOMS\Utils\Excel; namespace phpOMS\Utils\Excel;
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
require_once realpath(__DIR__ . '/../../../Resources/phpexcel/Classes/PHPExcel.php'); require_once \realpath(__DIR__ . '/../../../Resources/phpexcel/Classes/PHPExcel.php');
/** /**
* Excel class. * Excel class.

View File

@ -171,7 +171,7 @@ abstract class Json extends ValidatorAbstract
} }
} }
return count($completePaths) === 0; return \count($completePaths) === 0;
} }
/** /**

View File

@ -75,12 +75,12 @@ final class Validator extends ValidatorAbstract
*/ */
public static function isType($var, $constraint) : bool public static function isType($var, $constraint) : bool
{ {
if (!is_array($constraint)) { if (!\is_array($constraint)) {
$constraint = [$constraint]; $constraint = [$constraint];
} }
foreach ($constraint as $key => $value) { foreach ($constraint as $key => $value) {
if (!is_a($var, $value)) { if (!\is_a($var, $value)) {
return false; return false;
} }
} }

View File

@ -17,6 +17,9 @@ class FileCacheJsonSerializable implements \JsonSerializable
{ {
public $val = 'asdf'; public $val = 'asdf';
/**
* {@inheritdoc}
*/
public function jsonSerialize() public function jsonSerialize()
{ {
return 'abc'; return 'abc';

View File

@ -38,6 +38,12 @@ class BaseModelMapper extends DataMapperAbstract
'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'], 'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'],
]; ];
/**
* Belongs to.
*
* @var array<string, array<string, string>>
* @since 1.0.0
*/
protected static $belongsTo = [ protected static $belongsTo = [
'belongsToOne' => [ 'belongsToOne' => [
'mapper' => BelongsToModelMapper::class, 'mapper' => BelongsToModelMapper::class,
@ -50,8 +56,12 @@ class BaseModelMapper extends DataMapperAbstract
'mapper' => OwnsOneModelMapper::class, 'mapper' => OwnsOneModelMapper::class,
'dest' => 'test_base_owns_one_self', 'dest' => 'test_base_owns_one_self',
], ],
]; ]; /**
* Has many relation.
*
* @var array<string, array<string, string>>
* @since 1.0.0
*/
protected static $hasMany = [ protected static $hasMany = [
'hasManyDirect' => [ 'hasManyDirect' => [
'mapper' => ManyToManyDirectModelMapper::class, 'mapper' => ManyToManyDirectModelMapper::class,

View File

@ -26,7 +26,7 @@ class CityMapperTest extends \PHPUnit\Framework\TestCase
$con = new SqliteConnection([ $con = new SqliteConnection([
'prefix' => '', 'prefix' => '',
'db' => 'sqlite', 'db' => 'sqlite',
'database' => realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
]); ]);
DataMapperAbstract::setConnection($con); DataMapperAbstract::setConnection($con);

View File

@ -26,7 +26,7 @@ class CountryMapperTest extends \PHPUnit\Framework\TestCase
$con = new SqliteConnection([ $con = new SqliteConnection([
'prefix' => '', 'prefix' => '',
'db' => 'sqlite', 'db' => 'sqlite',
'database' => realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
]); ]);
DataMapperAbstract::setConnection($con); DataMapperAbstract::setConnection($con);

View File

@ -26,7 +26,7 @@ class CurrencyMapperTest extends \PHPUnit\Framework\TestCase
$con = new SqliteConnection([ $con = new SqliteConnection([
'prefix' => '', 'prefix' => '',
'db' => 'sqlite', 'db' => 'sqlite',
'database' => realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
]); ]);
DataMapperAbstract::setConnection($con); DataMapperAbstract::setConnection($con);

View File

@ -26,7 +26,7 @@ class IbanMapperTest extends \PHPUnit\Framework\TestCase
$con = new SqliteConnection([ $con = new SqliteConnection([
'prefix' => '', 'prefix' => '',
'db' => 'sqlite', 'db' => 'sqlite',
'database' => realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
]); ]);
DataMapperAbstract::setConnection($con); DataMapperAbstract::setConnection($con);

View File

@ -26,7 +26,7 @@ class LanguageMapperTest extends \PHPUnit\Framework\TestCase
$con = new SqliteConnection([ $con = new SqliteConnection([
'prefix' => '', 'prefix' => '',
'db' => 'sqlite', 'db' => 'sqlite',
'database' => realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'), 'database' => \realpath(__DIR__ . '/../../../Localization/Defaults/localization.sqlite'),
]); ]);
DataMapperAbstract::setConnection($con); DataMapperAbstract::setConnection($con);

View File

@ -24,7 +24,7 @@ class InfoManagerTest extends \PHPUnit\Framework\TestCase
$info = new InfoManager(__DIR__ . '/info-test.json'); $info = new InfoManager(__DIR__ . '/info-test.json');
$info->load(); $info->load();
$jarray = \json_decode(file_get_contents(__DIR__ . '/info-test.json'), true); $jarray = \json_decode(\file_get_contents(__DIR__ . '/info-test.json'), true);
self::assertEquals($jarray, $info->get()); self::assertEquals($jarray, $info->get());
self::assertEquals($jarray['name']['id'], $info->getId()); self::assertEquals($jarray['name']['id'], $info->getId());

View File

@ -23,17 +23,17 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
{ {
public static function setUpBeforeClass() : void public static function setUpBeforeClass() : void
{ {
if (file_exists(__DIR__ . '/testPackage.zip')) { if (\file_exists(__DIR__ . '/testPackage.zip')) {
unlink(__DIR__ . '/testPackage.zip'); unlink(__DIR__ . '/testPackage.zip');
} }
if (file_exists(__DIR__ . '/testPackageExtracted')) { if (\file_exists(__DIR__ . '/testPackageExtracted')) {
\array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/testSubPackage/*')); \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/testSubPackage/*'));
\rmdir(__DIR__ . '/testPackageExtracted/testSubPackage'); \rmdir(__DIR__ . '/testPackageExtracted/testSubPackage');
\array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/*')); \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/*'));
} }
if (file_exists(__DIR__ . '/public.key')) { if (\file_exists(__DIR__ . '/public.key')) {
unlink(__DIR__ . '/public.key'); unlink(__DIR__ . '/public.key');
} }
@ -126,24 +126,24 @@ class PackageManagerTest extends \PHPUnit\Framework\TestCase
$package->extract(__DIR__ . '/testPackageExtracted'); $package->extract(__DIR__ . '/testPackageExtracted');
$package->cleanup(); $package->cleanup();
self::assertFalse(file_exists(__DIR__ . '/testPackage.zip')); self::assertFalse(\file_exists(__DIR__ . '/testPackage.zip'));
self::assertFalse(file_exists(__DIR__ . '/testPackageExtracted')); self::assertFalse(\file_exists(__DIR__ . '/testPackageExtracted'));
} }
public static function tearDownAfterClass() : void public static function tearDownAfterClass() : void
{ {
if (file_exists(__DIR__ . '/testPackage.zip')) { if (\file_exists(__DIR__ . '/testPackage.zip')) {
unlink(__DIR__ . '/testPackage.zip'); unlink(__DIR__ . '/testPackage.zip');
} }
if (file_exists(__DIR__ . '/testPackageExtracted')) { if (\file_exists(__DIR__ . '/testPackageExtracted')) {
\array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/testSubPackage/*')); \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/testSubPackage/*'));
\rmdir(__DIR__ . '/testPackageExtracted/testSubPackage'); \rmdir(__DIR__ . '/testPackageExtracted/testSubPackage');
\array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/*')); \array_map('unlink', \glob(__DIR__ . '/testPackageExtracted/*'));
\rmdir(__DIR__ . '/testPackageExtracted'); \rmdir(__DIR__ . '/testPackageExtracted');
} }
if (file_exists(__DIR__ . '/public.key')) { if (\file_exists(__DIR__ . '/public.key')) {
unlink(__DIR__ . '/public.key'); unlink(__DIR__ . '/public.key');
} }

View File

@ -38,7 +38,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
self::assertEquals('test', Directory::name($dirPath)); self::assertEquals('test', Directory::name($dirPath));
self::assertEquals('test', Directory::basename($dirPath)); self::assertEquals('test', Directory::basename($dirPath));
self::assertEquals('test', Directory::dirname($dirPath)); self::assertEquals('test', Directory::dirname($dirPath));
self::assertEquals(\str_replace('\\', '/', realpath($dirPath . '/../')), Directory::parent($dirPath)); self::assertEquals(\str_replace('\\', '/', \realpath($dirPath . '/../')), Directory::parent($dirPath));
self::assertEquals($dirPath, Directory::dirpath($dirPath)); self::assertEquals($dirPath, Directory::dirpath($dirPath));
$now = new \DateTime('now'); $now = new \DateTime('now');

View File

@ -44,7 +44,7 @@ class FileTest extends \PHPUnit\Framework\TestCase
self::assertTrue(File::prepend($testFile, 'test5')); self::assertTrue(File::prepend($testFile, 'test5'));
self::assertEquals('test5test3test4', File::get($testFile)); self::assertEquals('test5test3test4', File::get($testFile));
self::assertEquals(\str_replace('\\', '/', realpath(\dirname($testFile) . '/../')), File::parent($testFile)); self::assertEquals(\str_replace('\\', '/', \realpath(\dirname($testFile) . '/../')), File::parent($testFile));
self::assertEquals('txt', File::extension($testFile)); self::assertEquals('txt', File::extension($testFile));
self::assertEquals('test', File::name($testFile)); self::assertEquals('test', File::name($testFile));
self::assertEquals('test.txt', File::basename($testFile)); self::assertEquals('test.txt', File::basename($testFile));

View File

@ -44,7 +44,7 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase
self::assertTrue(FtpStorage::prepend($testFile, 'test5')); self::assertTrue(FtpStorage::prepend($testFile, 'test5'));
self::assertEquals('test5test3test4', FtpStorage::get($testFile)); self::assertEquals('test5test3test4', FtpStorage::get($testFile));
self::assertEquals(\str_replace('\\', '/', realpath(\dirname($testFile) . '/../')), FtpStorage::parent($testFile)); self::assertEquals(\str_replace('\\', '/', \realpath(\dirname($testFile) . '/../')), FtpStorage::parent($testFile));
self::assertEquals('txt', FtpStorage::extension($testFile)); self::assertEquals('txt', FtpStorage::extension($testFile));
self::assertEquals('test', FtpStorage::name($testFile)); self::assertEquals('test', FtpStorage::name($testFile));
self::assertEquals('test.txt', FtpStorage::basename($testFile)); self::assertEquals('test.txt', FtpStorage::basename($testFile));
@ -103,7 +103,7 @@ class FtpStorageTest extends \PHPUnit\Framework\TestCase
self::assertEquals('test', FtpStorage::name($dirPath)); self::assertEquals('test', FtpStorage::name($dirPath));
self::assertEquals('test', FtpStorage::basename($dirPath)); self::assertEquals('test', FtpStorage::basename($dirPath));
self::assertEquals('test', FtpStorage::dirname($dirPath)); self::assertEquals('test', FtpStorage::dirname($dirPath));
self::assertEquals(\str_replace('\\', '/', realpath($dirPath . '/../')), FtpStorage::parent($dirPath)); self::assertEquals(\str_replace('\\', '/', \realpath($dirPath . '/../')), FtpStorage::parent($dirPath));
self::assertEquals($dirPath, FtpStorage::dirpath($dirPath)); self::assertEquals($dirPath, FtpStorage::dirpath($dirPath));
$now = new \DateTime('now'); $now = new \DateTime('now');

View File

@ -30,7 +30,7 @@ class DirectoryTest extends \PHPUnit\Framework\TestCase
self::assertEquals('test', Directory::name($dirPath)); self::assertEquals('test', Directory::name($dirPath));
self::assertEquals('test', Directory::basename($dirPath)); self::assertEquals('test', Directory::basename($dirPath));
self::assertEquals('test', Directory::dirname($dirPath)); self::assertEquals('test', Directory::dirname($dirPath));
self::assertEquals(\str_replace('\\', '/', realpath($dirPath . '/../')), Directory::parent($dirPath)); self::assertEquals(\str_replace('\\', '/', \realpath($dirPath . '/../')), Directory::parent($dirPath));
self::assertEquals($dirPath, Directory::dirpath($dirPath)); self::assertEquals($dirPath, Directory::dirpath($dirPath));
$now = new \DateTime('now'); $now = new \DateTime('now');

View File

@ -36,7 +36,7 @@ class FileTest extends \PHPUnit\Framework\TestCase
self::assertTrue(File::prepend($testFile, 'test5')); self::assertTrue(File::prepend($testFile, 'test5'));
self::assertEquals('test5test3test4', File::get($testFile)); self::assertEquals('test5test3test4', File::get($testFile));
self::assertEquals(\str_replace('\\', '/', realpath(\dirname($testFile) . '/../')), File::parent($testFile)); self::assertEquals(\str_replace('\\', '/', \realpath(\dirname($testFile) . '/../')), File::parent($testFile));
self::assertEquals('txt', File::extension($testFile)); self::assertEquals('txt', File::extension($testFile));
self::assertEquals('test', File::name($testFile)); self::assertEquals('test', File::name($testFile));
self::assertEquals('test.txt', File::basename($testFile)); self::assertEquals('test.txt', File::basename($testFile));

View File

@ -36,7 +36,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase
self::assertTrue(LocalStorage::prepend($testFile, 'test5')); self::assertTrue(LocalStorage::prepend($testFile, 'test5'));
self::assertEquals('test5test3test4', LocalStorage::get($testFile)); self::assertEquals('test5test3test4', LocalStorage::get($testFile));
self::assertEquals(\str_replace('\\', '/', realpath(\dirname($testFile) . '/../')), LocalStorage::parent($testFile)); self::assertEquals(\str_replace('\\', '/', \realpath(\dirname($testFile) . '/../')), LocalStorage::parent($testFile));
self::assertEquals('txt', LocalStorage::extension($testFile)); self::assertEquals('txt', LocalStorage::extension($testFile));
self::assertEquals('test', LocalStorage::name($testFile)); self::assertEquals('test', LocalStorage::name($testFile));
self::assertEquals('test.txt', LocalStorage::basename($testFile)); self::assertEquals('test.txt', LocalStorage::basename($testFile));
@ -91,7 +91,7 @@ class LocalStorageTest extends \PHPUnit\Framework\TestCase
self::assertEquals('test', LocalStorage::name($dirPath)); self::assertEquals('test', LocalStorage::name($dirPath));
self::assertEquals('test', LocalStorage::basename($dirPath)); self::assertEquals('test', LocalStorage::basename($dirPath));
self::assertEquals('test', LocalStorage::dirname($dirPath)); self::assertEquals('test', LocalStorage::dirname($dirPath));
self::assertEquals(\str_replace('\\', '/', realpath($dirPath . '/../')), LocalStorage::parent($dirPath)); self::assertEquals(\str_replace('\\', '/', \realpath($dirPath . '/../')), LocalStorage::parent($dirPath));
self::assertEquals($dirPath, LocalStorage::dirpath($dirPath)); self::assertEquals($dirPath, LocalStorage::dirpath($dirPath));
$now = new \DateTime('now'); $now = new \DateTime('now');

View File

@ -21,7 +21,7 @@ class RepositoryTest extends \PHPUnit\Framework\TestCase
{ {
$repo = new Repository(\realpath(__DIR__ . '/../../../')); $repo = new Repository(\realpath(__DIR__ . '/../../../'));
self::assertTrue('phpOMS' === $repo->getName() || 'build' === $repo->getName()); self::assertTrue('phpOMS' === $repo->getName() || 'build' === $repo->getName());
self::assertEquals(\str_replace('\\', '/', realpath(__DIR__ . '/../../../.git')), \str_replace('\\', '/', $repo->getDirectoryPath())); self::assertEquals(\str_replace('\\', '/', \realpath(__DIR__ . '/../../../.git')), \str_replace('\\', '/', $repo->getDirectoryPath()));
self::assertEquals(\realpath(__DIR__ . '/../../../'), $repo->getPath()); self::assertEquals(\realpath(__DIR__ . '/../../../'), $repo->getPath());
} }
} }

View File

@ -28,7 +28,7 @@ class MarkdownTest extends \PHPUnit\Framework\TestCase
if ($data[1] === 'md') { if ($data[1] === 'md') {
self::assertEquals( self::assertEquals(
\file_get_contents(__DIR__ . '/data/' . $data[0] . '.html'), \file_get_contents(__DIR__ . '/data/' . $data[0] . '.html'),
Markdown::parse(file_get_contents(__DIR__ . '/data/' . $data[0] . '.md')), Markdown::parse(\file_get_contents(__DIR__ . '/data/' . $data[0] . '.md')),
$file $file
); );
} }

View File

@ -19,20 +19,20 @@ class JsonTest extends \PHPUnit\Framework\TestCase
{ {
public function testJson() : void public function testJson() : void
{ {
$template = \json_decode(file_get_contents(__DIR__ . '/json/template.json'), true); $template = \json_decode(\file_get_contents(__DIR__ . '/json/template.json'), true);
$valid = \json_decode(file_get_contents(__DIR__ . '/json/valid.json'), true); $valid = \json_decode(\file_get_contents(__DIR__ . '/json/valid.json'), true);
self::assertTrue(Json::validateTemplate($template, $valid)); self::assertTrue(Json::validateTemplate($template, $valid));
self::assertTrue(Json::validateTemplate($template, $valid, true)); self::assertTrue(Json::validateTemplate($template, $valid, true));
$additional = \json_decode(file_get_contents(__DIR__ . '/json/additional.json'), true); $additional = \json_decode(\file_get_contents(__DIR__ . '/json/additional.json'), true);
self::assertTrue(Json::validateTemplate($template, $additional)); self::assertTrue(Json::validateTemplate($template, $additional));
self::assertFalse(Json::validateTemplate($template, $additional, true)); self::assertFalse(Json::validateTemplate($template, $additional, true));
$incomplete = \json_decode(file_get_contents(__DIR__ . '/json/incomplete.json'), true); $incomplete = \json_decode(\file_get_contents(__DIR__ . '/json/incomplete.json'), true);
self::assertFalse(Json::validateTemplate($template, $incomplete)); self::assertFalse(Json::validateTemplate($template, $incomplete));
$invalid = \json_decode(file_get_contents(__DIR__ . '/json/invalid.json'), true); $invalid = \json_decode(\file_get_contents(__DIR__ . '/json/invalid.json'), true);
self::assertFalse(Json::validateTemplate($template, $invalid)); self::assertFalse(Json::validateTemplate($template, $invalid));
} }
} }