mirror of
https://github.com/Karaka-Management/oms-Navigation.git
synced 2026-01-24 22:38:40 +00:00
add unit tests
This commit is contained in:
parent
9e9b3f417b
commit
86375c2ef7
|
|
@ -46,8 +46,6 @@ final class AdminTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
$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));
|
||||
}
|
||||
|
|
|
|||
65
tests/Models/NavigationTest.php
Normal file
65
tests/Models/NavigationTest.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @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\Navigation\tests\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Navigation\Models\Navigation;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Module\ModuleManager;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
use phpOMS\Utils\TestUtils;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NavigationTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private Navigation $nav;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$request = new HttpRequest(new HttpUri('http://127.0.0.1/en/backend'));
|
||||
$request->createRequestHashs(1);
|
||||
|
||||
$account = AccountMapper::getWithPermissions(9999);
|
||||
$this->nav = Navigation::getInstance($request, $account, $GLOBALS['dbpool'], 1, 'Backend');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Navigation\Models\Navigation
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertTrue(\count($this->nav->getNav()) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Navigation\Models\Navigation
|
||||
* @group module
|
||||
*/
|
||||
public function testGetInstanceInvalidHashes() : void
|
||||
{
|
||||
TestUtils::setMember($this->nav, 'instance', null);
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
$account = AccountMapper::getWithPermissions(9999);
|
||||
$nav = Navigation::getInstance(null, $account, $GLOBALS['dbpool'], 1, 'Backend');
|
||||
}
|
||||
}
|
||||
|
|
@ -21,34 +21,54 @@ use Modules\Navigation\Views\NavigationView;
|
|||
*/
|
||||
final class NavigationViewTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private NavigationView $view;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->view = new NavigationView();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Navigation\Views\NavigationView
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
$view = new NavigationView();
|
||||
|
||||
self::assertEquals(0, $view->getNavId());
|
||||
self::assertEquals([], $view->getNav());
|
||||
self::assertEquals(0, $view->parent);
|
||||
self::assertEquals(0, $this->view->getNavId());
|
||||
self::assertEquals([], $this->view->getNav());
|
||||
self::assertEquals(0, $this->view->parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Navigation\Views\NavigationView
|
||||
* @group module
|
||||
*/
|
||||
public function testGetSet() : void
|
||||
public function testNavIdInputOutput() : void
|
||||
{
|
||||
$view = new NavigationView();
|
||||
$this->view->setNavId(2);
|
||||
self::assertEquals(2, $this->view->getNavId());
|
||||
}
|
||||
|
||||
$view->setNavId(2);
|
||||
self::assertEquals(2, $view->getNavId());
|
||||
/**
|
||||
* @covers Modules\Navigation\Views\NavigationView
|
||||
* @group module
|
||||
*/
|
||||
public function testNavInputOutput() : void
|
||||
{
|
||||
$this->view->setNav([1, 2, 3]);
|
||||
self::assertEquals([1, 2, 3], $this->view->getNav());
|
||||
}
|
||||
|
||||
$view->setNav([1, 2, 3]);
|
||||
self::assertEquals([1, 2, 3], $view->getNav());
|
||||
|
||||
$view->parent = 4;
|
||||
self::assertEquals(4, $view->parent);
|
||||
/**
|
||||
* @covers Modules\Navigation\Views\NavigationView
|
||||
* @group module
|
||||
*/
|
||||
public function testParentInputOutput() : void
|
||||
{
|
||||
$this->view->parent = 4;
|
||||
self::assertEquals(4, $this->view->parent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" columns="120" stopOnError="true" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
|
||||
<exclude>
|
||||
<directory>*vendor*</directory>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user