mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 14:58:42 +00:00
fix tests
This commit is contained in:
parent
9b71428f88
commit
c224209c28
|
|
@ -52,7 +52,9 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
`test_base_null` int(11) DEFAULT NULL,
|
`test_base_null` int(11) DEFAULT NULL,
|
||||||
`test_base_float` decimal(5, 4) DEFAULT NULL,
|
`test_base_float` decimal(5, 4) DEFAULT NULL,
|
||||||
`test_base_belongs_to_one` int(11) DEFAULT NULL,
|
`test_base_belongs_to_one` int(11) DEFAULT NULL,
|
||||||
|
`test_base_belongs_top_one` int(11) DEFAULT NULL,
|
||||||
`test_base_owns_one_self` int(11) DEFAULT NULL,
|
`test_base_owns_one_self` int(11) DEFAULT NULL,
|
||||||
|
`test_base_owns_onep_self` int(11) DEFAULT NULL,
|
||||||
`test_base_json` varchar(254) DEFAULT NULL,
|
`test_base_json` varchar(254) DEFAULT NULL,
|
||||||
`test_base_json_serializable` varchar(254) DEFAULT NULL,
|
`test_base_json_serializable` varchar(254) DEFAULT NULL,
|
||||||
`test_base_serializable` varchar(254) DEFAULT NULL,
|
`test_base_serializable` varchar(254) DEFAULT NULL,
|
||||||
|
|
@ -113,6 +115,49 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
|
||||||
PRIMARY KEY (`test_has_many_rel_relations_id`)
|
PRIMARY KEY (`test_has_many_rel_relations_id`)
|
||||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||||
)->execute();
|
)->execute();
|
||||||
|
|
||||||
|
// private
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `test_has_many_directp` (
|
||||||
|
`test_has_many_directp_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_has_many_directp_string` varchar(254) NOT NULL,
|
||||||
|
`test_has_many_directp_to` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_has_many_directp_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `test_has_many_relp` (
|
||||||
|
`test_has_many_relp_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_has_many_relp_string` varchar(254) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_has_many_relp_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `test_has_many_rel_relationsp` (
|
||||||
|
`test_has_many_rel_relationsp_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_has_many_rel_relationsp_src` int(11) NOT NULL,
|
||||||
|
`test_has_many_rel_relationsp_dest` int(11) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_has_many_rel_relationsp_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `test_belongs_to_onep` (
|
||||||
|
`test_belongs_to_onep_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_belongs_to_onep_string` varchar(254) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_belongs_to_onep_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
|
|
||||||
|
$GLOBALS['dbpool']->get()->con->prepare(
|
||||||
|
'CREATE TABLE `test_owns_onep` (
|
||||||
|
`test_owns_onep_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`test_owns_onep_string` varchar(254) NOT NULL,
|
||||||
|
PRIMARY KEY (`test_owns_onep_id`)
|
||||||
|
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
|
||||||
|
)->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown() : void
|
protected function tearDown() : void
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ class BaseModelMapper extends DataMapperFactory
|
||||||
'test_base_datetime_null' => ['name' => 'test_base_datetime_null', 'type' => 'DateTime', 'internal' => 'datetime_null'],
|
'test_base_datetime_null' => ['name' => 'test_base_datetime_null', 'type' => 'DateTime', 'internal' => 'datetime_null'],
|
||||||
'test_base_owns_one_self' => ['name' => 'test_base_owns_one_self', 'type' => 'int', 'internal' => 'ownsOneSelf'],
|
'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'],
|
'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOne'],
|
||||||
'test_base_owns_one_self' => ['name' => 'test_base_owns_one_self', 'type' => 'int', 'internal' => 'ownsOneSelfPrivate', 'private' => true],
|
'test_base_owns_onep_self' => ['name' => 'test_base_owns_onep_self', 'type' => 'int', 'internal' => 'ownsOneSelfPrivate', 'private' => true],
|
||||||
'test_base_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOnePrivate', 'private' => true],
|
'test_base_belongs_top_one' => ['name' => 'test_base_belongs_top_one', 'type' => 'int', 'internal' => 'belongsToOnePrivate', 'private' => true],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,8 +57,8 @@ class BaseModelMapper extends DataMapperFactory
|
||||||
'private' => true,
|
'private' => true,
|
||||||
],
|
],
|
||||||
'belongsToOnePrivate' => [
|
'belongsToOnePrivate' => [
|
||||||
'mapper' => BelongsToModelMapper::class,
|
'mapper' => BelongsToModelPrivateMapper::class,
|
||||||
'external' => 'test_base_belongs_to_one',
|
'external' => 'test_base_belongs_top_one',
|
||||||
'private' => true,
|
'private' => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
@ -69,8 +69,8 @@ class BaseModelMapper extends DataMapperFactory
|
||||||
'external' => 'test_base_owns_one_self',
|
'external' => 'test_base_owns_one_self',
|
||||||
],
|
],
|
||||||
'ownsOneSelfPrivate' => [
|
'ownsOneSelfPrivate' => [
|
||||||
'mapper' => OwnsOneModelMapper::class,
|
'mapper' => OwnsOneModelPrivateMapper::class,
|
||||||
'external' => 'test_base_owns_one_self',
|
'external' => 'test_base_owns_onep_self',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -101,17 +101,17 @@ class BaseModelMapper extends DataMapperFactory
|
||||||
'external' => null,
|
'external' => null,
|
||||||
],
|
],
|
||||||
'hasManyDirectPrivate' => [
|
'hasManyDirectPrivate' => [
|
||||||
'mapper' => ManyToManyDirectModelMapper::class,
|
'mapper' => ManyToManyDirectModelPrivateMapper::class,
|
||||||
'table' => 'test_has_many_direct',
|
'table' => 'test_has_many_directp',
|
||||||
'self' => 'test_has_many_direct_to',
|
'self' => 'test_has_many_directp_to',
|
||||||
'external' => null,
|
'external' => null,
|
||||||
'private' => true,
|
'private' => true,
|
||||||
],
|
],
|
||||||
'hasManyRelationsPrivate' => [
|
'hasManyRelationsPrivate' => [
|
||||||
'mapper' => ManyToManyRelModelMapper::class,
|
'mapper' => ManyToManyRelModelPrivateMapper::class,
|
||||||
'table' => 'test_has_many_rel_relations',
|
'table' => 'test_has_many_rel_relationsp',
|
||||||
'external' => 'test_has_many_rel_relations_src',
|
'external' => 'test_has_many_rel_relationsp_src',
|
||||||
'self' => 'test_has_many_rel_relations_dest',
|
'self' => 'test_has_many_rel_relationsp_dest',
|
||||||
'private' => true
|
'private' => true
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Jingga
|
||||||
|
*
|
||||||
|
* PHP Version 8.1
|
||||||
|
*
|
||||||
|
* @package tests
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 2.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace phpOMS\tests\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
|
|
||||||
|
class BelongsToModelMapper extends DataMapperFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const COLUMNS = [
|
||||||
|
'test_belongs_to_onep_id' => ['name' => 'test_belongs_to_onep_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_belongs_to_onep_string' => ['name' => 'test_belongs_to_onep_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const TABLE = 'test_belongs_to_onep';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary field name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const PRIMARYFIELD = 'test_belongs_to_onep_id';
|
||||||
|
|
||||||
|
public const MODEL = BelongsToModel::class;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Jingga
|
||||||
|
*
|
||||||
|
* PHP Version 8.1
|
||||||
|
*
|
||||||
|
* @package tests
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 2.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace phpOMS\tests\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
|
|
||||||
|
class ManyToManyDirectModelMapper extends DataMapperFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const COLUMNS = [
|
||||||
|
'test_has_many_directp_id' => ['name' => 'test_has_many_directp_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_has_many_directp_string' => ['name' => 'test_has_many_directp_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
'test_has_many_directp_to' => ['name' => 'test_has_many_directp_to', 'type' => 'int', 'internal' => 'to'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const TABLE = 'test_has_many_directp';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary field name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const PRIMARYFIELD = 'test_has_many_directp_id';
|
||||||
|
|
||||||
|
public const MODEL = ManyToManyDirectModel::class;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Jingga
|
||||||
|
*
|
||||||
|
* PHP Version 8.1
|
||||||
|
*
|
||||||
|
* @package tests
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 2.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace phpOMS\tests\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
|
|
||||||
|
class ManyToManyRelModelMapper extends DataMapperFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const COLUMNS = [
|
||||||
|
'test_has_many_relp_id' => ['name' => 'test_has_many_relp_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_has_many_relp_string' => ['name' => 'test_has_many_relp_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const TABLE = 'test_has_many_relp';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary field name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const PRIMARYFIELD = 'test_has_many_relp_id';
|
||||||
|
|
||||||
|
public const MODEL = ManyToManyRelModel::class;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Jingga
|
||||||
|
*
|
||||||
|
* PHP Version 8.1
|
||||||
|
*
|
||||||
|
* @package tests
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 2.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace phpOMS\tests\DataStorage\Database\TestModel;
|
||||||
|
|
||||||
|
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||||
|
|
||||||
|
class OwnsOneModelMapper extends DataMapperFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Columns.
|
||||||
|
*
|
||||||
|
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const COLUMNS = [
|
||||||
|
'test_owns_onep_id' => ['name' => 'test_owns_onep_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
|
'test_owns_onep_string' => ['name' => 'test_owns_onep_string', 'type' => 'string', 'internal' => 'string'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary table.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const TABLE = 'test_owns_onep';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Primary field name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public const PRIMARYFIELD = 'test_owns_onep_id';
|
||||||
|
|
||||||
|
public const MODEL = OwnsOneModel::class;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user