for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Pagerfanta\Tests\Adapter;
use Pagerfanta\Adapter\Propel2Adapter;
use PHPUnit\Framework\TestCase;
/**
* Propel2AdapterTest
*
* @author Claude Khedhiri <[email protected]>
*/
class Propel2AdapterTest extends TestCase
{
private $query;
* @var Propel2Adapter
private $adapter;
protected function setUp()
if ($this->isPropel2NotAvaiable()) {
$this->markTestSkipped('Propel 2 is not available');
}
$this->query = $this->createQueryMock();
$this->adapter = new Propel2Adapter($this->query);
$this->query
object<PHPUnit\Framework\MockObject\MockObject>
object<Propel\Runtime\ActiveQuery\ModelCriteria>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
private function isPropel2NotAvaiable()
return !class_exists('Propel\Runtime\ActiveQuery\ModelCriteria');
private function createQueryMock()
return $this
->getMockBuilder('Propel\Runtime\ActiveQuery\ModelCriteria')
->disableOriginalConstructor()
->getMock();
public function testGetQuery()
$this->assertSame($this->query, $this->adapter->getQuery());
public function testGetNbResults()
->expects($this->once())
->method('offset')
->with(0);
->method('count')
->will($this->returnValue(100));
$this->assertSame(100, $this->adapter->getNbResults());
public function testGetSlice()
$offset = 14;
$length = 20;
$slice = new \ArrayObject();
->method('limit')
->with($length);
->with($offset);
->method('find')
->will($this->returnValue($slice));
$this->assertSame($slice, $this->adapter->getSlice($offset, $length));
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: