Skip to content

Instantly share code, notes, and snippets.

@h4cc
Last active May 5, 2017 23:05
Show Gist options
  • Save h4cc/6595865 to your computer and use it in GitHub Desktop.
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:
<?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();
@andrewmatthews
Copy link

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