Last active
May 5, 2017 23:05
-
-
Save h4cc/6595865 to your computer and use it in GitHub Desktop.
If you get this message from PHPUnit: 'Class "Doctrine\ORM\Query" is declared "final"'
Check out the following code:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Use the Abstract query, which has nearly all needed Methods as the Query. | |
$this->queryMock = $this->getMockBuilder('\Doctrine\ORM\AbstractQuery') | |
->setMethods(array('setParameter', 'getResult')) | |
->disableOriginalConstructor() | |
->getMockForAbstractClass(); |
It will not work with Doctrine\ORM\Tools\Pagination\Paginator because of type hinting on the method cloneQuery
Unfortunately this will not work if you need to interact with the Query::setFirstResult()
or Query::setMaxResults()
methods as they do not exist on AbstractQuery
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you save my life, thank you very much for the share ;)