mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-02-05 07:58:39 +00:00
add tests and test todos
This commit is contained in:
parent
0f3a1d7c7f
commit
c2d99b8aa8
|
|
@ -178,7 +178,7 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
/** @var Localization #l11n */
|
||||
/** @var Localization $l11n */
|
||||
$l11n = AccountMapper::get($accountId)->getL11n();
|
||||
|
||||
if ((bool) ($request->getData('load') ?? false)) {
|
||||
|
|
|
|||
|
|
@ -119,6 +119,9 @@ final class AccountMapper extends DataMapperAbstract
|
|||
*
|
||||
* @return Account
|
||||
*
|
||||
* @todo Orange-Management/oms-Admin#11
|
||||
* [AccountMapper] Create test for getWithPermission()
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getWithPermissions(int $id) : Account
|
||||
|
|
|
|||
|
|
@ -55,4 +55,57 @@ trait ApiControllerSettingsTrait
|
|||
$this->module->apiSettingsGet($request, $response);
|
||||
self::assertEquals('US', $response->get('')['response']);
|
||||
}
|
||||
|
||||
public function testApiAccountLocalizationLoadSet() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->setData('account_id', 1);
|
||||
$request->setData('load', true);
|
||||
$request->setData('localization_load', 'de_DE');
|
||||
$this->module->apiSettingsAccountLocalizationSet($request, $response);
|
||||
|
||||
$l11n = $response->get('')['response'];
|
||||
self::assertEquals($l11n->getLanguage(), 'de');
|
||||
|
||||
$request->setData('localization_load', 'en_US', true);
|
||||
$this->module->apiSettingsAccountLocalizationSet($request, $response);
|
||||
|
||||
$l11n = $response->get('')['response'];
|
||||
self::assertEquals($l11n->getLanguage(), 'en');
|
||||
}
|
||||
|
||||
public function testApiAccountLocalizationSet() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(1);
|
||||
$request->setData('account_id', 1);
|
||||
|
||||
$data = \json_decode('{"settings_country":"US","settings_language":"en","settings_temperature":"celsius","settings_timezone":"America\/New_York","settings_timeformat_vs":"d.m","settings_timeformat_s":"m.y","settings_timeformat_m":"Y.m.d","settings_timeformat_l":"Y.m.d h:i","settings_timeformat_vl":"Y.m.d h:i:s","settings_currency":"EUR","settings_currencyformat":"0","settings_decimal":".","settings_thousands":",","settings_precision_vs":"0","settings_precision_s":"1","settings_precision_m":"2","settings_precision_l":"3","settings_precision_vl":"5","settings_weight_vl":"mg","settings_weight_l":"g","settings_weight_m":"kg","settings_weight_h":"t","settings_weight_vh":"t","settings_speed_vs":"mps","settings_speed_s":"ms","settings_speed_m":"kph","settings_speed_f":"kph","settings_speed_vf":"mach","settings_speed_sea":"mpd","settings_length_vs":"micron","settings_length_s":"mm","settings_length_m":"cm","settings_length_l":"m","settings_length_vl":"km","settings_length_sea":"mi","settings_area_vs":"micron","settings_area_s":"mm","settings_area_m":"cm","settings_area_l":"m","settings_area_vl":"km","settings_volume_vs":"mul","settings_volume_s":"ml","settings_volume_m":"l","settings_volume_l":"cm","settings_volume_vl":"m","settings_volume_teaspoon":"Metric tsp","settings_volume_tablespoon":"Metric tblsp","settings_volume_glass":"Metric cup"}', true);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$request->setData($key, $value);
|
||||
}
|
||||
|
||||
$this->module->apiSettingsAccountLocalizationSet($request, $response);
|
||||
|
||||
$l11n = $response->get('')['response'];
|
||||
self::assertEquals($l11n->getCurrency(), 'EUR');
|
||||
}
|
||||
|
||||
public function testInvalidPermissionAccountLocalizationSet() : void
|
||||
{
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->getHeader()->setAccount(2);
|
||||
$request->setData('account_id', 1);
|
||||
$this->module->apiSettingsAccountLocalizationSet($request, $response);
|
||||
|
||||
self::assertEquals([], $response->get('')['response']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
34
tests/Models/NullAccountPermissionTest.php
Normal file
34
tests/Models/NullAccountPermissionTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\tests\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccountPermission;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullAccountPermissionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Admin\Models\AccountPermission', new NullAccountPermission());
|
||||
}
|
||||
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullAccountPermission(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
34
tests/Models/NullAccountTest.php
Normal file
34
tests/Models/NullAccountTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\tests\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullAccountTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Admin\Models\Account', new NullAccount());
|
||||
}
|
||||
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullAccount(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
34
tests/Models/NullAddressTest.php
Normal file
34
tests/Models/NullAddressTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\tests\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAddress;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullAddressTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Admin\Models\Address', new NullAddress());
|
||||
}
|
||||
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullAddress(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
34
tests/Models/NullGroupPermissionTest.php
Normal file
34
tests/Models/NullGroupPermissionTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\tests\Models;
|
||||
|
||||
use Modules\Admin\Models\NullGroupPermission;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullGroupPermissionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Admin\Models\GroupPermission', new NullGroupPermission());
|
||||
}
|
||||
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullGroupPermission(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
34
tests/Models/NullGroupTest.php
Normal file
34
tests/Models/NullGroupTest.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.4
|
||||
*
|
||||
* @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\Admin\tests\Models;
|
||||
|
||||
use Modules\Admin\Models\NullGroup;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullGroupTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\Admin\Models\Group', new NullGroup());
|
||||
}
|
||||
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullGroup(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user