Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ResponseCollection::prev().

  • Loading branch information...
commit 9d237d4352d6b8c7551109a032c3a192ac33502e 1 parent 81c0a78
@boenrobot boenrobot authored
View
2  RELEASE-1.0.0b2
@@ -4,7 +4,7 @@ A lot of new conviniences and a few bug fixes.
* Added support for CLI argument syntax at Request constructor.
* Added optional arguments to request constructor for a tag and a query.
* Added Communicator::isSeekableStream() and made Communicator::sendWordFromStream() use it.
-* Added ResponseCollection::end().
+* Added ResponseCollection::prev() and ResponseCollection::end().
* Changed the default value of the $value of Message::setArgument from NULL to an empty string.
* Changed ResponseCollection::getLast() to return FALSE when the collection is empty.
* Changed Request::setArgument() so that any invalid value is casted to string.
View
12 src/PEAR2/Net/RouterOS/ResponseCollection.php
@@ -220,6 +220,18 @@ public function current()
}
/**
+ * Moves the pointer backwards by 1, and gets the previous response.
+ *
+ * @return Response The next {@link Response} object, or FALSE if the
+ * position is not valid.
+ */
+ public function prev()
+ {
+ --$this->position;
+ return $this->current();
+ }
+
+ /**
* Moves the pointer to the last valid position, and returns the last
* response.
*
View
6 tests/ClientFeaturesTest.php
@@ -34,6 +34,12 @@ public function testSendSyncReturningCollection()
__NAMESPACE__ . '\Response', $list->end(),
'The list is empty'
);
+ $this->assertEquals(Response::TYPE_FINAL, $list->current()->getType());
+ $this->assertInstanceOf(
+ __NAMESPACE__ . '\Response', $list->prev(),
+ 'The list is empty'
+ );
+ $this->assertEquals(Response::TYPE_DATA, $list->current()->getType());
}
public function testSendSyncReturningCollectionWithStreams()
Please sign in to comment.
Something went wrong with that request. Please try again.