mirror of
https://github.com/Karaka-Management/oms-Exchange.git
synced 2026-01-13 09:38:40 +00:00
121 lines
3.2 KiB
PHP
Executable File
121 lines
3.2 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Karaka
|
|
*
|
|
* PHP Version 8.1
|
|
*
|
|
* @package tests
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link https://karaka.app
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Exchange\tests\Models;
|
|
|
|
use Modules\Exchange\Models\InterfaceManager;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
final class InterfaceManagerTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
private InterfaceManager $interface;
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function setUp() : void
|
|
{
|
|
$this->interface = new InterfaceManager();
|
|
}
|
|
|
|
/**
|
|
* @covers Modules\Exchange\Models\InterfaceManager
|
|
* @group module
|
|
*/
|
|
public function testDefault() : void
|
|
{
|
|
self::assertEquals(0, $this->interface->getId());
|
|
self::assertEquals('', $this->interface->getPath());
|
|
self::assertEquals('', $this->interface->getName());
|
|
self::assertEquals('', $this->interface->getInterfacePath());
|
|
self::assertFalse($this->interface->hasImport());
|
|
self::assertFalse($this->interface->hasExport());
|
|
self::assertEquals([], $this->interface->get());
|
|
}
|
|
|
|
/**
|
|
* @covers Modules\Exchange\Models\InterfaceManager
|
|
* @group module
|
|
*/
|
|
public function testLoadInputOutput() : void
|
|
{
|
|
$this->interface = new InterfaceManager(__DIR__ . '/testInterface.json');
|
|
$this->interface->load();
|
|
|
|
self::assertEquals(
|
|
\json_decode(\file_get_contents(__DIR__ . '/testInterface.json'), true),
|
|
$this->interface->get()
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @covers Modules\Exchange\Models\InterfaceManager
|
|
* @group module
|
|
*/
|
|
public function testSetInputOutput() : void
|
|
{
|
|
$this->interface = new InterfaceManager(__DIR__ . '/testInterface.json');
|
|
$this->interface->load();
|
|
|
|
$this->interface->set('website', 'https://karaka.app');
|
|
self::assertEquals('https://karaka.app', $this->interface->get()['website']);
|
|
|
|
self::assertNotEquals(
|
|
\json_decode(\file_get_contents(__DIR__ . '/testInterface.json'), true),
|
|
$this->interface->get()
|
|
);
|
|
|
|
$this->interface->update();
|
|
self::assertEquals(
|
|
\json_decode(\file_get_contents(__DIR__ . '/testInterface.json'), true),
|
|
$this->interface->get()
|
|
);
|
|
|
|
$this->interface->set('website', '');
|
|
$this->interface->update();
|
|
}
|
|
|
|
/**
|
|
* @covers Modules\Exchange\Models\InterfaceManager
|
|
* @group module
|
|
*/
|
|
public function testInvalidPathLoad() : void
|
|
{
|
|
$this->expectException(\phpOMS\System\File\PathException::class);
|
|
$this->interface->load();
|
|
}
|
|
|
|
/**
|
|
* @covers Modules\Exchange\Models\InterfaceManager
|
|
* @group module
|
|
*/
|
|
public function testInvalidPathUpdate() : void
|
|
{
|
|
$this->expectException(\phpOMS\System\File\PathException::class);
|
|
$this->interface->update();
|
|
}
|
|
|
|
/**
|
|
* @covers Modules\Exchange\Models\InterfaceManager
|
|
* @group module
|
|
*/
|
|
public function testInvalidDataSet() : void
|
|
{
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
$this->interface->set('test/path', new InterfaceManager());
|
|
}
|
|
}
|