Permalink
Browse files

Added ResponseCollection::prev().

  • Loading branch information...
1 parent 81c0a78 commit 9d237d4352d6b8c7551109a032c3a192ac33502e @boenrobot boenrobot committed Oct 11, 2011
Showing with 19 additions and 1 deletion.
  1. +1 −1 RELEASE-1.0.0b2
  2. +12 −0 src/PEAR2/Net/RouterOS/ResponseCollection.php
  3. +6 −0 tests/ClientFeaturesTest.php
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()

0 comments on commit 9d237d4

Please sign in to comment.