public function testWriteLog() { $rawData = '[{"sg_event_id":"8rQZ-LulQcObW_2WyUTLpg","zurmoToken":"' . md5(ZURMO_TOKEN) . '","sg_message_id":"14826db909d.7e66.8eff7e.filter-297.4955.5401C16C1B.0","event":"processed","itemClass":"CampaignItem","email":"*****@*****.**","itemId":31,"smtp-id":"<*****@*****.**>","timestamp":1409401197,"personId":42}]'; // Not Coding Standard SendGridLogUtil::writeLog('test', $rawData); $logPath = SendGridLogUtil::getLogFilePath('test'); $this->assertTrue(file_exists($logPath)); $testContent = file_get_contents($logPath); $this->assertEquals($rawData, $testContent); @unlink($logPath); //Failure test $rawData = '[{"sg_event_id":"8rQZ-LulQcObW_2WyUTLpg","sg_message_id":"14826db909d.7e66.8eff7e.filter-297.4955.5401C16C1B.0","event":"processed","itemClass":"CampaignItem","email":"*****@*****.**","itemId":31,"smtp-id":"<*****@*****.**>","timestamp":1409401197,"personId":42}]'; // Not Coding Standard SendGridLogUtil::writeLog('test', $rawData); $logPath = SendGridLogUtil::getLogFilePath('test'); $this->assertFalse(file_exists($logPath)); }
/** * Writes log. * @param string $username Username for the sendgrid api * @see Global configuration screen for sendgrid. The username there is what is being * input here. */ public function actionWriteLog($username) { SendGridLogUtil::writeLog($username, file_get_contents("php://input")); }