mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-02-14 15:28:41 +00:00
get overall coverage to 76%
This commit is contained in:
parent
e13ef6d10d
commit
b516c95f79
|
|
@ -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": {
|
"organization_department": {
|
||||||
"name": "organization_department",
|
"name": "organization_department",
|
||||||
"fields": {
|
"fields": {
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,6 @@ class Unit implements \JsonSerializable, ArrayableInterface
|
||||||
*/
|
*/
|
||||||
protected int $status = Status::INACTIVE;
|
protected int $status = Status::INACTIVE;
|
||||||
|
|
||||||
/**
|
|
||||||
* Media files
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
protected array $files = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -115,73 +107,6 @@ class Unit implements \JsonSerializable, ArrayableInterface
|
||||||
return $this->id;
|
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
|
* Get status
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -69,21 +69,6 @@ final class UnitMapper extends DataMapperAbstract
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Has many relation.
|
|
||||||
*
|
|
||||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
|
||||||
* @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.
|
* Model to use by the mapper.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Orange Management
|
|
||||||
*
|
|
||||||
* PHP Version 8.0
|
|
||||||
*
|
|
||||||
* @package tests
|
|
||||||
* @copyright Dennis Eichhorn
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @version 1.0.0
|
|
||||||
* @link https://orange-management.org
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Modules\Organization\tests\Models;
|
|
||||||
|
|
||||||
use Modules\Organization\Models\NullDepartment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class Null extends \PHPUnit\Framework\TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @covers Modules\Organization\Models\NullDepartment
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testNull() : void
|
|
||||||
{
|
|
||||||
self::assertInstanceOf('\Modules\Organization\Models\Department', new NullDepartment());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Modules\Organization\Models\NullDepartment
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testId() : void
|
|
||||||
{
|
|
||||||
$null = new NullDepartment(2);
|
|
||||||
self::assertEquals(2, $null->getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Orange Management
|
|
||||||
*
|
|
||||||
* PHP Version 8.0
|
|
||||||
*
|
|
||||||
* @package tests
|
|
||||||
* @copyright Dennis Eichhorn
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @version 1.0.0
|
|
||||||
* @link https://orange-management.org
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Modules\Organization\tests\Models;
|
|
||||||
|
|
||||||
use Modules\Organization\Models\NullPosition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class Null extends \PHPUnit\Framework\TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @covers Modules\Organization\Models\NullPosition
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testNull() : void
|
|
||||||
{
|
|
||||||
self::assertInstanceOf('\Modules\Organization\Models\Position', new NullPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Modules\Organization\Models\NullPosition
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testId() : void
|
|
||||||
{
|
|
||||||
$null = new NullPosition(2);
|
|
||||||
self::assertEquals(2, $null->getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Orange Management
|
|
||||||
*
|
|
||||||
* PHP Version 8.0
|
|
||||||
*
|
|
||||||
* @package tests
|
|
||||||
* @copyright Dennis Eichhorn
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @version 1.0.0
|
|
||||||
* @link https://orange-management.org
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Modules\Organization\tests\Models;
|
|
||||||
|
|
||||||
use Modules\Organization\Models\NullUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class Null extends \PHPUnit\Framework\TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @covers Modules\Organization\Models\NullUnit
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testNull() : void
|
|
||||||
{
|
|
||||||
self::assertInstanceOf('\Modules\Organization\Models\Unit', new NullUnit());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Modules\Organization\Models\NullUnit
|
|
||||||
* @group framework
|
|
||||||
*/
|
|
||||||
public function testId() : void
|
|
||||||
{
|
|
||||||
$null = new NullUnit(2);
|
|
||||||
self::assertEquals(2, $null->getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user