public function clear($log)
{
if ($log === 'change') {
$this->changeRepository->clearLog();
} elseif ($log === 'system') {
$this->systemRepository->clearLog();
} else {
throw new \UnexpectedValueException("Invalid log type requested: {$log}");
}
$this->app['logger.system']->info(ucfirst($log) . ' log cleared.', ['event' => 'security']);
}
public function testClear() { $app = $this->getApp(); $mocker = new DoctrineMockBuilder(); $db = $mocker->getConnectionMock(); $db->expects($this->at(1))->method('executeQuery')->with($this->equalTo("TRUNCATE bolt_log_system")); $db->expects($this->at(2))->method('executeQuery')->with($this->equalTo("TRUNCATE bolt_log_change")); $app['db'] = $db; $log = new Manager($app); $log->clear('system'); $log->clear('change'); $this->setExpectedException('Exception', 'Invalid log type requested: invalid'); $log->clear('invalid'); }