public function testSetClearDayOfYear() { $start = TimeHelper::getDayOfYear(); $this->assertNotEqual($start, 400); //not more than 365 days in a year TimeHelper::setDayOfYear(450); $now = TimeHelper::getDayOfYear(); $this->assertEqual(450, $now); TimeHelper::clearDayOfYear(); $now = TimeHelper::getDayOfYear(); $this->assertNotEqual(450, $now); }
public function testMandrillHTMLDailyPaymentDue() { unlink(FileDataManager::getDataPath(Mailer::EMAIL)); $plugin = new InsightsGeneratorPlugin(); $config = Config::getInstance(); $config->setValue('mandrill_api_key', '1234'); $config->setValue('thinkupllc_endpoint', 'http://example.com/thinkup/'); $plugin_dao = DAOFactory::getDAO('PluginDAO'); $plugin_id = $plugin_dao->getPluginId($plugin->folder_name); $plugin_option_dao = DAOFactory::GetDAO('PluginOptionDAO'); $long_ago = date('Y-m-d', strtotime('-7 day')); $plugin_option_dao->insertOption($plugin_id, 'mandrill_template', $template = 'my_template'); $plugin_option_dao->insertOption($plugin_id, 'last_daily_email', $long_ago); $options = $plugin_option_dao->getOptionsHash($plugin->folder_name, true); $builders = self::buildDataForDailyEmailFreeTrial(); $i = 0; while ($i < 5) { $owner_builder = FixtureBuilder::build('owners', array('id' => 1, 'full_name' => 'ThinkUp Q. User', 'is_admin' => 1, 'email' => '*****@*****.**', 'is_activated' => 1, 'email_notification_frequency' => 'daily', 'timezone' => 'America/New_York', 'is_free_trial' => 0, 'joined' => '-' . $i . 'd', 'membership_level' => 'Member')); $this->simulateLogin('*****@*****.**'); $plugin->current_timestamp = strtotime('5pm'); //Cycle through the 5 copy options for when a payment fails TimeHelper::setDayOfYear($i); $plugin->crawl(); $sent = Mailer::getLastMail(); $merge_vars = array(); $decoded = json_decode($sent); foreach ($decoded->global_merge_vars as $mv) { $merge_vars[$mv->name] = $mv->content; } $html_email = $merge_vars['insights']; $this->debug($html_email); $this->assertPattern('/Update your payment info/', $html_email); unlink(FileDataManager::getDataPath(Mailer::EMAIL)); $plugin_option_dao->updateOption($options['last_daily_email']->id, 'last_daily_email', $long_ago); $owner_builder = null; $i++; } }