M
M
Maxim Kovalev2014-07-20 07:45:07
PHPUnit
Maxim Kovalev, 2014-07-20 07:45:07

How to test Zend Framework 2 app with Paginator using PHPUnit?

Greetings! When creating a test for the application, I encountered an error:

Argument 1 passed to Zend\Paginator\Adapter\Iterator::__construct() must implement interface Iterator, array given

in this piece of code:
$albums       = $this->getAlbumTable()->fetchAll( $select );
      $itemsPerPage = 2;

                        // Ошибка возникает в этой строке
      $paginator = new Paginator( new paginatorIterator( $albums ) );

      $paginator->setCurrentPageNumber( $page )
                ->setItemCountPerPage( $itemsPerPage )
                ->setPageRange( 7 );

I understand that the passed parameter is of the wrong type. The application itself works, but the test fails. I can't figure out how to bypass/disable this error handling.
Here's the article I'm testing on:
Unit Testing a Zend Framework
2
application

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question