Skip to content

Commit e5705b1

Browse files
committed
Added unit tests for Util::comment();
Marked the test for Util::count()'s mode be incomplete, due to it being absent in the final PHP 5.6 builds; Altered Client examples according to the Wiki; Added Util example files, matching those in the Wiki; Fixed the suggested firewall rule in Roscon's connection error message.
1 parent 2a0d4a0 commit e5705b1

26 files changed

+262
-7
lines changed

examples/callback-and-loop.php renamed to examples/Client/callback-and-loop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require_once 'PEAR2/Autoload.php';
55

6-
$client = new RouterOS\Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
77

88
//Custom function, defined specifically for the example
99
$responseHandler = function ($response) {

examples/loop-and-extract.php renamed to examples/Client/loop-and-extract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require_once 'PEAR2/Autoload.php';
55

6-
$client = new RouterOS\Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
77

88
$addRequest = new RouterOS\Request('/ip/arp/add');
99

examples/send-and-complete.php renamed to examples/Client/send-and-complete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require_once 'PEAR2/Autoload.php';
55

6-
$client = new RouterOS\Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
77

88
$addRequest = new RouterOS\Request('/ip/arp/add');
99

examples/send-and-forget.php renamed to examples/Client/send-and-forget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require_once 'PEAR2/Autoload.php';
55

6-
$client = new RouterOS\Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
77

88
$addRequest = new RouterOS\Request('/ip/arp/add');
99

examples/sync-request-arguments.php renamed to examples/Client/sync-request-arguments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require_once 'PEAR2/Autoload.php';
55

6-
$client = new RouterOS\Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
77

88
$addRequest = new RouterOS\Request('/ip/arp/add');
99

examples/sync-request-simple.php renamed to examples/Client/sync-request-simple.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require_once 'PEAR2/Autoload.php';
55

6-
$client = new RouterOS\Client('192.168.0.1', 'admin');
6+
$client = new RouterOS\Client('192.168.88.1', 'admin', 'password');
77

88
$responses = $client->sendSync(new RouterOS\Request('/ip/arp/print'));
99

examples/Util/add.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
use PEAR2\Net\RouterOS;
3+
require_once 'PEAR2/Autoload.php';
4+
5+
$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));
6+
$util->setMenu('/ip arp');
7+
$util->add(
8+
array(
9+
'address' => '192.168.88.100',
10+
'mac-address' => '00:00:00:00:00:01'
11+
),
12+
array(
13+
'address' => '192.168.88.101',
14+
'mac-address' => '00:00:00:00:00:02'
15+
)
16+
);

examples/Util/count.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
use PEAR2\Net\RouterOS;
3+
require_once 'PEAR2/Autoload.php';
4+
5+
$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));
6+
$util->setMenu('/ip arp');
7+
8+
//With function
9+
echo count($util) . "\n";
10+
11+
//With method call
12+
echo $util->count() . "\n";
13+
14+
//Count only disabled ARP items
15+
echo $util->count(COUNT_NORMAL, RouterOS\Query::where('disabled', 'true')) . "\n";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
use PEAR2\Net\RouterOS;
3+
require_once 'PEAR2/Autoload.php';
4+
5+
$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));
6+
$util->setMenu('/ip arp');
7+
$util->remove(0);
8+
$util->disable(Query::where('comment', 'DISABLE ME'));
9+
$util->enable(1);

examples/Util/exec-basic.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
use PEAR2\Net\RouterOS;
3+
require_once 'PEAR2/Autoload.php';
4+
5+
$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));
6+
$util->setMenu('/ip arp');
7+
8+
$util->exec('
9+
add address=192.168.88.100 mac-address=00:00:00:00:00:01 comment=customer_1
10+
add address=192.168.88.101 mac-address=00:00:00:00:00:02 comment=customer_2
11+
/tool
12+
fetch url="http://example.com/?name=customer_1"
13+
fetch url="http://example.com/?name=customer_2"
14+
');

0 commit comments

Comments
 (0)