Last Updated: February 25, 2016
·
1.375K
· 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');
}

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside