From c224209c2850e12f91371d791eb41d51069cb8ab Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 22 Oct 2023 04:32:50 +0000 Subject: [PATCH] fix tests --- .../Database/DataMapperAbstractTest.php | 45 +++++++++++++++++ .../Database/TestModel/BaseModelMapper.php | 26 +++++----- .../TestModel/BelongsToModelPrivateMapper.php | 49 ++++++++++++++++++ .../ManyToManyDirectModelPrivateMapper.php | 50 +++++++++++++++++++ .../ManyToManyRelModelPrivateMapper.php | 49 ++++++++++++++++++ .../TestModel/OwnsOneModelPrivateMapper.php | 49 ++++++++++++++++++ 6 files changed, 255 insertions(+), 13 deletions(-) create mode 100644 tests/DataStorage/Database/TestModel/BelongsToModelPrivateMapper.php create mode 100644 tests/DataStorage/Database/TestModel/ManyToManyDirectModelPrivateMapper.php create mode 100644 tests/DataStorage/Database/TestModel/ManyToManyRelModelPrivateMapper.php create mode 100644 tests/DataStorage/Database/TestModel/OwnsOneModelPrivateMapper.php diff --git a/tests/DataStorage/Database/DataMapperAbstractTest.php b/tests/DataStorage/Database/DataMapperAbstractTest.php index ea2afe43a..4fd37988f 100755 --- a/tests/DataStorage/Database/DataMapperAbstractTest.php +++ b/tests/DataStorage/Database/DataMapperAbstractTest.php @@ -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 diff --git a/tests/DataStorage/Database/TestModel/BaseModelMapper.php b/tests/DataStorage/Database/TestModel/BaseModelMapper.php index 7ef5c61d4..28a735696 100755 --- a/tests/DataStorage/Database/TestModel/BaseModelMapper.php +++ b/tests/DataStorage/Database/TestModel/BaseModelMapper.php @@ -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 ], ]; diff --git a/tests/DataStorage/Database/TestModel/BelongsToModelPrivateMapper.php b/tests/DataStorage/Database/TestModel/BelongsToModelPrivateMapper.php new file mode 100644 index 000000000..35d102ea4 --- /dev/null +++ b/tests/DataStorage/Database/TestModel/BelongsToModelPrivateMapper.php @@ -0,0 +1,49 @@ + + * @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; +} diff --git a/tests/DataStorage/Database/TestModel/ManyToManyDirectModelPrivateMapper.php b/tests/DataStorage/Database/TestModel/ManyToManyDirectModelPrivateMapper.php new file mode 100644 index 000000000..32c78c9ba --- /dev/null +++ b/tests/DataStorage/Database/TestModel/ManyToManyDirectModelPrivateMapper.php @@ -0,0 +1,50 @@ + + * @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; +} diff --git a/tests/DataStorage/Database/TestModel/ManyToManyRelModelPrivateMapper.php b/tests/DataStorage/Database/TestModel/ManyToManyRelModelPrivateMapper.php new file mode 100644 index 000000000..0fe7ec31c --- /dev/null +++ b/tests/DataStorage/Database/TestModel/ManyToManyRelModelPrivateMapper.php @@ -0,0 +1,49 @@ + + * @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; +} diff --git a/tests/DataStorage/Database/TestModel/OwnsOneModelPrivateMapper.php b/tests/DataStorage/Database/TestModel/OwnsOneModelPrivateMapper.php new file mode 100644 index 000000000..3cc2fd7f8 --- /dev/null +++ b/tests/DataStorage/Database/TestModel/OwnsOneModelPrivateMapper.php @@ -0,0 +1,49 @@ + + * @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; +}