mirror of
https://github.com/Karaka-Management/oms-Attribute.git
synced 2026-01-11 16:48:41 +00:00
update readme
This commit is contained in:
parent
91b23baa47
commit
ba11b05657
|
|
@ -16,7 +16,7 @@ Generally, the development philosophy is result orientated. This means that anyo
|
|||
|
||||
Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty.
|
||||
|
||||
Open tasks can be found in the project overview: [PROJECT.md](https://github.com/Karaka-Management/Organization-Guide/blob/master/Project/PROJECT.md)
|
||||
Open tasks can be found in the project overview: [PROJECT.md](https://github.com/orgs/Karaka-Management/projects/10)
|
||||
|
||||
Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task.
|
||||
|
||||
|
|
|
|||
|
|
@ -191,18 +191,6 @@ class AttributeType implements \JsonSerializable
|
|||
$this->fields = $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default values
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @sicne 1.0.0
|
||||
*/
|
||||
public function getDefaults() : array
|
||||
{
|
||||
return $this->defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an attribute type has a certain default id
|
||||
*
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ Currently Karaka is still developing the first Alpha version. As soon as we have
|
|||
|
||||
General updates can be found in our info section at https://jingga.app/info and developer updates can be found in our developer section at https://jingga.app/dev. In our developer section you can also check out the automatically generated reports such as code coverage, code style, static analysis etc. as well as our code style guide lines and developer documentation.
|
||||
|
||||
* [Project Status](https://github.com/Karaka-Management/Organization-Guide/blob/master/Project/PROJECT.md)
|
||||
* [Project Status](https://github.com/orgs/Karaka-Management/projects/10)
|
||||
|
||||
## Tech stack
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ General updates can be found in our info section at https://jingga.app/info and
|
|||
|
||||
## Become a contributor
|
||||
|
||||
Karaka has a very open culture and we always welcome new people who share our philosophy in providing create solutions which just work. You can find the development process description which also describes how to become a contributer in the [Organization documentation](https://github.com/Karaka-Management/Organization-Guide/blob/master/Processes/Development.md).
|
||||
Karaka has a very open culture and we always welcome new people who share our philosophy in providing create solutions which just work. You can find the development process description which also describes how to become a contributer in the [Organization documentation](https://github.com/Karaka-Management/Organization-Guide/blob/master/Processes/01_Development.md).
|
||||
|
||||
## Misc
|
||||
|
||||
|
|
|
|||
69
tests/Models/AttributeHolderTraitTest.php
Normal file
69
tests/Models/AttributeHolderTraitTest.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?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;
|
||||
use Modules\Attribute\Models\AttributeHolderTrait;
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use Modules\Attribute\Models\AttributeValueType;
|
||||
use Modules\Attribute\Models\NullAttribute;
|
||||
|
||||
/**
|
||||
* @testdox Modules\Admin\tests\Models\AttributeTest: Attribute model
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class AttributeHolderTraitTestTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private $holder = null;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->holder = new class() {
|
||||
public $attributes = [];
|
||||
|
||||
use AttributeHolderTrait;
|
||||
};
|
||||
|
||||
$this->holder->attributes[] = new Attribute();
|
||||
|
||||
$this->holder->attributes[0]->type = new AttributeType('testType');
|
||||
|
||||
$this->holder->attributes[0]->value = new AttributeValue();
|
||||
$this->holder->attributes[0]->value->setValue('testValue', AttributeValueType::_STRING);
|
||||
}
|
||||
|
||||
public function testHasAttributeValue() : void
|
||||
{
|
||||
self::assertTrue($this->holder->hasAttributeValue('testType', 'testValue'));
|
||||
self::assertFalse($this->holder->hasAttributeValue('invalidTestType', 'testValue'));
|
||||
}
|
||||
|
||||
public function testHasAttributeType() : void
|
||||
{
|
||||
self::assertTrue($this->holder->hasAttributeType('testType'));
|
||||
self::assertFalse($this->holder->hasAttributeType('invalidTestType'));
|
||||
}
|
||||
|
||||
public function testGetAttribute() : void
|
||||
{
|
||||
self::assertInstanceOf(Attribute::class, $this->holder->getAttribute('testType'));
|
||||
self::assertInstanceOf(NullAttribute::class, $this->holder->getAttribute('invalidTestType'));
|
||||
}
|
||||
}
|
||||
122
tests/Models/AttributeTypeTest.php
Normal file
122
tests/Models/AttributeTypeTest.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?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\AttributeType;
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use Modules\Attribute\Models\AttributeValueType;
|
||||
|
||||
/**
|
||||
* @testdox Modules\Admin\tests\Models\AttributeTypeTest: Attribute model
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetDefaultString() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue('abc', AttributeValueType::_STRING);
|
||||
|
||||
self::assertEquals('abc', $type->getDefaultByValue('abc')->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultInt() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(1, AttributeValueType::_INT);
|
||||
|
||||
self::assertEquals(1, $type->getDefaultByValue(1)->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultFloatInt() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(1, AttributeValueType::_FLOAT_INT);
|
||||
|
||||
self::assertEquals(1, $type->getDefaultByValue(1)->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultBool() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(false, AttributeValueType::_BOOL);
|
||||
|
||||
self::assertEquals(false, $type->getDefaultByValue(false)->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultFloat() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue(1.23, AttributeValueType::_FLOAT);
|
||||
|
||||
self::assertEquals(1.23, $type->getDefaultByValue(1.23)->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultDateTime() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
$type->defaults[0]->setValue($val = new \DateTime('now'), AttributeValueType::_DATETIME);
|
||||
|
||||
self::assertEquals($val, $type->getDefaultByValue($val->format('Y-m-d H:i:s'))->getValue());
|
||||
}
|
||||
|
||||
public function testDefaultId() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
$type->defaults[] = new AttributeValue();
|
||||
|
||||
self::assertTrue($type->hasDefaultId(0));
|
||||
self::assertFalse($type->hasDefaultId(9));
|
||||
}
|
||||
|
||||
public function testToArray() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$type->toArray()
|
||||
);
|
||||
}
|
||||
|
||||
public function testJsonSerialize() : void
|
||||
{
|
||||
$type = new AttributeType();
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$type->jsonSerialize()
|
||||
);
|
||||
}
|
||||
}
|
||||
105
tests/Models/AttributeValueTest.php
Normal file
105
tests/Models/AttributeValueTest.php
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?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\AttributeValue;
|
||||
use Modules\Attribute\Models\AttributeValueType;
|
||||
use Modules\Attribute\Models\AttributeValueValue;
|
||||
|
||||
/**
|
||||
* @testdox Modules\Admin\tests\Models\AttributeValueTest: Attribute model
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class AttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testGetDefaultString() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
$value->setValue('abc', AttributeValueType::_STRING);
|
||||
|
||||
self::assertEquals('abc', $value->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultInt() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
$value->setValue(1, AttributeValueType::_INT);
|
||||
|
||||
self::assertEquals(1, $value->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultFloatInt() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
$value->setValue(1, AttributeValueType::_FLOAT_INT);
|
||||
|
||||
self::assertEquals(1, $value->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultBool() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
$value->setValue(false, AttributeValueType::_BOOL);
|
||||
|
||||
self::assertEquals(false, $value->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultFloat() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
$value->setValue(1.23, AttributeValueType::_FLOAT);
|
||||
|
||||
self::assertEquals(1.23, $value->getValue());
|
||||
}
|
||||
|
||||
public function testGetDefaultDateTime() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
$value->setValue($val = new \DateTime('now'), AttributeValueType::_DATETIME);
|
||||
|
||||
self::assertEquals($val, $value->getValue());
|
||||
}
|
||||
|
||||
public function testToArray() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$value->toArray()
|
||||
);
|
||||
}
|
||||
|
||||
public function testJsonSerialize() : void
|
||||
{
|
||||
$value = new AttributeValue();
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '',
|
||||
'validationPattern' => '',
|
||||
'custom' => false,
|
||||
'isRequired' => false,
|
||||
],
|
||||
$value->jsonSerialize()
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user