diff --git a/tests/APIConnectorTest.php b/tests/APIConnectorTest.php index 7644495..f0a5829 100644 --- a/tests/APIConnectorTest.php +++ b/tests/APIConnectorTest.php @@ -37,7 +37,7 @@ class APIConnectorTest extends TestCase public function constructProvider(): array { return [ - [new ResourceStream(fopen(__FILE__, 'rb')),], // Myself, sure I exists + [new ResourceStream(fopen(__FILE__, 'rb'))], // Myself, sure I exists [new ResourceStream(fsockopen('tcp://' . getenv('ROS_HOST'), getenv('ROS_PORT_MODERN')))], // Socket [new ResourceStream(STDIN), false], // Try it, but do not close STDIN please !!! [new StringStream('Hello World !!!')], // Try it, but do not close STDIN please !!! diff --git a/tests/APILengthCoDecTest.php b/tests/APILengthCoDecTest.php index 74322e0..2d22ba3 100644 --- a/tests/APILengthCoDecTest.php +++ b/tests/APILengthCoDecTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase; use RouterOS\APILengthCoDec; use RouterOS\Streams\StringStream; use RouterOS\Helpers\BinaryStringHelper; +use UnexpectedValueException; /** * Limit code coverage to the class @@ -99,7 +100,7 @@ class APILengthCoDecTest extends TestCase */ public function testDecodeLengthControlWord(string $encodedLength): void { - $this->expectException(\UnexpectedValueException::class); + $this->expectException(UnexpectedValueException::class); APILengthCoDec::decodeLength(new StringStream($encodedLength)); } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 3841efd..ba5a679 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -122,7 +122,7 @@ class ClientTest extends TestCase 'pass' => $this->config['pass'], 'host' => $this->config['host'], 'port' => $this->port_legacy, - 'legacy' => true + 'legacy' => true, ]); $this->assertIsObject($obj); } catch (Exception $e) { @@ -143,7 +143,7 @@ class ClientTest extends TestCase 'pass' => $this->config['pass'], 'host' => $this->config['host'], 'port' => $this->port_legacy, - 'legacy' => false + 'legacy' => false, ]); $this->assertIsObject($obj); } catch (Exception $e) { @@ -159,7 +159,7 @@ class ClientTest extends TestCase 'user' => $this->config['user'], 'pass' => 'admin2', 'host' => $this->config['host'], - 'attempts' => 2 + 'attempts' => 2, ]); } @@ -172,7 +172,7 @@ class ClientTest extends TestCase 'pass' => $this->config['pass'], 'host' => $this->config['host'], 'port' => 11111, - 'attempts' => 2 + 'attempts' => 2, ]); } @@ -206,7 +206,7 @@ class ClientTest extends TestCase $read = $this->client->query('/interface/print', [ ['type', 'ether'], - ['type', 'vlan'] + ['type', 'vlan'], ], '|')->read(); $this->assertCount(1, $read); $this->assertEquals('*1', $read[0]['.id']); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 2aa17cc..7f9ca3e 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -2,6 +2,7 @@ namespace RouterOS\Tests; +use Exception; use PHPUnit\Framework\TestCase; use RouterOS\Config; use RouterOS\Exceptions\ConfigException; @@ -13,7 +14,7 @@ class ConfigTest extends TestCase try { $obj = new Config(); $this->assertIsObject($obj); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertStringContainsString('Must be initialized ', $e->getMessage()); } } @@ -23,7 +24,7 @@ class ConfigTest extends TestCase $obj = new Config(); $params = $obj->getParameters(); - $this->assertCount(6, $params); + $this->assertCount(7, $params); $this->assertEquals(false, $params['legacy']); $this->assertEquals(false, $params['ssl']); $this->assertEquals(10, $params['timeout']); @@ -36,7 +37,7 @@ class ConfigTest extends TestCase $obj = new Config(['timeout' => 100]); $params = $obj->getParameters(); - $this->assertCount(6, $params); + $this->assertCount(7, $params); $this->assertEquals(100, $params['timeout']); } @@ -52,7 +53,7 @@ class ConfigTest extends TestCase public function testSetArr(): void { $obj = new Config([ - 'timeout' => 111 + 'timeout' => 111, ]); $params = $obj->getParameters(); diff --git a/tests/Helpers/BinaryStringHelperTest.php b/tests/Helpers/BinaryStringHelperTest.php index 716ebff..462e6b6 100644 --- a/tests/Helpers/BinaryStringHelperTest.php +++ b/tests/Helpers/BinaryStringHelperTest.php @@ -3,7 +3,6 @@ namespace RouterOS\Tests\Helpers; use PHPUnit\Framework\TestCase; - use RouterOS\Helpers\BinaryStringHelper; /** @@ -33,8 +32,8 @@ class BinaryStringHelperTest extends TestCase // strange behaviour : // TypeError: Argument 1 passed to RouterOS\Tests\Helpers\BinaryStringHelperTest::test__IntegerToNBOBinaryString() must be of the type integer, float given - // Seems that php auto convert to float 0xFFF.... - // + // Seems that php auto convert to float 0xFFF.... + // // [0xFFFFFFFFFFFFFFFF, chr(0xFF).chr(0xFF).chr(0xFF).chr(0xFF).chr(0xFF).chr(0xFF).chr(0xFF).chr(0xFF)], // Let's try random value diff --git a/tests/Laravel/ServiceProviderTests.php b/tests/Laravel/ServiceProviderTests.php index 468fc2f..469a80b 100644 --- a/tests/Laravel/ServiceProviderTests.php +++ b/tests/Laravel/ServiceProviderTests.php @@ -8,19 +8,19 @@ use RouterOS\Laravel\Wrapper; class ServiceProviderTests extends TestCase { private $client = [ - "__construct", - "query", - "read", - "readAsIterator", - "parseResponse", - "connect", - "export", - "getSocket", - "q", - "r", - "ri", - "qr", - "qri", + '__construct', + 'query', + 'read', + 'readAsIterator', + 'parseResponse', + 'connect', + 'export', + 'getSocket', + 'q', + 'r', + 'ri', + 'qr', + 'qri', ]; public function testAbstractsAreLoaded(): void @@ -34,7 +34,7 @@ class ServiceProviderTests extends TestCase $config = \RouterOS::config([ 'host' => '192.168.1.3', 'user' => 'admin', - 'pass' => 'admin' + 'pass' => 'admin', ]); $this->assertInstanceOf(Config::class, $config); @@ -54,7 +54,7 @@ class ServiceProviderTests extends TestCase $client = \RouterOS::client([ 'host' => '192.168.1.3', 'user' => 'admin', - 'pass' => 'admin' + 'pass' => 'admin', ], false); $this->assertEquals(get_class_methods($client), $this->client); diff --git a/tests/Laravel/TestCase.php b/tests/Laravel/TestCase.php index 8faf6f6..bf88067 100644 --- a/tests/Laravel/TestCase.php +++ b/tests/Laravel/TestCase.php @@ -14,7 +14,7 @@ use Orchestra\Testbench\TestCase as Orchestra; abstract class TestCase extends Orchestra { /** - * @inheritdoc + * {@inheritdoc} */ protected function getPackageProviders($app): array { @@ -24,7 +24,7 @@ abstract class TestCase extends Orchestra } /** - * @inheritdoc + * {@inheritdoc} */ protected function getPackageAliases($app): array { diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 4a91071..1b978ae 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -2,6 +2,7 @@ namespace RouterOS\Tests; +use Exception; use PHPUnit\Framework\TestCase; use RouterOS\Exceptions\QueryException; use RouterOS\Query; @@ -13,7 +14,7 @@ class QueryTest extends TestCase try { $obj = new Query('test'); $this->assertIsObject($obj); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertStringContainsString('Must be initialized ', $e->getMessage()); } } @@ -23,7 +24,7 @@ class QueryTest extends TestCase try { $obj = new Query('test', ['line1', 'line2', 'line3']); $this->assertIsObject($obj); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertStringContainsString('Must be initialized ', $e->getMessage()); } } @@ -33,7 +34,7 @@ class QueryTest extends TestCase try { $obj = new Query(['test', 'line1', 'line2', 'line3']); $this->assertIsObject($obj); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertStringContainsString('Must be initialized ', $e->getMessage()); } } @@ -57,7 +58,7 @@ class QueryTest extends TestCase $this->expectException(QueryException::class); $obj = new Query(null); - $test = $obj->getEndpoint(); + $obj->getEndpoint(); } public function testSetEndpoint(): void @@ -90,7 +91,7 @@ class QueryTest extends TestCase $attrs = $obj->getAttributes(); $this->assertCount(1, $attrs); - $this->assertEquals($attrs[0], 'line'); + $this->assertEquals('line', $attrs[0]); } public function testWhere(): void @@ -101,7 +102,7 @@ class QueryTest extends TestCase $attrs = $obj->getAttributes(); $this->assertCount(2, $attrs); - $this->assertEquals($attrs[1], '?key2=value2'); + $this->assertEquals('?key2=value2', $attrs[1]); } @@ -113,7 +114,7 @@ class QueryTest extends TestCase $attrs = $obj->getAttributes(); $this->assertCount(2, $attrs); - $this->assertEquals($attrs[1], '=key2=value2'); + $this->assertEquals('=key2=value2', $attrs[1]); } public function testTag(): void @@ -124,7 +125,7 @@ class QueryTest extends TestCase $query = $obj->getQuery(); $this->assertCount(3, $query); - $this->assertEquals($query[2], '.tag=test'); + $this->assertEquals('.tag=test', $query[2]); } public function testOperator(): void @@ -135,7 +136,7 @@ class QueryTest extends TestCase $query = $obj->getQuery(); $this->assertCount(3, $query); - $this->assertEquals($query[2], '?#|'); + $this->assertEquals('?#|', $query[2]); } public function testWhereEx(): void @@ -153,8 +154,8 @@ class QueryTest extends TestCase $query = $obj->getQuery(); $this->assertCount(2, $query); - $this->assertEquals($query[0], 'test'); - $this->assertEquals($query[1], 'line'); + $this->assertEquals('test', $query[0]); + $this->assertEquals('line', $query[1]); } public function testGetQueryEx(): void diff --git a/tests/ResponseIteratorTest.php b/tests/ResponseIteratorTest.php index b01d3c8..ed205be 100644 --- a/tests/ResponseIteratorTest.php +++ b/tests/ResponseIteratorTest.php @@ -4,7 +4,6 @@ namespace RouterOS\Tests; use PHPUnit\Framework\TestCase; use RouterOS\Client; -use RouterOS\ResponseIterator; class ResponseIteratorTest extends TestCase { diff --git a/tests/Streams/ResourceStreamTest.php b/tests/Streams/ResourceStreamTest.php index 8ce56d4..15d0e03 100644 --- a/tests/Streams/ResourceStreamTest.php +++ b/tests/Streams/ResourceStreamTest.php @@ -4,9 +4,9 @@ namespace RouterOS\Tests\Streams; use InvalidArgumentException; use PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Constraint\IsType; use RouterOS\Exceptions\StreamException; use RouterOS\Streams\ResourceStream; +use stdClass; /** * Limit code coverage to the class RouterOS\APIStream @@ -23,7 +23,6 @@ class ResourceStreamTest extends TestCase * * @param $notResource */ - public function testConstructNotResource($notResource): void { $this->expectException(InvalidArgumentException::class); @@ -42,9 +41,9 @@ class ResourceStreamTest extends TestCase [3.14], // float ['a string'], // string [ - [0, 3.14] // Array + [0, 3.14], // Array ], - [new \stdClass()], // Object + [new stdClass()], // Object // What else ? ]; } @@ -83,8 +82,8 @@ class ResourceStreamTest extends TestCase public function constructProvider(): array { return [ - [fopen(__FILE__, 'rb'),], // Myself, sure I exists - [fsockopen('tcp://' . getenv('ROS_HOST'), getenv('ROS_PORT_MODERN')),], // Socket + [fopen(__FILE__, 'rb')], // Myself, sure I exists + [fsockopen('tcp://' . getenv('ROS_HOST'), getenv('ROS_PORT_MODERN'))], // Socket [STDIN, false], // Try it, but do not close STDIN please !!! // What else ? ]; @@ -167,6 +166,7 @@ class ResourceStreamTest extends TestCase $resource = fopen(__FILE__, 'rb'); $me = new ResourceStream($resource); fclose($resource); + return [ [$me, 1], ]; @@ -269,5 +269,4 @@ class ResourceStreamTest extends TestCase [new ResourceStream(fopen('/dev/null', 'wb')), 'sasasaas'], // Take that ]; } - } diff --git a/tests/Streams/StringStreamTest.php b/tests/Streams/StringStreamTest.php index 9943a5a..eb0e7cd 100644 --- a/tests/Streams/StringStreamTest.php +++ b/tests/Streams/StringStreamTest.php @@ -2,9 +2,9 @@ namespace RouterOS\Tests\Streams; +use Generator; +use InvalidArgumentException; use PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Constraint\IsType; - use RouterOS\Streams\StringStream; use RouterOS\Exceptions\StreamException; @@ -81,7 +81,7 @@ class StringStreamTest extends TestCase */ public function testWriteWithNegativeLength(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $stream = new StringStream('Does not matters'); $stream->write('PLOP', -1); } @@ -108,7 +108,7 @@ class StringStreamTest extends TestCase */ public function testReadBadLength(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $stream = new StringStream('123456789'); $stream->read(-1); } @@ -124,7 +124,7 @@ class StringStreamTest extends TestCase */ public function testReadWhileEmpty(StringStream $stream, int $length): void { - $this->expectException(\RouterOS\Exceptions\StreamException::class); + $this->expectException(StreamException::class); $stream->read($length); } @@ -132,7 +132,7 @@ class StringStreamTest extends TestCase * @return \Generator * @throws StreamException */ - public function readWhileEmptyProvider(): ?\Generator + public function readWhileEmptyProvider(): ?Generator { $stream = new StringStream('123456789'); $stream->read(9); @@ -149,7 +149,7 @@ class StringStreamTest extends TestCase public function testReadClosed(): void { - $this->expectException(\RouterOS\Exceptions\StreamException::class); + $this->expectException(StreamException::class); $stream = new StringStream('123456789'); $stream->close(); $stream->read(1);