test fixes

This commit is contained in:
Dennis Eichhorn 2023-04-17 19:44:57 +02:00
parent 5b2c9d499b
commit 004eb33a4f
26 changed files with 84 additions and 126 deletions

View File

@ -46,7 +46,7 @@ final class EUVATBffOnline implements EUVATInterface
{
$result = [
'status' => -1,
'vat' => 'C',
'vat' => 'B',
'name' => '',
'city' => '',
'postal' => '',
@ -102,7 +102,7 @@ final class EUVATBffOnline implements EUVATInterface
{
$result = [
'status' => -1,
'vat' => 'C',
'vat' => 'B',
'name' => 'C',
'city' => 'C',
'postal' => 'C',

View File

@ -46,7 +46,7 @@ final class EUVATVies implements EUVATInterface
{
$result = [
'status' => -1,
'vat' => 'C',
'vat' => 'B',
'name' => '',
'city' => '',
'postal' => '',
@ -101,7 +101,7 @@ final class EUVATVies implements EUVATInterface
{
$result = [
'status' => -1,
'vat' => 'C',
'vat' => 'B',
'name' => 'C',
'city' => 'C',
'postal' => 'C',
@ -137,13 +137,16 @@ final class EUVATVies implements EUVATInterface
$result = \array_merge($result, self::parseResponse($json));
if ($otherName === '') {
$result['name'] = 'D';
} elseif (\stripos($result['name'], $otherName) !== false && \strlen($otherName) / \strlen($result['name']) > 0.8 || \levenshtein($otherName, $result['name']) / \strlen($result['name']) < 0.2) {
$result['name'] = 'C';
} elseif ((\stripos($result['name'], $otherName) !== false
&& \strlen($otherName) / \strlen($result['name']) > 0.8)
|| \levenshtein($otherName, $result['name']) / \strlen($result['name']) < 0.2
) {
$result['name'] = 'A';
} elseif ($result['name'] === '') {
$result['name'] = 'C';
} else {
$result['name'] = 'C';
$result['name'] = 'B';
}
if ($otherCity === '') {
@ -153,7 +156,7 @@ final class EUVATVies implements EUVATInterface
} elseif ($result['city'] === '') {
$result['city'] = 'C';
} else {
$result['city'] = 'C';
$result['city'] = 'B';
}
if ($otherPostal === '') {
@ -163,7 +166,7 @@ final class EUVATVies implements EUVATInterface
} elseif ($result['postal'] === '') {
$result['postal'] = 'C';
} else {
$result['postal'] = 'C';
$result['postal'] = 'B';
}
if ($otherStreet === '') {
@ -175,7 +178,7 @@ final class EUVATVies implements EUVATInterface
} elseif ($result['address'] === '') {
$result['address'] = 'C';
} else {
$result['address'] = 'C';
$result['address'] = 'B';
}
$result['status'] = $json['userError'] === 'VALID' ? 0 : -1;

View File

@ -135,7 +135,11 @@ class Grammar extends GrammarAbstract
$sql[] = $this->compileRandom($query, $query->random);
break;
case queryType::NONE:
case QueryType::RAW:
$sql[] = $query->raw;
break;
case QueryType::NONE:
return [];
default:
throw new \InvalidArgumentException('Unknown query type.');

View File

@ -15,6 +15,7 @@ declare(strict_types=1);
namespace phpOMS\DataStorage\Session;
use phpOMS\DataStorage\LockException;
use phpOMS\Log\FileLogger;
use phpOMS\Uri\UriFactory;
/**
@ -97,7 +98,14 @@ final class HttpSession implements SessionInterface
\session_start();
// @codeCoverageIgnoreEnd
} else {
throw new \Exception('Bad application workflow');
$logger = FileLogger::getInstance();
$logger->error(
FileLogger::MSG_FULL, [
'message' => 'Bad application flow.',
'line' => __LINE__,
'file' => self::class,
]
);
}
if ($this->inactivityInterval > 0

View File

@ -77,7 +77,7 @@ class PacketManager
$response = new SocketResponse();
$this->dispatcher->dispatch(
$this->router->route($data, null, RouteVerb::ANY, 'Socket', 1, $client->getAccount()),
$this->router->route($data, null, RouteVerb::ANY, 2, 1, $client->getAccount()),
$request,
$response
);

View File

@ -73,16 +73,17 @@ class Graph
/**
* Define a relationship between two nodes
*
* @param Node $node1 First node
* @param Node $node2 Second node
* @param Node $node1 First node
* @param Node $node2 Second node
* @param bool $directed Is directed
*
* @return Edge
*
* @since 1.0.0
*/
public function setNodeRelative(Node $node1, Node $node2) : Edge
public function setNodeRelative(Node $node1, Node $node2, bool $directed = false) : Edge
{
return $node1->setNodeRelative($node2, null, true);
return $node1->setNodeRelative($node2, null, $directed);
}
/**

View File

@ -136,7 +136,7 @@ final class GroupTest extends \PHPUnit\Framework\TestCase
$group->addPermission(new class() extends PermissionAbstract {});
self::assertCount(1, $group->getPermissions());
self::assertFalse($group->hasPermission(PermissionType::READ, 1, 'a', 'a', 1, 1, 1));
self::assertFalse($group->hasPermission(PermissionType::READ, 1, null, 'a', 1, 1, 1));
self::assertTrue($group->hasPermission(PermissionType::NONE));
}

View File

@ -30,10 +30,9 @@ final class EUVATBffOnlineTest extends \PHPUnit\Framework\TestCase
*/
public function testValidateInvalidId() : void
{
$bff = new EUVATBffOnline();
$status = $bff->validate('DE123456789', 'DE123456789');
$status = EUVATBffOnline::validate('DE123456789', 'DE123456789');
self::assertEquals(0, $status['status']);
self::assertEquals('C', $status['vat']);
self::assertEquals('B', $status['vat']);
}
}

View File

@ -30,10 +30,9 @@ final class EUVATViesTest extends \PHPUnit\Framework\TestCase
*/
public function testValidateInvalidId() : void
{
$vies = new EUVATVies();
$status = $vies->validate('DE123456789');
$status = EUVATVies::validate('DE123456789');
self::assertEquals(0, $status['status']);
self::assertEquals('C', $status['vat']);
self::assertEquals('B', $status['vat']);
}
}

View File

@ -52,7 +52,7 @@ final class RestTest extends \PHPUnit\Framework\TestCase
$request = new HttpRequest(new HttpUri('http://httpbin.org/post'));
$request->setMethod(RequestMethod::POST);
self::assertTrue($request->setData('pdata', 'abc'));
self::assertEquals('abc', REST::request($request)->getJsonData()['form']['pdata']);
self::assertEquals('abc', REST::request($request)->getJsonData()['form']['pdata'] ?? '');
}
/**
@ -65,7 +65,7 @@ final class RestTest extends \PHPUnit\Framework\TestCase
$request = new HttpRequest(new HttpUri('http://httpbin.org/put'));
$request->setMethod(RequestMethod::PUT);
self::assertTrue($request->setData('pdata', 'abc'));
self::assertEquals('abc', REST::request($request)->getJsonData()['form']['pdata']);
self::assertEquals('abc', REST::request($request)->getJsonData()['form']['pdata'] ?? '');
}
/**
@ -78,7 +78,7 @@ final class RestTest extends \PHPUnit\Framework\TestCase
$request = new HttpRequest(new HttpUri('http://httpbin.org/delete'));
$request->setMethod(RequestMethod::DELETE);
self::assertTrue($request->setData('ddata', 'abc'));
self::assertEquals('abc', REST::request($request)->getJsonData()['form']['ddata']);
self::assertEquals('abc', REST::request($request)->getJsonData()['form']['ddata'] ?? '');
}
/**
@ -91,7 +91,7 @@ final class RestTest extends \PHPUnit\Framework\TestCase
$request = new HttpRequest(new HttpUri('http://httpbin.org/get'));
$request->setMethod(RequestMethod::GET);
self::assertTrue($request->setData('gdata', 'abc'));
self::assertEquals('abc', REST::request($request)->getJsonData()['args']['gdata']);
self::assertEquals('abc', REST::request($request)->getJsonData()['args']['gdata'] ?? '');
}
/**

View File

@ -62,11 +62,11 @@ final class NotifyTest extends \PHPUnit\Framework\TestCase
public function testSetGet() : void
{
$obj = new Notify('message', NotifyType::WARNING);
$obj->setDelay(3);
$obj->setStay(5);
$obj->setLevel(NotifyType::ERROR);
$obj->setMessage('msg');
$obj->setTitle('title');
$obj->delay = 3;
$obj->stay = 5;
$obj->level = NotifyType::ERROR;
$obj->message ='msg';
$obj->title = 'title';
self::assertEquals([
'type' => 'notify',

View File

@ -0,0 +1 @@
404: Not Found

View File

@ -0,0 +1 @@
To copy!

View File

View File

@ -0,0 +1 @@
To copy!

View File

View File

View File

@ -59,7 +59,7 @@ $app->moduleManager = new ModuleManager($app, __DIR__ . '/../../../../Modules/'
$app->dispatcher = new Dispatcher($app);
$app->eventManager = new EventManager($app->dispatcher);
$app->eventManager->importFromFile(__DIR__ . '/../../../Socket/Hooks.php');
$app->l11nManager = new L11nManager($app->appName);
$app->l11nManager = new L11nManager();
$app->router = new SocketRouter();
$socket = new Server($app);

View File

@ -1,26 +0,0 @@
<?php
/**
* Karaka
*
* 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 phpOMS\tests\Stdlib\Graph;
/**
* @internal
*/
final class BinaryTreeTest extends \PHPUnit\Framework\TestCase
{
public function testPlaceholder() : void
{
self::markTestIncomplete();
}
}

View File

@ -33,10 +33,10 @@ final class EdgeTest extends \PHPUnit\Framework\TestCase
{
$edge = new Edge(new Node('1'), new Node('2'));
self::assertEquals([new Node('1'), new Node('2')], $edge->getNodes());
self::assertTrue($edge->getNode1()->isEqual(new Node('1')));
self::assertTrue($edge->getNode2()->isEqual(new Node('2')));
self::assertEquals(1.0, $edge->getWeight());
self::assertFalse($edge->isDirected());
self::assertTrue($edge->node1->isEqual(new Node('1')));
self::assertTrue($edge->node2->isEqual(new Node('2')));
self::assertEquals(1.0, $edge->weight);
self::assertFalse($edge->isDirected);
}
/**
@ -47,7 +47,7 @@ final class EdgeTest extends \PHPUnit\Framework\TestCase
public function testDirected() : void
{
$edge = new Edge(new Node('7'), new Node('8'), 1.0, true);
self::assertTrue($edge->isDirected());
self::assertTrue($edge->isDirected);
}
/**
@ -58,11 +58,11 @@ final class EdgeTest extends \PHPUnit\Framework\TestCase
public function testWeightInputOutput() : void
{
$edge = new Edge(new Node('7'), new Node('8'), 2.0, true);
self::assertEquals(2.0, $edge->getWeight());
self::assertEquals(2.0, $edge->weight);
$edge = new Edge(new Node('7'), new Node('8'), 1.0);
$edge->setWeight(3.0);
self::assertEquals(3.0, $edge->getWeight());
$edge->weight = 3.0;
self::assertEquals(3.0, $edge->weight);
}
/**

View File

@ -49,18 +49,14 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
self::assertEquals(0, $this->graph->getSize());
self::assertEquals(0, $this->graph->getGirth());
self::assertEquals(0, $this->graph->getCircuitRank());
self::assertEquals(0, $this->graph->getNodeConnectivity());
self::assertEquals(0, $this->graph->getEdgeConnectivity());
self::assertTrue($this->graph->isConnected());
self::assertTrue($this->graph->isBipartite());
self::assertTrue($this->graph->isTriangleFree());
self::assertTrue($this->graph->isBipartite(1));
self::assertFalse($this->graph->isDirected());
self::assertFalse($this->graph->hasCycle());
self::assertEquals([], $this->graph->getBridges());
self::assertEquals([], $this->graph->getFloydWarshallShortestPath());
self::assertEquals([], $this->graph->getDijkstraShortestPath());
self::assertEquals([], $this->graph->longestPath());
self::assertEquals([], $this->graph->longestPathBetweenNodes('invalid1', 'invalid2'));
self::assertEquals([], $this->graph->shortestPathBetweenNodes('invalid1', 'invalid2'));
@ -76,10 +72,9 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
* @covers phpOMS\Stdlib\Graph\Graph
* @group framework
*/
public function testDirectedInputOutput() : void
public function testDirectedOutput() : void
{
$this->graph->setDirected(true);
self::assertTrue($this->graph->isDirected());
self::assertFalse($this->graph->isDirected());
}
/**
@ -143,8 +138,8 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
$bridges = $this->graph->getBridges();
self::assertCount(1, $bridges);
self::assertEquals('1', $bridges[0]->getNode1()->getId());
self::assertEquals('6', $bridges[0]->getNode2()->getId());
self::assertEquals('1', $bridges[0]->node1->getId());
self::assertEquals('6', $bridges[0]->node2->getId());
}
/**
@ -265,12 +260,12 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
self::assertEquals(
$node1->getId(),
$this->graph->getEdge($node1->getId(), $node3->getId())->getNode1()->getId()
$this->graph->getEdge($node1->getId(), $node3->getId())->node1->getId()
);
self::assertEquals(
$node3->getId(),
$this->graph->getEdge($node1->getId(), $node3->getId())->getNode2()->getId()
$this->graph->getEdge($node1->getId(), $node3->getId())->node2->getId()
);
self::assertNull($this->graph->getEdge('invalid1', 'invalid2'));
@ -310,8 +305,6 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
*/
public function testDirectedCycle() : void
{
$this->graph->setDirected(true);
$node0 = new Node('0');
$node1 = new Node('1');
$node2 = new Node('2');
@ -322,10 +315,10 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
$this->graph->setNode($node2);
$this->graph->setNode($node3);
$this->graph->setNodeRelative($node0, $node1);
$this->graph->setNodeRelative($node1, $node2);
$this->graph->setNodeRelative($node2, $node3);
$this->graph->setNodeRelative($node1, $node3);
$this->graph->setNodeRelative($node0, $node1, true);
$this->graph->setNodeRelative($node1, $node2, true);
$this->graph->setNodeRelative($node2, $node3, true);
$this->graph->setNodeRelative($node1, $node3, true);
self::assertFalse($this->graph->hasCycle());
@ -350,8 +343,8 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
$this->graph->setNode($node2);
$this->graph->setNode($node3);
$node0->setNodeRelative($node1)->setWeight(2.0);
$node2->setNodeRelative($node3)->setWeight(3.0);
$node0->setNodeRelative($node1)->weight = 2.0;
$node2->setNodeRelative($node3)->weight = 3.0;
self::assertEquals(5.0, $this->graph->getCost());
}
@ -377,18 +370,18 @@ final class GraphTest extends \PHPUnit\Framework\TestCase
$this->graph->setNode($node5);
$this->graph->setNode($node6);
$node1->setNodeRelative($node5)->setWeight(4.0);
$node1->setNodeRelative($node4)->setWeight(1.0);
$node1->setNodeRelative($node2)->setWeight(2.0);
$node1->setNodeRelative($node5)->weight = 4.0;
$node1->setNodeRelative($node4)->weight = 1.0;
$node1->setNodeRelative($node2)->weight = 2.0;
$node2->setNodeRelative($node3)->setWeight(3.0);
$node2->setNodeRelative($node4)->setWeight(3.0);
$node2->setNodeRelative($node6)->setWeight(7.0);
$node2->setNodeRelative($node3)->weight = 3.0;
$node2->setNodeRelative($node4)->weight = 3.0;
$node2->setNodeRelative($node6)->weight = 7.0;
$node3->setNodeRelative($node4)->setWeight(5.0);
$node3->setNodeRelative($node6)->setWeight(8.0);
$node3->setNodeRelative($node4)->weight = 5.0;
$node3->setNodeRelative($node6)->weight = 8.0;
$node4->setNodeRelative($node5)->setWeight(9.0);
$node4->setNodeRelative($node5)->weight = 9.0;
$minimalSpanningTree = $this->graph->getKruskalMinimalSpanningTree();
$nodes = $minimalSpanningTree->getNodes();

View File

@ -1,26 +0,0 @@
<?php
/**
* Karaka
*
* 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 phpOMS\tests\Stdlib\Graph;
/**
* @internal
*/
final class TreeTest extends \PHPUnit\Framework\TestCase
{
public function testPlaceholder() : void
{
self::markTestIncomplete();
}
}

View File

@ -14,12 +14,12 @@ declare(strict_types=1);
namespace phpOMS\tests\Utils\Barcode;
use phpOMS\Utils\Barcode\C128Abstract;
use phpOMS\Utils\Barcode\BarAbstract;
/**
* @internal
*/
final class C128AbstractTest extends \PHPUnit\Framework\TestCase
final class BarAbstractTest extends \PHPUnit\Framework\TestCase
{
protected $obj = null;
@ -28,7 +28,7 @@ final class C128AbstractTest extends \PHPUnit\Framework\TestCase
*/
protected function setUp() : void
{
$this->obj = new class() extends C128Abstract {};
$this->obj = new class() extends BarAbstract {};
}
/**