当前位置: 首页>>代码示例>>PHP>>正文


PHP Test::get_test_user方法代码示例

本文整理汇总了PHP中Test::get_test_user方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::get_test_user方法的具体用法?PHP Test::get_test_user怎么用?PHP Test::get_test_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Test的用法示例。


在下文中一共展示了Test::get_test_user方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testUrlFor

 function testUrlFor()
 {
     $user = Test::get_test_user();
     PA::$config->enable_fancy_url = TRUE;
     $this->assertEquals(url_for("user", array("login" => $user->login_name)), PA::$url . '/users/' . $user->login_name . '/');
     $this->assertEquals(url_for("user", array("login" => $user->login_name, "one" => 1, "two" => 2)), PA::$url . '/users/' . $user->login_name . '/?one=1&two=2');
     $this->assertEquals(url_for("user", array("login" => $user->login_name, "one" => 1, "two" => 2), array("one" => "asdf", "three" => "foo")), PA::$url . '/users/' . $user->login_name . '/?one=1&two=2&three=foo');
     PA::$config->enable_fancy_url = FALSE;
     $this->assertEquals(url_for("user", array("login" => $user->login_name)), PA::$url . '/user.php?login=' . $user->login_name);
     $this->assertEquals(url_for("user", array("login" => $user->login_name, "one" => 1, "two" => 2)), PA::$url . '/user.php?login=' . $user->login_name . '&one=1&two=2');
     $this->assertEquals(url_for("user", array("login" => $user->login_name, "one" => 1, "two" => 2), array("one" => "asdf", "three" => "foo")), PA::$url . '/user.php?login=' . $user->login_name . '&one=1&two=2&three=foo');
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:12,代码来源:UrlGenerationTest.php

示例2: testAddDeleteShadowUser

 public function testAddDeleteShadowUser()
 {
     //    Dal::register_query_callback("explain_query");
     global $network_info;
     echo "getting a user\n";
     $user = Test::get_test_user();
     $testusername = $user->first_name . " " . $user->last_name;
     echo "test user = {$testusername}\n";
     $namespace = 'php_unit';
     // testuser data
     $testdata = array('user_id' => "pa_" . $user->user_id, 'login_name' => 'testuser', 'email' => $namespace . $user->email, 'first_name' => $user->first_name, 'last_name' => $user->last_name);
     echo "TEST DATA:\n";
     print_r($testdata);
     $shadow_user = new ShadowUser($namespace);
     echo "Test load this shadow user, this should fail\n";
     $sh = $shadow_user->load($testdata['user_id']);
     $this->assertNull($sh);
     echo "Create a shadow user\n";
     $shadow_user = ShadowUser::create($namespace, $testdata, $network_info);
     echo "SHADOW USER DATA:\n";
     print_r($shadow_user);
     $this->assertNotNull($shadow_user);
     echo "Test updating the data\n";
     $testdata2 = $testdata;
     $testdata2['email'] = $namespace . "add" . $user->email;
     $testdata2['login_name'] = "newlogin";
     $testdata2['first_name'] = "newName";
     print_r($testdata2);
     $su2 = new ShadowUser($namespace);
     // load this with new data
     $su2->load($testdata2);
     unset($su2);
     Cache::reset();
     // now load it only via the original remote uid
     $su3 = new ShadowUser($namespace);
     $su3->load($testdata['user_id']);
     echo "UPDATED SHADOW USER DATA:\n";
     print_r($su3);
     echo "Delete it\n";
     ShadowUser::delete($shadow_user->user_id);
     // there should not be a shadow user of this id anymore
     $this->assertNull($shadow_user->load($testdata['user_id']));
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:43,代码来源:ShadowUserTest.php

示例3: testEmailNotification

 function testEmailNotification()
 {
     // test requires xdebug and xdebug_get_declared_vars().
     if (!extension_loaded('xdebug')) {
         echo ($msg = "Need xdebug extension for email notification test") . "\n";
         $this->markTestIncomplete($msg);
     }
     if (ini_get('xdebug.collect_vars') != 1) {
         echo ($msg = "need to set xdebug.collect_vars = 1") . "\n";
         $this->markTestIncomplete($msg);
     }
     $this->assertEquals($GLOBALS['this_test_requires_globals'], "test", "xdebug not working - or need to update phpunit?  see http://pear.php.net/bugs/bug.php?id=5053 for more info.");
     // hook mail()
     global $mail_testing_callback;
     $mail_testing_callback = array("EmailNotificationTest", "mail_hook");
     // load main network and get a fake owner user
     global $network_info, $owner;
     $network_info = Network::get_mothership_info();
     $owner = Test::get_test_user();
     // override destination so we get an e-mail
     $extra = unserialize($network_info->extra);
     $extra['notify_owner']['announcement']['value'] = NET_EMAIL;
     $extra['notify_owner']['content_to_homepage']['value'] = NET_EMAIL;
     $network_info->extra = serialize($extra);
     $this->assertEquals(count(EmailNotificationTest::$messages), 0);
     // now trigger a fake network announcement
     $owner_name = 'John Q. NetworkOwner';
     announcement(array('params' => array('aid' => "whatever"), 'owner_name' => $owner_name));
     $this->assertEquals(count(EmailNotificationTest::$messages), 1);
     $msg = EmailNotificationTest::$messages[0];
     $this->assertContains("nnouncement", $msg[1]);
     $this->assertContains("network", $msg[1]);
     $this->assertContains($owner_name, $msg[2]);
     $this->assertContains("nnouncement", $msg[2]);
     // now trigger a fake content posting to community blog
     $comm_blog_post = array('owner_name' => $owner_name, 'params' => array('first_name' => "Firstname", 'network_name' => "Network Name", 'user_id' => $owner->user_id, 'user_image' => $owner->picture, 'cid' => '1234', 'content_title' => 'Fake content title'));
     content_posted_to_comm_blog($comm_blog_post);
     $this->assertEquals(count(EmailNotificationTest::$messages), 2);
     $msg = EmailNotificationTest::$messages[1];
     $this->assertContains("Community Blog", $msg[1]);
     $this->assertContains("posted", $msg[1]);
     $this->assertContains($owner_name, $msg[2]);
     $this->assertContains("Firstname has posted", $msg[2]);
     echo "The site name is " . PA::$site_name . "\n";
     $this->assertContains(PA::$site_name, $msg[2]);
     /* The following test won't work yet -- as the site name is
                inserted in the messages early, so changing it now won't
                have any effect.
     
     	// now change the site name and make sure it shows up properly
     	$old_config_site_name = PA::$site_name;
     	$new_config_site_name = PA::$site_name = "Test site name - for EmailNotificationTest";
     	content_posted_to_comm_blog($comm_blog_post);
     	$this->assertEquals(count(EmailNotificationTest::$messages), 3);
     	$msg = EmailNotificationTest::$messages[2];
     	$this->assertContains("Community Blog", $msg[1]);
     	$this->assertContains("posted", $msg[1]);
     	$this->assertContains($owner_name, $msg[2]);
     	$this->assertContains("Firstname has posted", $msg[2]);
     	echo "The site name is ". PA::$site_name ."\n";
     	$this->assertContains(PA::$site_name, $msg[2]);
     	$this->assertNotContains($old_config_site_name, $msg[2]);
     	$this->assertNotContains("PeopleAggregator", $msg[2]);
     	*/
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:65,代码来源:EmailNotificationTest.php

示例4: testNetworkCreation

 function testNetworkCreation()
 {
     // check that we can create networks
     $can = Network::can_network_be_created();
     $this->assertFalse($can['error'], $can['error_msg']);
     // get network owner user and figure out name etc
     $user = Test::get_test_user();
     $name = "testnet" . rand(10000, 99999);
     $network_basic_controls = array();
     // with crossed fingers, we hope that it will succeed without any of the detail here!
     // make a new network
     $net = new Network();
     $net->set_params(array('user_id' => $user->user_id, 'name' => "auto-test network ({$name})", 'address' => $name, 'tagline' => "not much of a tagline", 'category_id' => 8, 'type' => 0, 'description' => "This network has been created automatically by a PHPUnit test.  If the test succeeds, it will be deleted, too!", 'extra' => serialize($network_basic_controls), 'created' => time(), 'changed' => time()));
     $net->save();
     //default_page_setting($net->address);
     // read it in again and see if it still works
     $net_read = Network::get_network_by_address($net->address);
     $this->assertEquals($net_read->network_id, $net->network_id);
     $this->assertEquals($net_read->type, 0);
     $this->assertEquals($net_read->member_count, 1);
     $this->assertEquals($net_read->owner_id, $user->user_id);
     // a user joins
     $user2 = Test::get_test_user(2);
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // a user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // make it into a moderated network
     $net->type = 2;
     $net->save();
     // check that it really is moderated
     $net_read = Network::get_network_by_address($net->address);
     $this->assertEquals($net_read->network_id, $net->network_id);
     $this->assertEquals($net_read->type, 2);
     // a user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // request approved
     Network::approve($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // all requests accepted (of course, there will only be the one)
     Network::approve_all($net->network_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 2);
     // user leaves
     Network::leave($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // user requests
     Network::join($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // request denied
     Network::deny($net->network_id, $user2->user_id);
     $this->assertEquals(Network::get_network_by_address($net->address)->member_count, 1);
     // delete network
     Network::delete($net->network_id);
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:62,代码来源:NetworkCreationTest.php

示例5: testAddDeleteContentComments

 function testAddDeleteContentComments()
 {
     //    Dal::register_query_callback("explain_query");
     echo "getting a user\n";
     $user = Test::get_test_user();
     echo "test user = {$user->first_name} {$user->last_name}\n";
     echo "adding some content\n";
     $post = new BlogPost();
     $post->author_id = $user->user_id;
     $post->parent_collection_id = -1;
     $post->title = "Test blog post (from testAddDeleteContentComments)";
     $post->body = "<p>This is the post body!</p><p>Foo <b>foo</b> foo</p>";
     $post->allow_comments = 1;
     $post->is_active = 1;
     $post->display_on = DISPLAY_ON_HOMEPAGE;
     $post->save();
     echo "... saved as content_id={$post->content_id}\n";
     echo "testing that it is retrievable\n";
     $post_retr = Content::load_content($post->content_id, $user->user_id);
     $this->assertEquals($post_retr->content_id, $post->content_id);
     $this->assertEquals($post_retr->title, $post->title);
     $this->assertEquals($post_retr->body, $post->body);
     $this->assertEquals($post_retr->author_id, $user->user_id);
     $this->assertEquals($post_retr->is_active, 1);
     echo "posting a comment\n";
     $cmt = new Comment();
     $cmt->content_id = $post->content_id;
     $cmt_comment = "This is an automatic comment - on an autogenerated post";
     $cmt->comment = $cmt_comment;
     $cmt->user_id = $user->user_id;
     $cmt->name = $cmt->email = $cmt->homepage = '';
     $cmt->ip_addr = '127.0.0.1';
     $cmt->referrer = 'http://example.com/';
     $cmt->user_agent = 'phpunit auto-test';
     $cmt->save();
     echo "... saved as comment_id={$cmt->comment_id}\n";
     echo "testing that the comment is retrievable\n";
     $cmt_retr = new Comment();
     $cmt_retr->load($cmt->comment_id);
     $this->assertEquals($cmt_retr->comment_id, $cmt->comment_id);
     $this->assertEquals($cmt_retr->content_id, $post->content_id);
     $this->assertEquals($cmt_retr->comment, $cmt_comment);
     $this->assertEquals($cmt_retr->is_active, 1);
     echo "testing that we see one comment on the post\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     echo count($comments) . " comments\n";
     //var_dump($comments);
     $this->assertEquals(count($comments), 1);
     echo "testing that we have no trackbacks on the post\n";
     $trackbacks = Content::get_trackbacks_for_content($post->content_id);
     echo count($trackbacks) . " trackbacks\n";
     //var_dump($trackbacks);
     $this->assertEquals(count($trackbacks), 0);
     echo "posting ANOTHER comment\n";
     $cmt2 = new Comment();
     $cmt2->content_id = $post->content_id;
     $cmt2_comment = "This is ANOTHER automatic comment - on the same autogenerated post";
     $cmt2->comment = $cmt_comment;
     $cmt2->user_id = $user->user_id;
     $cmt2->name = $cmt2->email = $cmt2->homepage = '';
     $cmt2->ip_addr = '127.0.0.1';
     $cmt2->referrer = 'http://example.com/';
     $cmt2->user_agent = 'phpunit auto-test';
     $cmt2->save();
     echo "... saved as comment_id={$cmt2->comment_id}\n";
     echo "testing that we see two comments on the post\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     $this->assertEquals(count($comments), 2);
     echo "deleting the first comment\n";
     $cmt_retr->delete();
     echo "testing that we see one comment on the post again (not seeing the deleted one)\n";
     $comments = Comment::get_comment_for_content($post->content_id);
     $this->assertEquals(count($comments), 1);
     echo "testing that the first comment (now deleted) is not retrievable\n";
     $cmt_retr_fail = new Comment();
     try {
         $cmt_retr_fail->load($cmt->comment_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
     }
     echo "deleting the post\n";
     Content::delete_by_id($post->content_id);
     echo "testing that the post is not retrievable\n";
     try {
         $post_retr_fail = Content::load_content($post->content_id, $user->user_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), CONTENT_NOT_FOUND);
     }
     echo "testing that the last comment is not retrievable\n";
     $cmt_retr_fail = new Comment();
     try {
         $cmt_retr_fail->load($cmt->comment_id);
         $this->assertTrue(FALSE);
         // shouldn't get here
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST);
//.........这里部分代码省略.........
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:101,代码来源:ContentCommentsTest.php

示例6: testAddUpdateDeleteEvent

 public function testAddUpdateDeleteEvent()
 {
     //    Dal::register_query_callback("explain_query");
     echo "getting a user\n";
     $user = Test::get_test_user();
     $testusername = $user->first_name . " " . $user->last_name;
     echo "test user = {$testusername}\n";
     /* setup some times and time strings */
     $today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
     $tomorrow = mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"));
     $yesterday = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
     $lastmonth = mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"));
     $nextmonth = mktime(0, 0, 0, date("m") + 1, date("d"), date("Y"));
     $nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1);
     $oneday = 60 * 60 * 24;
     $simple_dateformat = "Y-m-d";
     /* use the constants in the format parameter */
     // something like: Mon, 15 Aug 2005 15:12:46 UTC
     $now_rfc822 = date(DATE_RFC822);
     // something like: 2000-07-01T00:00:00+00:00
     // $now_atom = date(DATE_ATOM);
     // create an Event
     echo "create and save Event\n";
     $e = new Event();
     $e->content_id = "http://myevent.info/1";
     // anything basically
     $e->user_id = $user->user_id;
     $e->event_title = "Test Event for {$testusername}";
     $now = time();
     $nowplusoneday = $now + $oneday;
     $e->start_time = date(DATE_ATOM, $now);
     $e->end_time = date(DATE_ATOM, $now + 60 * 60);
     // duration 1h
     $e->event_data = array('description' => "This Event takes place to test the class Event", 'start' => $now, 'end' => $now + 60 * 60);
     $e->save();
     // print_r($e);
     // see if we got it
     echo "Retrieving Event {$e->event_id}\n";
     $e2 = new Event();
     $e2->load($e->event_id);
     echo "Testing integrity of dates\n";
     // print_r($e2);
     // see if the stored timestamps match
     $this->assertEquals($now, $e2->event_data['start']);
     // see if our dates survived the DB conversion roundtrip
     $this->assertEquals($now, strtotime($e2->start_time));
     $this->assertEquals($now + 60 * 60, strtotime($e2->end_time));
     // create two EventAssociations
     $ea1 = new EventAssociation();
     $ea2 = new EventAssociation();
     $ea1->user_id = $user->user_id;
     $ea2->user_id = $user->user_id;
     // user EventAssocoiation
     $ea1->assoc_target_type = 'user';
     $ea1->assoc_target_id = $user->user_id;
     // could very well be other user
     $ea1->assoc_target_name = $testusername;
     $ea1->event_id = $e->event_id;
     $ea1->save();
     // network EventAssocoiation
     // find a network the user is member of
     // $networks = Network::get_user_networks($user->user_id);
     $network = Network::get_mothership_info();
     // use the mothership
     // print_r($network);
     $ea2->assoc_target_type = 'network';
     $ea2->assoc_target_id = $network->network_id;
     // could very well be other user
     $ea2->assoc_target_name = $network->name;
     $ea2->event_id = $e->event_id;
     $ea2->save();
     echo "Testing EventAssociations for Event {$e->event_id}\n";
     $assoc_ids = EventAssociation::find_for_event($e->event_id);
     // print_r($assoc_ids);
     $a_cnt = count($assoc_ids);
     $this->assertEquals($a_cnt, 2, "expected 2 assocs, got {$a_cnt}\n");
     echo "Testing EventAssociations::find_for_target_and_delta for Network\n";
     $assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id);
     // find_for_target_and_delta($target_type, $target_id, $range_start = NULL, $range_end = NULL)
     // print_r($assoc_ids);
     $a_cnt = count($assoc_ids);
     // we expect at least one (or more, the user might have others too)
     $this->assertTrue($a_cnt >= 1, "expected 1 or more assocs, got {$a_cnt}\n");
     echo "Testing EventAssociations::find_for_target_and_delta for Today\n";
     /*
     echo "yesterday = " . date(DATE_ATOM, $yesterday) . "\n";
     echo "today = " . date(DATE_ATOM, $today) . "\n";
     echo "event start_time = " . date(DATE_ATOM, strtotime($e2->start_time)) . "\n";
     echo "event end_time = " . date(DATE_ATOM, strtotime($e2->end_time)) . "\n";
     echo "tomorrow = " . date(DATE_ATOM, $tomorrow) . "\n";
     */
     $assoc_ids = EventAssociation::find_for_target_and_delta('network', $network->network_id, date(DATE_ATOM, $today), date(DATE_ATOM, $tomorrow));
     print_r($assoc_ids);
     /* 
     $assocs = EventAssociation::load_in_list($assoc_ids);
     print_r($assocs);
     */
     $a_cnt = count($assoc_ids);
     // we expect at least one (or more, the user might have others too)
     $this->assertTrue($a_cnt >= 1, "expected 1 or more assocs, got {$a_cnt}\n");
//.........这里部分代码省略.........
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:101,代码来源:EventArchitectureTest.php


注:本文中的Test::get_test_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。