htlvpg
Last Updated: February 25, 2016
·
983
· rgeyer

Mock magic method for ZendFramework 1.x Zend_Log

If you're mocking a ZendLog logger for your PHPUnit tests, make sure you're mocking the _call() magic method so that consumers can still use the form $log->info() etc.

public function testMockZendLog() {
  $log = $this->getMock('Zend_Log');
  $log->expects($this->once())
    ->method('__call')
    ->with('info', array('your message');
  $log->info('your message');
}