aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-08 15:23:37 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-11-08 15:23:37 +0100
commitdc9d1bb0121366d16c5ae0c32ac06d1110ac1e4b (patch)
tree00e21bad8e4046c184533137a1ec95f823532f4e
parent3d6ca0e2b55a6c6a04f483d9d115d6b44c906244 (diff)
downloadSocket-dc9d1bb0121366d16c5ae0c32ac06d1110ac1e4b.zip
Socket-dc9d1bb0121366d16c5ae0c32ac06d1110ac1e4b.tar.gz
Socket-dc9d1bb0121366d16c5ae0c32ac06d1110ac1e4b.tar.bz2
chore(php) Fix some type issues.
-rw-r--r--Source/Client.php4
-rw-r--r--Source/Connection/Connection.php11
-rw-r--r--Source/Connection/Group.php2
-rw-r--r--Source/Server.php6
-rw-r--r--Test/Unit/Client.php19
-rw-r--r--Test/Unit/Connection/Connection.php61
-rw-r--r--Test/Unit/Connection/Group.php20
-rw-r--r--Test/Unit/Connection/Handler.php39
-rw-r--r--Test/Unit/Exception/BrokenPipe.php3
-rw-r--r--Test/Unit/Exception/Exception.php2
-rw-r--r--Test/Unit/Server.php13
-rw-r--r--Test/Unit/Socket.php6
-rw-r--r--Test/Unit/Transport.php8
13 files changed, 109 insertions, 85 deletions
diff --git a/Source/Client.php b/Source/Client.php
index 0484127..a1f3764 100644
--- a/Source/Client.php
+++ b/Source/Client.php
@@ -187,7 +187,7 @@ class Client extends Connection
/**
* Select connections.
*/
- public function select(): self
+ public function select(): iterable
{
$read = $this->getStack();
$write = null;
@@ -205,7 +205,7 @@ class Client extends Connection
/**
* Consider another client when selecting connection.
*/
- public function consider(Connection $other): self
+ public function consider(Connection $other): Connection
{
if (!($other instanceof self)) {
throw new Exception(
diff --git a/Source/Connection/Connection.php b/Source/Connection/Connection.php
index c73d0b7..dd8b50d 100644
--- a/Source/Connection/Connection.php
+++ b/Source/Connection/Connection.php
@@ -129,7 +129,7 @@ abstract class Connection extends Stream implements Stream\IStream\In, Stream\IS
/**
* Start a connection.
*/
- public function __construct(string $socket, int $timeout, int $flag, string $context = null)
+ public function __construct(?string $socket, int $timeout, int $flag, string $context = null)
{
// Children could setSocket() before __construct.
if (null !== $socket) {
@@ -138,7 +138,10 @@ abstract class Connection extends Stream implements Stream\IStream\In, Stream\IS
$this->setTimeout($timeout);
$this->setFlag($flag);
- $this->setContext($context);
+
+ if (null !== $context) {
+ $this->setContext($context);
+ }
return;
}
@@ -160,7 +163,7 @@ abstract class Connection extends Stream implements Stream\IStream\In, Stream\IS
/**
* Select connections.
*/
- abstract public function select(): self;
+ abstract public function select(): iterable;
/**
* Consider another connection when selecting connection.
@@ -463,7 +466,7 @@ abstract class Connection extends Stream implements Stream\IStream\In, Stream\IS
*/
protected function getNodeId($resource): string
{
- return md5((int) $resource);
+ return sha1((string) (int) $resource, true);
}
/**
diff --git a/Source/Connection/Group.php b/Source/Connection/Group.php
index fb505c4..e0a3d8b 100644
--- a/Source/Connection/Group.php
+++ b/Source/Connection/Group.php
@@ -78,7 +78,7 @@ class Group implements \ArrayAccess, \IteratorAggregate, \Countable
/**
* Add a connection.
*/
- public function offsetSet($offset, Handler $connection): void
+ public function offsetSet($offset, $connection): void
{
if (!($connection instanceof Handler)) {
throw new Socket\Exception(
diff --git a/Source/Server.php b/Source/Server.php
index e0b5a38..e1ffdc3 100644
--- a/Source/Server.php
+++ b/Source/Server.php
@@ -242,7 +242,7 @@ class Server extends Connection
/**
* Connect and accept the first connection.
*/
- public function connect(): self
+ public function connect(): Connection
{
parent::connect();
@@ -271,7 +271,7 @@ class Server extends Connection
/**
* Select connections.
*/
- public function select(): self
+ public function select(): iterable
{
$read = $this->getStack();
$write = null;
@@ -312,7 +312,7 @@ class Server extends Connection
/**
* Consider another server when selecting connection.
*/
- public function consider(Connection $other): self
+ public function consider(Connection $other): Connection
{
if ($other instanceof Client) {
if (true === $other->isDisconnected()) {
diff --git a/Test/Unit/Client.php b/Test/Unit/Client.php
index d494b8c..d15b867 100644
--- a/Test/Unit/Client.php
+++ b/Test/Unit/Client.php
@@ -38,6 +38,7 @@ declare(strict_types=1);
namespace Hoa\Socket\Test\Unit;
+use Hoa\Socket as LUT;
use Hoa\Socket\Client as SUT;
use Hoa\Stream;
use Hoa\Test;
@@ -58,7 +59,7 @@ class Client extends Test\Unit\Suite
->when($result = new \Mock\Hoa\Socket\Client())
->then
->object($result)
- ->isInstanceOf('Hoa\Socket\Connection');
+ ->isInstanceOf(LUT\Connection::class);
}
public function case_constructor(): void
@@ -74,7 +75,7 @@ class Client extends Test\Unit\Suite
->then
->let($_socket = $result->getSocket())
->object($_socket)
- ->isInstanceOf('Hoa\Socket\Socket')
+ ->isInstanceOf(LUT\Socket::class)
->integer($_socket->getAddressType())
->isEqualTo($_socket::ADDRESS_DOMAIN)
->string($_socket->getTransport())
@@ -125,7 +126,7 @@ class Client extends Test\Unit\Suite
->exception(function () use ($self, $client, $streamName): void {
$self->invoke($client)->_open($streamName);
})
- ->isInstanceOf('Hoa\Socket\Exception')
+ ->isInstanceOf(LUT\Exception::class)
->hasCode(0)
->boolean($called)
->isTrue();
@@ -163,7 +164,7 @@ class Client extends Test\Unit\Suite
->exception(function () use ($self, $client, $streamName): void {
$self->invoke($client)->_open($streamName);
})
- ->isInstanceOf('Hoa\Socket\Exception')
+ ->isInstanceOf(LUT\Exception::class)
->hasCode(1)
->boolean($called)
->isTrue();
@@ -213,7 +214,7 @@ class Client extends Test\Unit\Suite
->let($node = $client->getCurrentNode())
->object($node)
- ->isInstanceOf('Hoa\Socket\Node')
+ ->isInstanceOf(LUT\Node::class)
->string($node->getId())
->isEqualTo($this->invoke($client)->getNodeId($result))
->resource($node->getSocket())
@@ -277,7 +278,7 @@ class Client extends Test\Unit\Suite
->let($node = $client->getCurrentNode())
->object($node)
- ->isInstanceOf('Hoa\Socket\Node')
+ ->isInstanceOf(LUT\Node::class)
->string($node->getId())
->isEqualTo($this->invoke($client)->getNodeId($result))
->resource($node->getSocket())
@@ -389,7 +390,7 @@ class Client extends Test\Unit\Suite
->exception(function () use ($client, $other): void {
$client->consider($other);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_consider_disconnected_client(): void
@@ -417,8 +418,10 @@ class Client extends Test\Unit\Suite
$this->calling($node)->getId = 'foo',
$this->calling($other)->isDisconnected = $disconnected,
$this->calling($other)->getCurrentNode = $node,
- $this->calling($other)->connect = function () use (&$called): void {
+ $this->calling($other)->connect = function () use (&$called, $other) {
$called = true;
+
+ return $other;
},
$oldStack = $this->invoke($client)->getStack(),
diff --git a/Test/Unit/Connection/Connection.php b/Test/Unit/Connection/Connection.php
index b8aaaa1..1ad24a3 100644
--- a/Test/Unit/Connection/Connection.php
+++ b/Test/Unit/Connection/Connection.php
@@ -39,8 +39,10 @@ declare(strict_types=1);
namespace Hoa\Socket\Test\Unit\Connection;
use Hoa\Socket as LUT;
+use Hoa\Stream;
use Hoa\Test;
use Mock\Hoa\Socket\Connection as SUT;
+use Mock\Hoa\Socket\Test\Unit\Connection\Unclosable as UnclosableConnection;
/**
* Class \Hoa\Socket\Test\Unit\Connection\Connection.
@@ -58,11 +60,11 @@ class Connection extends Test\Unit\Suite
->when($result = new SUT())
->then
->object($result)
- ->isInstanceOf('Hoa\Stream')
- ->isInstanceOf('Hoa\Stream\IStream\In')
- ->isInstanceOf('Hoa\Stream\IStream\Out')
- ->isInstanceOf('Hoa\Stream\IStream\Pathable')
- ->isInstanceOf('Iterator');
+ ->isInstanceOf(Stream::class)
+ ->isInstanceOf(Stream\IStream\In::class)
+ ->isInstanceOf(Stream\IStream\Out::class)
+ ->isInstanceOf(Stream\IStream\Pathable::class)
+ ->isInstanceOf(\Iterator::class);
}
public function case_constructor(): void
@@ -78,7 +80,7 @@ class Connection extends Test\Unit\Suite
->then
->let($_socket = $result->getSocket())
->object($_socket)
- ->isInstanceOf('Hoa\Socket\Socket')
+ ->isInstanceOf(LUT\Socket::class)
->integer($_socket->getAddressType())
->isEqualTo($_socket::ADDRESS_DOMAIN)
->string($_socket->getTransport())
@@ -104,7 +106,7 @@ class Connection extends Test\Unit\Suite
$socket = 'tcp://hoa-project.net:80',
$timeout = 42,
$flag = 153,
- $connection = new SUT($socket, $timeout, $flag),
+ $connection = new UnclosableConnection($socket, $timeout, $flag),
$this->calling($connection)->open = function () use (&$called): void {
$called = true;
@@ -248,20 +250,13 @@ class Connection extends Test\Unit\Suite
$socket = 'tcp://hoa-project.net:80',
$timeout = 42,
$flag = 153,
- $connection = new SUT($socket, $timeout, $flag),
- $connection->connect(),
-
- $this->calling($connection)->open = null,
- $this->calling($connection)->_close = function () use (&$called): void {
- $called = true;
- }
+ $connection = new UnclosableConnection($socket, $timeout, $flag),
+ $connection->connect()
)
->when($result = $connection->disconnect())
->then
->variable($result)
->isNull()
- ->boolean($called)
- ->isTrue()
->boolean($connection->isDisconnected())
->isTrue();
}
@@ -277,7 +272,7 @@ class Connection extends Test\Unit\Suite
->exception(function () use ($connection, $socketUri): void {
$this->invoke($connection)->setSocket($socketUri);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_set_socket(): void
@@ -294,7 +289,7 @@ class Connection extends Test\Unit\Suite
->isNull()
->let($socket = $connection->getSocket())
->object($socket)
- ->isInstanceOf('Hoa\Socket\Socket')
+ ->isInstanceOf(LUT\Socket::class)
->integer($socket->getAddressType())
->isEqualTo($socket::ADDRESS_DOMAIN)
->string($socket->getTransport())
@@ -575,7 +570,7 @@ class Connection extends Test\Unit\Suite
->when($result = $this->invoke($connection)->getNodeId($resource))
->then
->string($result)
- ->isEqualTo(md5((int) $resource));
+ ->isEqualTo(sha1((string) (int) $resource, true));
}
public function case_read_on_a_null_stream(): void
@@ -590,7 +585,7 @@ class Connection extends Test\Unit\Suite
->exception(function () use ($connection): void {
$connection->read(42);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_read_a_negative_length(): void
@@ -605,7 +600,7 @@ class Connection extends Test\Unit\Suite
->exception(function () use ($connection): void {
$connection->read(-1);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_read_encrypted_node(): void
@@ -631,13 +626,13 @@ class Connection extends Test\Unit\Suite
->integer($_length)
->isEqualTo($length);
- return $_length;
+ return $_stream;
}
)
->when($result = $connection->read($length))
->then
- ->integer($result)
- ->isEqualTo($length)
+ ->string($result)
+ ->isEqualTo($stream)
->boolean($called)
->isTrue();
}
@@ -925,7 +920,7 @@ class Connection extends Test\Unit\Suite
->exception(function () use ($connection): void {
$connection->write('foo', 3);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_write_a_negative_length(): void
@@ -941,7 +936,7 @@ class Connection extends Test\Unit\Suite
->exception(function () use ($connection): void {
$connection->write('foo', -1);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_write_on_encrypted_node(): void
@@ -1039,7 +1034,7 @@ class Connection extends Test\Unit\Suite
->exception(function () use ($connection, $string, $length): void {
$connection->write($string, $length);
})
- ->isInstanceOf('Hoa\Socket\Exception\BrokenPipe');
+ ->isInstanceOf(LUT\Exception\BrokenPipe::class);
}
public function case_write(): void
@@ -1108,7 +1103,7 @@ class Connection extends Test\Unit\Suite
->exception(function () use ($connection, $string, $length): void {
$connection->write($string, $length);
})
- ->isInstanceOf('Hoa\Socket\Exception\BrokenPipe');
+ ->isInstanceOf(LUT\Exception\BrokenPipe::class);
}
public function case_base_name(): void
@@ -1172,7 +1167,7 @@ class Connection extends Test\Unit\Suite
}
}
-abstract class ConnectionIterator extends \Hoa\Socket\Connection\Connection
+abstract class ConnectionIterator extends LUT\Connection\Connection
{
protected $_iterator = ['foo', 'bar', 'baz'];
@@ -1181,3 +1176,11 @@ abstract class ConnectionIterator extends \Hoa\Socket\Connection\Connection
return $this->_current();
}
}
+
+abstract class Unclosable extends LUT\Connection\Connection
+{
+ public function _close(): bool
+ {
+ return false;
+ }
+}
diff --git a/Test/Unit/Connection/Group.php b/Test/Unit/Connection/Group.php
index f9a980c..36082b2 100644
--- a/Test/Unit/Connection/Group.php
+++ b/Test/Unit/Connection/Group.php
@@ -57,9 +57,9 @@ class Group extends Test\Unit\Suite
->when($result = new SUT())
->then
->object($result)
- ->isInstanceOf('ArrayAccess')
- ->isInstanceOf('IteratorAggregate')
- ->isInstanceOf('Countable');
+ ->isInstanceOf(\ArrayAccess::class)
+ ->isInstanceOf(\IteratorAggregate::class)
+ ->isInstanceOf(\Countable::class);
}
public function case_offset_exists(): void
@@ -120,7 +120,7 @@ class Group extends Test\Unit\Suite
->exception(function () use ($group): void {
$group->offsetSet(null, 42);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_offset_set_with_a_null_offset(): void
@@ -197,12 +197,14 @@ class Group extends Test\Unit\Suite
$this->mockGenerator->orphanize('__construct'),
$connectionA = new \Mock\Hoa\Socket\Connection\Handler(),
$connectionB = new \Mock\Hoa\Socket\Connection\Handler(),
- $this->calling($connectionA)->merge = function (LUT\Connection\Handler $connection) use ($self, &$called, $connectionB): void {
+ $this->calling($connectionA)->merge = function (LUT\Connection\Handler $connection) use ($self, &$called, $connectionA, $connectionB) {
$called = true;
$self
->object($connection)
->isIdenticalTo($connectionB);
+
+ return $connectionA;
},
$group = new SUT(),
@@ -234,7 +236,7 @@ class Group extends Test\Unit\Suite
->exception(function () use ($group): void {
$group->offsetUnset('foo');
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_get_empty_iterator(): void
@@ -244,7 +246,7 @@ class Group extends Test\Unit\Suite
->when($result = $group->getIterator())
->then
->iterator($result)
- ->isInstanceOf('ArrayIterator')
+ ->isInstanceOf(\ArrayIterator::class)
->hasSize(0);
}
@@ -259,7 +261,7 @@ class Group extends Test\Unit\Suite
->when($result = $group->getIterator())
->then
->iterator($result)
- ->isInstanceOf('ArrayIterator')
+ ->isInstanceOf(\ArrayIterator::class)
->hasSize(1);
}
@@ -317,7 +319,7 @@ class Group extends Test\Unit\Suite
->exception(function () use ($group): void {
$group->run();
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_run(): void
diff --git a/Test/Unit/Connection/Handler.php b/Test/Unit/Connection/Handler.php
index 95a82ad..a81dd32 100644
--- a/Test/Unit/Connection/Handler.php
+++ b/Test/Unit/Connection/Handler.php
@@ -38,6 +38,7 @@ declare(strict_types=1);
namespace Hoa\Socket\Test\Unit\Connection;
+use Hoa\Exception;
use Hoa\Socket as LUT;
use Hoa\Test;
use Mock\Hoa\Socket\Connection\Handler as SUT;
@@ -106,13 +107,15 @@ class Handler extends Test\Unit\Suite
$connection = new \Mock\Hoa\Socket\Server(),
$handler = new SUT($connection),
- $this->calling($connection)->connectAndWait = function () use (&$connectCalled): void {
+ $this->calling($connection)->connectAndWait = function () use (&$connectCalled, $connection) {
$connectCalled = true;
+
+ return $connection;
},
$this->calling($connection)->disconnect = function () use (&$disconnectCalled): void {
$disconnectCalled = true;
},
- $this->calling($connection)->select = [],
+ $this->calling($connection)->select = $connection,
$this->constant->SUCCEED = false
)
@@ -134,13 +137,15 @@ class Handler extends Test\Unit\Suite
$connection = new \Mock\Hoa\Socket\Connection(),
$handler = new SUT($connection),
- $this->calling($connection)->connect = function () use (&$connectCalled): void {
+ $this->calling($connection)->connect = function () use (&$connectCalled, $connection) {
$connectCalled = true;
+
+ return $connection;
},
$this->calling($connection)->disconnect = function () use (&$disconnectCalled): void {
$disconnectCalled = true;
},
- $this->calling($connection)->select = [],
+ $this->calling($connection)->select = $connection,
$this->constant->SUCCEED = false
)
@@ -276,11 +281,13 @@ class Handler extends Test\Unit\Suite
$this->mockGenerator->orphanize('__construct'),
$nodeX = new \Mock\Hoa\Socket\Node(),
- $resourceY = 42,
+ $this->mockGenerator->orphanize('__construct'),
+ $socketY = new \Mock\Hoa\Socket(),
- $this->calling($connectionA)->select = [$resourceY],
+ $this->calling($connectionA)->select = [42],
+ $this->calling($connectionA)->is = true,
$this->calling($connectionB)->getCurrentNode = $nodeX,
- $this->calling($nodeX)->getSocket = $resourceY,
+ $this->calling($nodeX)->getSocket = $socketY,
$this->calling($handlerA)->_run = function (LUT\Node $node) use (&$runCalledA): void {
$runCalledA = true;
@@ -317,14 +324,14 @@ class Handler extends Test\Unit\Suite
$connectionB = new \Mock\Hoa\Socket\Connection(),
$handlerB = new SUT($connectionB),
- $this->calling($connectionA)->consider = function (LUT\Connection $connection) use ($self, &$called, $connectionB): void {
+ $this->calling($connectionA)->consider = function (LUT\Connection $connection) use ($self, &$called, $connectionA, $connectionB) {
$called = true;
$self
->object($connection)
->isIdenticalTo($connectionB);
- return;
+ return $connectionA;
}
)
->when($result = $handlerA->merge($handlerB))
@@ -681,7 +688,9 @@ class Handler extends Test\Unit\Suite
$exception = new LUT\Exception\BrokenPipe('Foo', 0),
$this->mockGenerator->orphanize('__construct'),
- $resource = 42,
+ $socket = new \Mock\Hoa\Socket(),
+
+ $this->mockGenerator->orphanize('__construct'),
$connection = new \Mock\Hoa\Socket\Connection(),
$handler = new SUT($connection),
@@ -690,7 +699,7 @@ class Handler extends Test\Unit\Suite
$nodeY = new \Mock\Hoa\Socket\Node(),
$nodeZ = new \Mock\Hoa\Socket\Node(),
- $this->calling($connection)->getSocket = $resource,
+ $this->calling($connection)->getSocket = $socket,
$this->calling($connection)->getNodes = [$nodeX, $nodeY, $nodeZ],
$this->calling($nodeY)->getConnection = $connection,
@@ -704,7 +713,7 @@ class Handler extends Test\Unit\Suite
->exception(function () use ($handler, $predicate, $message): void {
$handler->broadcastIf($predicate, $message, 'bar', 'baz');
})
- ->isInstanceOf('Hoa\Exception\Group')
+ ->isInstanceOf(Exception\Group::class)
->integer(count($this->exception))
->isEqualTo(2)
->object($this->exception[$nodeY->getId()])
@@ -725,7 +734,9 @@ class Handler extends Test\Unit\Suite
},
$this->mockGenerator->orphanize('__construct'),
- $resource = 42,
+ $socket = new \Mock\Hoa\Socket(),
+
+ $this->mockGenerator->orphanize('__construct'),
$connection = new \Mock\Hoa\Socket\Connection(),
$handler = new SUT($connection),
@@ -734,7 +745,7 @@ class Handler extends Test\Unit\Suite
$nodeY = new \Mock\Hoa\Socket\Node(),
$nodeZ = new \Mock\Hoa\Socket\Node(),
- $this->calling($connection)->getSocket = $resource,
+ $this->calling($connection)->getSocket = $socket,
$this->calling($connection)->getNodes = [$nodeX, $nodeY, $nodeZ],
$this->calling($nodeY)->getConnection = $connection,
diff --git a/Test/Unit/Exception/BrokenPipe.php b/Test/Unit/Exception/BrokenPipe.php
index 515d93e..2017654 100644
--- a/Test/Unit/Exception/BrokenPipe.php
+++ b/Test/Unit/Exception/BrokenPipe.php
@@ -38,6 +38,7 @@ declare(strict_types=1);
namespace Hoa\Socket\Test\Unit\Exception;
+use Hoa\Socket as LUT;
use Hoa\Socket\Exception\BrokenPipe as SUT;
use Hoa\Test;
@@ -56,6 +57,6 @@ class BrokenPipe extends Test\Unit\Suite
->when($result = new SUT('foo', 0))
->then
->object($result)
- ->isInstanceOf('Hoa\Socket\Exception\Exception');
+ ->isInstanceOf(LUT\Exception\Exception::class);
}
}
diff --git a/Test/Unit/Exception/Exception.php b/Test/Unit/Exception/Exception.php
index 88a3013..8d8f4b2 100644
--- a/Test/Unit/Exception/Exception.php
+++ b/Test/Unit/Exception/Exception.php
@@ -56,6 +56,6 @@ class Exception extends Test\Unit\Suite
->when($result = new SUT('foo', 0))
->then
->object($result)
- ->isInstanceOf('Hoa\Exception\Exception');
+ ->isInstanceOf(\Hoa\Exception\Exception::class);
}
}
diff --git a/Test/Unit/Server.php b/Test/Unit/Server.php
index c38db90..3978369 100644
--- a/Test/Unit/Server.php
+++ b/Test/Unit/Server.php
@@ -38,6 +38,7 @@ declare(strict_types=1);
namespace Hoa\Socket\Test\Unit;
+use Hoa\Socket as LUT;
use Hoa\Socket\Server as SUT;
use Hoa\Stream;
use Hoa\Test;
@@ -58,7 +59,7 @@ class Server extends Test\Unit\Suite
->when($result = new \Mock\Hoa\Socket\Server())
->then
->object($result)
- ->isInstanceOf('Hoa\Socket\Connection');
+ ->isInstanceOf(LUT\Connection::class);
}
public function case_constructor(): void
@@ -74,7 +75,7 @@ class Server extends Test\Unit\Suite
->then
->let($_socket = $result->getSocket())
->object($_socket)
- ->isInstanceOf('Hoa\Socket\Socket')
+ ->isInstanceOf(LUT\Socket::class)
->integer($_socket->getAddressType())
->isEqualTo($_socket::ADDRESS_DOMAIN)
->string($_socket->getTransport())
@@ -170,7 +171,7 @@ class Server extends Test\Unit\Suite
->exception(function () use ($socket, $timeout, $flag): void {
new SUT($socket, $timeout, $flag);
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_open_cannot_join(): void
@@ -201,7 +202,7 @@ class Server extends Test\Unit\Suite
->exception(function () use ($self, $server, $streamName): void {
$self->invoke($server)->_open($streamName);
})
- ->isInstanceOf('Hoa\Socket\Exception')
+ ->isInstanceOf(LUT\Exception::class)
->hasCode(1)
->boolean($called)
->isTrue();
@@ -350,7 +351,7 @@ class Server extends Test\Unit\Suite
->exception(function () use ($server): void {
$server->connect();
})
- ->isInstanceOf('Hoa\Socket\Exception')
+ ->isInstanceOf(LUT\Exception::class)
->boolean($called)
->isTrue();
}
@@ -504,7 +505,7 @@ class Server extends Test\Unit\Suite
->exception(function () use ($server): void {
$server->select();
})
- ->isInstanceOf('Hoa\Socket\Exception')
+ ->isInstanceOf(LUT\Exception::class)
->boolean($called0)
->isTrue()
->boolean($called1)
diff --git a/Test/Unit/Socket.php b/Test/Unit/Socket.php
index 089b0d8..08e4491 100644
--- a/Test/Unit/Socket.php
+++ b/Test/Unit/Socket.php
@@ -177,7 +177,7 @@ class Socket extends Test\Unit\Suite
->exception(function (): void {
new SUT('tcp://[2001:0db8:85a3::]:80');
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(SUT\Exception::class);
}
public function case_ipv6_disabled_by_AF_INET6(): void
@@ -192,7 +192,7 @@ class Socket extends Test\Unit\Suite
->exception(function (): void {
new SUT('tcp://[2001:0db8:85a3::]:80');
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(SUT\Exception::class);
}
public function case_full_path()
@@ -214,7 +214,7 @@ class Socket extends Test\Unit\Suite
->exception(function (): void {
new SUT('foobar');
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(SUT\Exception::class);
}
public function case_has_port(): void
diff --git a/Test/Unit/Transport.php b/Test/Unit/Transport.php
index ea10bbb..97fc26e 100644
--- a/Test/Unit/Transport.php
+++ b/Test/Unit/Transport.php
@@ -166,11 +166,11 @@ class Transport extends Test\Unit\Suite
})
->then
->object($result)
- ->isInstanceOf('Closure')
+ ->isInstanceOf(\Closure::class)
->exception(function () use ($result, $transport): void {
$result($transport . '://127.0.0.1:80');
})
- ->isInstanceOf('Hoa\Socket\Exception');
+ ->isInstanceOf(LUT\Exception::class);
}
public function case_get_standard_factory(): void
@@ -181,7 +181,7 @@ class Transport extends Test\Unit\Suite
})
->then
->object($result)
- ->isInstanceOf('Closure')
+ ->isInstanceOf(\Closure::class)
->object($result('tcp://127.0.0.1:80'))
->isEqualTo(new LUT('tcp://127.0.0.1:80'));
}
@@ -211,7 +211,7 @@ class Transport extends Test\Unit\Suite
})
->then
->object($result)
- ->isInstanceOf('Closure')
+ ->isInstanceOf(\Closure::class)
->object($result('foo://bar/baz'))
->isEqualTo(new LUT('tcp://bar/baz'))
->boolean($called)