grantAccess('flagPost'); $post = $this->postMocker->mockSingle(); $post = $this->assert->doesNotThrow(function() use ($post) { return Api::run( new FlagPostJob(), [ JobArgs::ARG_POST_NAME => $post->getName(), ]); }); $logPath = Logger::getLogPath(); $logs = file_get_contents($logPath); $logs = explode("\n", $logs); $this->assert->areEqual(1, count($logs)); $this->assert->isTrue(strpos($logs[0], 'flagged @' . $post->getId() . ' for moderator attention') !== false); } public function testDoubleFlagging() { $this->grantAccess('flagPost'); $post = $this->postMocker->mockSingle(); $this->assert->doesNotThrow(function() use ($post) { Api::run( new FlagPostJob(), [ JobArgs::ARG_POST_NAME => $post->getName(), ]); }); $this->assert->throws(function() use ($post) { return Api::run( new FlagPostJob(), [ JobArgs::ARG_POST_NAME => $post->getName(), ]); }, 'You already flagged this post'); } }