Skip to content

Commit 6e41221

Browse files
committed
Added a check for PEAR2_Console_CommandLine in roscon.php;
Added a test for the NotSupporedException from Util::getAll(); CS fixes.
1 parent 0a8f8b9 commit 6e41221

File tree

4 files changed

+70
-27
lines changed

4 files changed

+70
-27
lines changed

scripts/roscon.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@
125125
unset($autoloader, $cwd);
126126
}
127127

128+
//PEAR2_Console_CommandLine is bundled in the archive, but may not be
129+
//available if this package was installed with a package manager.
130+
if (!class_exists('PEAR2\Console\CommandLine', true)) {
131+
fwrite(
132+
STDERR,
133+
<<<HEREDOC
134+
PEAR2_Console_CommandLine was not found.
135+
Please install it with the package manager used to install PEAR2_Net_RouterOS.
136+
(i.e. Pyrus, PEAR or Composer)
137+
HEREDOC
138+
);
139+
exit(11);
140+
}
141+
128142
// Locate the data dir, in preference as:
129143
// 1. The PHP_PEAR_DATA_DIR environment variable, if available
130144
// 2. The data folder at "mypear" (filled at install time by Pyrus/PEAR)

tests/Client/Safe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ function ($response, $client) use (&$repliesCount, &$mark, $limit) {
427427
Response::TYPE_DATA,
428428
$response->getType(),
429429
'Callbacks inside must be of type ' .
430-
Response::TYPE_DATA
430+
Response::TYPE_DATA
431431
);
432432
return $repliesCount === $limit;
433433
} elseif ($response->getType() !== Response::TYPE_DATA) {

tests/Misc/ConnectionlessTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class ConnectionlessTest extends PHPUnit_Framework_TestCase
3131
/**
3232
* @param string $command
3333
*
34-
* @dataProvider providerNonAbsoluteCommand
35-
*
3634
* @return void
35+
*
36+
* @dataProvider providerNonAbsoluteCommand
3737
*/
3838
public function testNonAbsoluteCommand($command)
3939
{
@@ -61,9 +61,9 @@ public function providerNonAbsoluteCommand()
6161
/**
6262
* @param string $command
6363
*
64-
* @dataProvider providerUnresolvableCommand
65-
*
6664
* @return void
65+
*
66+
* @dataProvider providerUnresolvableCommand
6767
*/
6868
public function testUnresolvableCommand($command)
6969
{
@@ -89,9 +89,9 @@ public function providerUnresolvableCommand()
8989
/**
9090
* @param string $command
9191
*
92-
* @dataProvider providerInvalidCommand
93-
*
9492
* @return void
93+
*
94+
* @dataProvider providerInvalidCommand
9595
*/
9696
public function testInvalidCommand($command)
9797
{
@@ -119,9 +119,9 @@ public function providerInvalidCommand()
119119
* @param string $command
120120
* @param string $expected
121121
*
122-
* @dataProvider providerCommandTranslation
123-
*
124122
* @return void
123+
*
124+
* @dataProvider providerCommandTranslation
125125
*/
126126
public function testCommandTranslation($command, $expected)
127127
{
@@ -152,9 +152,9 @@ public function providerCommandTranslation()
152152
* @param string $expected
153153
* @param array $args
154154
*
155-
* @dataProvider providerCommandAndArgumentParsing
156-
*
157155
* @return void
156+
*
157+
* @dataProvider providerCommandAndArgumentParsing
158158
*/
159159
public function testCommandAndArgumentParsing($command, $expected, $args)
160160
{
@@ -593,9 +593,9 @@ public function providerCommandAndArgumentParsing()
593593
* @param string $command
594594
* @param int $code
595595
*
596-
* @dataProvider providerCommandArgumentParsingExceptions
597-
*
598596
* @return void
597+
*
598+
* @dataProvider providerCommandArgumentParsingExceptions
599599
*/
600600
public function testCommandArgumentParsingExceptions($command, $code)
601601
{
@@ -628,9 +628,9 @@ public function providerCommandArgumentParsingExceptions()
628628
/**
629629
* @param string $name
630630
*
631-
* @dataProvider providerInvalidArgumentName
632-
*
633631
* @return void
632+
*
633+
* @dataProvider providerInvalidArgumentName
634634
*/
635635
public function testInvalidArgumentName($name)
636636
{
@@ -650,9 +650,9 @@ public function testInvalidArgumentName($name)
650650
/**
651651
* @param string $name
652652
*
653-
* @dataProvider providerInvalidArgumentName
654-
*
655653
* @return void
654+
*
655+
* @dataProvider providerInvalidArgumentName
656656
*/
657657
public function testInvalidQueryArgumentName($name)
658658
{
@@ -696,9 +696,9 @@ public function testNonSeekableArgumentValue()
696696
/**
697697
* @param string|int $action
698698
*
699-
* @dataProvider providerInvalidQueryArgumentAction
700-
*
701699
* @return void
700+
*
701+
* @dataProvider providerInvalidQueryArgumentAction
702702
*/
703703
public function testInvalidQueryArgumentAction($action)
704704
{
@@ -782,9 +782,9 @@ public function testArgumentRemoval()
782782
* @param string $expected
783783
* @param int $length
784784
*
785-
* @dataProvider providerLengths
786-
*
787785
* @return void
786+
*
787+
* @dataProvider providerLengths
788788
*/
789789
public function testLengthEncoding($expected, $length)
790790
{
@@ -803,9 +803,9 @@ public function testLengthEncoding($expected, $length)
803803
* @param string $length
804804
* @param int $expected
805805
*
806-
* @dataProvider providerLengths
807-
*
808806
* @return void
807+
*
808+
* @dataProvider providerLengths
809809
*/
810810
public function testLengthDecoding($length, $expected)
811811
{
@@ -922,9 +922,9 @@ public function testLengthEncodingExceptions()
922922
/**
923923
* @param int $controlByte
924924
*
925-
* @dataProvider providerControlByte
926-
*
927925
* @return void
926+
*
927+
* @dataProvider providerControlByte
928928
*/
929929
public function testControlByteException($controlByte)
930930
{
@@ -992,9 +992,9 @@ public function testPrepareScript()
992992
* @param string $value
993993
* @param mixed $expected
994994
*
995-
* @dataProvider providerUtilParseValue
996-
*
997995
* @return void
996+
*
997+
* @dataProvider providerUtilParseValue
998998
*/
999999
public function testUtilParseValue($value, $expected)
10001000
{

tests/Util/Safe.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,33 @@ public function testInvalidGetallAndCount()
246246
$this->assertFalse($this->util->getAll());
247247
$this->assertCount(-1, $this->util);
248248
}
249+
250+
public function providerProhibitedArgs()
251+
{
252+
return array(
253+
0 => array(array('follow')),
254+
1 => array(array('follow-only'))
255+
);
256+
}
257+
258+
/**
259+
* @param array $args Arguments for the Util::getAll() call.
260+
*
261+
* @return void
262+
*
263+
* @dataProvider providerProhibitedArgs
264+
*/
265+
public function testGetallArgExceptions(array $args)
266+
{
267+
$this->util->setMenu('/queue simple');
268+
try {
269+
$this->util->getAll($args);
270+
$this->fail('Supplying these arguments should result in an exception');
271+
} catch (NotSupportedException $e) {
272+
$this->assertSame(
273+
NotSupportedException::CODE_ARG_PROHIBITED,
274+
$e->getCode()
275+
);
276+
}
277+
}
249278
}

0 commit comments

Comments
 (0)