function testTagFields() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->set('nick', 'test'); $user->save(); $POD->changeActor(array('id' => $user->id)); //log in as user $user2 = $POD->getPerson(); $user2->email = '*****@*****.**'; //create user $user2->password = '******'; $user2->set('nick', 'test2'); $user2->save(); $user2->sendMessage('hi user2'); sleep(2); $user2->sendMessage('hi again user2'); $POD->changeActor(array('id' => $user2->id)); $inbox = $POD->getInbox(); $this->assertTrue($inbox); $thread = $inbox->newThread($user->id); $this->assertNotNull($thread->MESSAGES); $messages = $thread->messages(); $this->assertEqual($thread->unreadCount(), 2); $this->assertEqual($messages->count(), 2); $first_message = $messages->getNext(); $this->assertEqual($first_message->to()->get('id'), $user2->id); $this->assertEqual($first_message->from()->get('id'), $user->id); $thread->markAsRead(); $this->assertEqual($thread->unreadCount(), 0); $this->assertEqual($thread->recipient()->get('id'), $user->id); $second_message = $messages->getNext(); $thread->reply('hello to you'); $this->assertTrue($thread->success()); $POD->changeActor(array('id' => $user->id)); $inbox = $POD->getInbox(); $thread = $inbox->newThread($user2->id); $this->assertEqual($thread->unreadCount(), 1); $messages = $thread->messages(); $this->assertEqual($messages->count(), 3); $messages->reset(); $message = $messages->getNext(); $this->assertEqual($message->message, 'hi user2'); ///Test fields of message object////// $this->assertNotNull($message->id); $this->assertEqual($message->userId, $user->id); $this->assertEqual($message->fromId, $user->id); $this->assertEqual($message->targetUserId, $user2->id); $this->assertNotNull($message->date); $this->assertEqual($message->status, 'read'); /////////////////////////////////// $POD->changeActor(array('id' => $user->id)); $user->delete(); $POD->changeActor(array('id' => $user2->id)); $user2->delete(); }
function test_File_fields() { $POD = new PeoplePod(); $user = $POD->getPerson(array('nick' => 'admin')); $POD->changeActor(array('id' => $user->id)); $most_recent = $POD->getFiles(array('userId' => $user->get('id'))); $file = $most_recent->getNext(); $this->assertIsA($file, 'File'); $this->assertTrue($file->isImage()); $creator = $file->creator(); $this->assertIsA($creator, 'Person'); $owner = $file->owner(); $this->assertIsA($owner, 'Person'); $this->assertTrue($file->get('userId'), $user->id); $this->assertEqual($file->get('extension'), 'jpg'); $this->assertNotNull($file->get('id')); $this->assertNotNull($file->get('contentId')); $this->assertEqual($file->get('original_name'), 'darwin.jpg'); $this->assertNull($file->get('description')); //should this be initialized to null? $this->assertEqual($file->get('mime_type'), 'image/jpeg'); $this->assertNotNull($file->get('date')); $this->assertNotNull($file->get('minutes')); $parent_content = $file->parent(); $this->assertIsA($parent_content, 'Content'); $this->assertEqual($parent_content->get('headline'), 'Darwin'); //now attempt to get a file by means of getFile() $new_file = $POD->getFile(array('id' => $file->get('id'))); $this->assertIsA($new_file, 'File'); }
function testTagFields() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = 'ben+test@e'; //create user $user->password = '******'; $user->set('nick', 'test'); $user->save(); $POD->changeActor(array('id' => $user->id)); //log in as user $content = $POD->getContent(); $content->set('headline', 'this is the headline'); $content->set('type', 'this is the type'); $content->save(); $this->assertFalse($content->hasTag('foo')); $content->addTag('foo'); $content->save(); $this->assertTrue($content->hasTag('foo')); $tags = $content->tags(); $tag = $tags->getNext(); $this->assertIsA($tag, 'Tag'); /// test of fields ////////////////////// $this->assertNotNull($tag->id); $this->assertEqual($tag->value, 'foo'); $this->assertNotNull($tag->get('date')); //////////////////////////////////////// $content->removeTag('nonexistant'); $this->assertFalse($content->success()); // should not be able to remove a tag that does not exist $tag_count = $content->tags()->count(); $this->assertEqual($tag_count, 1); $content->removeTag('foo'); $tag_count = $content->tags()->count(); $this->assertEqual($tag_count, 0); $string = "foo bar baz"; $content->tagsFromString($string); $tag_count = $content->tags()->count(); $this->assertEqual($tag_count, 3); $string = $content->tagsAsString(); $this->assertEqual($string, "foo bar baz"); $content->addTag(""); $this->assertEqual($tag_count, 3); $string = $content->tagsAsString(); $this->assertEqual($string, "foo bar baz "); $string = ""; //test adding a null value tag $content->tagsFromString($string); $tag_count = $content->tags()->count(); $this->assertEqual($tag_count, 0); $content->delete(); $user->delete(); }
function check_for_users_and_content() { $POD = new PeoplePod(); $extra_people = $POD->getPeople(array('testcase' => 'testuser')); $extra_content = $POD->getContents(array('testcase' => 'testcontent')); while ($next = $extra_content->getNext()) { $next->delete(true); } while ($next_person = $extra_people->getNext()) { $POD->changeActor(array('id' => $next_person->id)); $next_person->delete(); } }
function testPeoplePodsCreateUser() { $POD = new PeoplePod(); $user = $POD->getPerson(); $this->assertIsA($user, 'Person'); $this->assertNull($user->id); $user->email = '*****@*****.**'; $user->password = '******'; $user->nick = 'test'; $user->save(); $this->assertTrue($user->success()); $this->assertNotNull($user->id); $POD->changeActor(array('id' => $user->id)); $this->assertTrue($POD->isAuthenticated()); $user->delete(); }
function testCommentFunctions() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->nick = 'test'; $user->save(); $POD->changeActor(array('id' => $user->id)); $content = $POD->getContent(); $content->set('headline', 'this is the headline'); $content->set('type', 'this is the type'); $content->save(); $comment = $content->addComment('amazing!'); $comment->type = 'rating'; $comment2 = $content->addComment('blah'); $comment->type = 'rating'; $this->assertEqual($comment->author()->get('id'), $user->id); $this->assertEqual($comment->parent()->id, $content->id); $comment_stack = $content->comments(); $this->assertEqual($comment_stack->count(), 2); $next_comm = $comment_stack->getNext(); $this->assertIsA($next_comm, 'Comment'); $pod_comm_stack = $POD->getComments(); $pod_comm = $pod_comm_stack->getNext(); $this->assertIsA($pod_comm, 'Comment'); //test getComment to return a specific comment $pull_comm = $POD->getComment(array('id' => $comment2->id)); $this->assertEqual($pull_comm->comment, 'blah'); //test getComment to create a comment and associate it with a person and content obj $new_comment = $POD->getComment(); $new_comment->set('comment', 'This comment sucks!'); $new_comment->set('userId', $user->id); $new_comment->set('contentId', $content->get('id')); $new_comment->save(); $comment_stack = $POD->getComments(array('userId' => $user->id)); $this->assertEqual($comment_stack->count(), 3); $comment->delete(); $content->delete(); $user->delete(); }
function Test_relationship_functions() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->nick = 'test'; $user->save(); $POD->changeActor(array('id' => $user->id)); $content = $POD->getContent(); $content->set('headline', 'this is the test_tags headline'); $content->set('type', 'this is the type'); $content->save(); $new_content = $POD->getContent(); $new_content->set('headline', 'new child document'); $new_content->set('type', 'post'); $new_content->set('parentId', $content->get('id')); $new_content->save(); //Below tests parent(), and child() //test that the new content's id is set to it's parent's id $this->assertIdentical($new_content->get('parentId'), $content->get('id')); $this->assertIsA($content->children(), 'Stack'); //$this->assertIdentical($new_content->parent()->get('id'), $content->get('id')); //$this->assertFalse(is_string($new_content->parent()->get('id'))); //**Note** $new_content->'id' is either getting set, cashed, or returned as a string. While the parent content is set to an integer $this->assertEqual($new_content->parent()->get('id'), $content->get('id')); $this->assertFalse(is_string($content->get('id'))); //below tests comments() $content->addComment('first comment'); $content->addComment('second comment'); $content->addComment('third comment'); $content_comments = $content->comments(); $this->assertIsA($content_comments, 'Stack'); $first = $content_comments->getNext(); $this->assertEqual($first->comment, 'first comment'); $first = $content_comments->getNext(); $first = $content_comments->getNext(); // this should be the 'third comment' $this->assertEqual($first->comment, 'third comment'); $first = $content_comments->getNext(); // this should return null $this->assertNull($first); $content_comments->reset(); $first = $content_comments->getNext(); $this->assertEqual($first->comment, 'first comment'); //below tests files() $img_file = $content->files(); $this->assertNotNull($img_file); //below tests group() $group = $POD->getGroup(); $group->set('groupname', 'group 1'); $group->set('description', 'this is the group'); $group->save(); $this->assertTrue($group->success()); $content->setGroup($group->get('id')); $this->assertTrue($content->success()); $this->assertEqual($group->get('id'), $content->get('groupId')); $this->assertIsA($content->group(), 'Group'); // below tests tag() $string = "foo bar baz"; $content->tagsFromString($string); $tag_stack = $content->tags(); $this->assertIsA($tag_stack, 'Stack'); $tag = $tag_stack->getNext(); $this->assertIsA($tag, 'Tag'); $this->assertEqual($tag->value, 'foo'); $group->delete(); $new_content->delete(); $content->delete(); $user->delete(); }
function Test_favorite_watched() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->nick = 'test'; $user->save(); $POD->changeActor(array('id' => $user->id)); //log in as user $content = $POD->getContent(); $content->set('headline', 'this is the headline'); $content->set('type', 'this is the type'); $content->save(); $isFavorite = $user->isFavorite($content); $this->assertFalse($isFavorite); $user->toggleFavorite($content); $isFavorite = $user->isFavorite($content); $this->assertTrue($isFavorite); $isWatched = $user->isWatched($content); $this->assertTrue($isWatched); $user->toggleWatch($content); $isWatched = $user->isWatched($content); $this->assertFalse($isWatched); $content->delete(); $user->delete(); }
function CreateBaseContent() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->nick = 'test'; $user->addMeta('testcase', 'testuser'); // add a new field $user->save(); $user2 = $POD->getPerson(); $user2->email = '*****@*****.**'; //create user $user2->password = '******'; $user2->nick = 'test2'; $user2->addMeta('testcase', 'testuser'); // add a new field $user2->save(); $user3 = $POD->getPerson(); $user3->email = '*****@*****.**'; //create user $user3->password = '******'; $user3->nick = 'test3'; $user3->addMeta('testcase', 'testuser'); // add a new field $user3->save(); $POD->changeActor(array('id' => $user->id)); //log in as test $content = $POD->getContent(); $content->set('headline', 'first headline'); $content->set('type', 'same type'); $content->addMeta('testcase', 'testcontent'); // add a new field $content->save(); $content2 = $POD->getContent(); $content2->set('headline', 'second headline'); $content2->set('type', 'same type'); $content2->addMeta('testcase', 'testcontent'); // add a new field $content2->save(); $content3 = $POD->getContent(); $content3->set('headline', 'second headline'); $content3->set('type', 'different type'); $content3->addMeta('testcase', 'testcontent'); // add a new field $content3->save(); return $POD; }
function testGroupContentPrivacy() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->set('nick', 'test'); $user->save(); $POD->changeActor(array('id' => $user->id)); //log in as user $content = $POD->getContent(); $content->set('headline', 'this is the headline'); $content->set('type', 'this is the type'); $content->save(); $content2 = $POD->getContent(); $content2->set('headline', 'for friends'); $content2->set('type', 'Friends only'); $content2->set('privacy', 'friends_only'); $content2->save(); $content3 = $POD->getContent(); $content3->set('headline', 'Group members only!'); $content3->set('type', 'private'); $content3->save(); $group = $POD->getGroup(); $group->set('groupname', 'Music Learning Club Austin'); $group->set('description', 'A club where Austin people learn music.'); $group->save(); $group->addContent($content); $group->addContent($content2); $group->addContent($content3); $content3->set('privacy', 'group_only'); $content3->save(); $get_contents = $group->content(); $this->assertEqual($get_contents->count(), 3); //$user should have access to all three contents $user2 = $POD->getPerson(); $user2->email = '*****@*****.**'; //create user $user2->password = '******'; $user2->set('nick', 'test2'); $user2->save(); $POD->changeActor(array('id' => $user2->id)); $group->POD->changeActor(array('id' => $user2->id)); // $user2->addFriend($user); //at this point $user is in $user2's friendlist, but not in the group $get_contents = $group->content()->fill(); $this->assertEqual($get_contents->count(), 1); while ($check = $get_contents->getNext()) { $this->assertNotEqual($check->get('headline'), 'Group members only!'); $this->assertNotEqual($check->get('headline'), 'for friends'); } $POD->changeActor(array('id' => $user->id)); $group->delete(); $user->delete(); $POD->changeActor(array('id' => $user2->id)); $user2->delete(); }