Maybe: 
```
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container->expects($this->any())
     ->method('get')
     ->with('phpbb.boardrules.entity')
     ->will($this->returnCallback(function() use ($db) {
        return new \ext\phpbb\boardrules\entity\rule($db, 'phpbb_boardrules');
    })
);
```