getMock('Psr\Log\LoggerInterface'); $mock->expects($this->at(0)) ->method('log') ->with('error', 'Testing'); $mock->expects($this->at(1)) ->method('log') ->with('debug', array(1, 2)); Log::config('trait_test', ['engine' => $mock]); $subject = $this->getObjectForTrait('Cake\Log\LogTrait'); $subject->log('Testing'); $subject->log(array(1, 2), 'debug'); } }