Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wowo/1331795 to your computer and use it in GitHub Desktop.
Save wowo/1331795 to your computer and use it in GitHub Desktop.
Mockery's way to mock Doctrine2 Entity Manager
<?php
class AbstractManagerBase extends \PHPUnit_Framework_TestCase
{
protected function getEmMock()
{
$emMock = \Mockery::mock('\Doctrine\ORM\EntityManager',
array(
'getRepository' => new FakeRepository(),
'getClassMetadata' => (object)array('name' => 'aClass'),
'persist' => null,
'flush' => null,
));
return $emMock; // it tooks 6 lines, yay!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment