test fixes

This commit is contained in:
Dennis Eichhorn 2023-10-16 22:23:57 +00:00
parent 39ed9367a6
commit 5e3939426a
4 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,72 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Admin\tests\Models;
use Modules\Attribute\Models\Attribute;
/**
* @testdox Modules\Admin\tests\Models\AttributeTest: Attribute model
*
* @internal
*/
final class AttributeTest extends \PHPUnit\Framework\TestCase
{
public function testDeepClone() : void
{
$attr = new Attribute();
$clone = $attr->deepClone();
$attr->ref = 1;
self::assertNotEquals($attr->ref, $clone->ref);
}
public function testToArray() : void
{
$attr = new Attribute();
$array = $attr->toArray();
unset($array['type']);
unset($array['value']);
self::assertEquals(
[
'id' => 0,
'ref' => 0,
],
$array
);
}
public function testJsonSerialize() : void
{
$attr = new Attribute();
$array = $attr->jsonSerialize();
unset($array['type']);
unset($array['value']);
self::assertEquals(
[
'id' => 0,
'ref' => 0,
],
$array
);
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Attribute\tests\Models;
use Modules\Attribute\Models\NullAttribute;
/**
* @internal
*/
final class NullAttributeTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Attribute\Models\NullAttribute
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Attribute\Models\Attribute', new NullAttribute());
}
/**
* @covers Modules\Attribute\Models\NullAttribute
* @group module
*/
public function testId() : void
{
$null = new NullAttribute(2);
self::assertEquals(2, $null->id);
}
/**
* @covers Modules\Attribute\Models\NullAttribute
* @group module
*/
public function testJsonSerialize() : void
{
$null = new NullAttribute(2);
self::assertEquals(['id' => 2], $null);
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Attribute\tests\Models;
use Modules\Attribute\Models\NullAttributeType;
/**
* @internal
*/
final class NullAttributeTypeTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Attribute\Models\NullAttributeType
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Attribute\Models\AttributeType', new NullAttributeType());
}
/**
* @covers Modules\Attribute\Models\NullAttributeType
* @group module
*/
public function testId() : void
{
$null = new NullAttributeType(2);
self::assertEquals(2, $null->id);
}
/**
* @covers Modules\Attribute\Models\NullAttributeType
* @group module
*/
public function testJsonSerialize() : void
{
$null = new NullAttributeType(2);
self::assertEquals(['id' => 2], $null);
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Attribute\tests\Models;
use Modules\Attribute\Models\NullAttributeValue;
/**
* @internal
*/
final class NullAttributeValueTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Attribute\Models\NullAttributeValue
* @group module
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Attribute\Models\AttributeValue', new NullAttributeValue());
}
/**
* @covers Modules\Attribute\Models\NullAttributeValue
* @group module
*/
public function testId() : void
{
$null = new NullAttributeValue(2);
self::assertEquals(2, $null->id);
}
/**
* @covers Modules\Attribute\Models\NullAttributeValue
* @group module
*/
public function testJsonSerialize() : void
{
$null = new NullAttributeValue(2);
self::assertEquals(['id' => 2], $null);
}
}