Skip to content

Commit 6352a83

Browse files
committed
Removed deprecated "strict" option from phpunit.xml;
Fixed testSendAsyncWithCallbackAndCancelWithin(), which should allow for additional data replies, as long as it ends with an error reply, followed by a final reply.
1 parent 416b442 commit 6352a83

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

docs/wiki

Submodule wiki updated from 5eb9c09 to 6c3a27a

tests/Client/Safe.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,10 @@ public function testSendAsyncWithCallbackAndCancelWithin()
401401
->setArgument('interval', '0.5')
402402
->setTag('ping');
403403
$repliesCount = 0;
404+
$mark = array();
404405
$this->object->sendAsync(
405406
$ping,
406-
function ($response, $client) use (&$repliesCount, $limit) {
407+
function ($response, $client) use (&$repliesCount, &$mark, $limit) {
407408
PHPUnit_Framework_TestCase::assertInstanceOf(
408409
ROS_NAMESPACE . '\Response',
409410
$response,
@@ -421,12 +422,27 @@ function ($response, $client) use (&$repliesCount, $limit) {
421422
'The callback must only receive responses meant for it.'
422423
);
423424
$repliesCount++;
424-
return $repliesCount === $limit;
425+
if ($repliesCount <= $limit) {
426+
PHPUnit_Framework_TestCase::assertEquals(
427+
Response::TYPE_DATA,
428+
$response->getType(),
429+
'Callbacks inside must be of type ' .
430+
Response::TYPE_DATA
431+
);
432+
return $repliesCount === $limit;
433+
} elseif ($response->getType() !== Response::TYPE_DATA) {
434+
$mark[] = $response->getType();
435+
}
425436
}
426437
);
427438

428439
$this->object->loop();
429-
$this->assertEquals(
440+
$this->assertSame(
441+
array(Response::TYPE_ERROR, Response::TYPE_FINAL),
442+
$mark,
443+
print_r($mark, true)
444+
);
445+
$this->assertGreaterThanOrEqual(
430446
$limit + 2/* The !trap and !done*/,
431447
$repliesCount,
432448
"Extra callbacks were executed during second loop."

tests/Client/Unsafe.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class Unsafe extends PHPUnit_Framework_TestCase
2222

2323
/**
2424
* Runs the test in a separate process for the sake of
25-
* peristent connections.
25+
* persistent connections.
2626
*
2727
* @runInSeparateProcess
2828
*
@@ -33,7 +33,7 @@ public function testSystemReboot()
3333
$this->object->sendSync(new Request('/system/reboot'));
3434
$this->object->close();
3535
$this->object = null;
36-
sleep(1);
36+
sleep(2);
3737
while (true) {
3838
try {
3939
$this->object = new Client(\HOSTNAME, USERNAME, PASSWORD, PORT);

tests/Misc/ConnectionlessTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
use PEAR2\Net\RouterOS\LengthException;
1010
use PEAR2\Net\RouterOS\NotSupportedException;
1111
use PEAR2\Net\RouterOS\Query;
12-
use PEAR2\Net\RouterOS\Registry;
1312
use PEAR2\Net\RouterOS\Request;
14-
use PEAR2\Net\RouterOS\Response;
1513
use PEAR2\Net\RouterOS\UnexpectedValueException;
1614
use PEAR2\Net\RouterOS\Util;
1715
use PEAR2\Net\Transmitter as T;
@@ -686,7 +684,7 @@ public function providerInvalidArgumentName()
686684

687685
public function testNonSeekableArgumentValue()
688686
{
689-
$value = fopen('php://input', 'r');
687+
$value = fopen('php://output', 'a');
690688
$request = new Request('/ping');
691689
$request->setArgument('address', $value);
692690
$actual = $request->getArgument('address');
@@ -735,7 +733,7 @@ public function providerInvalidQueryArgumentAction()
735733

736734
public function testNonSeekableCommunicatorWord()
737735
{
738-
$value = fopen('php://input', 'r');
736+
$value = fopen('php://output', 'a');
739737
$com = new Communicator(HOSTNAME, PORT);
740738
Client::login($com, USERNAME, PASSWORD);
741739
try {
@@ -752,7 +750,7 @@ public function testNonSeekableCommunicatorWord()
752750

753751
public function testNonSeekableQueryArgumentValue()
754752
{
755-
$value = fopen('php://input', 'r');
753+
$value = fopen('php://output', 'a');
756754
$stringValue = (string) $value;
757755
$query1 = Query::where('address', $stringValue);
758756
$query2 = Query::where('address', $value);

tests/phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
colors="false"
55
stopOnFailure="true"
66
verbose="true"
7-
strict="true"
87

98
convertErrorsToExceptions="true"
109
convertNoticesToExceptions="true"

0 commit comments

Comments
 (0)