public function HoneypotCssTestCase::testHoneypotCssUpdateOnCron in Honeypot 7
Test cron-based CSS file update.
File
- ./
honeypot.test, line 359 - Testing for Honeypot module.
Class
- HoneypotCssTestCase
- Test Honeypot's CSS generation routines.
Code
public function testHoneypotCssUpdateOnCron() {
$honeypot_css = honeypot_get_css_file_path();
$original_element_name = variable_get('honeypot_element_name', 'url');
// Update the honeypot element name.
variable_set('honeypot_element_name', 'test');
// Make sure the Honeypot CSS file still exists.
$this
->assertTrue(file_exists($honeypot_css));
// Run cron.
honeypot_cron();
// Make sure the Honeypot CSS file was updated with the new element name.
$handle = fopen($honeypot_css, 'r');
$contents = fread($handle, filesize($honeypot_css));
fclose($handle);
$updated_element_name_in_css = strpos($contents, 'test') === 1;
$this
->assertTrue($updated_element_name_in_css);
// For debug.
$this
->verbose($contents);
// Revert the honeypot element name back to the original.
variable_set('honeypot_element_name', $original_element_name);
}