mirror of
https://github.com/Karaka-Management/oms-Tag.git
synced 2026-01-11 07:38:41 +00:00
cs fixes, bug fixes, code coverage
This commit is contained in:
parent
aae4c96731
commit
13fe6009a5
|
|
@ -12,9 +12,7 @@ If you have a good idea for improvement feel free to create a new issue with all
|
|||
|
||||
### Issues
|
||||
|
||||
Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the `Project.md` file in the `Docs` repository.
|
||||
|
||||
The issue information can be used to provide additional information such as priority, difficulty and type. For your first issue try to find a issue marked `[d:first]` or `[d:beginner]`.
|
||||
Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the code marked with `@todo` or in the [PROJECT.md](https://github.com/Orange-Management/Docs/blob/master/Project/PROJECT.md) file.
|
||||
|
||||
### Code Style
|
||||
|
||||
|
|
|
|||
|
|
@ -24,4 +24,16 @@ namespace Modules\Tag\Models;
|
|||
*/
|
||||
final class NullTagL11n extends TagL11n
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ declare(strict_types=1);
|
|||
namespace Modules\Tag\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
|
|
@ -67,7 +66,7 @@ class Tag implements \JsonSerializable, ArrayableInterface
|
|||
* @var null|Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected ?Account $owner = null;
|
||||
public ?Account $owner = null;
|
||||
|
||||
/**
|
||||
* Tag type.
|
||||
|
|
@ -77,32 +76,6 @@ class Tag implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
protected int $type = TagType::SINGLE;
|
||||
|
||||
/**
|
||||
* Get created by
|
||||
*
|
||||
* @return Account
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getOwner() : Account
|
||||
{
|
||||
return $this->owner ?? new NullAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set created by
|
||||
*
|
||||
* @param Account $id Created by
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setOwner(Account $id) : void
|
||||
{
|
||||
$this->owner = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
|
|
|
|||
42
tests/Models/NullTagL11nTest.php
Normal file
42
tests/Models/NullTagL11nTest.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?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\Tag\tests\Models;
|
||||
|
||||
use Modules\Tag\Models\NullTagL11n;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullTagL11nTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\Tag\Models\NullTagL11n
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Tag\Models\TagL11n', new NullTagL11n());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Tag\Models\NullTagL11n
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullTagL11n(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ final class TagTest extends \PHPUnit\Framework\TestCase
|
|||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->tag->getId());
|
||||
self::assertInstanceOf(NullAccount::class, $this->tag->getOwner());
|
||||
self::assertInstanceOf(NullAccount::class, $this->tag->owner);
|
||||
self::assertEquals(TagType::SINGLE, $this->tag->getType());
|
||||
self::assertEquals('00000000', $this->tag->color);
|
||||
self::assertEquals('', $this->tag->getL11n());
|
||||
|
|
@ -69,8 +69,8 @@ final class TagTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testOwnerInputOutput() : void
|
||||
{
|
||||
$this->tag->setOwner(new NullAccount(2));
|
||||
self::assertEquals(2, $this->tag->getOwner()->getId());
|
||||
$this->tag->owner = new NullAccount(2);
|
||||
self::assertEquals(2, $this->tag->owner->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -100,7 +100,7 @@ final class TagTest extends \PHPUnit\Framework\TestCase
|
|||
public function testSerialize() : void
|
||||
{
|
||||
$this->tag->setL11n($t = new TagL11n('Test'));
|
||||
$this->tag->setOwner($a = new NullAccount(2));
|
||||
$this->tag->owner = new NullAccount(2);
|
||||
$this->tag->color = 'ffffffff';
|
||||
$this->tag->setType(TagType::SHARED);
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ final class TagTest extends \PHPUnit\Framework\TestCase
|
|||
'title' => $t,
|
||||
'color' => 'ffffffff',
|
||||
'type' => TagType::SHARED,
|
||||
'owner' => $a,
|
||||
'owner' => $this->tag->owner,
|
||||
],
|
||||
$this->tag->jsonSerialize()
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user