mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-02-02 10:28:41 +00:00
add tests
This commit is contained in:
parent
d08c9e741e
commit
900db6305d
51
tests/Admin/AdminTest.php
Normal file
51
tests/Admin/AdminTest.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?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\tests\Navigation\Admin;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Navigation\Models\Navigation;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Module\ModuleManager;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class AdminTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected const MODULE_NAME = 'Navigation';
|
||||
protected const URI_LOAD = '';
|
||||
|
||||
use \Modules\tests\ModuleTestTrait;
|
||||
|
||||
/**
|
||||
* Test if navigation model works correct
|
||||
*
|
||||
* @group final
|
||||
* @group module
|
||||
*/
|
||||
public function testNavigationElements() : void
|
||||
{
|
||||
$request = new HttpRequest(new HttpUri('http://127.0.0.1/en/backend'));
|
||||
$request->createRequestHashs(1);
|
||||
|
||||
$account = AccountMapper::getWithPermissions(1);
|
||||
$nav = Navigation::getInstance($request, $account, $GLOBALS['dbpool'], 1, 'Backend')->getNav();
|
||||
$moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules');
|
||||
$modules = $moduleManager->getInstalledModules(false);
|
||||
|
||||
self::assertGreaterThan(0, \count($nav));
|
||||
}
|
||||
}
|
||||
46
tests/Views/NavigationViewTest.php
Normal file
46
tests/Views/NavigationViewTest.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?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\tests\Navigation\Views;
|
||||
|
||||
use Modules\Navigation\Views\NavigationView;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class NavigationViewTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDefault() : void
|
||||
{
|
||||
$view = new NavigationView();
|
||||
|
||||
self::assertEquals(0, $view->getNavId());
|
||||
self::assertEquals([], $view->getNav());
|
||||
self::assertEquals(0, $view->getParent());
|
||||
}
|
||||
|
||||
public function testGetSet() : void
|
||||
{
|
||||
$view = new NavigationView();
|
||||
|
||||
$view->setNavId(2);
|
||||
self::assertEquals(2, $view->getNavId());
|
||||
|
||||
$view->setNav([1, 2, 3]);
|
||||
self::assertEquals([1, 2, 3], $view->getNav());
|
||||
|
||||
$view->setParent(4);
|
||||
self::assertEquals(4, $view->getParent());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user