Permalink
Browse files

Add factory paginator tests

Add factory paginator tests
  • Loading branch information...
1 parent 76ee4e7 commit 76f8c649ed32df6b9240aa527d09dd95bbc51ed3 @blanchonvincent blanchonvincent committed Sep 8, 2012
@@ -16,11 +16,13 @@
* @category Zend
* @package Zend_Paginator
*/
-class Factory implements Countable, IteratorAggregate
+class Factory
{
+ protected static $adapters;
+
public static function factory($items, $adapter)
{
- if(!$adapter instanceof AdapterInterface && $adapter instanceof AdapterAggregateInterface) {
+ if(!$adapter instanceof AdapterInterface && !$adapter instanceof AdapterAggregateInterface) {
$adapter = self::getAdapterPluginManager()->get($adapter, $items);
}
@@ -287,7 +287,7 @@ public function __construct($adapter)
$this->adapter = $adapter->getPaginatorAdapter();
} else {
throw new Exception\InvalidArgumentException(
- 'Zend_Paginator only accepts instances of the type ' .
+ 'Zend\Paginator only accepts instances of the type ' .
'Zend\Paginator\Adapter\AdapterInterface or Zend\Paginator\AdapterAggregateInterface.'
);
}
@@ -11,6 +11,7 @@
namespace ZendTest\Paginator;
use Zend\Paginator\Factory;
+use Zend\Paginator\Adapter\ArrayAdapter;
/**
* @category Zend
@@ -20,8 +21,19 @@
*/
class FactoryTest extends \PHPUnit_Framework_TestCase
{
+ public function testCanFactoryPaginatorWithStringAdapterObject()
+ {
+ $datas = array(1, 2, 3);
+ $paginator = Factory::Factory($datas, new ArrayAdapter($datas));
+ $this->assertInstanceOf('Zend\Paginator\Adapter\ArrayAdapter', $paginator->getAdapter());
+ $this->assertEquals(count($datas), $paginator->getCurrentItemCount());
+ }
+
public function testCanFactoryPaginatorWithStringAdapterName()
{
-
+ $datas = array(1, 2, 3);
+ $paginator = Factory::Factory($datas, 'array');
+ $this->assertInstanceOf('Zend\Paginator\Adapter\ArrayAdapter', $paginator->getAdapter());
+ $this->assertEquals(count($datas), $paginator->getCurrentItemCount());
}
}

0 comments on commit 76f8c64

Please sign in to comment.