diff --git a/Autoloader.php b/Autoloader.php index bf5814f02..445e7380c 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -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); diff --git a/System/OperatingSystem.php b/System/OperatingSystem.php index 063d317cd..98bd26635 100644 --- a/System/OperatingSystem.php +++ b/System/OperatingSystem.php @@ -43,4 +43,4 @@ final class OperatingSystem return SystemType::UNKNOWN; } -} \ No newline at end of file +} diff --git a/System/SystemType.php b/System/SystemType.php index 78f9304c3..dd18e822a 100644 --- a/System/SystemType.php +++ b/System/SystemType.php @@ -32,4 +32,4 @@ abstract class SystemType extends Enum /* public */ const WIN = 2; /* public */ const LINUX = 3; /* public */ const OSX = 4; -} \ No newline at end of file +} diff --git a/tests/Account/AccountManagerTest.php b/tests/Account/AccountManagerTest.php index 3f5a26049..71c43e2f6 100644 --- a/tests/Account/AccountManagerTest.php +++ b/tests/Account/AccountManagerTest.php @@ -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()); diff --git a/tests/Account/GroupTest.php b/tests/Account/GroupTest.php index 1e91018e9..dde22ef13 100644 --- a/tests/Account/GroupTest.php +++ b/tests/Account/GroupTest.php @@ -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 */ diff --git a/tests/Autoloader.php b/tests/Autoloader.php index 631685b2b..0b478ad50 100644 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -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); diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 5695e72ce..3b0892a21 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -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(); diff --git a/tests/DataStorage/Cache/NullCacheTest.php b/tests/DataStorage/Cache/NullCacheTest.php index f1e344ed8..096bf331e 100644 --- a/tests/DataStorage/Cache/NullCacheTest.php +++ b/tests/DataStorage/Cache/NullCacheTest.php @@ -29,4 +29,4 @@ class NullCacheTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $cache->stats()); self::assertEquals(0, $cache->getThreshold()); } -} \ No newline at end of file +} diff --git a/tests/DataStorage/Database/DataMapperAbstractTest.php b/tests/DataStorage/Database/DataMapperAbstractTest.php index 95d1fe249..452745211 100644 --- a/tests/DataStorage/Database/DataMapperAbstractTest.php +++ b/tests/DataStorage/Database/DataMapperAbstractTest.php @@ -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); diff --git a/tests/DataStorage/Database/Query/BuilderTest.php b/tests/DataStorage/Database/Query/BuilderTest.php index 7b0b46b68..3b652e5cf 100644 --- a/tests/DataStorage/Database/Query/BuilderTest.php +++ b/tests/DataStorage/Database/Query/BuilderTest.php @@ -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); diff --git a/tests/DataStorage/Database/TestModel/BaseModel.php b/tests/DataStorage/Database/TestModel/BaseModel.php index e5d1b2652..7d8890229 100644 --- a/tests/DataStorage/Database/TestModel/BaseModel.php +++ b/tests/DataStorage/Database/TestModel/BaseModel.php @@ -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]; } }; diff --git a/tests/Dispatcher/DispatcherTest.php b/tests/Dispatcher/DispatcherTest.php index fead2657e..d1e5490bb 100644 --- a/tests/Dispatcher/DispatcherTest.php +++ b/tests/Dispatcher/DispatcherTest.php @@ -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( diff --git a/tests/Dispatcher/TestController.php b/tests/Dispatcher/TestController.php index 4addf7c32..94efb91b2 100644 --- a/tests/Dispatcher/TestController.php +++ b/tests/Dispatcher/TestController.php @@ -23,4 +23,4 @@ class TestController { return true; } -} \ No newline at end of file +} diff --git a/tests/Localization/langTestFile.php b/tests/Localization/langTestFile.php index 09dd142bb..9100d2c8e 100644 --- a/tests/Localization/langTestFile.php +++ b/tests/Localization/langTestFile.php @@ -3,4 +3,4 @@ return ['Test' => [ 'key' => 'value' ] -]; \ No newline at end of file +]; diff --git a/tests/Math/Matrix/MatrixTest.php b/tests/Math/Matrix/MatrixTest.php index 9fa4aa82c..2658bc9b1 100644 --- a/tests/Math/Matrix/MatrixTest.php +++ b/tests/Math/Matrix/MatrixTest.php @@ -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() diff --git a/tests/Math/Statistic/AverageTest.php b/tests/Math/Statistic/AverageTest.php index 66a2c0885..0468cf9fe 100644 --- a/tests/Math/Statistic/AverageTest.php +++ b/tests/Math/Statistic/AverageTest.php @@ -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])); } } diff --git a/tests/Module/InfoManagerTest.php b/tests/Module/InfoManagerTest.php index c0e22c316..53d5e3c49 100644 --- a/tests/Module/InfoManagerTest.php +++ b/tests/Module/InfoManagerTest.php @@ -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); } diff --git a/tests/Module/ModuleAbstractTest.php b/tests/Module/ModuleAbstractTest.php index cec0b5beb..590d5135c 100644 --- a/tests/Module/ModuleAbstractTest.php +++ b/tests/Module/ModuleAbstractTest.php @@ -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); } -} \ No newline at end of file +} diff --git a/tests/Module/ModuleManagerTest.php b/tests/Module/ModuleManagerTest.php index bc66071fb..9e4848462 100644 --- a/tests/Module/ModuleManagerTest.php +++ b/tests/Module/ModuleManagerTest.php @@ -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'); diff --git a/tests/Router/routerTestFile.php b/tests/Router/routerTestFile.php index 565f6928a..3387f798d 100644 --- a/tests/Router/routerTestFile.php +++ b/tests/Router/routerTestFile.php @@ -6,4 +6,4 @@ return [ "verb" => 1, ] ] -]; \ No newline at end of file +]; diff --git a/tests/Stdlib/Base/EnumArrayDemo.php b/tests/Stdlib/Base/EnumArrayDemo.php new file mode 100644 index 000000000..5d37320b9 --- /dev/null +++ b/tests/Stdlib/Base/EnumArrayDemo.php @@ -0,0 +1,24 @@ + 1, + 'ENUM2' => 'abc', + ]; +} diff --git a/tests/Stdlib/Base/EnumArrayTest.php b/tests/Stdlib/Base/EnumArrayTest.php index 609df5967..0451601d4 100644 --- a/tests/Stdlib/Base/EnumArrayTest.php +++ b/tests/Stdlib/Base/EnumArrayTest.php @@ -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() diff --git a/tests/Stdlib/Base/EnumDemo.php b/tests/Stdlib/Base/EnumDemo.php new file mode 100644 index 000000000..7337ee59b --- /dev/null +++ b/tests/Stdlib/Base/EnumDemo.php @@ -0,0 +1,22 @@ +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')); diff --git a/tests/Utils/ArrayUtilsTest.php b/tests/Utils/ArrayUtilsTest.php index ef1db128a..d029f7a20 100644 --- a/tests/Utils/ArrayUtilsTest.php +++ b/tests/Utils/ArrayUtilsTest.php @@ -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)); diff --git a/tests/Utils/RnG/DateTimeTest.php b/tests/Utils/RnG/DateTimeTest.php index ec29f541b..b29fe3249 100644 --- a/tests/Utils/RnG/DateTimeTest.php +++ b/tests/Utils/RnG/DateTimeTest.php @@ -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); diff --git a/tests/Utils/TaskSchedule/TaskAbstractTest.php b/tests/Utils/TaskSchedule/TaskAbstractTest.php index 4980b01f3..0f83f80f5 100644 --- a/tests/Utils/TaskSchedule/TaskAbstractTest.php +++ b/tests/Utils/TaskSchedule/TaskAbstractTest.php @@ -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 + { + + } }; } diff --git a/tests/Utils/TestUtilsTest.php b/tests/Utils/TestUtilsTest.php index 49ba6571d..32b98026b 100644 --- a/tests/Utils/TestUtilsTest.php +++ b/tests/Utils/TestUtilsTest.php @@ -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));