當前位置: 首頁>>代碼示例>>PHP>>正文


PHP InsightPluginParent::shouldGenerateMonthlyInsight方法代碼示例

本文整理匯總了PHP中InsightPluginParent::shouldGenerateMonthlyInsight方法的典型用法代碼示例。如果您正苦於以下問題:PHP InsightPluginParent::shouldGenerateMonthlyInsight方法的具體用法?PHP InsightPluginParent::shouldGenerateMonthlyInsight怎麽用?PHP InsightPluginParent::shouldGenerateMonthlyInsight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在InsightPluginParent的用法示例。


在下文中一共展示了InsightPluginParent::shouldGenerateMonthlyInsight方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testShouldGenerateMonthlyInsight

 public function testShouldGenerateMonthlyInsight()
 {
     $instance = new Instance();
     $instance->id = 10;
     $instance->network_username = 'testeriffic';
     $instance->network = 'twitter';
     $time_now = date("Y-m-d H:i:s");
     $today = date('Y-m-d', strtotime('today'));
     $yesterday = date('Y-m-d', strtotime('-1 day'));
     $builders = array();
     $builders[] = FixtureBuilder::build('insights', array('id' => 76, 'instance_id' => 10, 'slug' => 'some_slug', 'date' => $today, 'time_generated' => $time_now));
     $builders[] = FixtureBuilder::build('insights', array('id' => 77, 'instance_id' => 10, 'slug' => 'some_other_slug', 'date' => $yesterday, 'time_generated' => $time_now));
     $insight_plugin_parent = new InsightPluginParent();
     $insight_plugin_parent->insight_dao = DAOFactory::getDAO('InsightDAO');
     // Test default values
     $this->assertTrue($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance));
     $this->assertFalse($insight_plugin_parent->shouldGenerateMonthlyInsight('some_slug', $instance));
     // Test regeneration on a given date
     $this->assertTrue($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = $today));
     $this->assertFalse($insight_plugin_parent->shouldGenerateMonthlyInsight('some_other_slug', $instance, $insight_date = $yesterday));
     $this->assertTrue($insight_plugin_parent->shouldGenerateMonthlyInsight('some_other_slug', $instance, $insight_date = $yesterday, $regenerate_existing_insight = true));
     // Test for day of month
     $day_of_month1 = date('j');
     $day_of_month2 = date('j', strtotime('-1 day'));
     $this->assertTrue($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_month = $day_of_month1));
     $this->assertFalse($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_month = $day_of_month2));
     // Test with last week of posts
     $this->assertTrue($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_month = null, $count_related_posts = 13));
     $this->assertFalse($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_month = null, $count_related_posts = 0));
     // Test excluded networks
     $this->assertTrue($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_month = null, $count_last_week_of_posts = null, $excluded_networks = array('facebook')));
     $this->assertFalse($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_month = null, $count_last_week_of_posts = null, $excluded_networks = array('twitter', 'facebook')));
     // test bonus magic day
     $today = date('j');
     for ($i = 1; $i <= 31; $i++) {
         if ($today == ($i + 15) % date('t') + 1) {
             $bonus_day = $i;
             break;
         }
     }
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => $instance->id));
     $builders[] = FixtureBuilder::build('owners', array('id' => 1, 'joined' => date('Y-m-d', strtotime('-20 day')), 'email' => 'a@b.com'));
     $this->assertFalse($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = true, $day_of_month = $bonus_day));
     $instance->id++;
     $builders[] = FixtureBuilder::build('owner_instances', array('owner_id' => 2, 'instance_id' => $instance->id));
     $builders[] = FixtureBuilder::build('owners', array('id' => 2, 'joined' => date('Y-m-d'), 'email' => 'b@b.com'));
     $this->assertTrue($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = true, $day_of_month = $bonus_day));
     $this->assertFalse($insight_plugin_parent->shouldGenerateMonthlyInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = true, $day_of_month = $bonus_day, null, null, false));
 }
開發者ID:pepeleproso,項目名稱:ThinkUp,代碼行數:49,代碼來源:TestOfInsightPluginParent.php


注:本文中的InsightPluginParent::shouldGenerateMonthlyInsight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。