Browse Source

tests updated, config file updated

tags/0.8
Paul Rock 7 years ago
parent
commit
721676be70
  1. 26
      phpunit.xml
  2. 35
      tests/ClientTest.php
  3. 15
      tests/ConfigTest.php
  4. 1
      tests/QueryTest.php

26
phpunit.xml

@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit bootstrap="./vendor/autoload.php" colors="true">
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./tests</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
</logging>
<testsuites> <testsuites>
<testsuite name="RouterOS API on PHP tests"> <testsuite name="RouterOS API on PHP tests">
<directory suffix=".php">./tests/</directory> <directory suffix=".php">./tests/</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
</phpunit> </phpunit>

35
tests/ClientTest.php

@ -10,7 +10,6 @@ use RouterOS\Exceptions\ClientException;
class ClientTest extends TestCase class ClientTest extends TestCase
{ {
public function test__construct() public function test__construct()
{ {
try { 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() public function test__constructLegacy()
{ {
try { try {
@ -80,5 +112,4 @@ class ClientTest extends TestCase
$this->assertCount(3, $readTrap); $this->assertCount(3, $readTrap);
$this->assertEquals('!trap', $readTrap[0]); $this->assertEquals('!trap', $readTrap[0]);
} }
} }

15
tests/ConfigTest.php

@ -20,7 +20,7 @@ class ConfigTest extends TestCase
public function testGetParameters() public function testGetParameters()
{ {
$obj = new Config();
$obj = new Config();
$params = $obj->getParameters(); $params = $obj->getParameters();
$this->assertCount(5, $params); $this->assertCount(5, $params);
@ -31,6 +31,15 @@ class ConfigTest extends TestCase
$this->assertEquals($params['delay'], 1); $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() public function testSet()
{ {
$obj = new Config(); $obj = new Config();
@ -42,7 +51,7 @@ class ConfigTest extends TestCase
public function testSetArr() public function testSetArr()
{ {
$obj = new Config([
$obj = new Config([
'timeout' => 111 'timeout' => 111
]); ]);
$params = $obj->getParameters(); $params = $obj->getParameters();
@ -85,7 +94,7 @@ class ConfigTest extends TestCase
public function testGet() public function testGet()
{ {
$obj = new Config();
$obj = new Config();
$test1 = $obj->get('legacy'); $test1 = $obj->get('legacy');
$this->assertEquals($test1, false); $this->assertEquals($test1, false);

1
tests/QueryTest.php

@ -8,7 +8,6 @@ use RouterOS\Query;
class QueryTest extends TestCase class QueryTest extends TestCase
{ {
public function test__construct() public function test__construct()
{ {
try { try {

Loading…
Cancel
Save