From b516c95f79a162d2a190e0503d0cb1c2b76f2f99 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 24 Oct 2021 13:18:08 +0200 Subject: [PATCH] get overall coverage to 76% --- Admin/Install/db.json | 26 ------------ Models/Unit.php | 75 --------------------------------- Models/UnitMapper.php | 15 ------- tests/Models/NullDepartment.php | 42 ------------------ tests/Models/NullPosition.php | 42 ------------------ tests/Models/NullUnit.php | 42 ------------------ 6 files changed, 242 deletions(-) delete mode 100644 tests/Models/NullDepartment.php delete mode 100644 tests/Models/NullPosition.php delete mode 100644 tests/Models/NullUnit.php diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 196dfb8..710b826 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -51,32 +51,6 @@ } } }, - "organization_unit_media": { - "name": "organization_unit_media", - "fields": { - "organization_unit_media_id": { - "name": "organization_unit_media_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true - }, - "organization_unit_media_src": { - "name": "organization_unit_media_src", - "type": "INT", - "null": false, - "foreignTable": "organization_unit", - "foreignKey": "organization_unit_id" - }, - "organization_unit_media_dst": { - "name": "organization_unit_media_dst", - "type": "INT", - "null": false, - "foreignTable": "media", - "foreignKey": "media_id" - } - } - }, "organization_department": { "name": "organization_department", "fields": { diff --git a/Models/Unit.php b/Models/Unit.php index cfaff5b..d6fab4b 100755 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -84,14 +84,6 @@ class Unit implements \JsonSerializable, ArrayableInterface */ protected int $status = Status::INACTIVE; - /** - * Media files - * - * @var array - * @since 1.0.0 - */ - protected array $files = []; - /** * Constructor. * @@ -115,73 +107,6 @@ class Unit implements \JsonSerializable, ArrayableInterface return $this->id; } - /** - * Get media. - * - * @return array - * - * @since 1.0.0 - */ - public function getFiles() : array - { - return $this->files; - } - - /** - * Add media. - * - * @param Media $file Media - * - * @return void - * - * @since 1.0.0 - */ - public function addFile(Media $file) : void - { - $this->files[] = $file; - } - - /** - * Get media file by type - * - * @param string $type Media type - * - * @return Media - * - * @since 1.0.0 - */ - public function getFileByType(string $type) : Media - { - foreach ($this->files as $file) { - if ($file->type === $type) { - return $file; - } - } - - return new NullMedia(); - } - - /** - * Get all media files by type - * - * @param string $type Media type - * - * @return Media[] - * - * @since 1.0.0 - */ - public function getFilesByType(string $type) : array - { - $files = []; - foreach ($this->files as $file) { - if ($file->type === $type) { - $files[] = $file; - } - } - - return $files; - } - /** * Get status * diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index b610045..cd527fb 100755 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -69,21 +69,6 @@ final class UnitMapper extends DataMapperAbstract ], ]; - /** - * Has many relation. - * - * @var array - * @since 1.0.0 - */ - protected static array $hasMany = [ - 'files' => [ - 'mapper' => MediaMapper::class, /* mapper of the related object */ - 'table' => 'organization_unit_media', /* table of the related object, null if no relation table is used (many->1) */ - 'external' => 'organization_unit_media_dst', - 'self' => 'organization_unit_media_src', - ], - ]; - /** * Model to use by the mapper. * diff --git a/tests/Models/NullDepartment.php b/tests/Models/NullDepartment.php deleted file mode 100644 index d9a3736..0000000 --- a/tests/Models/NullDepartment.php +++ /dev/null @@ -1,42 +0,0 @@ -getId()); - } -} diff --git a/tests/Models/NullPosition.php b/tests/Models/NullPosition.php deleted file mode 100644 index 851050a..0000000 --- a/tests/Models/NullPosition.php +++ /dev/null @@ -1,42 +0,0 @@ -getId()); - } -} diff --git a/tests/Models/NullUnit.php b/tests/Models/NullUnit.php deleted file mode 100644 index d18320b..0000000 --- a/tests/Models/NullUnit.php +++ /dev/null @@ -1,42 +0,0 @@ -getId()); - } -}