From 9b48cd3a87559a064a9275a28e804f8ab0da6a96 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 25 Dec 2022 00:06:17 +0100 Subject: [PATCH] test fixes and changes for release --- Admin/Install/Navigation.install.json | 2 +- Models/Employee.php | 53 ++++++++++++++++++++++++++ Models/EmployeeEducationHistory.php | 54 +++++++++++++++++++++++++++ Models/EmployeeHistory.php | 54 +++++++++++++++++++++++++++ Models/EmployeeWorkHistory.php | 54 +++++++++++++++++++++++++++ tests/Bootstrap.php | 19 ++++++++++ 6 files changed, 235 insertions(+), 1 deletion(-) diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 7353a63..c5ce6bf 100755 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -8,7 +8,7 @@ "uri": null, "target": "self", "icon": "fa fa-user", - "order": 90, + "order": 60, "from": "HumanResourceManagement", "permission": { "permission": 2, "category": null, "element": null }, "parent": 0, diff --git a/Models/Employee.php b/Models/Employee.php index 06a773d..90d3750 100755 --- a/Models/Employee.php +++ b/Models/Employee.php @@ -163,6 +163,59 @@ class Employee implements \JsonSerializable return \hash_equals($this->semiPrivateHash, $hash); } + /** + * Get files + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFiles() : array + { + return $this->files; + } + + /** + * Get media file by type + * + * @param null|int $type Media type + * + * @return Media + * + * @since 1.0.0 + */ + public function getFileByType(int $type = null) : Media + { + foreach ($this->files as $file) { + if ($file->type === $type) { + return $file; + } + } + + return new NullMedia(); + } + + /** + * Get all media files by type + * + * @param null|int $type Media type + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFilesByType(int $type = null) : array + { + $files = []; + foreach ($this->files as $file) { + if ($file->type === $type) { + $files[] = $file; + } + } + + return $files; + } + /** * Get employee company history. * diff --git a/Models/EmployeeEducationHistory.php b/Models/EmployeeEducationHistory.php index 7eee6e1..a069987 100755 --- a/Models/EmployeeEducationHistory.php +++ b/Models/EmployeeEducationHistory.php @@ -16,6 +16,7 @@ namespace Modules\HumanResourceManagement\Models; use Modules\Admin\Models\Address; use Modules\Media\Models\Media; +use Modules\Media\Models\NullMedia; /** * Employee class. @@ -101,6 +102,59 @@ class EmployeeEducationHistory implements \JsonSerializable return $this->id; } + /** + * Get files + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFiles() : array + { + return $this->files; + } + + /** + * Get media file by type + * + * @param null|int $type Media type + * + * @return Media + * + * @since 1.0.0 + */ + public function getFileByType(int $type = null) : Media + { + foreach ($this->files as $file) { + if ($file->type === $type) { + return $file; + } + } + + return new NullMedia(); + } + + /** + * Get all media files by type + * + * @param null|int $type Media type + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFilesByType(int $type = null) : array + { + $files = []; + foreach ($this->files as $file) { + if ($file->type === $type) { + $files[] = $file; + } + } + + return $files; + } + /** * {@inheritdoc} */ diff --git a/Models/EmployeeHistory.php b/Models/EmployeeHistory.php index 9e1b2cc..85a73a6 100755 --- a/Models/EmployeeHistory.php +++ b/Models/EmployeeHistory.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\HumanResourceManagement\Models; use Modules\Media\Models\Media; +use Modules\Media\Models\NullMedia; use Modules\Organization\Models\Department; use Modules\Organization\Models\NullDepartment; use Modules\Organization\Models\NullPosition; @@ -124,6 +125,59 @@ class EmployeeHistory implements \JsonSerializable return $this->id; } + /** + * Get files + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFiles() : array + { + return $this->files; + } + + /** + * Get media file by type + * + * @param null|int $type Media type + * + * @return Media + * + * @since 1.0.0 + */ + public function getFileByType(int $type = null) : Media + { + foreach ($this->files as $file) { + if ($file->type === $type) { + return $file; + } + } + + return new NullMedia(); + } + + /** + * Get all media files by type + * + * @param null|int $type Media type + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFilesByType(int $type = null) : array + { + $files = []; + foreach ($this->files as $file) { + if ($file->type === $type) { + $files[] = $file; + } + } + + return $files; + } + /** * {@inheritdoc} */ diff --git a/Models/EmployeeWorkHistory.php b/Models/EmployeeWorkHistory.php index a3c478f..f641085 100755 --- a/Models/EmployeeWorkHistory.php +++ b/Models/EmployeeWorkHistory.php @@ -16,6 +16,7 @@ namespace Modules\HumanResourceManagement\Models; use Modules\Admin\Models\Address; use Modules\Media\Models\Media; +use Modules\Media\Models\NullMedia; /** * Employee class. @@ -97,6 +98,59 @@ class EmployeeWorkHistory implements \JsonSerializable return $this->id; } + /** + * Get files + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFiles() : array + { + return $this->files; + } + + /** + * Get media file by type + * + * @param null|int $type Media type + * + * @return Media + * + * @since 1.0.0 + */ + public function getFileByType(int $type = null) : Media + { + foreach ($this->files as $file) { + if ($file->type === $type) { + return $file; + } + } + + return new NullMedia(); + } + + /** + * Get all media files by type + * + * @param null|int $type Media type + * + * @return Media[] + * + * @since 1.0.0 + */ + public function getFilesByType(int $type = null) : array + { + $files = []; + foreach ($this->files as $file) { + if ($file->type === $type) { + $files[] = $file; + } + } + + return $files; + } + /** * {@inheritdoc} */ diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index d46fd31..b5d36a8 100755 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -257,6 +257,25 @@ $CONFIG = [ 'root' => '/', 'https' => false, ], + 'app' => [ + 'path' => __DIR__, + 'default' => [ + 'app' => 'Backend', + 'id' => 'backend', + 'lang' => 'en', + 'theme' => 'Backend', + 'org' => 1, + ], + 'domains' => [ + '127.0.0.1' => [ + 'app' => 'Backend', + 'id' => 'backend', + 'lang' => 'en', + 'theme' => 'Backend', + 'org' => 1, + ], + ], + ], 'socket' => [ 'master' => [ 'host' => '127.0.0.1',