From 721676be707ca4b374b10bac3dd2f2cb6536e805 Mon Sep 17 00:00:00 2001 From: Paul Rock Date: Sun, 17 Feb 2019 13:31:50 +0300 Subject: [PATCH] tests updated, config file updated --- phpunit.xml | 26 ++++++++++++-------------- tests/ClientTest.php | 35 +++++++++++++++++++++++++++++++++-- tests/ConfigTest.php | 15 ++++++++++++--- tests/QueryTest.php | 1 - 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index f01c06b..1c4a840 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,21 +1,19 @@ - + + + + ./src + + ./tests + + + + + + ./tests/ - - - ./src/ - - diff --git a/tests/ClientTest.php b/tests/ClientTest.php index ddf1a82..9eac2ff 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -10,7 +10,6 @@ use RouterOS\Exceptions\ClientException; class ClientTest extends TestCase { - public function test__construct() { try { @@ -25,6 +24,39 @@ class ClientTest extends TestCase } } + public function test__construct2() + { + try { + $config = new Config([ + 'user' => 'admin', + 'pass' => 'admin', + 'host' => '127.0.0.1' + ]); + $obj = new Client($config); + $this->assertInternalType('object', $obj); + $socket = $obj->getSocket(); + $this->assertInternalType('resource', $socket); + } catch (\Exception $e) { + $this->assertContains('Must be initialized ', $e->getMessage()); + } + } + + public function test__construct3() + { + try { + $obj = new Client([ + 'user' => 'admin', + 'pass' => 'admin', + 'host' => '127.0.0.1' + ]); + $this->assertInternalType('object', $obj); + $socket = $obj->getSocket(); + $this->assertInternalType('resource', $socket); + } catch (\Exception $e) { + $this->assertContains('Must be initialized ', $e->getMessage()); + } + } + public function test__constructLegacy() { try { @@ -80,5 +112,4 @@ class ClientTest extends TestCase $this->assertCount(3, $readTrap); $this->assertEquals('!trap', $readTrap[0]); } - } diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 8cf1097..d444888 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -20,7 +20,7 @@ class ConfigTest extends TestCase public function testGetParameters() { - $obj = new Config(); + $obj = new Config(); $params = $obj->getParameters(); $this->assertCount(5, $params); @@ -31,6 +31,15 @@ class ConfigTest extends TestCase $this->assertEquals($params['delay'], 1); } + public function testGetParameters2() + { + $obj = new Config(['timeout' => 100]); + $params = $obj->getParameters(); + + $this->assertCount(5, $params); + $this->assertEquals($params['timeout'], 100); + } + public function testSet() { $obj = new Config(); @@ -42,7 +51,7 @@ class ConfigTest extends TestCase public function testSetArr() { - $obj = new Config([ + $obj = new Config([ 'timeout' => 111 ]); $params = $obj->getParameters(); @@ -85,7 +94,7 @@ class ConfigTest extends TestCase public function testGet() { - $obj = new Config(); + $obj = new Config(); $test1 = $obj->get('legacy'); $this->assertEquals($test1, false); diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 570d3c7..9044a6d 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -8,7 +8,6 @@ use RouterOS\Query; class QueryTest extends TestCase { - public function test__construct() { try {