test fixes

This commit is contained in:
Dennis Eichhorn 2023-04-17 19:44:57 +02:00
parent d1ffc698af
commit 66f0ea48cc
8 changed files with 3 additions and 379 deletions

View File

@ -25,6 +25,7 @@ use phpOMS\Application\ApplicationAbstract;
use phpOMS\DataStorage\Session\HttpSession;
use phpOMS\Dispatcher\Dispatcher;
use phpOMS\Event\EventManager;
use phpOMS\Localization\L11nManager;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\ModuleManager;
use phpOMS\Router\WebRouter;
@ -63,6 +64,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$this->app->eventManager = new EventManager($this->app->dispatcher);
$this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php');
$this->app->sessionManager = new HttpSession(36000);
$this->app->l11nManager = new L11nManager();
$account = new Account();
TestUtils::setMember($account, 'id', 1);

View File

@ -1,42 +0,0 @@
<?php
/**
* Karaka
*
* 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\SupplierManagement\tests\Models;
use Modules\SupplierManagement\Models\NullSupplierAttribute;
/**
* @internal
*/
final class NullSupplierAttributeTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\SupplierManagement\Models\NullSupplierAttribute
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\SupplierManagement\Models\SupplierAttribute', new NullSupplierAttribute());
}
/**
* @covers Modules\SupplierManagement\Models\NullSupplierAttribute
* @group framework
*/
public function testId() : void
{
$null = new NullSupplierAttribute(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -1,42 +0,0 @@
<?php
/**
* Karaka
*
* 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\SupplierManagement\tests\Models;
use Modules\SupplierManagement\Models\NullSupplierAttributeType;
/**
* @internal
*/
final class NullSupplierAttributeTypeTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\SupplierManagement\Models\NullSupplierAttributeType
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\SupplierManagement\Models\SupplierAttributeType', new NullSupplierAttributeType());
}
/**
* @covers Modules\SupplierManagement\Models\NullSupplierAttributeType
* @group framework
*/
public function testId() : void
{
$null = new NullSupplierAttributeType(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -1,42 +0,0 @@
<?php
/**
* Karaka
*
* 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\SupplierManagement\tests\Models;
use Modules\SupplierManagement\Models\NullSupplierAttributeValue;
/**
* @internal
*/
final class NullSupplierAttributeValueTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\SupplierManagement\Models\NullSupplierAttributeValue
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\SupplierManagement\Models\SupplierAttributeValue', new NullSupplierAttributeValue());
}
/**
* @covers Modules\SupplierManagement\Models\NullSupplierAttributeValue
* @group framework
*/
public function testId() : void
{
$null = new NullSupplierAttributeValue(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -1,63 +0,0 @@
<?php
/**
* Karaka
*
* 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\SupplierManagement\tests\Models;
use Modules\SupplierManagement\Models\SupplierAttribute;
/**
* @internal
*/
final class SupplierAttributeTest extends \PHPUnit\Framework\TestCase
{
private SupplierAttribute $attribute;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->attribute = new SupplierAttribute();
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttribute
* @group module
*/
public function testDefault() : void
{
self::assertEquals(0, $this->attribute->getId());
self::assertInstanceOf('\Modules\SupplierManagement\Models\SupplierAttributeType', $this->attribute->type);
self::assertInstanceOf('\Modules\SupplierManagement\Models\SupplierAttributeValue', $this->attribute->value);
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttribute
* @group module
*/
public function testSerialize() : void
{
$serialized = $this->attribute->jsonSerialize();
self::assertEquals(
[
'id',
'supplier',
'type',
'value',
],
\array_keys($serialized)
);
}
}

View File

@ -1,82 +0,0 @@
<?php
/**
* Karaka
*
* 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\SupplierManagement\tests\Models;
use Modules\SupplierManagement\Models\SupplierAttributeType;
use phpOMS\Localization\BaseStringL11n;
/**
* @internal
*/
final class SupplierAttributeTypeTest extends \PHPUnit\Framework\TestCase
{
private SupplierAttributeType $type;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->type = new SupplierAttributeType();
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeType
* @group module
*/
public function testDefault() : void
{
self::assertEquals(0, $this->type->getId());
self::assertEquals('', $this->type->getL11n());
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeType
* @group module
*/
public function testL11nInputOutput() : void
{
$this->type->setL11n('Test');
self::assertEquals('Test', $this->type->getL11n());
$this->type->setL11n(new BaseStringL11n('NewTest'));
self::assertEquals('NewTest', $this->type->getL11n());
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeType
* @group module
*/
public function testSerialize() : void
{
$this->type->name = 'Title';
$this->type->fields = 2;
$this->type->custom = true;
$this->type->validationPattern = '\d*';
$this->type->isRequired = true;
self::assertEquals(
[
'id' => 0,
'name' => 'Title',
'fields' => 2,
'custom' => true,
'validationPattern' => '\d*',
'isRequired' => true,
],
$this->type->jsonSerialize()
);
}
}

View File

@ -1,107 +0,0 @@
<?php
/**
* Karaka
*
* 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\SupplierManagement\tests\Models;
use Modules\SupplierManagement\Models\AttributeValueType;
use Modules\SupplierManagement\Models\SupplierAttributeValue;
/**
* @internal
*/
final class SupplierAttributeValueTest extends \PHPUnit\Framework\TestCase
{
private SupplierAttributeValue $value;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->value = new SupplierAttributeValue();
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeValue
* @group module
*/
public function testDefault() : void
{
self::assertEquals(0, $this->value->getId());
self::assertNull($this->value->getValue());
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeValue
* @group module
*/
public function testValueIntInputOutput() : void
{
$this->value->setValue(1, AttributeValueType::_INT);
self::assertEquals(1, $this->value->getValue());
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeValue
* @group module
*/
public function testValueFloatInputOutput() : void
{
$this->value->setValue(1.1, AttributeValueType::_FLOAT);
self::assertEquals(1.1, $this->value->getValue());
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeValue
* @group module
*/
public function testValueStringInputOutput() : void
{
$this->value->setValue('test', AttributeValueType::_STRING);
self::assertEquals('test', $this->value->getValue());
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeValue
* @group module
*/
public function testValueDateInputOutput() : void
{
$dat = new \DateTime('now');
$this->value->setValue('now', AttributeValueType::_DATETIME);
self::assertEquals($dat->format('Y-m-d'), $this->value->getValue()->format('Y-m-d'));
}
/**
* @covers Modules\SupplierManagement\Models\SupplierAttributeValue
* @group module
*/
public function testSerialize() : void
{
$this->value->setValue('test', AttributeValueType::_STRING);
$this->value->isDefault = true;
self::assertEquals(
[
'id' => 0,
'valueInt' => null,
'valueStr' => 'test',
'valueDec' => null,
'valueDat' => null,
'isDefault' => true,
],
$this->value->jsonSerialize()
);
}
}

View File

@ -52,7 +52,7 @@ final class SupplierTest extends \PHPUnit\Framework\TestCase
self::assertEquals([], $this->supplier->getAddresses());
self::assertEquals([], $this->supplier->getContactElements());
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->supplier->createdAt->format('Y-m-d'));
self::assertInstanceOf('\Modules\Profile\Models\Profile', $this->supplier->profile);
self::assertInstanceOf('\Modules\Admin\Models\Account', $this->supplier->account);
self::assertInstanceOf('\Modules\Admin\Models\Address', $this->supplier->mainAddress);
self::assertInstanceOf('\Modules\Profile\Models\NullContactElement', $this->supplier->getMainContactElement(0));
}