mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Further php cs fixes
This commit is contained in:
parent
c2c9767470
commit
51cd98b1a7
|
|
@ -14,7 +14,7 @@ declare(strict_types = 1);
|
|||
|
||||
namespace phpOMS;
|
||||
|
||||
spl_autoload_register('\phpOMS\Autoloader::default_autoloader');
|
||||
spl_autoload_register('\phpOMS\Autoloader::defaultAutoloader');
|
||||
|
||||
/**
|
||||
* Autoloader class.
|
||||
|
|
@ -32,7 +32,7 @@ class Autoloader
|
|||
*
|
||||
* @param string $class Class path
|
||||
*
|
||||
* @example Autoloader::default_autoloader('\phpOMS\Autoloader') // void
|
||||
* @example Autoloader::defaultAutoloader('\phpOMS\Autoloader') // void
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -40,7 +40,7 @@ class Autoloader
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function default_autoloader(string $class) /* : void */
|
||||
public static function defaultAutoloader(string $class) /* : void */
|
||||
{
|
||||
$class = ltrim($class, '\\');
|
||||
$class = str_replace(['_', '\\'], '/', $class);
|
||||
|
|
|
|||
|
|
@ -43,4 +43,4 @@ final class OperatingSystem
|
|||
|
||||
return SystemType::UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,4 @@ abstract class SystemType extends Enum
|
|||
/* public */ const WIN = 2;
|
||||
/* public */ const LINUX = 3;
|
||||
/* public */ const OSX = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
class AccountManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testAttributes() {
|
||||
public function testAttributes()
|
||||
{
|
||||
$manager = new AccountManager($GLOBALS['httpSession']);
|
||||
self::assertInstanceOf('\phpOMS\Account\AccountManager', $manager);
|
||||
|
||||
|
|
@ -32,7 +33,8 @@ class AccountManagerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertObjectHasAttribute('accounts', $manager);
|
||||
}
|
||||
|
||||
public function testDefault() {
|
||||
public function testDefault()
|
||||
{
|
||||
$manager = new AccountManager($GLOBALS['httpSession']);
|
||||
|
||||
self::assertEquals(0, $manager->count());
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ require_once __DIR__ . '/../Autoloader.php';
|
|||
|
||||
class GroupTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testAttributes() {
|
||||
public function testAttributes()
|
||||
{
|
||||
$group = new Group();
|
||||
self::assertInstanceOf('\phpOMS\Account\Group', $group);
|
||||
|
||||
|
|
@ -34,7 +35,8 @@ class GroupTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertObjectHasAttribute('status', $group);
|
||||
}
|
||||
|
||||
public function testDefault() {
|
||||
public function testDefault()
|
||||
{
|
||||
$group = new Group();
|
||||
|
||||
/* Testing default values */
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types = 1);
|
|||
|
||||
namespace Tests\PHPUnit;
|
||||
|
||||
spl_autoload_register('\Tests\PHPUnit\Autoloader::default_autoloader');
|
||||
spl_autoload_register('\Tests\PHPUnit\Autoloader::defaultAutoloader');
|
||||
|
||||
/**
|
||||
* Autoloader class.
|
||||
|
|
@ -32,7 +32,7 @@ class Autoloader
|
|||
*
|
||||
* @param string $class Class path
|
||||
*
|
||||
* @example Autoloader::default_autoloader('\Tests\PHPUnit\Autoloader') // void
|
||||
* @example Autoloader::defaultAutoloader('\Tests\PHPUnit\Autoloader') // void
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -40,7 +40,7 @@ class Autoloader
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function default_autoloader(string $class) /* : void */
|
||||
public static function defaultAutoloader(string $class) /* : void */
|
||||
{
|
||||
$class = ltrim($class, '\\');
|
||||
$class = str_replace(['_', '\\'], '/', $class);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ $db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin'
|
|||
$db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
|
||||
$db = null;
|
||||
|
||||
$httpSession = new HttpSession();
|
||||
$httpSession = new HttpSession();
|
||||
$GLOBALS['session'] = $httpSession;
|
||||
|
||||
$GLOBALS['dbpool'] = new DatabasePool();
|
||||
|
|
|
|||
|
|
@ -29,4 +29,4 @@ class NullCacheTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals([], $cache->stats());
|
||||
self::assertEquals(0, $cache->getThreshold());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testRead()
|
||||
{
|
||||
$id = BaseModelMapper::create($this->model);
|
||||
$id = BaseModelMapper::create($this->model);
|
||||
$modelR = BaseModelMapper::get($id);
|
||||
|
||||
self::assertEquals($this->model->id, $modelR->id);
|
||||
|
|
@ -132,17 +132,17 @@ class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testUpdate()
|
||||
{
|
||||
$id = BaseModelMapper::create($this->model);
|
||||
$id = BaseModelMapper::create($this->model);
|
||||
$modelR = BaseModelMapper::get($id);
|
||||
|
||||
$modelR->string = 'Update';
|
||||
$modelR->int = '321';
|
||||
$modelR->bool = true;
|
||||
$modelR->float = 3.15;
|
||||
$modelR->null = null;
|
||||
$modelR->string = 'Update';
|
||||
$modelR->int = '321';
|
||||
$modelR->bool = true;
|
||||
$modelR->float = 3.15;
|
||||
$modelR->null = null;
|
||||
$modelR->datetime = new \DateTime('now');
|
||||
|
||||
$id2 = BaseModelMapper::update($modelR);
|
||||
$id2 = BaseModelMapper::update($modelR);
|
||||
$modelR2 = BaseModelMapper::get($id2);
|
||||
|
||||
self::assertEquals($modelR->string, $modelR2->string);
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ class BuilderTest extends \PHPUnit\Framework\TestCase
|
|||
$sql = 'SELECT `a`.`test`, `b`.`test` FROM `a`, `b` WHERE `a`.`test` = \'abc\';';
|
||||
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', 'abc')->toSql());
|
||||
|
||||
$query = new Builder($this->con);
|
||||
$query = new Builder($this->con);
|
||||
$datetime = new \Datetime('now');
|
||||
$sql = 'SELECT `a`.`test`, `b`.`test` FROM `a`, `b` WHERE `a`.`test` = \'' . $datetime->format('Y-m-d H:i:s') . '\';';
|
||||
$sql = 'SELECT `a`.`test`, `b`.`test` FROM `a`, `b` WHERE `a`.`test` = \'' . $datetime->format('Y-m-d H:i:s') . '\';';
|
||||
self::assertEquals($sql, $query->select('a.test', 'b.test')->from('a', 'b')->where('a.test', '=', $datetime)->toSql());
|
||||
|
||||
$query = new Builder($this->con);
|
||||
|
|
|
|||
|
|
@ -57,19 +57,24 @@ class BaseModel
|
|||
new ManyToManyRelModel(),
|
||||
];
|
||||
|
||||
$this->ownsOneSelf = new OwnsOneModel();
|
||||
$this->ownsOneSelf = new OwnsOneModel();
|
||||
$this->belongsToOne = new BelongsToModel();
|
||||
|
||||
$this->serializable = new class implements \Serializable {
|
||||
public function serialize() {
|
||||
public function serialize()
|
||||
{
|
||||
return '123';
|
||||
}
|
||||
|
||||
public function unserialize($data) {}
|
||||
public function unserialize($data)
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$this->jsonSerializable = new class implements \JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [1, 2, 3];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->app = new class extends ApplicationAbstract {};
|
||||
$this->app->router = new Router();
|
||||
$this->app = new class extends ApplicationAbstract {};
|
||||
$this->app->router = new Router();
|
||||
$this->app->dispatcher = new Dispatcher($this->app);
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testClosure()
|
||||
{
|
||||
$l11nManager = new L11nManager();
|
||||
$l11nManager = new L11nManager();
|
||||
$localization = new Localization($l11nManager);
|
||||
|
||||
self::assertTrue(
|
||||
|
|
@ -60,7 +60,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testPathMethod()
|
||||
{
|
||||
$l11nManager = new L11nManager();
|
||||
$l11nManager = new L11nManager();
|
||||
$localization = new Localization($l11nManager);
|
||||
|
||||
self::assertTrue(
|
||||
|
|
@ -76,7 +76,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testPathStatic()
|
||||
{
|
||||
$l11nManager = new L11nManager();
|
||||
$l11nManager = new L11nManager();
|
||||
$localization = new Localization($l11nManager);
|
||||
|
||||
self::assertTrue(
|
||||
|
|
@ -92,7 +92,7 @@ class DispatcherTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testArray()
|
||||
{
|
||||
$l11nManager = new L11nManager();
|
||||
$l11nManager = new L11nManager();
|
||||
$localization = new Localization($l11nManager);
|
||||
|
||||
self::assertTrue(
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ class TestController
|
|||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
return ['Test' => [
|
||||
'key' => 'value'
|
||||
]
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -57,14 +57,14 @@ class MatrixTest extends \PHPUnit\Framework\TestCase
|
|||
$A = new Matrix();
|
||||
$A->setMatrix([[1, 2], [3, 4]]);
|
||||
|
||||
self::assertEquals([[1-2, 2-2], [3-2, 4-2]], $A->sub(2)->toArray());
|
||||
self::assertEquals([[1+2, 2+2], [3+2, 4+2]], $A->add(2)->toArray());
|
||||
self::assertEquals([[1 - 2, 2 - 2], [3 - 2, 4 - 2]], $A->sub(2)->toArray());
|
||||
self::assertEquals([[1 + 2, 2 + 2], [3 + 2, 4 + 2]], $A->add(2)->toArray());
|
||||
|
||||
$B = new Matrix();
|
||||
$B->setMatrix([[1, 2], [3, 4]]);
|
||||
|
||||
self::assertEquals([[1-1, 2-2], [3-3, 4-4]], $A->sub($B)->toArray());
|
||||
self::assertEquals([[1+1, 2+2], [3+3, 4+4]], $A->add($B)->toArray());
|
||||
self::assertEquals([[1 - 1, 2 - 2], [3 - 3, 4 - 4]], $A->sub($B)->toArray());
|
||||
self::assertEquals([[1 + 1, 2 + 2], [3 + 3, 4 + 4]], $A->add($B)->toArray());
|
||||
}
|
||||
|
||||
public function testDet()
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ class AverageTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
public function testAverage()
|
||||
{
|
||||
self::assertEquals(-3/2, Average::averageDatasetChange([6, 7, 6, 3, 0]));
|
||||
self::assertEquals(-3 / 2, Average::averageDatasetChange([6, 7, 6, 3, 0]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,14 @@ class InfoManagerTest extends \PHPUnit\Framework\TestCase
|
|||
$info = new InfoManager(__Dir__ . '/info-test.json');
|
||||
$info->load();
|
||||
|
||||
$testObj = new class { public $test = 1; public function test() { echo $this->test; }};
|
||||
$testObj = new class {
|
||||
public $test = 1;
|
||||
|
||||
public function test()
|
||||
{
|
||||
echo $this->test;
|
||||
}
|
||||
};
|
||||
|
||||
$info->set('/name/internal', $testObj);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
public function testModuleAbstract()
|
||||
{
|
||||
$moduleClass = new class(null) extends ModuleAbstract {
|
||||
const MODULE_VERSION = '1.2.3';
|
||||
const MODULE_NAME = 'Test';
|
||||
const MODULE_ID = 2;
|
||||
const MODULE_VERSION = '1.2.3';
|
||||
const MODULE_NAME = 'Test';
|
||||
const MODULE_ID = 2;
|
||||
protected static $dependencies = [1, 2];
|
||||
};
|
||||
|
||||
|
|
@ -32,4 +32,4 @@ class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(2, $moduleClass::MODULE_ID);
|
||||
self::assertEquals('1.2.3', $moduleClass::MODULE_VERSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->app = new class extends ApplicationAbstract {};
|
||||
$this->app->dbPool = $GLOBALS['dbpool'];
|
||||
$this->app = new class extends ApplicationAbstract {};
|
||||
$this->app->dbPool = $GLOBALS['dbpool'];
|
||||
$this->app->dispatcher = new Dispatcher($this->app);
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ class ModuleManagerTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testGetSet()
|
||||
{
|
||||
$this->app->router = new Router();
|
||||
$this->app->router = new Router();
|
||||
$this->app->dispatcher = new Dispatcher($this->app);
|
||||
|
||||
$moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules');
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ return [
|
|||
"verb" => 1,
|
||||
]
|
||||
]
|
||||
];
|
||||
];
|
||||
|
|
|
|||
24
tests/Stdlib/Base/EnumArrayDemo.php
Normal file
24
tests/Stdlib/Base/EnumArrayDemo.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @package TBD
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Stdlib\Base;
|
||||
|
||||
use phpOMS\Stdlib\Base\EnumArray;
|
||||
|
||||
final class EnumArrayDemo extends EnumArray
|
||||
{
|
||||
protected static $constants = [
|
||||
'ENUM1' => 1,
|
||||
'ENUM2' => 'abc',
|
||||
];
|
||||
}
|
||||
|
|
@ -15,16 +15,6 @@ namespace phpOMS\tests\Stdlib\Base;
|
|||
|
||||
use phpOMS\Stdlib\Base\EnumArray;
|
||||
|
||||
final class EnumArrayDemo extends EnumArray
|
||||
{
|
||||
protected static $constants = [
|
||||
'ENUM1' => 1,
|
||||
'ENUM2' => 'abc',
|
||||
];
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
class EnumArrayTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetSet()
|
||||
|
|
|
|||
22
tests/Stdlib/Base/EnumDemo.php
Normal file
22
tests/Stdlib/Base/EnumDemo.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @package TBD
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://website.orange-management.de
|
||||
*/
|
||||
|
||||
namespace phpOMS\tests\Stdlib\Base;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
final class EnumDemo extends Enum
|
||||
{
|
||||
const ENUM1 = 1;
|
||||
const ENUM2 = ';l';
|
||||
}
|
||||
|
|
@ -15,12 +15,6 @@ namespace phpOMS\tests\Stdlib\Base;
|
|||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
final class EnumDemo extends Enum
|
||||
{
|
||||
const ENUM1 = 1;
|
||||
const ENUM2 = ';l';
|
||||
};
|
||||
|
||||
class EnumTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetSet()
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class SmartDateTimeTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(0, $datetime->getFirstDayOfMonth());
|
||||
|
||||
$expected = new \DateTime('now');
|
||||
$obj = SmartDateTime::createFromDateTime($expected);
|
||||
$obj = SmartDateTime::createFromDateTime($expected);
|
||||
self::assertEquals($expected->format('Y-m-d H:i:s'), $obj->format('Y-m-d H:i:s'));
|
||||
self::assertEquals(date("Y-m-t", strtotime($expected->format('Y-m-d'))), $obj->getEndOfMonth()->format('Y-m-d'));
|
||||
self::assertEquals(date("Y-m-01", strtotime($expected->format('Y-m-d'))), $obj->getStartOfMonth()->format('Y-m-d'));
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class ArrayUtilsTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function testArrayRecursiveManipulation()
|
||||
{
|
||||
$numArr = [1, 2, 3, 4];
|
||||
$numArr = [1, 2, 3, 4];
|
||||
$numArrRec = [1, [2, [3, 4]]];
|
||||
self::assertEquals(10, ArrayUtils::arraySumRecursive($numArrRec));
|
||||
self::assertEquals($numArr, ArrayUtils::arrayFlatten($numArrRec));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class DateTimeTest extends \PHPUnit\Framework\TestCase
|
|||
$dateMin = new \DateTime();
|
||||
$dateMax = new \DateTime();
|
||||
|
||||
$min = mt_rand(0, PHP_INT_MAX-2);
|
||||
$min = mt_rand(0, PHP_INT_MAX - 2);
|
||||
$max = mt_rand($min + 1, PHP_INT_MAX);
|
||||
|
||||
$dateMin->setTimestamp($min);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,10 @@ class TaskAbstractTest extends \PHPUnit\Framework\TestCase
|
|||
protected function setUp()
|
||||
{
|
||||
$this->class = new class('') extends TaskAbstract {
|
||||
public static function createWith(array $jobData) : TaskAbstract {}
|
||||
public static function createWith(array $jobData) : TaskAbstract
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ class TestUtilsTest extends \PHPUnit\Framework\TestCase
|
|||
public function testGet()
|
||||
{
|
||||
$class = new class {
|
||||
private $a = 1;
|
||||
private $a = 1;
|
||||
protected $b = 2;
|
||||
public $c = 3;
|
||||
public $c = 3;
|
||||
};
|
||||
|
||||
self::assertEquals(1, TestUtils::getMember($class, 'a'));
|
||||
|
|
@ -37,9 +37,9 @@ class TestUtilsTest extends \PHPUnit\Framework\TestCase
|
|||
public function testSet()
|
||||
{
|
||||
$class = new class {
|
||||
private $a = 1;
|
||||
private $a = 1;
|
||||
protected $b = 2;
|
||||
public $c = 3;
|
||||
public $c = 3;
|
||||
};
|
||||
|
||||
self::assertTrue(TestUtils::setMember($class, 'a', 4));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user