本文整理汇总了PHP中FixtureBuilder类的典型用法代码示例。如果您正苦于以下问题:PHP FixtureBuilder类的具体用法?PHP FixtureBuilder怎么用?PHP FixtureBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FixtureBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
/**
* Builds our data
* @param str table name (without prefix)
* @param array hash args of column values (optional)
* @param bool debug (defaults to false)
* @return FixtureBuilder our builder object with column values
*/
public static function build($table, $args = null, $debug = false)
{
$builder = new FixtureBuilder($debug);
$builder->buildData($table, $args);
$builder->table = $table;
return $builder;
}
示例2: buildData
private function buildData()
{
// Create a owner
$builders = array();
$builders[] = FixtureBuilder::build('users', array('user_id' => '113612142759476883204', 'network' => 'foursquare'));
return $builders;
}
示例3: buildData
protected function buildData()
{
$session = new Session();
$cryptpass = $session->pwdcrypt("oldpassword");
$builder = FixtureBuilder::build('owners', array('id' => 1, 'full_name' => 'ThinkUp J. User', 'email' => 'me@example.com', 'pwd' => $cryptpass, 'activation_code' => 8888, 'is_activated' => 1));
return $builder;
}
示例4: testOutput
public function testOutput()
{
//not logged in
$controller = new TwitterPluginHashtagConfigurationController(null, 'twitter', 'ginatrapani');
$output = $controller->go();
$v_mgr = $controller->getViewManager();
$config = Config::getInstance();
$this->assertEqual('You must <a href="' . $config->getValue('site_root_path') . 'session/login.php">log in</a> to do this.', $v_mgr->getTemplateDataItem('error_msg'));
//logged in, no user set up
$this->simulateLogin('me@example.com');
$owner_dao = DAOFactory::getDAO('OwnerDAO');
$owner = $owner_dao->getByEmail(Session::getLoggedInUser());
$controller = new TwitterPluginHashtagConfigurationController(null, 'twitter', 'ginatrapani');
$output = $controller->go();
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('user'), 'string');
$this->assertEqual('Twitter user @ginatrapani does not exist.', $v_mgr->getTemplateDataItem('error_msg'));
//logged in, user set up
$builders = array();
$builders[] = FixtureBuilder::build('instances', array('network_username' => 'ginatrapani', 'network' => 'twitter'));
$controller = new TwitterPluginHashtagConfigurationController(null, 'twitter', 'ginatrapani');
$output = $controller->go();
$v_mgr = $controller->getViewManager();
$this->assertIsA($v_mgr->getTemplateDataItem('user'), 'string');
$this->assertIsA($v_mgr->getTemplateDataItem('hashtags'), 'array');
}
示例5: testIsConfigured
public function testIsConfigured()
{
$plugin = new Plugin(array('id' => 1, 'folder_name' => 'twitter', 'name' => 'Twitter Plugin', 'description' => '', 'version' => '0.10', 'author' => 'Gina Trapani', 'homepage' => '', 'is_active' => 1));
//no options, no requirements
$this->assertTrue($plugin->isConfigured());
//option, no requirements
$builders[] = FixtureBuilder::build('options', array('namespace' => 'plugin_options-1', 'option_name' => 'api_key', 'option_value' => 'mykeyeeeee'));
$plugin->options_hash = null;
$this->assertTrue($plugin->isConfigured());
//requirement AND option
$plugin->addRequiredSetting('api_key');
$plugin->options_hash = null;
$this->assertTrue($plugin->isConfigured());
//another requirements without a matching setting
$plugin->addRequiredSetting('another_thinger');
$plugin->options_hash = null;
$this->assertFalse($plugin->isConfigured());
//2 requirements, 2 set
$builders[] = FixtureBuilder::build('options', array('namespace' => 'plugin_options-1', 'option_name' => 'another_thinger', 'option_value' => 'mythingerrrrr'));
$plugin->options_hash = null;
$this->assertTrue($plugin->isConfigured());
$builders[] = FixtureBuilder::build('options', array('namespace' => 'plugin_options-1', 'option_name' => 'yet_another_thinger', 'option_value' => 'mythingerrrrr222'));
$plugin->options_hash = null;
$this->assertTrue($plugin->isConfigured());
}
示例6: buildPluginOptions
/**
* build plugin option values
*/
private function buildPluginOptions()
{
$plugin1 = FixtureBuilder::build('plugins', array('id' => 2, 'folder_name' => 'facebook'));
$plugin_opt1 = FixtureBuilder::build('plugin_options', array('plugin_id' => 2, 'option_name' => 'facebook_api_key', 'option_value' => "dummy_key"));
$plugin_opt2 = FixtureBuilder::build('plugin_options', array('plugin_id' => 2, 'option_name' => 'facebook_api_secret', 'option_value' => "dummy_secret"));
return array($plugin_opt1, $plugin_opt2, $plugin1);
}
示例7: buildData
private function buildData()
{
$builders = array();
$builders[] = FixtureBuilder::build('owners', array('id' => 1, 'email' => 'admin@example.com', 'pwd' => 'XXX', 'is_activated' => 1, 'is_admin' => 1));
//Insert test links (not images, not expanded)
$counter = 0;
while ($counter < 40) {
$post_id = $counter + 80;
$pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT);
$builders[] = FixtureBuilder::build('links', array('url' => "http://example.com/{$counter}", 'expanded_url' => null, 'title' => "Link {$counter}", 'clicks' => 0, 'post_id' => $post_id, 'is_image' => 0, 'error' => null));
$counter++;
}
//Insert test links (images on Flickr that don't exist, not expanded)
$counter = 0;
while ($counter < 2) {
$post_id = $counter + 80;
$pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT);
$builders[] = FixtureBuilder::build('links', array('url' => "http://flic.kr/p/{$counter}", 'expanded_url' => null, 'title' => "Link {$counter}", 'clicks' => 0, 'post_id' => $post_id, 'is_image' => 1, 'error' => null));
$counter++;
}
// Insert legit Flickr shortened link, not expanded
$builders[] = FixtureBuilder::build('links', array('url' => "http://flic.kr/p/7QQBy7", 'expanded_url' => null, 'title' => "Link 0", 'clicks' => 0, 'post_id' => 200, 'is_image' => 1, 'error' => null));
//Insert test links with errors (images from Flickr, not expanded)
$counter = 0;
while ($counter < 5) {
$post_id = $counter + 80;
$pseudo_minute = str_pad($counter, 2, "0", STR_PAD_LEFT);
$builders[] = FixtureBuilder::build('links', array('url' => "http://flic.kr/p/{$counter}", 'expanded_url' => null, 'title' => "Link {$counter}", 'clicks' => 0, 'post_id' => $post_id, 'is_image' => 1, 'error' => 'Photo not found'));
$counter++;
}
return $builders;
}
示例8: testShouldGenerateInsight
public function testShouldGenerateInsight()
{
$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->shouldGenerateInsight('a_slug', $instance));
$this->assertFalse($insight_plugin_parent->shouldGenerateInsight('some_slug', $instance));
// Test regeneration on a given date
$this->assertTrue($insight_plugin_parent->shouldGenerateInsight('a_slug', $instance, $insight_date = $today));
$this->assertFalse($insight_plugin_parent->shouldGenerateInsight('some_other_slug', $instance, $insight_date = $yesterday));
$this->assertTrue($insight_plugin_parent->shouldGenerateInsight('some_other_slug', $instance, $insight_date = $yesterday, $regenerate_existing_insight = true));
// Test for day of week
$dow1 = date('w');
$dow2 = date('w', strtotime('-1 day'));
$this->assertTrue($insight_plugin_parent->shouldGenerateInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = $dow1));
$this->assertFalse($insight_plugin_parent->shouldGenerateInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = $dow2));
// Test with last week of posts
$this->assertTrue($insight_plugin_parent->shouldGenerateInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = null, $count_last_week_of_posts = 13));
$this->assertFalse($insight_plugin_parent->shouldGenerateInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = null, $count_last_week_of_posts = 0));
// Test excluded networks
$this->assertTrue($insight_plugin_parent->shouldGenerateInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = null, $count_last_week_of_posts = null, $excluded_networks = array('facebook')));
$this->assertFalse($insight_plugin_parent->shouldGenerateInsight('a_slug', $instance, $insight_date = 'today', $regenerate_existing_insight = false, $day_of_week = null, $count_last_week_of_posts = null, $excluded_networks = array('twitter', 'facebook')));
}
示例9: testFromName
public function testFromName()
{
$config = Config::getInstance();
$config->setValue("app_title_prefix", "My Crazy Custom ");
$_SERVER['HTTP_HOST'] = "my_thinkup_hostname";
Mailer::mail('you@example.com', 'Testing 123', 'Me worky, yo?');
$email_body = Mailer::getLastMail();
$this->debug($email_body);
$this->assertPattern('/From: "My Crazy Custom ThinkUp" <notifications@my_thinkup_hostname>/', $email_body);
$config->setValue("app_title_prefix", "My Other Installation of ");
$_SERVER['HTTP_HOST'] = null;
$_SERVER['SERVER_NAME'] = "my_other_hostname";
Mailer::mail('you@example.com', 'Testing 123', 'Me worky, yo?');
$email_body = Mailer::getLastMail();
$this->debug($email_body);
$this->assertPattern('/From: "My Other Installation of ThinkUp" <notifications@my_other_hostname>/', $email_body);
$config->setValue("app_title_prefix", "Yet Another Installation of ");
$_SERVER['HTTP_HOST'] = null;
$_SERVER['SERVER_NAME'] = null;
$builder = FixtureBuilder::build('options', array('namespace' => 'application_options', 'option_name' => 'server_name', 'option_value' => 'testservername'));
Mailer::mail('you@example.com', 'Testing 123', 'Me worky, yo?');
$email_body = Mailer::getLastMail();
$this->debug($email_body);
$this->assertPattern('/From: "Yet Another Installation of ThinkUp" <notifications@testservername>/', $email_body);
}
示例10: testInstanceMoreThan3Hours
public function testInstanceMoreThan3Hours()
{
$instance_builder = FixtureBuilder::build('instances', array('crawler_last_run' => '-4h'));
$controller = new CheckCrawlerController(true);
$results = $controller->go();
$this->assertEqual("Crawler hasn't run in 4 hours", $results, $results);
}
示例11: buildData
private function buildData()
{
$owner_builder = FixtureBuilder::build('owners', array('id' => 1, 'email' => 'me@example.com', 'pwd' => 'XXX', 'is_activated' => 1));
$instance_builder = FixtureBuilder::build('instances', array('id' => 1, 'network_username' => 'jack', 'network' => 'twitter'));
$owner_instance_builder = FixtureBuilder::build('owner_instances', array('owner_id' => 1, 'instance_id' => 1));
return array($owner_builder, $instance_builder, $owner_instance_builder);
}
示例12: testLoadConfigViewData
public function testLoadConfigViewData()
{
$this->simulateLogin('me@example.com', true);
$controller = new AppConfigController(true);
$results = $controller->control();
$json_obj = json_decode($results);
//var_dump($json_obj);
$this->assertFalse($json_obj->app_config_settings->recaptcha_enable->required);
$this->assertEqual(count($json_obj->values), 0, 'no app settings stored');
$bvalue = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'recaptcha_enable', 'option_value' => 'true');
$bvalue2 = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'recaptcha_private_key', 'option_value' => 'abc123');
$bvalue3 = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'recaptcha_public_key', 'option_value' => 'abc123public');
$bvalue4 = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'default_instance', 'option_value' => '123');
$bvalue5 = array('namespace' => OptionDAO::APP_OPTIONS, 'option_name' => 'is_opted_out_usage_stats', 'option_value' => 'true');
$bdata = FixtureBuilder::build('options', $bvalue);
$bdata2 = FixtureBuilder::build('options', $bvalue2);
$bdata3 = FixtureBuilder::build('options', $bvalue3);
$bdata4 = FixtureBuilder::build('options', $bvalue4);
$bdata5 = FixtureBuilder::build('options', $bvalue5);
$results = $controller->control();
$json_obj = json_decode($results);
$this->assertFalse($json_obj->app_config_settings->recaptcha_enable->required);
$this->assertTrue($json_obj->values->recaptcha_enable->option_value, "uses db config value");
$this->assertEqual($json_obj->values->recaptcha_private_key->option_value, 'abc123');
$this->assertEqual($json_obj->values->recaptcha_public_key->option_value, 'abc123public');
$this->assertEqual($json_obj->values->default_instance->option_value, '123');
$this->assertTrue($json_obj->values->is_opted_out_usage_stats->option_value);
}
示例13: buildData
protected function buildData()
{
$builders = array();
$builders[] = FixtureBuilder::build('sessions', array('session_id' => 'foobar', 'updated' => date('c'), 'data' => serialize(array('foo' => 'bar'))));
$builders[] = FixtureBuilder::build('sessions', array('session_id' => 'nofoo', 'updated' => date('c'), 'data' => serialize(array('blah' => 'baz'))));
$builders[] = FixtureBuilder::build('sessions', array('session_id' => 'oldsession', 'updated' => date('c', time() - 200), 'data' => 'still here'));
return $builders;
}
示例14: buildData
protected function buildData()
{
$builders = array();
$builders[] = FixtureBuilder::build('cookies', array('owner_email' => 'me@test.com', 'cookie' => 'chocolate'));
$builders[] = FixtureBuilder::build('cookies', array('owner_email' => 'me@test.com', 'cookie' => 'gingersnap'));
$builders[] = FixtureBuilder::build('cookies', array('owner_email' => 'you@test.com', 'cookie' => 'oreo'));
return $builders;
}
示例15: testOnlyOnce
public function testOnlyOnce()
{
$insight_builder = FixtureBuilder::build('insights', array('id' => 30, 'instance_id' => $this->instance->id, 'slug' => 'twitter_age', 'date' => '-1d'));
$plugin = new TwitterAgeInsight();
$plugin->generateInsight($this->instance, $this->makeUser('2011-10-01'), array(), 1);
$result = $this->insight_dao->getInsight('twitter_age', $this->instance->id, date('Y-m-d'));
$this->assertNull($result);
}