mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 07:18:39 +00:00
Make tests part of the repos
This commit is contained in:
parent
0e3288748b
commit
3245dbd1bc
64
tests/Account/AccountManagerTest.php
Normal file
64
tests/Account/AccountManagerTest.php
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
use phpOMS\Account\Account;
|
||||||
|
use phpOMS\Account\AccountManager;
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
|
use phpOMS\DataStorage\Session\HttpSession;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class AccountManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testAttributes() {
|
||||||
|
$manager = new AccountManager($GLOBALS['httpSession']);
|
||||||
|
self::assertInstanceOf('\phpOMS\Account\AccountManager', $manager);
|
||||||
|
|
||||||
|
/* Testing members */
|
||||||
|
self::assertObjectHasAttribute('accounts', $manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDefault() {
|
||||||
|
$manager = new AccountManager($GLOBALS['httpSession']);
|
||||||
|
|
||||||
|
self::assertEquals(0, $manager->count());
|
||||||
|
self::assertInstanceOf('\phpOMS\Account\Account', $manager->get(0));
|
||||||
|
self::assertInstanceOf('\phpOMS\Account\NullAccount', $manager->get(-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetGet()
|
||||||
|
{
|
||||||
|
$manager = new AccountManager($GLOBALS['httpSession']);
|
||||||
|
$account = new Account(3);
|
||||||
|
|
||||||
|
$account->generatePassword('abcd');
|
||||||
|
|
||||||
|
$added = $manager->add($account);
|
||||||
|
self::assertTrue($added);
|
||||||
|
self::assertEquals($account, $manager->get($account->getId()));
|
||||||
|
self::assertEquals(1, $manager->count());
|
||||||
|
|
||||||
|
$added = $manager->add($account);
|
||||||
|
self::assertFalse($added);
|
||||||
|
|
||||||
|
self::assertTrue($manager->remove($account->getId()));
|
||||||
|
self::assertFalse($manager->remove(-1));
|
||||||
|
self::assertEquals(0, $manager->count());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
31
tests/Account/AccountStatusTest.php
Normal file
31
tests/Account/AccountStatusTest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Account\AccountStatus;
|
||||||
|
|
||||||
|
class AccountStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(4, count(AccountStatus::getConstants()));
|
||||||
|
self::assertEquals(1, AccountStatus::ACTIVE);
|
||||||
|
self::assertEquals(2, AccountStatus::INACTIVE);
|
||||||
|
self::assertEquals(3, AccountStatus::TIMEOUT);
|
||||||
|
self::assertEquals(4, AccountStatus::BANNED);
|
||||||
|
}
|
||||||
|
}
|
||||||
195
tests/Account/AccountTest.php
Normal file
195
tests/Account/AccountTest.php
Normal file
|
|
@ -0,0 +1,195 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
use phpOMS\Account\Account;
|
||||||
|
use phpOMS\Account\Group;
|
||||||
|
use phpOMS\Account\AccountStatus;
|
||||||
|
use phpOMS\Account\AccountType;
|
||||||
|
use phpOMS\Account\PermissionAbstract;
|
||||||
|
use phpOMS\Account\PermissionType;
|
||||||
|
use phpOMS\Localization\L11nManager;
|
||||||
|
use phpOMS\Localization\Localization;
|
||||||
|
use phpOMS\Localization\NullLocalization;
|
||||||
|
use phpOMS\Log\FileLogger;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class AccountTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
protected $l11nManager = null;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->l11nManager = new L11nManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAttributes()
|
||||||
|
{
|
||||||
|
$account = new Account();
|
||||||
|
self::assertInstanceOf('\phpOMS\Account\Account', $account);
|
||||||
|
|
||||||
|
/* Testing members */
|
||||||
|
self::assertObjectHasAttribute('id', $account);
|
||||||
|
self::assertObjectHasAttribute('name1', $account);
|
||||||
|
self::assertObjectHasAttribute('name2', $account);
|
||||||
|
self::assertObjectHasAttribute('name3', $account);
|
||||||
|
self::assertObjectHasAttribute('email', $account);
|
||||||
|
self::assertObjectHasAttribute('origin', $account);
|
||||||
|
self::assertObjectHasAttribute('login', $account);
|
||||||
|
self::assertObjectHasAttribute('lastActive', $account);
|
||||||
|
self::assertObjectHasAttribute('createdAt', $account);
|
||||||
|
self::assertObjectHasAttribute('permissions', $account);
|
||||||
|
self::assertObjectHasAttribute('groups', $account);
|
||||||
|
self::assertObjectHasAttribute('type', $account);
|
||||||
|
self::assertObjectHasAttribute('status', $account);
|
||||||
|
self::assertObjectHasAttribute('l11n', $account);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
$account = new Account();
|
||||||
|
|
||||||
|
/* Testing default values */
|
||||||
|
self::assertTrue(is_int($account->getId()));
|
||||||
|
self::assertEquals(0, $account->getId());
|
||||||
|
|
||||||
|
self::assertInstanceOf('\phpOMS\Localization\NullLocalization', $account->getL11n());
|
||||||
|
|
||||||
|
self::assertEquals([], $account->getGroups());
|
||||||
|
|
||||||
|
self::assertTrue(is_string($account->getName()));
|
||||||
|
self::assertEquals('', $account->getName());
|
||||||
|
|
||||||
|
self::assertTrue(is_string($account->getName1()));
|
||||||
|
self::assertEquals('', $account->getName1());
|
||||||
|
|
||||||
|
self::assertTrue(is_string($account->getName2()));
|
||||||
|
self::assertEquals('', $account->getName2());
|
||||||
|
|
||||||
|
self::assertTrue(is_string($account->getName3()));
|
||||||
|
self::assertEquals('', $account->getName3());
|
||||||
|
|
||||||
|
self::assertTrue(is_string($account->getEmail()));
|
||||||
|
self::assertEquals('', $account->getEmail());
|
||||||
|
|
||||||
|
self::assertTrue(is_int($account->getStatus()));
|
||||||
|
self::assertEquals(AccountStatus::INACTIVE, $account->getStatus());
|
||||||
|
|
||||||
|
self::assertTrue(is_int($account->getType()));
|
||||||
|
self::assertEquals(AccountType::USER, $account->getType());
|
||||||
|
|
||||||
|
self::assertEquals([], $account->getPermissions());
|
||||||
|
|
||||||
|
self::assertInstanceOf('\DateTime', $account->getLastActive());
|
||||||
|
self::assertInstanceOf('\DateTime', $account->getCreatedAt());
|
||||||
|
|
||||||
|
$array = $account->toArray();
|
||||||
|
self::assertTrue(is_array($array));
|
||||||
|
self::assertGreaterThan(0, count($array));
|
||||||
|
self::assertEquals(json_encode($array), $account->__toString());
|
||||||
|
self::assertEquals($array, $account->jsonSerialize());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetGet()
|
||||||
|
{
|
||||||
|
$account = new Account();
|
||||||
|
|
||||||
|
/* Just test if no error happens */
|
||||||
|
$account->generatePassword('abcd');
|
||||||
|
|
||||||
|
$account->addGroup(new Group());
|
||||||
|
self::assertEquals(1, count($account->getGroups()));
|
||||||
|
|
||||||
|
$account->setName('Login');
|
||||||
|
self::assertEquals('Login', $account->getName());
|
||||||
|
|
||||||
|
$account->setName1('Donald');
|
||||||
|
self::assertEquals('Donald', $account->getName1());
|
||||||
|
|
||||||
|
$account->setName2('Fauntleroy');
|
||||||
|
self::assertEquals('Fauntleroy', $account->getName2());
|
||||||
|
|
||||||
|
$account->setName3('Duck');
|
||||||
|
self::assertEquals('Duck', $account->getName3());
|
||||||
|
|
||||||
|
$account->setEmail('d.duck@duckburg.com');
|
||||||
|
self::assertEquals('d.duck@duckburg.com', $account->getEmail());
|
||||||
|
|
||||||
|
$account->setName('Login');
|
||||||
|
self::assertEquals('Login', $account->getName());
|
||||||
|
|
||||||
|
$account->setStatus(AccountStatus::ACTIVE);
|
||||||
|
self::assertEquals(AccountStatus::ACTIVE, $account->getStatus());
|
||||||
|
|
||||||
|
$account->setType(AccountType::GROUP);
|
||||||
|
self::assertEquals(AccountType::GROUP, $account->getType());
|
||||||
|
|
||||||
|
$account->addPermission(new class extends PermissionAbstract {});
|
||||||
|
self::assertEquals(1, count($account->getPermissions()));
|
||||||
|
|
||||||
|
$account->setPermissions([
|
||||||
|
new class extends PermissionAbstract {},
|
||||||
|
new class extends PermissionAbstract {},
|
||||||
|
]);
|
||||||
|
self::assertEquals(2, count($account->getPermissions()));
|
||||||
|
|
||||||
|
$account->addPermissions([
|
||||||
|
new class extends PermissionAbstract {},
|
||||||
|
new class extends PermissionAbstract {},
|
||||||
|
]);
|
||||||
|
self::assertEquals(4, count($account->getPermissions()));
|
||||||
|
|
||||||
|
self::assertFalse($account->hasPermission(PermissionType::READ, 1, 'a', 1, 1, 1, 1));
|
||||||
|
self::assertTrue($account->hasPermission(PermissionType::NONE));
|
||||||
|
|
||||||
|
$account->setL11n(new NullLocalization());
|
||||||
|
self::assertInstanceOf('\phpOMS\Localization\NullLocalization', $account->getL11n());
|
||||||
|
$account->setL11n(new Localization());
|
||||||
|
self::assertInstanceOf('\phpOMS\Localization\Localization', $account->getL11n());
|
||||||
|
self::assertNotInstanceOf('\phpOMS\Localization\NullLocalization', $account->getL11n());
|
||||||
|
|
||||||
|
$datetime = new \DateTime('now');
|
||||||
|
$account->updateLastActive();
|
||||||
|
self::assertEquals($datetime->format('Y-m-d h:i:s'), $account->getLastActive()->format('Y-m-d h:i:s'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testEmailException()
|
||||||
|
{
|
||||||
|
$account = new Account();
|
||||||
|
$account->setEmail('d.duck!@#%@duckburg');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testStatusException()
|
||||||
|
{
|
||||||
|
$account = new Account();
|
||||||
|
$account->setStatus(99);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testTypeException()
|
||||||
|
{
|
||||||
|
$account = new Account();
|
||||||
|
$account->setType(99);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
tests/Account/AccountTypeTest.php
Normal file
29
tests/Account/AccountTypeTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Account\AccountType;
|
||||||
|
|
||||||
|
class AccountTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(2, count(AccountType::getConstants()));
|
||||||
|
self::assertEquals(0, AccountType::USER);
|
||||||
|
self::assertEquals(1, AccountType::GROUP);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Account/GroupStatusTest.php
Normal file
30
tests/Account/GroupStatusTest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Account\GroupStatus;
|
||||||
|
|
||||||
|
class GroupStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(3, count(GroupStatus::getConstants()));
|
||||||
|
self::assertEquals(1, GroupStatus::ACTIVE);
|
||||||
|
self::assertEquals(2, GroupStatus::INACTIVE);
|
||||||
|
self::assertEquals(4, GroupStatus::HIDDEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
74
tests/Account/GroupTest.php
Normal file
74
tests/Account/GroupTest.php
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
use phpOMS\Account\Group;
|
||||||
|
use phpOMS\Account\GroupStatus;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class GroupTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testAttributes() {
|
||||||
|
$group = new Group();
|
||||||
|
self::assertInstanceOf('\phpOMS\Account\Group', $group);
|
||||||
|
|
||||||
|
/* Testing members */
|
||||||
|
self::assertObjectHasAttribute('id', $group);
|
||||||
|
self::assertObjectHasAttribute('name', $group);
|
||||||
|
self::assertObjectHasAttribute('description', $group);
|
||||||
|
self::assertObjectHasAttribute('members', $group);
|
||||||
|
self::assertObjectHasAttribute('parents', $group);
|
||||||
|
self::assertObjectHasAttribute('permissions', $group);
|
||||||
|
self::assertObjectHasAttribute('status', $group);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDefault() {
|
||||||
|
$group = new Group();
|
||||||
|
|
||||||
|
/* Testing default values */
|
||||||
|
self::assertTrue(is_int($group->getId()));
|
||||||
|
self::assertEquals(0, $group->getId());
|
||||||
|
|
||||||
|
self::assertTrue(is_string($group->getName()));
|
||||||
|
self::assertEquals('', $group->getName());
|
||||||
|
|
||||||
|
self::assertTrue(is_int($group->getStatus()));
|
||||||
|
self::assertEquals(GroupStatus::INACTIVE, $group->getStatus());
|
||||||
|
|
||||||
|
self::assertTrue(is_string($group->getDescription()));
|
||||||
|
self::assertEquals('', $group->getDescription());
|
||||||
|
|
||||||
|
$array = $group->toArray();
|
||||||
|
self::assertTrue(is_array($array));
|
||||||
|
self::assertGreaterThan(0, count($array));
|
||||||
|
self::assertEquals(json_encode($array), $group->__toString());
|
||||||
|
self::assertEquals($array, $group->jsonSerialize());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetGet()
|
||||||
|
{
|
||||||
|
$group = new Group();
|
||||||
|
|
||||||
|
$group->setName('Duck');
|
||||||
|
self::assertEquals('Duck', $group->getName());
|
||||||
|
|
||||||
|
$group->setDescription('Animal');
|
||||||
|
self::assertEquals('Animal', $group->getDescription());
|
||||||
|
|
||||||
|
$group->setStatus(GroupStatus::ACTIVE);
|
||||||
|
self::assertEquals(GroupStatus::ACTIVE, $group->getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Account/NullAccountTest.php
Normal file
27
tests/Account/NullAccountTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Account\NullAccount;
|
||||||
|
|
||||||
|
class NullAccountTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testNull()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf('\phpOMS\Account\Account', new NullAccount());
|
||||||
|
}
|
||||||
|
}
|
||||||
72
tests/Account/PermissionAbstractTest.php
Normal file
72
tests/Account/PermissionAbstractTest.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Account\PermissionAbstract;
|
||||||
|
use phpOMS\Account\PermissionType;
|
||||||
|
|
||||||
|
class PermissionAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testAbstractDefault()
|
||||||
|
{
|
||||||
|
$perm = new class extends PermissionAbstract {};
|
||||||
|
|
||||||
|
self::assertEquals(0, $perm->getId());
|
||||||
|
self::assertEquals(null, $perm->getUnit());
|
||||||
|
self::assertEquals(null, $perm->getApp());
|
||||||
|
self::assertEquals(null, $perm->getModule());
|
||||||
|
self::assertEquals(null, $perm->getFrom());
|
||||||
|
self::assertEquals(null, $perm->getType());
|
||||||
|
self::assertEquals(null, $perm->getElement());
|
||||||
|
self::assertEquals(null, $perm->getComponent());
|
||||||
|
self::assertEquals(PermissionType::NONE, $perm->getPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAbstractGetSet()
|
||||||
|
{
|
||||||
|
$perm = new class extends PermissionAbstract {};
|
||||||
|
|
||||||
|
$perm->setUnit(1);
|
||||||
|
self::assertEquals(1, $perm->getUnit());
|
||||||
|
|
||||||
|
$perm->setApp('Test');
|
||||||
|
self::assertEquals('Test', $perm->getApp());
|
||||||
|
|
||||||
|
$perm->setModule(2);
|
||||||
|
self::assertEquals(2, $perm->getModule());
|
||||||
|
|
||||||
|
$perm->setFrom(3);
|
||||||
|
self::assertEquals(3, $perm->getFrom());
|
||||||
|
|
||||||
|
$perm->setType(4);
|
||||||
|
self::assertEquals(4, $perm->getType());
|
||||||
|
|
||||||
|
$perm->setElement(5);
|
||||||
|
self::assertEquals(5, $perm->getElement());
|
||||||
|
|
||||||
|
$perm->setComponent(6);
|
||||||
|
self::assertEquals(6, $perm->getComponent());
|
||||||
|
|
||||||
|
$perm->setPermission(PermissionType::READ);
|
||||||
|
self::assertEquals(PermissionType::READ, $perm->getPermission());
|
||||||
|
|
||||||
|
$perm->addPermission(PermissionType::CREATE);
|
||||||
|
self::assertTrue($perm->hasPermission(PermissionType::CREATE));
|
||||||
|
self::assertTrue($perm->hasPermission(PermissionType::READ));
|
||||||
|
self::assertFalse($perm->hasPermission(PermissionType::MODIFY));
|
||||||
|
}
|
||||||
|
}
|
||||||
34
tests/Account/PermissionTypeTest.php
Normal file
34
tests/Account/PermissionTypeTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?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 Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Account\PermissionType;
|
||||||
|
|
||||||
|
class PermissionTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(6, count(PermissionType::getConstants()));
|
||||||
|
self::assertEquals(PermissionType::getConstants(), array_unique(PermissionType::getConstants()));
|
||||||
|
|
||||||
|
self::assertEquals(1, PermissionType::NONE);
|
||||||
|
self::assertEquals(2, PermissionType::READ);
|
||||||
|
self::assertEquals(4, PermissionType::CREATE);
|
||||||
|
self::assertEquals(8, PermissionType::MODIFY);
|
||||||
|
self::assertEquals(16, PermissionType::DELETE);
|
||||||
|
self::assertEquals(32, PermissionType::PERMISSION);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
tests/ApplicationAbstractTest.php
Normal file
34
tests/ApplicationAbstractTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\ApplicationAbstract;
|
||||||
|
use phpOMS\UnhandledHandler;
|
||||||
|
|
||||||
|
class ApplicationAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testGetSet()
|
||||||
|
{
|
||||||
|
$obj = new class extends ApplicationAbstract {};
|
||||||
|
|
||||||
|
$obj->appName = 'Test';
|
||||||
|
self::assertEquals('Test', $obj->appName);
|
||||||
|
|
||||||
|
$obj->appName = 'ABC';
|
||||||
|
self::assertEquals('Test', $obj->appName);
|
||||||
|
}
|
||||||
|
}
|
||||||
79
tests/Asset/AssetManagerTest.php
Normal file
79
tests/Asset/AssetManagerTest.php
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
use phpOMS\Asset\AssetManager;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class AssetManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testAttributes()
|
||||||
|
{
|
||||||
|
$manager = new AssetManager();
|
||||||
|
self::assertInstanceOf('\phpOMS\Asset\AssetManager', $manager);
|
||||||
|
|
||||||
|
/* Testing members */
|
||||||
|
self::assertObjectHasAttribute('assets', $manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
$manager = new AssetManager();
|
||||||
|
|
||||||
|
/* Testing default values */
|
||||||
|
self::assertNull($manager->get('myAsset'));
|
||||||
|
self::assertEquals(0, $manager->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetGet()
|
||||||
|
{
|
||||||
|
$manager = new AssetManager();
|
||||||
|
|
||||||
|
/* Test set/get/count */
|
||||||
|
$manager->set('first', 'FirstUri');
|
||||||
|
$set = $manager->set('myAsset', 'AssetUri');
|
||||||
|
self::assertTrue($set);
|
||||||
|
self::assertEquals('AssetUri', $manager->get('myAsset'));
|
||||||
|
self::assertEquals(2, $manager->count());
|
||||||
|
|
||||||
|
$set = $manager->set('myAsset', 'AssetUri2', false);
|
||||||
|
self::assertFalse($set);
|
||||||
|
self::assertEquals('AssetUri', $manager->get('myAsset'));
|
||||||
|
self::assertEquals(2, $manager->count());
|
||||||
|
|
||||||
|
$set = $manager->set('myAsset', 'AssetUri2');
|
||||||
|
self::assertTrue($set);
|
||||||
|
self::assertEquals('AssetUri2', $manager->get('myAsset'));
|
||||||
|
self::assertEquals(2, $manager->count());
|
||||||
|
|
||||||
|
$set = $manager->set('myAsset', 'AssetUri3', true);
|
||||||
|
self::assertTrue($set);
|
||||||
|
self::assertEquals('AssetUri3', $manager->get('myAsset'));
|
||||||
|
self::assertEquals(2, $manager->count());
|
||||||
|
|
||||||
|
/* Test remove */
|
||||||
|
$rem = $manager->remove('myAsset');
|
||||||
|
self::assertTrue($rem);
|
||||||
|
self::assertEquals(1, $manager->count());
|
||||||
|
|
||||||
|
self::assertNull($manager->get('myAsset'));
|
||||||
|
|
||||||
|
$rem = $manager->remove('myAsset');
|
||||||
|
self::assertFalse($rem);
|
||||||
|
self::assertEquals(1, $manager->count());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Asset/AssetTypeTest.php
Normal file
30
tests/Asset/AssetTypeTest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Asset;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Asset\AssetType;
|
||||||
|
|
||||||
|
class AssetTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(3, count(AssetType::getConstants()));
|
||||||
|
self::assertEquals(0, AssetType::CSS);
|
||||||
|
self::assertEquals(1, AssetType::JS);
|
||||||
|
self::assertEquals(2, AssetType::JSLATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
tests/Auth/AuthTest.php
Normal file
34
tests/Auth/AuthTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Account;
|
||||||
|
|
||||||
|
use phpOMS\Auth\Auth;
|
||||||
|
use phpOMS\Auth\LoginReturnType;
|
||||||
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
|
use phpOMS\DataStorage\Session\ConsoleSession;
|
||||||
|
use phpOMS\DataStorage\Session\SocketSession;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class AuthTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testWithHttpSession()
|
||||||
|
{
|
||||||
|
self::assertEquals(0, Auth::authenticate($GLOBALS['httpSession']));
|
||||||
|
|
||||||
|
Auth::logout($GLOBALS['httpSession']);
|
||||||
|
self::assertEquals(0, Auth::authenticate($GLOBALS['httpSession']));
|
||||||
|
}
|
||||||
|
}
|
||||||
37
tests/Auth/LoginReturnTypeTest.php
Normal file
37
tests/Auth/LoginReturnTypeTest.php
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Auth;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Auth\LoginReturnType;
|
||||||
|
|
||||||
|
class LoginReturnTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(10, count(LoginReturnType::getConstants()));
|
||||||
|
self::assertEquals(0, LoginReturnType::OK);
|
||||||
|
self::assertEquals(-1, LoginReturnType::FAILURE);
|
||||||
|
self::assertEquals(-2, LoginReturnType::WRONG_PASSWORD);
|
||||||
|
self::assertEquals(-3, LoginReturnType::WRONG_USERNAME);
|
||||||
|
self::assertEquals(-4, LoginReturnType::WRONG_PERMISSION);
|
||||||
|
self::assertEquals(-5, LoginReturnType::NOT_ACTIVATED);
|
||||||
|
self::assertEquals(-6, LoginReturnType::WRONG_INPUT_EXCEEDED);
|
||||||
|
self::assertEquals(-7, LoginReturnType::TIMEOUTED);
|
||||||
|
self::assertEquals(-8, LoginReturnType::BANNED);
|
||||||
|
self::assertEquals(-9, LoginReturnType::INACTIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/AutoloadExceptionTest.php
Normal file
27
tests/AutoloadExceptionTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\AutoloadException;
|
||||||
|
|
||||||
|
class AutoloadExceptionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testException()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf(\RuntimeException::class, new AutoloadException(''));
|
||||||
|
}
|
||||||
|
}
|
||||||
75
tests/Autoloader.php
Normal file
75
tests/Autoloader.php
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit;
|
||||||
|
|
||||||
|
spl_autoload_register('\Tests\PHPUnit\Autoloader::default_autoloader');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Autoloader class.
|
||||||
|
*
|
||||||
|
* @package Framework
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class Autoloader
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loading classes by namespace + class name.
|
||||||
|
*
|
||||||
|
* @param string $class Class path
|
||||||
|
*
|
||||||
|
* @example Autoloader::default_autoloader('\Tests\PHPUnit\Autoloader') // void
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function default_autoloader(string $class) /* : void */
|
||||||
|
{
|
||||||
|
$class = ltrim($class, '\\');
|
||||||
|
$class = str_replace(['_', '\\'], '/', $class);
|
||||||
|
|
||||||
|
if (!file_exists($path = __DIR__ . '/../../' . $class . '.php')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
include_once $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if class exists.
|
||||||
|
*
|
||||||
|
* @param string $class Class path
|
||||||
|
*
|
||||||
|
* @example Autoloader::exists('\Tests\PHPUnit\Autoloader') // true
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static function exists(string $class) : bool
|
||||||
|
{
|
||||||
|
$class = ltrim($class, '\\');
|
||||||
|
$class = str_replace(['_', '\\'], '/', $class);
|
||||||
|
|
||||||
|
return file_exists(__DIR__ . '/../../' . $class . '.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
27
tests/AutoloaderTest.php
Normal file
27
tests/AutoloaderTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../phpOMS/Autoloader.php';
|
||||||
|
use phpOMS\Autoloader;
|
||||||
|
|
||||||
|
class AutoloaderTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testAutoloader()
|
||||||
|
{
|
||||||
|
self::assertTrue(Autoloader::exists('\phpOMS\Autoloader'));
|
||||||
|
self::assertFalse(Autoloader::exists('\Does\Not\Exist'));
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Bootstrap.php
Normal file
30
tests/Bootstrap.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
ini_set('memory_limit', '2048M');
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
require_once __DIR__ . '/../../phpOMS/Autoloader.php';
|
||||||
|
$CONFIG = require_once __DIR__ . '/../../config.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Session\HttpSession;
|
||||||
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
|
||||||
|
// Reset database
|
||||||
|
$db = new \PDO($CONFIG['db']['core']['masters']['admin']['db'] . ':host=' .
|
||||||
|
$CONFIG['db']['core']['masters']['admin']['host'],
|
||||||
|
$CONFIG['db']['core']['masters']['admin']['login'],
|
||||||
|
$CONFIG['db']['core']['masters']['admin']['password']
|
||||||
|
);
|
||||||
|
$db->exec('DROP DATABASE IF EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
|
||||||
|
$db->exec('CREATE DATABASE IF NOT EXISTS ' . $CONFIG['db']['core']['masters']['admin']['database']);
|
||||||
|
$db = null;
|
||||||
|
|
||||||
|
$httpSession = new HttpSession();
|
||||||
|
$GLOBALS['session'] = $httpSession;
|
||||||
|
|
||||||
|
$GLOBALS['dbpool'] = new DatabasePool();
|
||||||
|
$GLOBALS['dbpool']->create('admin', $CONFIG['db']['core']['masters']['admin']);
|
||||||
|
$GLOBALS['dbpool']->create('select', $CONFIG['db']['core']['masters']['select']);
|
||||||
|
|
||||||
|
DataMapperAbstract::setConnection($GLOBALS['dbpool']->get());
|
||||||
27
tests/Business/Finance/DepreciationTest.php
Normal file
27
tests/Business/Finance/DepreciationTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Depreciation;
|
||||||
|
|
||||||
|
class DepreciationTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
257
tests/Business/Finance/FinanceFormulasTest.php
Normal file
257
tests/Business/Finance/FinanceFormulasTest.php
Normal file
|
|
@ -0,0 +1,257 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance;
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\FinanceFormulas;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class FinanceFormulasTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testAnnualPercentageYield()
|
||||||
|
{
|
||||||
|
$expected = 0.06168;
|
||||||
|
|
||||||
|
$r = 0.06;
|
||||||
|
$n = 12;
|
||||||
|
$apy = FinanceFormulas::getAnnualPercentageYield($r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 5), round($apy, 5));
|
||||||
|
self::assertEquals(round($r, 2), FinanceFormulas::getStateAnnualInterestRateOfAPY($apy, $n));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFutureValueOfAnnuity()
|
||||||
|
{
|
||||||
|
$expected = 5204.04;
|
||||||
|
|
||||||
|
$P = 1000.00;
|
||||||
|
$r = 0.02;
|
||||||
|
$n = 5;
|
||||||
|
$fva = FinanceFormulas::getFutureValueOfAnnuity($P, $r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), round($fva, 2));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getNumberOfPeriodsOfFVA($fva, $P, $r));
|
||||||
|
self::assertEquals(round($P, 2), round(FinanceFormulas::getPeriodicPaymentOfFVA($fva, $r, $n), 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFutureValueOfAnnuityContinuousCompounding()
|
||||||
|
{
|
||||||
|
$expected = 12336.42;
|
||||||
|
|
||||||
|
$cf = 1000.00;
|
||||||
|
$r = 0.005;
|
||||||
|
$t = 12;
|
||||||
|
$fvacc = FinanceFormulas::getFutureValueOfAnnuityConinuousCompounding($cf, $r, $t);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), round($fvacc, 2));
|
||||||
|
self::assertEquals(round($cf, 2), round(FinanceFormulas::getCashFlowOfFVACC($fvacc, $r, $t), 2));
|
||||||
|
self::assertEquals($t, FinanceFormulas::getTimeOfFVACC($fvacc, $cf, $r));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnnuityPaymentPV()
|
||||||
|
{
|
||||||
|
$expected = 212.16;
|
||||||
|
|
||||||
|
$pv = 1000.00;
|
||||||
|
$r = 0.02;
|
||||||
|
$n = 5;
|
||||||
|
$p = FinanceFormulas::getAnnuityPaymentPV($pv, $r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), round($p, 2));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getNumberOfAPPV($p, $pv, $r));
|
||||||
|
self::assertEquals(round($pv, 2), round(FinanceFormulas::getPresentValueOfAPPV($p, $r, $n), 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnnuityPaymentFV()
|
||||||
|
{
|
||||||
|
$expected = 192.16;
|
||||||
|
|
||||||
|
$fv = 1000.00;
|
||||||
|
$r = 0.02;
|
||||||
|
$n = 5;
|
||||||
|
$p = FinanceFormulas::getAnnuityPaymentFV($fv, $r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), round($p, 2));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getNumberOfAPFV($p, $fv, $r));
|
||||||
|
self::assertEquals(round($fv, 2), round(FinanceFormulas::getFutureValueOfAPFV($p, $r, $n), 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAnnutiyPaymentFactorPV()
|
||||||
|
{
|
||||||
|
$expected = 0.21216;
|
||||||
|
|
||||||
|
$r = 0.02;
|
||||||
|
$n = 5;
|
||||||
|
$p = FinanceFormulas::getAnnutiyPaymentFactorPV($r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 5), round($p, 5));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getNumberOfAPFPV($p, $r));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPresentValueOfAnnuity()
|
||||||
|
{
|
||||||
|
$expected = 4713.46;
|
||||||
|
|
||||||
|
$P = 1000.00;
|
||||||
|
$r = 0.02;
|
||||||
|
$n = 5;
|
||||||
|
$pva = FinanceFormulas::getPresentValueOfAnnuity($P, $r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), round($pva, 2));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getNumberOfPeriodsOfPVA($pva, $P, $r));
|
||||||
|
self::assertEquals(round($P, 2), round(FinanceFormulas::getPeriodicPaymentOfPVA($pva, $r, $n), 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPresentValueAnnuityFactor()
|
||||||
|
{
|
||||||
|
$expected = 4.7135;
|
||||||
|
|
||||||
|
$r = 0.02;
|
||||||
|
$n = 5;
|
||||||
|
$p = FinanceFormulas::getPresentValueAnnuityFactor($r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 4), round($p, 4));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getPeriodsOfPVAF($p, $r));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testPresentValueOfAnnuityDue()
|
||||||
|
{
|
||||||
|
$expected = 454.60;
|
||||||
|
|
||||||
|
$P = 100.00;
|
||||||
|
$r = 0.05;
|
||||||
|
$n = 5;
|
||||||
|
|
||||||
|
$PV = FinanceFormulas::getPresentValueOfAnnuityDue($P, $r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), round($PV, 2));
|
||||||
|
self::assertEquals(round($P, 2), FinanceFormulas::getPeriodicPaymentOfPVAD($PV, $r, $n));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getPeriodsOfPVAD($PV, $P, $r));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFutureValueOfAnnuityDue()
|
||||||
|
{
|
||||||
|
$expected = 580.19;
|
||||||
|
|
||||||
|
$P = 100.00;
|
||||||
|
$r = 0.05;
|
||||||
|
$n = 5;
|
||||||
|
|
||||||
|
$FV = FinanceFormulas::getFutureValueOfAnnuityDue($P, $r, $n);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), round($FV, 2));
|
||||||
|
self::assertEquals(round($P, 2), FinanceFormulas::getPeriodicPaymentOfFVAD($FV, $r, $n));
|
||||||
|
self::assertEquals($n, FinanceFormulas::getPeriodsOfFVAD($FV, $P, $r));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRatios()
|
||||||
|
{
|
||||||
|
self::assertEquals(300 / 400, FinanceFormulas::getRelativeMarketShareByShare(300, 400));
|
||||||
|
self::assertEquals(300 / 400, FinanceFormulas::getRelativeMarketShareBySales(300, 400));
|
||||||
|
|
||||||
|
self::assertEquals(3 / 2, FinanceFormulas::getAssetToSalesRatio(3, 2));
|
||||||
|
self::assertEquals(2 / 3, FinanceFormulas::getAssetTurnoverRatio(3, 2));
|
||||||
|
|
||||||
|
self::assertEquals(365 / 1000, FinanceFormulas::getDaysInInventory(1000));
|
||||||
|
self::assertEquals(365 / 1000, FinanceFormulas::getAverageCollectionPeriod(1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getReceivablesTurnover(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getCurrentRatio(500, 1000));
|
||||||
|
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getDebtCoverageRatio(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getDebtRatio(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getDebtToEquityRatio(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getDebtToIncomeRatio(500, 1000));
|
||||||
|
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getInterestCoverageRatio(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getInventoryTurnoverRatio(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getNetProfitMargin(500, 1000));
|
||||||
|
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getReturnOnAssets(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getReturnOnEquity(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getReceivablesTurnoverRatio(500, 1000));
|
||||||
|
self::assertEquals(500 / 1000, FinanceFormulas::getQuickRatio(500, 1000));
|
||||||
|
|
||||||
|
self::assertEquals(500 / 1000 - 1, FinanceFormulas::getReturnOnInvestment(500, 1000));
|
||||||
|
self::assertEquals((500 - 300) / 500, FinanceFormulas::getRetentionRatio(500, 300));
|
||||||
|
self::assertEquals(500 / 1000 - 1, FinanceFormulas::getRateOfOnflation(500, 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompound()
|
||||||
|
{
|
||||||
|
$expected = 15.76;
|
||||||
|
|
||||||
|
$P = 100.00;
|
||||||
|
$r = 0.05;
|
||||||
|
$t = 3;
|
||||||
|
|
||||||
|
$C = round(FinanceFormulas::getCompoundInterest($P, $r, $t), 2);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), $C);
|
||||||
|
self::assertTrue(abs($P - FinanceFormulas::getPrincipalOfCompundInterest($C, $r, $t)) < 0.1);
|
||||||
|
self::assertEquals($t, (int) round(FinanceFormulas::getPeriodsOfCompundInterest($P, $C, $r), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testContinuousCompounding()
|
||||||
|
{
|
||||||
|
$expected = 116.18;
|
||||||
|
|
||||||
|
$P = 100.00;
|
||||||
|
$r = 0.05;
|
||||||
|
$t = 3;
|
||||||
|
|
||||||
|
$C = round(FinanceFormulas::getContinuousCompounding($P, $r, $t), 2);
|
||||||
|
|
||||||
|
self::assertEquals(round($expected, 2), $C);
|
||||||
|
self::assertEquals(round($P, 2), round(FinanceFormulas::getPrincipalOfContinuousCompounding($C, $r, $t), 2));
|
||||||
|
self::assertTrue(abs($t - FinanceFormulas::getPeriodsOfContinuousCompounding($P, $C, $r)) < 0.01);
|
||||||
|
self::assertTrue(abs($r - FinanceFormulas::getRateOfContinuousCompounding($P, $C, $t)) < 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSimpleInterest()
|
||||||
|
{
|
||||||
|
$P = 100.00;
|
||||||
|
$r = 0.05;
|
||||||
|
$t = 3;
|
||||||
|
|
||||||
|
$I = $P * $r * $t;
|
||||||
|
|
||||||
|
self::assertTrue(abs($I - FinanceFormulas::getSimpleInterest($P, $r, $t)) < 0.01);
|
||||||
|
self::assertTrue(abs($P - FinanceFormulas::getSimpleInterestPrincipal($I, $r, $t)) < 0.01);
|
||||||
|
self::assertTrue(abs($r - FinanceFormulas::getSimpleInterestRate($I, $P, $t)) < 0.01);
|
||||||
|
self::assertEquals($t, FinanceFormulas::getSimpleInterestTime($I, $P, $r));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNetPresentValue()
|
||||||
|
{
|
||||||
|
self::assertTrue(abs(1009.23 - FinanceFormulas::getNetPresentValue([10000, 500, 1000, 1500, 2000, 2500, 3000, 3500], 0.05)) < 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDiscountedPaybackPeriod()
|
||||||
|
{
|
||||||
|
$O1 = 5000;
|
||||||
|
$r = 0.05;
|
||||||
|
$CF = 1000;
|
||||||
|
|
||||||
|
self::assertTrue(abs(5.896 - FinanceFormulas::getDiscountedPaybackPeriod($CF, $O1, $r)) < 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDoublingTime()
|
||||||
|
{
|
||||||
|
$r = 0.05;
|
||||||
|
|
||||||
|
self::assertTrue(abs(14.207 - FinanceFormulas::getDoublingTime($r)) < 0.01);
|
||||||
|
self::assertTrue(abs($r - FinanceFormulas::getDoublingRate(14.207)) < 0.01);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/ARCHTest.php
Normal file
27
tests/Business/Finance/Forecasting/ARCHTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ARCH;
|
||||||
|
|
||||||
|
class ARCHTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/ARFIMATest.php
Normal file
27
tests/Business/Finance/Forecasting/ARFIMATest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ARFIMA;
|
||||||
|
|
||||||
|
class ARFIMATest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/ARIMATest.php
Normal file
27
tests/Business/Finance/Forecasting/ARIMATest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ARIMA;
|
||||||
|
|
||||||
|
class ARIMATest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/ARMATest.php
Normal file
27
tests/Business/Finance/Forecasting/ARMATest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ARMA;
|
||||||
|
|
||||||
|
class ARMATest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/ARTest.php
Normal file
27
tests/Business/Finance/Forecasting/ARTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\AR;
|
||||||
|
|
||||||
|
class ARTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ClassicalDecomposition;
|
||||||
|
|
||||||
|
class ClassicalDecompositionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting\ExponentialSmoothing;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ExponentialSmoothing\ExponentialSmoothing;
|
||||||
|
|
||||||
|
class ExponentialSmoothingTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting\ExponentialSmoothing;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ExponentialSmoothing\SeasonalType;
|
||||||
|
|
||||||
|
class SeasonalTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(4, count(SeasonalType::getConstants()));
|
||||||
|
self::assertEquals(SeasonalType::getConstants(), array_unique(SeasonalType::getConstants()));
|
||||||
|
|
||||||
|
self::assertEquals(0, SeasonalType::ALL);
|
||||||
|
self::assertEquals(1, SeasonalType::NONE);
|
||||||
|
self::assertEquals(2, SeasonalType::ADDITIVE);
|
||||||
|
self::assertEquals(4, SeasonalType::MULTIPLICATIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting\ExponentialSmoothing;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\ExponentialSmoothing\TrendType;
|
||||||
|
|
||||||
|
class TrendTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(4, count(TrendType::getConstants()));
|
||||||
|
self::assertEquals(TrendType::getConstants(), array_unique(TrendType::getConstants()));
|
||||||
|
|
||||||
|
self::assertEquals(0, TrendType::ALL);
|
||||||
|
self::assertEquals(1, TrendType::NONE);
|
||||||
|
self::assertEquals(2, TrendType::ADDITIVE);
|
||||||
|
self::assertEquals(4, TrendType::MULTIPLICATIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/GARCHTest.php
Normal file
27
tests/Business/Finance/Forecasting/GARCHTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\GARCH;
|
||||||
|
|
||||||
|
class GARCHTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/MATest.php
Normal file
27
tests/Business/Finance/Forecasting/MATest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\MA;
|
||||||
|
|
||||||
|
class MATest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/NARTest.php
Normal file
27
tests/Business/Finance/Forecasting/NARTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\NAR;
|
||||||
|
|
||||||
|
class NARTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/NMATest.php
Normal file
27
tests/Business/Finance/Forecasting/NMATest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\NMA;
|
||||||
|
|
||||||
|
class NMATest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Business/Finance/Forecasting/SARIMATest.php
Normal file
27
tests/Business/Finance/Forecasting/SARIMATest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\SARIMA;
|
||||||
|
|
||||||
|
class SARIMATest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Business/Finance/Forecasting/SmoothingTypeTest.php
Normal file
30
tests/Business/Finance/Forecasting/SmoothingTypeTest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance\Forecasting;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Forecasting\SmoothingType;
|
||||||
|
|
||||||
|
class SmoothingTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(1, count(SmoothingType::getConstants()));
|
||||||
|
self::assertEquals(SmoothingType::getConstants(), array_unique(SmoothingType::getConstants()));
|
||||||
|
|
||||||
|
self::assertEquals(1, SmoothingType::CENTERED_MOVING_AVERAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
tests/Business/Finance/LoanTest.php
Normal file
28
tests/Business/Finance/LoanTest.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Loan;
|
||||||
|
|
||||||
|
class LoanTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testRatios()
|
||||||
|
{
|
||||||
|
self::assertEquals(100 / 50, Loan::getLoanToDepositRatio(100, 50));
|
||||||
|
self::assertEquals(100 / 50, Loan::getLoanToValueRatio(100, 50));
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/Business/Finance/LorenzkurveTest.php
Normal file
30
tests/Business/Finance/LorenzkurveTest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\Lorenzkurve;
|
||||||
|
|
||||||
|
class LorenzkurveTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testLorenz()
|
||||||
|
{
|
||||||
|
$arr = [1, 1, 1, 1, 1, 1, 1, 10, 33, 50];
|
||||||
|
|
||||||
|
self::assertTrue(abs(0.71 - LorenzKurve::getGiniCoefficient($arr)) < 0.01);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
56
tests/Business/Finance/StockBondsTest.php
Normal file
56
tests/Business/Finance/StockBondsTest.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Finance;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Finance\StockBonds;
|
||||||
|
|
||||||
|
class StockBondsTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testRatios()
|
||||||
|
{
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getBookValuePerShare(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getCurrentYield(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getDividendPayoutRatio(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getDividendYield(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getDividendsPerShare(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getEarningsPerShare(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getEquityMultiplier(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getPriceToBookValue(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getPriceEarningsRatio(100, 50));
|
||||||
|
self::assertEquals(100 / 50, StockBonds::getPriceToSalesRatio(100, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testBondEquivalentYield()
|
||||||
|
{
|
||||||
|
self::assertEquals(0.40556, StockBonds::getBondEquivalentYield(100, 90, 100), '', 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testExpectedReturnCAPM()
|
||||||
|
{
|
||||||
|
self::assertEquals(7, StockBonds::getExpectedReturnCAPM(3, 2, 5), '', 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCapitalGainsYield()
|
||||||
|
{
|
||||||
|
self::assertEquals(0.1, StockBonds::getCapitalGainsYield(100, 110), '', 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDilutedEarningsPerShare()
|
||||||
|
{
|
||||||
|
self::assertEquals(9.09, StockBonds::getDilutedEarningsPerShare(1000, 100, 10), '', 0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
tests/Business/Marketing/MetricsTest.php
Normal file
26
tests/Business/Marketing/MetricsTest.php
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?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 Tests\PHPUnit\phpOMS\Business\Marketing;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Marketing\Metrics;
|
||||||
|
|
||||||
|
class MetricsTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testMetrics()
|
||||||
|
{
|
||||||
|
self::assertTrue(0.85 - Metrics::getCustomerRetention(105, 20, 100) < 0.01);
|
||||||
|
}
|
||||||
|
}
|
||||||
51
tests/Business/Marketing/NetPromoterScoreTest.php
Normal file
51
tests/Business/Marketing/NetPromoterScoreTest.php
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Marketing;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Marketing\NetPromoterScore;
|
||||||
|
|
||||||
|
class NetPromoterScoreTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
$nps = new NetPromoterScore();
|
||||||
|
|
||||||
|
self::assertEquals(0, $nps->getScore());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSet()
|
||||||
|
{
|
||||||
|
$nps = new NetPromoterScore();
|
||||||
|
|
||||||
|
for ($i = 0; $i < 10; $i++) {
|
||||||
|
$nps->add(mt_rand(0, 6));
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 30; $i++) {
|
||||||
|
$nps->add(mt_rand(7, 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 60; $i++) {
|
||||||
|
$nps->add(mt_rand(9, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
self::assertEquals(50, $nps->getScore());
|
||||||
|
self::assertEquals(10, $nps->countDetractors());
|
||||||
|
self::assertEquals(30, $nps->countPassives());
|
||||||
|
self::assertEquals(60, $nps->countPromoters());
|
||||||
|
}
|
||||||
|
}
|
||||||
29
tests/Business/Programming/MetricsTest.php
Normal file
29
tests/Business/Programming/MetricsTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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 Tests\PHPUnit\phpOMS\Business\Programming;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Business\Programming\Metrics;
|
||||||
|
|
||||||
|
class MetricsTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testMetrics()
|
||||||
|
{
|
||||||
|
self::assertEquals((int) sqrt(5 * 5 + 11 * 11 + 9 * 9), Metrics::abcScore(5, 11, 9));
|
||||||
|
|
||||||
|
self::assertEquals(1, Metrics::CRAP(1, 1.0));
|
||||||
|
self::assertEquals(10100, Metrics::CRAP(100, 0.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
35
tests/Business/Sales/MarketShareEstimationTest.php
Normal file
35
tests/Business/Sales/MarketShareEstimationTest.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Business\Sales;
|
||||||
|
|
||||||
|
use phpOMS\Business\Sales\MarketShareEstimation;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class MarketShareEstimationTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testZipfRank()
|
||||||
|
{
|
||||||
|
self::assertEquals(13, MarketShareEstimation::getRankFromMarketShare(1000, 0.01));
|
||||||
|
self::assertEquals(19, MarketShareEstimation::getRankFromMarketShare(100, 0.01));
|
||||||
|
self::assertEquals(8, MarketShareEstimation::getRankFromMarketShare(100000, 0.01));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testZipfShare()
|
||||||
|
{
|
||||||
|
self::assertTrue(abs(0.01 - MarketShareEstimation::getMarketShareFromRank(1000, 13)) < 0.01);
|
||||||
|
self::assertTrue(abs(0.01 - MarketShareEstimation::getMarketShareFromRank(100, 19)) < 0.01);
|
||||||
|
self::assertTrue(abs(0.01 - MarketShareEstimation::getMarketShareFromRank(100000, 8)) < 0.01);
|
||||||
|
}
|
||||||
|
}
|
||||||
75
tests/Config/OptionsTraitTest.php
Normal file
75
tests/Config/OptionsTraitTest.php
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Config;
|
||||||
|
|
||||||
|
use phpOMS\Config\OptionsTrait;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class OptionsTraitTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testOptionTrait()
|
||||||
|
{
|
||||||
|
$class = new class {
|
||||||
|
use OptionsTrait;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Testing members */
|
||||||
|
self::assertObjectHasAttribute('options', $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
$class = new class {
|
||||||
|
use OptionsTrait;
|
||||||
|
};
|
||||||
|
|
||||||
|
self::assertFalse($class->exists('someKey'));
|
||||||
|
self::assertNull($class->getOption('someKey'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetGet()
|
||||||
|
{
|
||||||
|
$class = new class {
|
||||||
|
use OptionsTrait;
|
||||||
|
};
|
||||||
|
|
||||||
|
self::assertTrue($class->setOption('a', 'value1'));
|
||||||
|
self::assertTrue($class->exists('a'));
|
||||||
|
self::assertEquals('value1', $class->getOption('a'));
|
||||||
|
|
||||||
|
self::assertTrue($class->setOption('a', 'value2'));
|
||||||
|
self::assertTrue($class->exists('a'));
|
||||||
|
self::assertEquals('value2', $class->getOption('a'));
|
||||||
|
|
||||||
|
self::assertTrue($class->setOption('a', 'value3', true));
|
||||||
|
self::assertTrue($class->exists('a'));
|
||||||
|
self::assertEquals('value3', $class->getOption('a'));
|
||||||
|
|
||||||
|
self::assertFalse($class->setOption('a', 'value4', false));
|
||||||
|
self::assertTrue($class->exists('a'));
|
||||||
|
self::assertEquals('value3', $class->getOption('a'));
|
||||||
|
|
||||||
|
self::assertTrue($class->setOptions(['b' => 2, 'c' => '3'], true));
|
||||||
|
self::assertFalse($class->setOptions(['b' => 4, 'c' => '5'], false));
|
||||||
|
self::assertTrue($class->exists('a'));
|
||||||
|
self::assertTrue($class->exists('b'));
|
||||||
|
self::assertTrue($class->exists('c'));
|
||||||
|
self::assertEquals('value3', $class->getOption('a'));
|
||||||
|
self::assertEquals(2, $class->getOption('b'));
|
||||||
|
self::assertEquals(3, $class->getOption('c'));
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/Console/CommandManagerTest.php
Normal file
27
tests/Console/CommandManagerTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\Console;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\Console\CommandManager;
|
||||||
|
|
||||||
|
class CommandManagerTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
39
tests/DataStorage/Cache/CacheFactoryTest.php
Normal file
39
tests/DataStorage/Cache/CacheFactoryTest.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Cache;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Cache\CacheFactory;
|
||||||
|
|
||||||
|
class CacheFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testCreate()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf(
|
||||||
|
\phpOMS\DataStorage\Cache\FileCache::class,
|
||||||
|
CacheFactory::create(['type' => 'file', 'path' => 'Cache'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testInvalidCacheType()
|
||||||
|
{
|
||||||
|
CacheFactory::create(['type' => 'invalid', 'path' => 'Cache']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
46
tests/DataStorage/Cache/CachePoolTest.php
Normal file
46
tests/DataStorage/Cache/CachePoolTest.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Cache;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Cache\CachePool;
|
||||||
|
use phpOMS\DataStorage\Cache\FileCache;
|
||||||
|
|
||||||
|
class CachePoolTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
$pool = new CachePool();
|
||||||
|
|
||||||
|
self::assertFalse($pool->remove('core'));
|
||||||
|
self::assertEquals(null, $pool->get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSet()
|
||||||
|
{
|
||||||
|
$pool = new CachePool();
|
||||||
|
|
||||||
|
self::assertTrue($pool->add('test', new FileCache(__DIR__)));
|
||||||
|
self::assertFalse($pool->add('test', new FileCache(__DIR__)));
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Cache\CacheInterface', $pool->get('test'));
|
||||||
|
self::assertTrue($pool->create('abc', ['type' => 'file', 'path' => __DIR__]));
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Cache\CacheInterface', $pool->get('abc'));
|
||||||
|
self::assertTrue($pool->remove('abc'));
|
||||||
|
self::assertEquals(null, $pool->get('abc'));
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Cache\CacheInterface', $pool->get('test'));
|
||||||
|
self::assertFalse($pool->remove('abc'));
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/DataStorage/Cache/CacheStatusTest.php
Normal file
30
tests/DataStorage/Cache/CacheStatusTest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Cache;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Cache\CacheStatus;
|
||||||
|
|
||||||
|
class CacheStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(3, count(CacheStatus::getConstants()));
|
||||||
|
self::assertEquals(0, CacheStatus::ACTIVE);
|
||||||
|
self::assertEquals(1, CacheStatus::INACTIVE);
|
||||||
|
self::assertEquals(2, CacheStatus::ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
tests/DataStorage/Cache/CacheTypeTest.php
Normal file
34
tests/DataStorage/Cache/CacheTypeTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Cache;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Cache\CacheType;
|
||||||
|
|
||||||
|
class CacheTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(7, count(CacheType::getConstants()));
|
||||||
|
self::assertEquals(0, CacheType::_INT);
|
||||||
|
self::assertEquals(1, CacheType::_STRING);
|
||||||
|
self::assertEquals(2, CacheType::_ARRAY);
|
||||||
|
self::assertEquals(3, CacheType::_SERIALIZABLE);
|
||||||
|
self::assertEquals(4, CacheType::_FLOAT);
|
||||||
|
self::assertEquals(5, CacheType::_BOOL);
|
||||||
|
self::assertEquals(6, CacheType::_JSONSERIALIZABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
0
tests/DataStorage/Cache/FileCacheTest.php
Normal file
0
tests/DataStorage/Cache/FileCacheTest.php
Normal file
0
tests/DataStorage/Cache/MemCacheTest.php
Normal file
0
tests/DataStorage/Cache/MemCacheTest.php
Normal file
35
tests/DataStorage/Cache/NullCacheTest.php
Normal file
35
tests/DataStorage/Cache/NullCacheTest.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Cache;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Cache\NullCache;
|
||||||
|
|
||||||
|
class NullCacheTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testCache()
|
||||||
|
{
|
||||||
|
$cache = new NullCache();
|
||||||
|
self::assertTrue($cache->add(1, 1));
|
||||||
|
self::assertEquals(null, $cache->get(1));
|
||||||
|
self::assertTrue($cache->delete(1));
|
||||||
|
self::assertTrue($cache->flush(1));
|
||||||
|
self::assertTrue($cache->flushAll());
|
||||||
|
self::assertTrue($cache->replace(1, 1));
|
||||||
|
self::assertEquals([], $cache->stats());
|
||||||
|
self::assertEquals(0, $cache->getThreshold());
|
||||||
|
}
|
||||||
|
}
|
||||||
0
tests/DataStorage/Cache/RedisCacheTest.php
Normal file
0
tests/DataStorage/Cache/RedisCacheTest.php
Normal file
0
tests/DataStorage/Cache/WinCacheTest.php
Normal file
0
tests/DataStorage/Cache/WinCacheTest.php
Normal file
72
tests/DataStorage/Cookie/CookieJarTest.php
Normal file
72
tests/DataStorage/Cookie/CookieJarTest.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Cookie;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Cookie\CookieJar;
|
||||||
|
use phpOMS\DataStorage\LockException;
|
||||||
|
|
||||||
|
class CookieJarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
$jar = new CookieJar();
|
||||||
|
|
||||||
|
self::assertFalse(CookieJar::isLocked());
|
||||||
|
self::assertFalse($jar->delete('abc'));
|
||||||
|
self::assertFalse($jar->delete('asd'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCookie()
|
||||||
|
{
|
||||||
|
$jar = new CookieJar();
|
||||||
|
|
||||||
|
self::assertTrue($jar->set('test', 'value'));
|
||||||
|
self::assertFalse($jar->set('test', 'value', 86400, '/', null, false, true, false));
|
||||||
|
self::assertTrue($jar->set('test2', 'value2', 86400, '/', null, false, true, false));
|
||||||
|
self::assertTrue($jar->set('test3', 'value3', 86400, '/', null, false, true, false));
|
||||||
|
|
||||||
|
// header already set
|
||||||
|
//self::assertTrue($jar->delete('test2'));
|
||||||
|
//self::assertFalse($jar->delete('test2'));
|
||||||
|
|
||||||
|
self::assertTrue($jar->remove('test2'));
|
||||||
|
self::assertFalse($jar->remove('test2'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\LockException
|
||||||
|
*/
|
||||||
|
public function testDeleteLocked()
|
||||||
|
{
|
||||||
|
$jar = new CookieJar();
|
||||||
|
self::assertTrue($jar->set('test', 'value'));
|
||||||
|
|
||||||
|
CookieJar::lock();
|
||||||
|
$jar->delete('test');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\LockException
|
||||||
|
*/
|
||||||
|
public function testSaveLocked()
|
||||||
|
{
|
||||||
|
CookieJar::lock();
|
||||||
|
|
||||||
|
$jar = new CookieJar();
|
||||||
|
$jar->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Connection;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\ConnectionFactory;
|
||||||
|
use phpOMS\DataStorage\Database\Connection\MysqlConnection;
|
||||||
|
|
||||||
|
class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testCreate()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf(
|
||||||
|
MysqlConnection::class,
|
||||||
|
ConnectionFactory::create($GLOBALS['CONFIG']['db']['core']['masters']['admin'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testInvalidDatabaseType()
|
||||||
|
{
|
||||||
|
ConnectionFactory::create(['db' => 'invalid']);
|
||||||
|
}
|
||||||
|
}
|
||||||
101
tests/DataStorage/Database/Connection/MysqlConnectionTest.php
Normal file
101
tests/DataStorage/Database/Connection/MysqlConnectionTest.php
Normal file
|
|
@ -0,0 +1,101 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Connection;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\MysqlConnection;
|
||||||
|
use phpOMS\DataStorage\Database\DatabaseStatus;
|
||||||
|
|
||||||
|
class MysqlConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testConnect()
|
||||||
|
{
|
||||||
|
$mysql = new MysqlConnection($GLOBALS['CONFIG']['db']['core']['masters']['admin']);
|
||||||
|
|
||||||
|
self::assertEquals(DatabaseStatus::OK, $mysql->getStatus());
|
||||||
|
self::assertEquals($GLOBALS['CONFIG']['db']['core']['masters']['admin']['database'], $mysql->getDatabase());
|
||||||
|
self::assertEquals($GLOBALS['CONFIG']['db']['core']['masters']['admin']['host'], $mysql->getHost());
|
||||||
|
self::assertEquals((int) $GLOBALS['CONFIG']['db']['core']['masters']['admin']['port'], $mysql->getPort());
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\MysqlGrammar', $mysql->getGrammar());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException
|
||||||
|
*/
|
||||||
|
public function testInvalidDatabaseType()
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
|
unset($db['db']);
|
||||||
|
|
||||||
|
$mysql = new MysqlConnection($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException
|
||||||
|
*/
|
||||||
|
public function testInvalidHost()
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
|
unset($db['host']);
|
||||||
|
|
||||||
|
$mysql = new MysqlConnection($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException
|
||||||
|
*/
|
||||||
|
public function testInvalidPort()
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
|
unset($db['port']);
|
||||||
|
|
||||||
|
$mysql = new MysqlConnection($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException
|
||||||
|
*/
|
||||||
|
public function testInvalidDatabase()
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
|
unset($db['database']);
|
||||||
|
|
||||||
|
$mysql = new MysqlConnection($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException
|
||||||
|
*/
|
||||||
|
public function testInvalidLogin()
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
|
unset($db['login']);
|
||||||
|
|
||||||
|
$mysql = new MysqlConnection($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException
|
||||||
|
*/
|
||||||
|
public function testInvalidPassword()
|
||||||
|
{
|
||||||
|
$db = $GLOBALS['CONFIG']['db']['core']['masters']['admin'];
|
||||||
|
unset($db['password']);
|
||||||
|
|
||||||
|
$mysql = new MysqlConnection($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Connection;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\PostgresConnection;
|
||||||
|
|
||||||
|
class PostgresConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Connection;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\SQLiteConnection;
|
||||||
|
|
||||||
|
class SQLiteConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Connection;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\SqlServerConnection;
|
||||||
|
|
||||||
|
class SqlServerConnectionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
174
tests/DataStorage/Database/DataMapperAbstractTest.php
Normal file
174
tests/DataStorage/Database/DataMapperAbstractTest.php
Normal file
|
|
@ -0,0 +1,174 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\MysqlConnection;
|
||||||
|
use phpOMS\DataStorage\Database\DatabaseStatus;
|
||||||
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
|
|
||||||
|
use Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel\BaseModel;
|
||||||
|
use Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel\BaseModelMapper;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
require_once __DIR__ . '/../../../../../config.php';
|
||||||
|
|
||||||
|
class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
protected $model = null;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->model = new BaseModel();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `oms_test_base` (
|
||||||
|
`test_base_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_base_string` varchar(254) NOT NULL,
|
||||||
|
`test_base_int` int(11) NOT NULL,
|
||||||
|
`test_base_bool` tinyint(1) DEFAULT NULL,
|
||||||
|
`test_base_null` int(11) DEFAULT NULL,
|
||||||
|
`test_base_float` decimal(5, 4) DEFAULT NULL,
|
||||||
|
`test_base_belongs_to_one` int(11) DEFAULT NULL,
|
||||||
|
`test_base_owns_one_self` int(11) DEFAULT NULL,
|
||||||
|
`test_base_json` varchar(254) DEFAULT NULL,
|
||||||
|
`test_base_json_serializable` varchar(254) DEFAULT NULL,
|
||||||
|
`test_base_datetime` datetime DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`test_base_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `oms_test_belongs_to_one` (
|
||||||
|
`test_belongs_to_one_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_belongs_to_one_string` varchar(254) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_belongs_to_one_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `oms_test_owns_one` (
|
||||||
|
`test_owns_one_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_owns_one_string` varchar(254) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_owns_one_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `oms_test_has_many_direct` (
|
||||||
|
`test_has_many_direct_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_has_many_direct_string` varchar(254) NOT NULL,
|
||||||
|
`test_has_many_direct_to` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_has_many_direct_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `oms_test_has_many_rel` (
|
||||||
|
`test_has_many_rel_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_has_many_rel_string` varchar(254) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_has_many_rel_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `oms_test_has_many_rel_relations` (
|
||||||
|
`test_has_many_rel_relations_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_has_many_rel_relations_src` int(11) NOT NULL,
|
||||||
|
`test_has_many_rel_relations_dest` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_has_many_rel_relations_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_base')->execute();
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_belongs_to_one')->execute();
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_owns_one')->execute();
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_direct')->execute();
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel')->execute();
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare('DROP TABLE oms_test_has_many_rel_relations')->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreate()
|
||||||
|
{
|
||||||
|
self::assertGreaterThan(0, BaseModelMapper::create($this->model));
|
||||||
|
self::assertGreaterThan(0, $this->model->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRead()
|
||||||
|
{
|
||||||
|
$id = BaseModelMapper::create($this->model);
|
||||||
|
$modelR = BaseModelMapper::get($id);
|
||||||
|
|
||||||
|
self::assertEquals($this->model->id, $modelR->id);
|
||||||
|
self::assertEquals($this->model->string, $modelR->string);
|
||||||
|
self::assertEquals($this->model->int, $modelR->int);
|
||||||
|
self::assertEquals($this->model->bool, $modelR->bool);
|
||||||
|
self::assertEquals($this->model->float, $modelR->float);
|
||||||
|
self::assertEquals($this->model->null, $modelR->null);
|
||||||
|
self::assertEquals($this->model->datetime->format('Y-m-d'), $modelR->datetime->format('Y-m-d'));
|
||||||
|
|
||||||
|
// todo implement these
|
||||||
|
//self::assertEquals('123', $modelR->serializable);
|
||||||
|
//self::assertEquals($this->model->json, $modelR->json);
|
||||||
|
//self::assertEquals([1, 2, 3], $modelR->jsonSerializable);
|
||||||
|
|
||||||
|
self::assertEquals(2, count($modelR->hasManyDirect));
|
||||||
|
self::assertEquals(2, count($modelR->hasManyRelations));
|
||||||
|
self::assertEquals(reset($this->model->hasManyDirect)->string, reset($modelR->hasManyDirect)->string);
|
||||||
|
self::assertEquals(reset($this->model->hasManyRelations)->string, reset($modelR->hasManyRelations)->string);
|
||||||
|
self::assertEquals($this->model->ownsOneSelf->string, $modelR->ownsOneSelf->string);
|
||||||
|
self::assertEquals($this->model->belongsToOne->string, $modelR->belongsToOne->string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUpdate()
|
||||||
|
{
|
||||||
|
$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->datetime = new \DateTime('now');
|
||||||
|
|
||||||
|
$id2 = BaseModelMapper::update($modelR);
|
||||||
|
$modelR2 = BaseModelMapper::get($id2);
|
||||||
|
|
||||||
|
self::assertEquals($modelR->string, $modelR2->string);
|
||||||
|
self::assertEquals($modelR->int, $modelR2->int);
|
||||||
|
self::assertEquals($modelR->bool, $modelR2->bool);
|
||||||
|
self::assertEquals($modelR->float, $modelR2->float);
|
||||||
|
self::assertEquals($modelR->null, $modelR2->null);
|
||||||
|
self::assertEquals($modelR->datetime->format('Y-m-d'), $modelR2->datetime->format('Y-m-d'));
|
||||||
|
|
||||||
|
// todo test update relations
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDelete()
|
||||||
|
{
|
||||||
|
$id = BaseModelMapper::create($this->model);
|
||||||
|
BaseModelMapper::delete($this->model);
|
||||||
|
$modelR = BaseModelMapper::get($id);
|
||||||
|
|
||||||
|
self::assertInstanceOf('\Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel\NullBaseModel', $modelR);
|
||||||
|
|
||||||
|
// todo test if relations also deleted
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
32
tests/DataStorage/Database/DatabaseExceptionFactoryTest.php
Normal file
32
tests/DataStorage/Database/DatabaseExceptionFactoryTest.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DatabaseExceptionFactory;
|
||||||
|
|
||||||
|
class DatabaseExceptionFactoryTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testException()
|
||||||
|
{
|
||||||
|
self::assertEquals('\PDOException', DatabaseExceptionFactory::createException(new \PDOException()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testExceptionMessage()
|
||||||
|
{
|
||||||
|
self::assertEquals('', DatabaseExceptionFactory::createExceptionMessage(new \PDOException()));
|
||||||
|
}
|
||||||
|
}
|
||||||
55
tests/DataStorage/Database/DatabasePoolTest.php
Normal file
55
tests/DataStorage/Database/DatabasePoolTest.php
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\MysqlConnection;
|
||||||
|
use phpOMS\DataStorage\Database\DatabaseStatus;
|
||||||
|
use phpOMS\DataStorage\Database\DatabasePool;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
require_once __DIR__ . '/../../../../../config.php';
|
||||||
|
|
||||||
|
class DatabasePoolTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testBasicConnection()
|
||||||
|
{
|
||||||
|
$dbPool = new DatabasePool();
|
||||||
|
/** @var array $CONFIG */
|
||||||
|
$dbPool->create('core', $GLOBALS['CONFIG']['db']['core']['masters']['admin']);
|
||||||
|
|
||||||
|
self::assertEquals($dbPool->get()->getStatus(), DatabaseStatus::OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetSet()
|
||||||
|
{
|
||||||
|
$dbPool = new DatabasePool();
|
||||||
|
/** @var array $CONFIG */
|
||||||
|
|
||||||
|
self::assertTrue($dbPool->create('core', $GLOBALS['CONFIG']['db']['core']['masters']['admin']));
|
||||||
|
self::assertFalse($dbPool->create('core', $GLOBALS['CONFIG']['db']['core']['masters']['admin']));
|
||||||
|
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Connection\ConnectionAbstract', $dbPool->get());
|
||||||
|
self::assertNull($dbPool->get('doesNotExist'));
|
||||||
|
self::assertEquals($dbPool->get('core'), $dbPool->get());
|
||||||
|
|
||||||
|
self::assertFalse($dbPool->remove('cores'));
|
||||||
|
self::assertTrue($dbPool->remove('core'));
|
||||||
|
|
||||||
|
self::assertNull($dbPool->get());
|
||||||
|
|
||||||
|
self::assertTrue($dbPool->add('core', new MysqlConnection($GLOBALS['CONFIG']['db']['core']['masters']['admin'])));
|
||||||
|
self::assertFalse($dbPool->add('core', new MysqlConnection($GLOBALS['CONFIG']['db']['core']['masters']['admin'])));
|
||||||
|
}
|
||||||
|
}
|
||||||
33
tests/DataStorage/Database/DatabaseStatusTest.php
Normal file
33
tests/DataStorage/Database/DatabaseStatusTest.php
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DatabaseStatus;
|
||||||
|
|
||||||
|
class DatabaseStatusTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(6, count(DatabaseStatus::getConstants()));
|
||||||
|
self::assertEquals(0, DatabaseStatus::OK);
|
||||||
|
self::assertEquals(1, DatabaseStatus::MISSING_DATABASE);
|
||||||
|
self::assertEquals(2, DatabaseStatus::MISSING_TABLE);
|
||||||
|
self::assertEquals(3, DatabaseStatus::FAILURE);
|
||||||
|
self::assertEquals(4, DatabaseStatus::READONLY);
|
||||||
|
self::assertEquals(5, DatabaseStatus::CLOSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
tests/DataStorage/Database/DatabaseTypeTest.php
Normal file
30
tests/DataStorage/Database/DatabaseTypeTest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DatabaseType;
|
||||||
|
|
||||||
|
class DatabaseTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(5, count(DatabaseType::getConstants()));
|
||||||
|
self::assertEquals('mysql', DatabaseType::MYSQL);
|
||||||
|
self::assertEquals('sqlite', DatabaseType::SQLITE);
|
||||||
|
self::assertEquals('mssql', DatabaseType::SQLSRV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?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 Tests\PHPUnit\phpOMS\DataStorage\Database\Exception;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Exception\InvalidConnectionConfigException;
|
||||||
|
|
||||||
|
class InvalidConnectionConfigExceptionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testException()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf(\InvalidArgumentException::class, new InvalidConnectionConfigException(''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?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 Tests\PHPUnit\phpOMS\DataStorage\Database\Exception;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Exception\InvalidMapperException;
|
||||||
|
|
||||||
|
class InvalidMapperExceptionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testException()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf(\RuntimeException::class, new InvalidMapperException(''));
|
||||||
|
}
|
||||||
|
}
|
||||||
244
tests/DataStorage/Database/Query/BuilderTest.php
Normal file
244
tests/DataStorage/Database/Query/BuilderTest.php
Normal file
|
|
@ -0,0 +1,244 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Connection\MysqlConnection;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
require_once __DIR__ . '/../../../../../../config.php';
|
||||||
|
|
||||||
|
class BuilderTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
protected $con = null;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->con = new MysqlConnection($GLOBALS['CONFIG']['db']['core']['masters']['admin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlSelect()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT DISTINCT `a`.`test` FROM `a` WHERE `a`.`test` = 1;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->distinct()->from('a')->where('a.test', '=', 1)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$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);
|
||||||
|
$datetime = new \Datetime('now');
|
||||||
|
$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);
|
||||||
|
$sql = 'SELECT `a`.`test`, `b`.`test` FROM `a`, `b` WHERE `a`.`test` = \'abc\' AND `b`.`test` = 2;';
|
||||||
|
$systemIdentifier = '`';
|
||||||
|
self::assertEquals($sql, $query->select('a.test', function () {
|
||||||
|
return '`b`.`test`';
|
||||||
|
})->from('a', function () use ($systemIdentifier) {
|
||||||
|
return $systemIdentifier . 'b' . $systemIdentifier;
|
||||||
|
})->where(['a.test', 'b.test'], ['=', '='], ['abc', 2], ['and', 'and'])->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test`, `b`.`test` FROM `a`, `b` WHERE `a`.`test` = \'abc\' ORDER BY `a`.`test` ASC, `b`.`test` DESC;';
|
||||||
|
self::assertEquals($sql,
|
||||||
|
$query->select('a.test', 'b.test')
|
||||||
|
->from('a', 'b')
|
||||||
|
->where('a.test', '=', 'abc')
|
||||||
|
->orderBy(['a.test', 'b.test', ], ['ASC', 'DESC', ])
|
||||||
|
->toSql()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlOrder()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 ORDER BY `a`.`test` DESC;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->newest('a.test')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 ORDER BY `a`.`test` ASC;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->oldest('a.test')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 ORDER BY `a`.`test` DESC;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy('a.test', 'DESC')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 ORDER BY `a`.`test` ASC;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy('a.test', 'ASC')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 ORDER BY `a`.`test`, `a`.`test2` DESC;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy(['a.test', 'a.test2'], ['DESC', 'DESC'])->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 ORDER BY `a`.`test`, `a`.`test2` ASC;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orderBy(['a.test', 'a.test2'], 'ASC')->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlOffsetLimit()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 LIMIT 3;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->limit(3)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 OFFSET 3;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->offset(3)->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlGroup()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 GROUP BY `a`;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->groupBy('a')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 GROUP BY `a`, `b`;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->groupBy('a')->groupBy('b')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->groupBy('a', 'b')->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlWheres()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 0;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', false)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', true)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = \'string\';';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 'string')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1.23;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1.23)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 AND `a`.`test2` = 2;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->where('a.test2', '=', 2, 'and')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 AND `a`.`test2` = 2;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->andWhere('a.test2', '=', 2)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 OR `a`.`test2` = 2;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->where('a.test2', '=', 2, 'or')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 OR `a`.`test2` = 2;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->orWhere('a.test2', '=', 2)->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 OR `a`.`test2` IS NULL;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereNull('a.test2', 'or')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 OR `a`.`test2` IS NOT NULL;';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereNotNull('a.test2', 'or')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 OR `a`.`test2` IN (1, 2, 3);';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereIn('a.test2', [1, 2, 3], 'or')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'SELECT `a`.`test` FROM `a` WHERE `a`.`test` = 1 OR `a`.`test2` IN (\'a\', \'b\', \'c\');';
|
||||||
|
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->whereIn('a.test2', ['a', 'b', 'c'], 'or')->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlInsert()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'INSERT INTO `a` VALUES (1, \'test\');';
|
||||||
|
self::assertEquals($sql, $query->insert()->into('a')->values(1, 'test')->toSql());
|
||||||
|
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'INSERT INTO `a` (`test`, `test2`) VALUES (1, \'test\');';
|
||||||
|
self::assertEquals($sql, $query->insert('test', 'test2')->into('a')->values(1, 'test')->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlDelete()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'DELETE FROM `a` WHERE `a`.`test` = 1;';
|
||||||
|
self::assertEquals($sql, $query->delete()->from('a')->where('a.test', '=', 1)->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMysqlUpdate()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
$sql = 'UPDATE `a` SET `a`.`test` = 1, `a`.`test2` = 2 WHERE `a`.`test` = 1;';
|
||||||
|
self::assertEquals($sql, $query->update('a')->set(['a.test' => 1])->set(['a.test2' => 2])->where('a.test', '=', 1)->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRaw()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con);
|
||||||
|
self::assertEquals('SELECT test.val FROM test;', $query->raw('SELECT test.val FROM test;')->toSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Exception
|
||||||
|
*/
|
||||||
|
public function testReadOnlyRaw()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con, true);
|
||||||
|
$query->raw('DROP DATABASE oms;');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Exception
|
||||||
|
*/
|
||||||
|
public function testReadOnlyInsert()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con, true);
|
||||||
|
$query->insert('test');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Exception
|
||||||
|
*/
|
||||||
|
public function testReadOnlyUpdate()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con, true);
|
||||||
|
$query->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Exception
|
||||||
|
*/
|
||||||
|
public function testReadOnlyDelete()
|
||||||
|
{
|
||||||
|
$query = new Builder($this->con, true);
|
||||||
|
$query->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Query/ColumnTest.php
Normal file
27
tests/DataStorage/Database/Query/ColumnTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Column;
|
||||||
|
|
||||||
|
class ColumnTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Query/CountTest.php
Normal file
27
tests/DataStorage/Database/Query/CountTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Count;
|
||||||
|
|
||||||
|
class CountTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Query/ExpressionTest.php
Normal file
27
tests/DataStorage/Database/Query/ExpressionTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Expression;
|
||||||
|
|
||||||
|
class ExpressionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Query/FromTest.php
Normal file
27
tests/DataStorage/Database/Query/FromTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\From;
|
||||||
|
|
||||||
|
class FromTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
32
tests/DataStorage/Database/Query/Grammar/GrammarTest.php
Normal file
32
tests/DataStorage/Database/Query/Grammar/GrammarTest.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Grammar\Grammar;
|
||||||
|
|
||||||
|
class GrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
$grammar = new Grammar();
|
||||||
|
self::assertEquals('Y-m-d H:i:s', $grammar->getDateFormat());
|
||||||
|
self::assertEquals('', $grammar->getTablePrefix());
|
||||||
|
|
||||||
|
$grammar->setTablePrefix('oms_');
|
||||||
|
self::assertEquals('oms_', $grammar->getTablePrefix());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Grammar\MicrosoftGrammar;
|
||||||
|
|
||||||
|
class MicrosoftGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new MicrosoftGrammar());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Grammar\MysqlGrammar;
|
||||||
|
use phpOMS\Utils\TestUtils;
|
||||||
|
|
||||||
|
class MysqlGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new MysqlGrammar());
|
||||||
|
self::assertEquals('`', TestUtils::getMember(new MysqlGrammar(), 'systemIdentifier'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Grammar\OracleGrammar;
|
||||||
|
use phpOMS\Utils\TestUtils;
|
||||||
|
|
||||||
|
class OracleGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new OracleGrammar());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Grammar\PostgresGrammar;
|
||||||
|
|
||||||
|
class PostgresGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new PostgresGrammar());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Grammar\SQLiteGrammar;
|
||||||
|
use phpOMS\Utils\TestUtils;
|
||||||
|
|
||||||
|
class SQLiteGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testDefault()
|
||||||
|
{
|
||||||
|
self::assertInstanceOf('\phpOMS\DataStorage\Database\Query\Grammar\Grammar', new SqliteGrammar());
|
||||||
|
self::assertEquals('`', TestUtils::getMember(new SqliteGrammar(), 'systemIdentifier'));
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Query/IntoTest.php
Normal file
27
tests/DataStorage/Database/Query/IntoTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Into;
|
||||||
|
|
||||||
|
class IntoTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
40
tests/DataStorage/Database/Query/JoinTypeTest.php
Normal file
40
tests/DataStorage/Database/Query/JoinTypeTest.php
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\JoinType;
|
||||||
|
|
||||||
|
class JoinTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(11, count(JoinType::getConstants()));
|
||||||
|
self::assertEquals(JoinType::getConstants(), array_unique(JoinType::getConstants()));
|
||||||
|
|
||||||
|
self::assertEquals('JOIN', JoinType::JOIN);
|
||||||
|
self::assertEquals('LEFT JOIN', JoinType::LEFT_JOIN);
|
||||||
|
self::assertEquals('LEFT OUTER JOIN', JoinType::LEFT_OUTER_JOIN);
|
||||||
|
self::assertEquals('LEFT INNER JOIN', JoinType::LEFT_INNER_JOIN);
|
||||||
|
self::assertEquals('RIGHT JOIN', JoinType::RIGHT_JOIN);
|
||||||
|
self::assertEquals('RIGHT OUTER JOIN', JoinType::RIGHT_OUTER_JOIN);
|
||||||
|
self::assertEquals('RIGHT INNER JOIN', JoinType::RIGHT_INNER_JOIN);
|
||||||
|
self::assertEquals('OUTER JOIN', JoinType::OUTER_JOIN);
|
||||||
|
self::assertEquals('INNER JOIN', JoinType::INNER_JOIN);
|
||||||
|
self::assertEquals('CROSS JOIN', JoinType::CROSS_JOIN);
|
||||||
|
self::assertEquals('FULL OUTER JOIN', JoinType::FULL_OUTER_JOIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
tests/DataStorage/Database/Query/QueryTypeTest.php
Normal file
35
tests/DataStorage/Database/Query/QueryTypeTest.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\QueryType;
|
||||||
|
|
||||||
|
class QueryTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(6, count(QueryType::getConstants()));
|
||||||
|
self::assertEquals(QueryType::getConstants(), array_unique(QueryType::getConstants()));
|
||||||
|
|
||||||
|
self::assertEquals(0, QueryType::SELECT);
|
||||||
|
self::assertEquals(1, QueryType::INSERT);
|
||||||
|
self::assertEquals(2, QueryType::UPDATE);
|
||||||
|
self::assertEquals(3, QueryType::DELETE);
|
||||||
|
self::assertEquals(4, QueryType::RANDOM);
|
||||||
|
self::assertEquals(5, QueryType::RAW);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Query/SelectTest.php
Normal file
27
tests/DataStorage/Database/Query/SelectTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Select;
|
||||||
|
|
||||||
|
class SelectTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
28
tests/DataStorage/Database/Query/WhereTest.php
Normal file
28
tests/DataStorage/Database/Query/WhereTest.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Query\Where;
|
||||||
|
|
||||||
|
class WhereTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
34
tests/DataStorage/Database/RelationTypeTest.php
Normal file
34
tests/DataStorage/Database/RelationTypeTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
|
|
||||||
|
class RelationTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(7, count(RelationType::getConstants()));
|
||||||
|
self::assertEquals(1, RelationType::NONE);
|
||||||
|
self::assertEquals(2, RelationType::NEWEST);
|
||||||
|
self::assertEquals(4, RelationType::BELONGS_TO);
|
||||||
|
self::assertEquals(8, RelationType::OWNS_ONE);
|
||||||
|
self::assertEquals(16, RelationType::HAS_MANY);
|
||||||
|
self::assertEquals(32, RelationType::ALL);
|
||||||
|
self::assertEquals(64, RelationType::REFERENCE);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Schema/BuilderTest.php
Normal file
27
tests/DataStorage/Database/Schema/BuilderTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Builder;
|
||||||
|
|
||||||
|
class BuilderTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema\Exception;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Exception\TableException;
|
||||||
|
|
||||||
|
class TableExceptionTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
27
tests/DataStorage/Database/Schema/Grammar/GrammarTest.php
Normal file
27
tests/DataStorage/Database/Schema/Grammar/GrammarTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Grammar\Grammar;
|
||||||
|
|
||||||
|
class GrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Grammar\MysqlGrammar;
|
||||||
|
|
||||||
|
class MysqlGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Grammar\PostgresGrammar;
|
||||||
|
|
||||||
|
class PostgresGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Grammar\SQLiteGrammar;
|
||||||
|
|
||||||
|
class SQLiteGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema\Grammar;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\Grammar\SqlServerGrammar;
|
||||||
|
|
||||||
|
class SqlServerGrammarTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholder()
|
||||||
|
{
|
||||||
|
self::markTestIncomplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
33
tests/DataStorage/Database/Schema/QueryTypeTest.php
Normal file
33
tests/DataStorage/Database/Schema/QueryTypeTest.php
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\Schema;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Schema\QueryType;
|
||||||
|
|
||||||
|
class QueryTypeTest extends \PHPUnit\Framework\TestCase
|
||||||
|
{
|
||||||
|
public function testEnums()
|
||||||
|
{
|
||||||
|
self::assertEquals(4, count(QueryType::getConstants()));
|
||||||
|
self::assertEquals(QueryType::getConstants(), array_unique(QueryType::getConstants()));
|
||||||
|
|
||||||
|
self::assertEquals(0, QueryType::SELECT);
|
||||||
|
self::assertEquals(1, QueryType::CREATE);
|
||||||
|
self::assertEquals(2, QueryType::DROP);
|
||||||
|
self::assertEquals(3, QueryType::ALTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
80
tests/DataStorage/Database/TestModel/BaseModel.php
Normal file
80
tests/DataStorage/Database/TestModel/BaseModel.php
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class BaseModel
|
||||||
|
{
|
||||||
|
public $id = 0;
|
||||||
|
|
||||||
|
public $string = 'Base';
|
||||||
|
|
||||||
|
public $int = 11;
|
||||||
|
|
||||||
|
public $bool = false;
|
||||||
|
|
||||||
|
public $float = 1.3;
|
||||||
|
|
||||||
|
public $null = null;
|
||||||
|
|
||||||
|
public $datetime = null;
|
||||||
|
|
||||||
|
public $hasManyDirect = [];
|
||||||
|
|
||||||
|
public $hasManyRelations = [];
|
||||||
|
|
||||||
|
public $ownsOneSelf = 0;
|
||||||
|
|
||||||
|
public $belongsToOne = 0;
|
||||||
|
|
||||||
|
public $serializable = null;
|
||||||
|
|
||||||
|
public $json = [1, 2, 3];
|
||||||
|
|
||||||
|
public $jsonSerializable = null;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->datetime = new \DateTime('2005-10-11');
|
||||||
|
|
||||||
|
$this->hasManyDirect = [
|
||||||
|
new ManyToManyDirectModel(),
|
||||||
|
new ManyToManyDirectModel(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->hasManyRelations = [
|
||||||
|
new ManyToManyRelModel(),
|
||||||
|
new ManyToManyRelModel(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->ownsOneSelf = new OwnsOneModel();
|
||||||
|
$this->belongsToOne = new BelongsToModel();
|
||||||
|
|
||||||
|
$this->serializable = new class implements \Serializable {
|
||||||
|
public function serialize() {
|
||||||
|
return '123';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unserialize($data) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
$this->jsonSerializable = new class implements \JsonSerializable {
|
||||||
|
public function jsonSerialize() {
|
||||||
|
return [1, 2, 3];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
80
tests/DataStorage/Database/TestModel/BaseModelMapper.php
Normal file
80
tests/DataStorage/Database/TestModel/BaseModelMapper.php
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Column;
|
||||||
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
|
|
||||||
|
class BaseModelMapper extends DataMapperAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $columns = [
|
||||||
|
'test_base_id' => ['name' => 'test_base_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_base_string' => ['name' => 'test_base_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
'test_base_int' => ['name' => 'test_base_int', 'type' => 'int', 'internal' => 'int'],
|
||||||
|
'test_base_bool' => ['name' => 'test_base_bool', 'type' => 'bool', 'internal' => 'bool'],
|
||||||
|
'test_base_null' => ['name' => 'test_base_null', 'type' => 'int', 'internal' => 'null'],
|
||||||
|
'test_base_float' => ['name' => 'test_base_float', 'type' => 'float', 'internal' => 'float'],
|
||||||
|
'test_base_json' => ['name' => 'test_base_json', 'type' => 'Json', 'internal' => 'json'],
|
||||||
|
'test_base_jsonSerialize' => ['name' => 'test_base_jsonSerialize', 'type' => 'jsonSerializable', 'internal' => 'jsonSerialize'],
|
||||||
|
'test_base_datetime' => ['name' => 'test_base_datetime', 'type' => 'DateTime', 'internal' => 'datetime'],
|
||||||
|
'test_base_owns_one_self' => ['name' => 'test_base_owns_one_self', 'type' => 'int', 'internal' => 'ownsOneSelf'],
|
||||||
|
'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $belongsTo = [
|
||||||
|
'belongsToOne' => [
|
||||||
|
'mapper' => BelongsToModelMapper::class,
|
||||||
|
'dest' => 'test_base_belongs_to_one',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $ownsOne = [
|
||||||
|
'ownsOneSelf' => [
|
||||||
|
'mapper' => OwnsOneModelMapper::class,
|
||||||
|
'dest' => 'test_base_owns_one_self',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $hasMany = [
|
||||||
|
'hasManyDirect' => [
|
||||||
|
'mapper' => ManyToManyDirectModelMapper::class,
|
||||||
|
'table' => 'test_has_many_direct',
|
||||||
|
'dst' => 'test_has_many_direct_to',
|
||||||
|
'src' => null,
|
||||||
|
],
|
||||||
|
'hasManyRelations' => [
|
||||||
|
'mapper' => ManyToManyRelModelMapper::class,
|
||||||
|
'table' => 'test_has_many_rel_relations',
|
||||||
|
'dst' => 'test_has_many_rel_relations_dest',
|
||||||
|
'src' => 'test_has_many_rel_relations_src',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $table = 'test_base';
|
||||||
|
|
||||||
|
protected static $createdAt = 'test_base_datetime';
|
||||||
|
|
||||||
|
protected static $primaryField = 'test_base_id';
|
||||||
|
}
|
||||||
24
tests/DataStorage/Database/TestModel/BelongsToModel.php
Normal file
24
tests/DataStorage/Database/TestModel/BelongsToModel.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class BelongsToModel
|
||||||
|
{
|
||||||
|
public $id = 0;
|
||||||
|
|
||||||
|
public $string = 'BelongsTo';
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Column;
|
||||||
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
|
|
||||||
|
class BelongsToModelMapper extends DataMapperAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $columns = [
|
||||||
|
'test_belongs_to_one_id' => ['name' => 'test_belongs_to_one_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_belongs_to_one_string' => ['name' => 'test_belongs_to_one_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $table = 'test_belongs_to_one';
|
||||||
|
|
||||||
|
protected static $primaryField = 'test_belongs_to_one_id';
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class ManyToManyDirectModel
|
||||||
|
{
|
||||||
|
public $id = 0;
|
||||||
|
|
||||||
|
public $string = 'ManyToManyDirect';
|
||||||
|
|
||||||
|
public $to = 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Column;
|
||||||
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
|
|
||||||
|
class ManyToManyDirectModelMapper extends DataMapperAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $columns = [
|
||||||
|
'test_has_many_direct_id' => ['name' => 'test_has_many_direct_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_has_many_direct_string' => ['name' => 'test_has_many_direct_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
'test_has_many_direct_to' => ['name' => 'test_has_many_direct_to', 'type' => 'int', 'internal' => 'to'],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $table = 'test_has_many_direct';
|
||||||
|
|
||||||
|
protected static $primaryField = 'test_has_many_direct_id';
|
||||||
|
}
|
||||||
24
tests/DataStorage/Database/TestModel/ManyToManyRelModel.php
Normal file
24
tests/DataStorage/Database/TestModel/ManyToManyRelModel.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class ManyToManyRelModel
|
||||||
|
{
|
||||||
|
public $id = 0;
|
||||||
|
|
||||||
|
public $string = 'ManyToManyRel';
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?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
|
||||||
|
*/
|
||||||
|
declare(strict_types = 1);
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
use phpOMS\DataStorage\Database\Query\Column;
|
||||||
|
use phpOMS\DataStorage\Database\RelationType;
|
||||||
|
|
||||||
|
class ManyToManyRelModelMapper extends DataMapperAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $columns = [
|
||||||
|
'test_has_many_rel_id' => ['name' => 'test_has_many_rel_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_has_many_rel_string' => ['name' => 'test_has_many_rel_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected static $table = 'test_has_many_rel';
|
||||||
|
|
||||||
|
protected static $primaryField = 'test_has_many_rel_id';
|
||||||
|
}
|
||||||
21
tests/DataStorage/Database/TestModel/NullBaseModel.php
Normal file
21
tests/DataStorage/Database/TestModel/NullBaseModel.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.1
|
||||||
|
*
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://website.orange-management.de
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Tests\PHPUnit\phpOMS\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../../../../phpOMS/Autoloader.php';
|
||||||
|
|
||||||
|
class NullBaseModel extends BaseModel
|
||||||
|
{
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user