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