test fixes

This commit is contained in:
Dennis Eichhorn 2024-03-17 02:36:48 +00:00
parent 5876d88901
commit 44098e33d2
22 changed files with 82 additions and 119 deletions

View File

@ -129,14 +129,14 @@ class SQLiteGrammar extends Grammar
$fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL'; $fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL';
} }
if ($field['primary'] ?? false) {
$keys .= ' PRIMARY KEY';
}
if ($field['autoincrement'] ?? false) { if ($field['autoincrement'] ?? false) {
$fieldQuery .= ' AUTOINCREMENT'; $fieldQuery .= ' AUTOINCREMENT';
} }
if ($field['primary'] ?? false) {
$fieldQuery .= ' PRIMARY KEY';
}
$fieldQuery .= ','; $fieldQuery .= ',';
if ($field['unique'] ?? false) { if ($field['unique'] ?? false) {

View File

@ -853,20 +853,17 @@ class Matrix implements \ArrayAccess, \Iterator
throw new InvalidDimensionException($this->m . 'x' . $this->n); throw new InvalidDimensionException($this->m . 'x' . $this->n);
} }
$sum = new IdentityMatrix($this->m); $eig = new EigenvalueDecomposition($this);
$v = $eig->getV();
$d = $eig->getD();
$factorial = 1; $vInv = $v->inverse();
$pow = clone $sum;
for ($i = 1; $i <= $iterations; ++$i) { for ($i = 0; $d->m; ++$i) {
$factorial *= $i; $d->matrix[$i][$i] = \exp($d->matrix[$i][$i]);
$coeff = 1 / $factorial;
$pow = $pow->mult($this);
$sum = $sum->add($pow->mult($coeff));
} }
return $sum; return $v->mult($d)->mult($vInv);
} }
/** /**

View File

@ -120,7 +120,7 @@ final class SocketRouter implements RouterInterface
{ {
$bound = []; $bound = [];
foreach ($this->routes as $route => $destination) { foreach ($this->routes as $route => $destination) {
if (!((bool) \preg_match('~^' . $route . '$~', $uri))) { if (!((bool) \preg_match('~' . $route . '~', $uri))) {
continue; continue;
} }

View File

@ -129,7 +129,7 @@ final class WebRouter implements RouterInterface
{ {
$bound = []; $bound = [];
foreach ($this->routes as $route => $destination) { foreach ($this->routes as $route => $destination) {
if (!((bool) \preg_match('~^' . $route . '$~', $uri))) { if (!((bool) \preg_match('~' . $route . '~', $uri))) {
continue; continue;
} }

View File

@ -36,7 +36,7 @@ class ClientConnection
private $connected = true; private $connected = true;
private Account $account; public Account $account;
/** /**
* Constructor. * Constructor.

View File

@ -108,9 +108,9 @@ class Server extends SocketAbstract
*/ */
public function create(string $ip, int $port) : void public function create(string $ip, int $port) : void
{ {
$this->app->logger->info('Creating socket...'); $this->app->logger?->info('Creating socket...');
parent::create($ip, $port); parent::create($ip, $port);
$this->app->logger->info('Binding socket...'); $this->app->logger?->info('Binding socket...');
\socket_bind($this->sock, $this->ip, $this->port); \socket_bind($this->sock, $this->ip, $this->port);
} }
@ -190,12 +190,12 @@ class Server extends SocketAbstract
*/ */
public function run() : void public function run() : void
{ {
$this->app->logger->info('Start listening...'); $this->app->logger?->info('Start listening...');
@\socket_listen($this->sock); @\socket_listen($this->sock);
@\socket_set_nonblock($this->sock); @\socket_set_nonblock($this->sock);
$this->conn[] = $this->sock; $this->conn[] = $this->sock;
$this->app->logger->info('Is running...'); $this->app->logger?->info('Is running...');
while ($this->run) { while ($this->run) {
$read = $this->conn; $read = $this->conn;
@ -225,12 +225,12 @@ class Server extends SocketAbstract
$data = \is_string($data) ? \trim($data) : ''; $data = \is_string($data) ? \trim($data) : '';
if (!$client->getHandshake()) { if (!$client->getHandshake()) {
$this->app->logger->debug('Doing handshake...'); $this->app->logger?->debug('Doing handshake...');
if ($this->handshake($client, $data)) { if ($this->handshake($client, $data)) {
$client->setHandshake(true); $client->setHandshake(true);
$this->app->logger->debug('Handshake succeeded.'); $this->app->logger?->debug('Handshake succeeded.');
} else { } else {
$this->app->logger->debug('Handshake failed.'); $this->app->logger?->debug('Handshake failed.');
$this->disconnectClient($client); $this->disconnectClient($client);
} }
} else { } else {
@ -239,7 +239,7 @@ class Server extends SocketAbstract
} }
} }
} }
$this->app->logger->info('Is shutdown...'); $this->app->logger?->info('Is shutdown...');
$this->close(); $this->close();
} }
@ -272,13 +272,13 @@ class Server extends SocketAbstract
*/ */
public function connectClient($socket) : void public function connectClient($socket) : void
{ {
$this->app->logger->debug('Connecting client...'); $this->app->logger?->debug('Connecting client...');
$this->app->accountManager->add(new NullAccount(1)); $this->app->accountManager->add(new NullAccount(1));
$this->clientManager->add($client = new ClientConnection(new NullAccount(1), $socket)); $this->clientManager->add($client = new ClientConnection(new NullAccount(1), $socket));
$this->conn[$client->getId()] = $socket; $this->conn[$client->getId()] = $socket;
$this->app->logger->debug('Connected client.'); $this->app->logger?->debug('Connected client.');
} }
/** /**
@ -292,7 +292,7 @@ class Server extends SocketAbstract
*/ */
public function disconnectClient($client) : void public function disconnectClient($client) : void
{ {
$this->app->logger->debug('Disconnecting client...'); $this->app->logger?->debug('Disconnecting client...');
$client->setConnected(false); $client->setConnected(false);
$client->setHandshake(false); $client->setHandshake(false);
\socket_shutdown($client->getSocket(), 2); \socket_shutdown($client->getSocket(), 2);
@ -303,7 +303,7 @@ class Server extends SocketAbstract
} }
$this->clientManager->remove($client->id); $this->clientManager->remove($client->id);
$this->app->logger->debug('Disconnected client.'); $this->app->logger?->debug('Disconnected client.');
} }
/** /**

View File

@ -517,7 +517,7 @@ class File extends FileAbstract implements FileInterface
return false; return false;
} }
$newParent = $this->findNode($to); $newParent = $this->findNode(\dirname($to));
$state = self::copy($this->con, $this->path, $to, $overwrite); $state = self::copy($this->con, $this->path, $to, $overwrite);

View File

@ -238,11 +238,11 @@ abstract class FileAbstract implements FtpContainerInterface
* *
* @param string $path Path of the node * @param string $path Path of the node
* *
* @return null|Directory * @return null|Directory|File
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function findNode(string $path) : ?Directory public function findNode(string $path) : null|Directory|File
{ {
// Change parent element // Change parent element
$currentPath = \explode('/', \trim($this->path, '/')); $currentPath = \explode('/', \trim($this->path, '/'));

View File

@ -491,7 +491,7 @@ final class File extends FileAbstract implements FileInterface
*/ */
public function copyNode(string $to, bool $overwrite = false) : bool public function copyNode(string $to, bool $overwrite = false) : bool
{ {
$newParent = $this->findNode($to); $newParent = $this->findNode(\dirname($to));
$state = self::copy($this->path, $to, $overwrite); $state = self::copy($this->path, $to, $overwrite);

View File

@ -269,11 +269,11 @@ abstract class FileAbstract implements LocalContainerInterface
* *
* @param string $path Path of the node * @param string $path Path of the node
* *
* @return null|Directory * @return null|Directory|File
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function findNode(string $path) : ?Directory public function findNode(string $path) : null|Directory|File
{ {
// Change parent element // Change parent element
$currentPath = \explode('/', \trim($this->path, '/')); $currentPath = \explode('/', \trim($this->path, '/'));

View File

@ -72,7 +72,7 @@ final class TesseractOcrTest extends \PHPUnit\Framework\TestCase
{ {
$this->expectException(PathException::class); $this->expectException(PathException::class);
$ocr = new TesseractOcr('/invalid/path'); TesseractOcr::setBin('/invalid/path');
} }
/** /**

View File

@ -67,7 +67,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->toSql()); self::assertEquals($sql, $query->select('a.test')->from('a')->where('a.test', '=', 1)->toSql());
$query = new Builder($con); $query = new Builder($con);
$sql = 'SELECT [a].[test] as t FROM [a] as b WHERE [a].[test] = 1;'; $sql = 'SELECT [a].[test] AS t FROM [a] AS b WHERE [a].[test] = 1;';
$sql = \strtr($sql, '[]', $iS . $iE); $sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->selectAs('a.test', 't')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql()); self::assertEquals($sql, $query->selectAs('a.test', 't')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
@ -121,7 +121,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd; $iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con); $query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b WHERE [a].[test] = 1 ORDER BY RAND() LIMIT 1;'; $sql = 'SELECT [a].[test] FROM [a] AS b WHERE [a].[test] = 1 ORDER BY RAND() LIMIT 1;';
$sql = \strtr($sql, '[]', $iS . $iE); $sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql()); self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
} }
@ -134,7 +134,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd; $iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con); $query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b ORDER BY RANDOM() LIMIT 1;'; $sql = 'SELECT [a].[test] FROM [a] AS b ORDER BY RANDOM() LIMIT 1;';
$sql = \strtr($sql, '[]', $iS . $iE); $sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql()); self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
} }
@ -147,7 +147,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd; $iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con); $query = new Builder($con);
$sql = 'SELECT [a].[test] FROM [a] as b ORDER BY RANDOM() LIMIT 1;'; $sql = 'SELECT [a].[test] FROM [a] AS b ORDER BY RANDOM() LIMIT 1;';
$sql = \strtr($sql, '[]', $iS . $iE); $sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql()); self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
} }
@ -160,7 +160,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
$iE = $con->getGrammar()->systemIdentifierEnd; $iE = $con->getGrammar()->systemIdentifierEnd;
$query = new Builder($con); $query = new Builder($con);
$sql = 'SELECT TOP 1 [a].[test] FROM [a] as b ORDER BY IDX FETCH FIRST 1 ROWS ONLY;'; $sql = 'SELECT TOP 1 [a].[test] FROM [a] AS b ORDER BY IDX FETCH FIRST 1 ROWS ONLY;';
$sql = \strtr($sql, '[]', $iS . $iE); $sql = \strtr($sql, '[]', $iS . $iE);
self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql()); self::assertEquals($sql, $query->random('a.test')->fromAs('a', 'b')->where('a.test', '=', 1)->toSql());
} }

View File

@ -180,7 +180,7 @@ final class BuilderTest extends \PHPUnit\Framework\TestCase
} elseif ($con instanceof SqlServerConnection) { } elseif ($con instanceof SqlServerConnection) {
$sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));'; $sql = 'CREATE TABLE IF NOT EXISTS [user_roles] ([user_id] INT AUTO_INCREMENT, [role_id] VARCHAR(10) DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
} elseif ($con instanceof SQLiteConnection) { } elseif ($con instanceof SQLiteConnection) {
$sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER PRIMARY KEY AUTOINCREMENT, [role_id] TEXT DEFAULT \'1\' NULL, PRIMARY KEY ([user_id]), FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));'; $sql = 'CREATE TABLE [user_roles] ([user_id] INTEGER AUTOINCREMENT PRIMARY KEY, [role_id] TEXT DEFAULT \'1\' NULL, FOREIGN KEY ([user_id]) REFERENCES [users] ([ext1_id]), FOREIGN KEY ([role_id]) REFERENCES [roles] ([ext2_id]));';
} }
$sql = \strtr($sql, '[]', $iS . $iE); $sql = \strtr($sql, '[]', $iS . $iE);

View File

@ -108,7 +108,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDynamicRouteAdding() : void public function testDynamicRouteAdding() : void
{ {
$this->router->add('^.*backends_admin -settings=general(\?.*$|$)', 'Controller:test'); $this->router->add('^.*backends_admin -settings=general( \-.*$|$)', 'Controller:test');
self::assertEquals( self::assertEquals(
[['dest' => 'Controller:test']], [['dest' => 'Controller:test']],
$this->router->route('backends_admin -settings=general -t 123') $this->router->route('backends_admin -settings=general -t 123')
@ -219,7 +219,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
public function testDataValidation() : void public function testDataValidation() : void
{ {
$this->router->add( $this->router->add(
'^.*backends_admin -settings=general(\?.*$|$)', '^.*backends_admin -settings=general( \-.*$|$)',
'Controller:test', 'Controller:test',
validation: ['test_pattern' => '/^[a-z]*$/'] validation: ['test_pattern' => '/^[a-z]*$/']
); );
@ -238,7 +238,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
public function testInvalidDataValidation() : void public function testInvalidDataValidation() : void
{ {
$this->router->add( $this->router->add(
'^.*backends_admin -settings=general(\?.*$|$)', '^.*backends_admin -settings=general( \-.*$|$)',
'Controller:test', 'Controller:test',
validation: ['test_pattern' => '/^[a-z]*$/'] validation: ['test_pattern' => '/^[a-z]*$/']
); );
@ -257,7 +257,7 @@ final class SocketRouterTest extends \PHPUnit\Framework\TestCase
public function testDataFromPattern() : void public function testDataFromPattern() : void
{ {
$this->router->add( $this->router->add(
'^.*-settings=general(\?.*$|$)', '^.*-settings=general( \-.*$|$)',
'Controller:test', 'Controller:test',
dataPattern: '/^.*?(settings)=([a-z]*).*?$/' dataPattern: '/^.*?(settings)=([a-z]*).*?$/'
); );

View File

@ -91,7 +91,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test') new HttpUri('http://test.com/backend/admin/settings/general?test')
))->uri->getRoute() ))->uri->getRoute()
) )
); );
@ -111,7 +111,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[], [],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test') new HttpUri('http://test.com/backend/admin/settings/general?test')
))->uri->getRoute() ))->uri->getRoute()
) )
); );
@ -130,7 +130,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backend/admin/settings/general/something?test') new HttpUri('http://test.com/backend/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::PUT) ))->uri->getRoute(), null, RouteVerb::PUT)
); );
} }
@ -147,7 +147,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']], [['dest' => 'Controller:test']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::ANY) ))->uri->getRoute(), null, RouteVerb::ANY)
); );
@ -155,7 +155,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']], [['dest' => 'Controller:test']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::SET) ))->uri->getRoute(), null, RouteVerb::SET)
); );
@ -163,7 +163,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']], [['dest' => 'Controller:test']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test')))->uri->getRoute(), null, RouteVerb::GET) new HttpUri('http://test.com/backends/admin/settings/general?test')))->uri->getRoute(), null, RouteVerb::GET)
); );
} }
@ -236,7 +236,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
self::assertEquals( self::assertEquals(
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route( $this->router->route(
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->uri->getRoute(), (new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general?test')))->uri->getRoute(),
null, null,
RouteVerb::GET, RouteVerb::GET,
null, null,
@ -300,7 +300,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
self::assertNotEquals( self::assertNotEquals(
[['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']], [['dest' => '\Modules\Admin\Controller:viewSettingsGeneral']],
$this->router->route( $this->router->route(
(new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general/something?test')))->uri->getRoute(), (new HttpRequest(new HttpUri('http://test.com/backend/admin/settings/general?test')))->uri->getRoute(),
null, null,
RouteVerb::GET, RouteVerb::GET,
null, null,
@ -329,7 +329,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']], [['dest' => 'Controller:test']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => 'abcdef']) ))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => 'abcdef'])
); );
} }
@ -353,7 +353,7 @@ final class WebRouterTest extends \PHPUnit\Framework\TestCase
[['dest' => 'Controller:test']], [['dest' => 'Controller:test']],
$this->router->route( $this->router->route(
(new HttpRequest( (new HttpRequest(
new HttpUri('http://test.com/backends/admin/settings/general/something?test') new HttpUri('http://test.com/backends/admin/settings/general?test')
))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => '123']) ))->uri->getRoute(), null, RouteVerb::ANY, null, null, null, ['test_pattern' => '123'])
); );
} }

View File

@ -1,7 +1,7 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
return [ return [
'^.*backend_admin -settings=general(\?.*$|$)' => [ '^.*backend_admin -settings=general( \-.*$|$)' => [
0 => [ 0 => [
'dest' => '\Modules\Admin\Controller:viewSettingsGeneral', 'dest' => '\Modules\Admin\Controller:viewSettingsGeneral',
], ],

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
use phpOMS\Account\PermissionType; use phpOMS\Account\PermissionType;
return [ return [
'^.*backend_admin -settings=general(\?.*$|$)' => [ '^.*backend_admin -settings=general( \-.*$|$)' => [
0 => [ 0 => [
'dest' => '\Modules\Admin\Controller:viewSettingsGeneral', 'dest' => '\Modules\Admin\Controller:viewSettingsGeneral',
'permission' => [ 'permission' => [

View File

@ -42,22 +42,19 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void public function testDefault() : void
{ {
$expected = [ $expected = [
'recipient' => '',
'fao' => '', 'fao' => '',
'location' => [ 'name' => '',
'postal' => '', 'postal' => '',
'city' => '', 'city' => '',
'country' => 'XX', 'country' => 'XX',
'address' => '', 'address' => '',
'state' => '', 'state' => '',
'lat' => 0.0, 'lat' => 0.0,
'lon' => 0.0, 'lon' => 0.0,
],
]; ];
self::assertEquals('', $this->address->recipient);
self::assertEquals('', $this->address->fao); self::assertEquals('', $this->address->fao);
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->location); self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address);
self::assertEquals($expected, $this->address->toArray()); self::assertEquals($expected, $this->address->toArray());
self::assertEquals($expected, $this->address->jsonSerialize()); self::assertEquals($expected, $this->address->jsonSerialize());
} }
@ -73,29 +70,6 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
self::assertEquals('fao', $this->address->fao); self::assertEquals('fao', $this->address->fao);
} }
/**
* @testdox The recipient can be set and returned
* @covers phpOMS\Stdlib\Base\Address
* @group framework
*/
public function testRecipientInputOutput() : void
{
$this->address->recipient = 'recipient';
self::assertEquals('recipient', $this->address->recipient);
}
/**
* @testdox The location can be set and returned
* @covers phpOMS\Stdlib\Base\Address
* @group framework
*/
public function testLocationInputOutput() : void
{
$this->address->location = new Location();
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $this->address->location);
}
/** /**
* @testdox The address can be turned into array data * @testdox The address can be turned into array data
* @covers phpOMS\Stdlib\Base\Address * @covers phpOMS\Stdlib\Base\Address
@ -104,22 +78,18 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
public function testArray() : void public function testArray() : void
{ {
$expected = [ $expected = [
'recipient' => 'recipient',
'fao' => 'fao', 'fao' => 'fao',
'location' => [ 'name' => '',
'postal' => '', 'postal' => '',
'city' => '', 'city' => '',
'country' => 'XX', 'country' => 'XX',
'address' => '', 'address' => '',
'state' => '', 'state' => '',
'lat' => 0.0, 'lat' => 0.0,
'lon' => 0.0, 'lon' => 0.0,
],
]; ];
$this->address->fao = 'fao'; $this->address->fao = 'fao';
$this->address->recipient = 'recipient';
$this->address->location = new Location();
self::assertEquals($expected, $this->address->toArray()); self::assertEquals($expected, $this->address->toArray());
} }
@ -132,22 +102,18 @@ final class AddressTest extends \PHPUnit\Framework\TestCase
public function testJsonSerialize() : void public function testJsonSerialize() : void
{ {
$expected = [ $expected = [
'recipient' => 'recipient',
'fao' => 'fao', 'fao' => 'fao',
'location' => [ 'name' => '',
'postal' => '', 'postal' => '',
'city' => '', 'city' => '',
'country' => 'XX', 'country' => 'XX',
'address' => '', 'address' => '',
'state' => '', 'state' => '',
'lat' => 0.0, 'lat' => 0.0,
'lon' => 0.0, 'lon' => 0.0,
],
]; ];
$this->address->fao = 'fao'; $this->address->fao = 'fao';
$this->address->recipient = 'recipient';
$this->address->location = new Location();
self::assertEquals($expected, $this->address->jsonSerialize()); self::assertEquals($expected, $this->address->jsonSerialize());
} }

Binary file not shown.

View File

@ -1,2 +1,2 @@
```chart ```chartjs
``` ```

Binary file not shown.

View File

@ -193,7 +193,7 @@ final class StringUtilsTest extends \PHPUnit\Framework\TestCase
); );
self::assertEquals( self::assertEquals(
'This is a <del>test</del><ins>new</ins> string.', 'This is a <del>test</del> <ins>new</ins> string.',
StringUtils::createDiffMarkup($original, $new, ' ') StringUtils::createDiffMarkup($original, $new, ' ')
); );