fix tests

This commit is contained in:
Dennis Eichhorn 2023-10-22 04:32:50 +00:00
parent 9b71428f88
commit c224209c28
6 changed files with 255 additions and 13 deletions

View File

@ -52,7 +52,9 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
`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_belongs_top_one` 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_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`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1;'
)->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

View File

@ -40,8 +40,8 @@ class BaseModelMapper extends DataMapperFactory
'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_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_belongs_to_one' => ['name' => 'test_base_belongs_to_one', 'type' => 'int', 'internal' => 'belongsToOnePrivate', 'private' => true],
'test_base_owns_onep_self' => ['name' => 'test_base_owns_onep_self', 'type' => 'int', 'internal' => 'ownsOneSelfPrivate', '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,
],
'belongsToOnePrivate' => [
'mapper' => BelongsToModelMapper::class,
'external' => 'test_base_belongs_to_one',
'mapper' => BelongsToModelPrivateMapper::class,
'external' => 'test_base_belongs_top_one',
'private' => true,
],
];
@ -69,8 +69,8 @@ class BaseModelMapper extends DataMapperFactory
'external' => 'test_base_owns_one_self',
],
'ownsOneSelfPrivate' => [
'mapper' => OwnsOneModelMapper::class,
'external' => 'test_base_owns_one_self',
'mapper' => OwnsOneModelPrivateMapper::class,
'external' => 'test_base_owns_onep_self',
],
];
@ -101,17 +101,17 @@ class BaseModelMapper extends DataMapperFactory
'external' => null,
],
'hasManyDirectPrivate' => [
'mapper' => ManyToManyDirectModelMapper::class,
'table' => 'test_has_many_direct',
'self' => 'test_has_many_direct_to',
'mapper' => ManyToManyDirectModelPrivateMapper::class,
'table' => 'test_has_many_directp',
'self' => 'test_has_many_directp_to',
'external' => null,
'private' => true,
],
'hasManyRelationsPrivate' => [
'mapper' => ManyToManyRelModelMapper::class,
'table' => 'test_has_many_rel_relations',
'external' => 'test_has_many_rel_relations_src',
'self' => 'test_has_many_rel_relations_dest',
'mapper' => ManyToManyRelModelPrivateMapper::class,
'table' => 'test_has_many_rel_relationsp',
'external' => 'test_has_many_rel_relationsp_src',
'self' => 'test_has_many_rel_relationsp_dest',
'private' => true
],
];

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}