Skip to content
Snippets Groups Projects
Commit 9e0b921f authored by Jan Kuchař's avatar Jan Kuchař
Browse files

SemanticCursor: added scrollToEnd() and scrollToBeginning()

parent caec84e5
No related branches found
No related tags found
1 merge request!1Driver into separate namespace
......@@ -19,7 +19,7 @@ namespace Grifart\Mappi\Cursor;
class SemanticCursor implements ICursor
{
/** @var ICursor */
private $cursor;
protected $cursor;
/**
* @param ICursor $cursor
......@@ -71,6 +71,22 @@ class SemanticCursor implements ICursor
$this->moveFromEndTo(0);
}
/**
* Scrolls to the END
*/
public function scrollToEnd() : int
{
return $this->scroll(ICursor::FETCH_REMAINING);
}
/**
* Scroll to the BEGINNING
*/
public function scrollToBeginning() : int
{
return $this->scroll(ICursor::FETCH_FOREGOING);
}
// ---- FETCH ----
/**
......
......@@ -137,6 +137,22 @@ class SemanticCursorTest extends BaseTest
$this->uut->moveToEnd();
}
// ---- the extension - scroll* ----
public function test_scrollBeginning() {
$this->mockedCursor->shouldReceive("scroll")
->with(ICursor::FETCH_FOREGOING)->once()->andReturn(5);
Assert::same(5, $this->uut->scrollToBeginning());
}
public function test_scrollEnd() {
$this->mockedCursor->shouldReceive("scroll")
->with(ICursor::FETCH_REMAINING)->once()->andReturn(5);
Assert::same(5, $this->uut->scrollToEnd());
}
// ---- the extension - fetch* ----
public function test_fetchNext()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment