Skip to content

Commit

Permalink
fixed naming bug + PHP 5.3 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
webdevsHub committed May 14, 2015
1 parent 55999d8 commit cfcd3a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/Elastica/ScanAndScroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function rewind()

// initial scan request
$this->_search->getQuery()->setSize($this->sizePerShard);
$this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
$this->_search->setOption(Search::OPTION_SCROLL, $this->_expiryTime);
$this->_search->setOption(Search::OPTION_SCROLL_ID, null);
$this->_search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCAN);
$this->_setScrollId($this->_search->search());
Expand Down
6 changes: 3 additions & 3 deletions lib/Elastica/Scroll.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Scroll implements \Iterator
public function __construct(Search $search, $expiryTime = '1m')
{
$this->_search = $search;
$this->expiryTime = $expiryTime;
$this->_expiryTime = $expiryTime;
}

/**
Expand All @@ -73,7 +73,7 @@ public function next()
{
$this->_saveOptions();

$this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
$this->_search->setOption(Search::OPTION_SCROLL, $this->_expiryTime);
$this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_nextScrollId);
$this->_search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCROLL);
$this->_setScrollId($this->_search->search());
Expand Down Expand Up @@ -122,7 +122,7 @@ public function rewind()
// initial search
$this->_saveOptions();

$this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
$this->_search->setOption(Search::OPTION_SCROLL, $this->_expiryTime);
$this->_search->setOption(Search::OPTION_SCROLL_ID, null);
$this->_search->setOption(Search::OPTION_SEARCH_TYPE, null);
$this->_setScrollId($this->_search->search());
Expand Down
11 changes: 6 additions & 5 deletions test/lib/Elastica/Test/ScrollTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ public function testForeach()
foreach ($scroll as $scrollId => $resultSet) {
$this->assertNotEmpty($scrollId);

$results = $resultSet->getResults();
switch (true) {
case $count === 1:
// hits: 1 - 5
$this->assertEquals(5, $resultSet->count());
$this->assertEquals('1', $resultSet->getResults()[0]->getId());
$this->assertEquals('5', $resultSet->getResults()[4]->getId());
$this->assertEquals('1', $results[0]->getId());
$this->assertEquals('5', $results[4]->getId());
break;
case $count === 2:
// hits: 6 - 10
$this->assertEquals(5, $resultSet->count());
$this->assertEquals('6', $resultSet->getResults()[0]->getId());
$this->assertEquals('10', $resultSet->getResults()[4]->getId());
$this->assertEquals('6', $results[0]->getId());
$this->assertEquals('10', $results[4]->getId());
break;
case $count === 3:
// hit: 11
$this->assertEquals(1, $resultSet->count());
$this->assertEquals('11', $resultSet->getResults()[0]->getId());
$this->assertEquals('11', $results[0]->getId());
break;
case $count === 4:
$this->assertEquals(0, $resultSet->count());
Expand Down

0 comments on commit cfcd3a5

Please sign in to comment.