|
@@ -44,7 +44,7 @@ class Zend_Paginator_Adapter_IteratorTest extends PHPUnit_Framework_TestCase
|
|
|
* @var Zend_Paginator_Adapter_Iterator
|
|
* @var Zend_Paginator_Adapter_Iterator
|
|
|
*/
|
|
*/
|
|
|
private $_adapter;
|
|
private $_adapter;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Prepares the environment before running a test.
|
|
* Prepares the environment before running a test.
|
|
|
*/
|
|
*/
|
|
@@ -62,40 +62,40 @@ class Zend_Paginator_Adapter_IteratorTest extends PHPUnit_Framework_TestCase
|
|
|
$this->_adapter = null;
|
|
$this->_adapter = null;
|
|
|
parent::tearDown();
|
|
parent::tearDown();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public function testGetsItemsAtOffsetZero()
|
|
public function testGetsItemsAtOffsetZero()
|
|
|
{
|
|
{
|
|
|
$actual = $this->_adapter->getItems(0, 10);
|
|
$actual = $this->_adapter->getItems(0, 10);
|
|
|
$this->assertType('LimitIterator', $actual);
|
|
$this->assertType('LimitIterator', $actual);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$i = 1;
|
|
$i = 1;
|
|
|
foreach ($actual as $item) {
|
|
foreach ($actual as $item) {
|
|
|
$this->assertEquals($i, $item);
|
|
$this->assertEquals($i, $item);
|
|
|
$i++;
|
|
$i++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public function testGetsItemsAtOffsetTen()
|
|
public function testGetsItemsAtOffsetTen()
|
|
|
{
|
|
{
|
|
|
$actual = $this->_adapter->getItems(10, 10);
|
|
$actual = $this->_adapter->getItems(10, 10);
|
|
|
$this->assertType('LimitIterator', $actual);
|
|
$this->assertType('LimitIterator', $actual);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$i = 11;
|
|
$i = 11;
|
|
|
foreach ($actual as $item) {
|
|
foreach ($actual as $item) {
|
|
|
$this->assertEquals($i, $item);
|
|
$this->assertEquals($i, $item);
|
|
|
$i++;
|
|
$i++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public function testReturnsCorrectCount()
|
|
public function testReturnsCorrectCount()
|
|
|
{
|
|
{
|
|
|
$this->assertEquals(101, $this->_adapter->count());
|
|
$this->assertEquals(101, $this->_adapter->count());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public function testThrowsExceptionIfNotCountable()
|
|
public function testThrowsExceptionIfNotCountable()
|
|
|
{
|
|
{
|
|
|
$iterator = new LimitIterator(new ArrayIterator(range(1, 101)));
|
|
$iterator = new LimitIterator(new ArrayIterator(range(1, 101)));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
new Zend_Paginator_Adapter_Iterator($iterator);
|
|
new Zend_Paginator_Adapter_Iterator($iterator);
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
@@ -103,7 +103,7 @@ class Zend_Paginator_Adapter_IteratorTest extends PHPUnit_Framework_TestCase
|
|
|
$this->assertEquals('Iterator must implement Countable', $e->getMessage());
|
|
$this->assertEquals('Iterator must implement Countable', $e->getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @group ZF-4151
|
|
* @group ZF-4151
|
|
|
*/
|
|
*/
|
|
@@ -117,4 +117,15 @@ class Zend_Paginator_Adapter_IteratorTest extends PHPUnit_Framework_TestCase
|
|
|
$this->fail('Empty iterator caused in an OutOfBoundsException');
|
|
$this->fail('Empty iterator caused in an OutOfBoundsException');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @group ZF-8084
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testGetItemsSerializable() {
|
|
|
|
|
+ $items = $this->_adapter->getItems(0, 1);
|
|
|
|
|
+ $innerIterator = $items->getInnerIterator();
|
|
|
|
|
+ $items = unserialize(serialize($items));
|
|
|
|
|
+ $this->assertTrue( ($items->getInnerIterator() == $innerIterator), 'getItems has to be serializable to use caching');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|