<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $topicId = 1; $comments = Doctrine::getTable('CommunityTopicComment')->createQuery('q')->where('community_topic_id = ?', $topicId)->execute(); $t->info('should fetch a list of comments '); $json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey', 'community_topic_id' => $topicId))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is(count($data['data']), count($comments), 'should have ' . count($comments) . ' comments'); $t->test()->ok(count($data['data'][0]['deletable']), 'should have deletable property'); $t->info('should be able to limit the number of comment'); $json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey', 'community_topic_id' => $topicId, 'count' => 5))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is(count($data['data']), 5, 'should have 5 comments'); $t->test()->ok(count($data['data'][0]['deletable']), 'should have deletable property'); $t->info('should return comments with parameters, max_id and since_id'); $json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey', 'community_topic_id' => $topicId, 'max_id' => 4, 'since_id' => 1))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is(count($data['data']), 2, 'should return 2 topics'); $t->test()->is($data['data'][0]['id'], '4', 'data 0 should have topic 4 '); $t->test()->is($data['data'][1]['id'], '2', 'data 2 should have topic 3 '); $t->info('non-members should not be able to fetch a list of comments '); $json = $t->post('/topic_comment/search.json', array('apiKey' => 'dummyApiKey4', 'community_topic_id' => $topicId))->with('response')->begin()->isStatusCode('400')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $mailAddress = '*****@*****.**'; $myFriendMailAddress = '*****@*****.**'; $notMyFriendMailAddress = 'sns5@example'; $t->login($mailAddress, 'password'); $t->setCulture('en'); $t->info('should be able to post a new diary entry'); $title = 'テストタイトル'; $body = 'テスト本文'; $publicFlag = PluginDiaryTable::PUBLIC_FLAG_SNS; //全員に公開 $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body, 'public_flag' => $publicFlag))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->ok($data['data']['id'], 'should have id'); $t->test()->ok($data['data']['member'], 'should have member info'); $t->test()->is($data['data']['title'], $title, 'should have the same title posted'); $t->test()->is($data['data']['body'], $body, 'should have the same body posted'); $t->test()->is($data['data']['public_flag'], $publicFlag, 'should have the same publid flag posted'); $t->test()->ok($data['data']['created_at'], 'should have the date posted'); $t->info('should return error when the title is empty'); $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => '', 'body' => $body, 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end(); $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'body' => $body, 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end(); $t->info('should return error when the body is empty'); $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => '', 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end(); $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'public_flag' => $publicFlag))->with('response')->begin()->isStatusCode('400')->end(); $t->info('should return error when the public flag is empty');
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $mailAddress = '*****@*****.**'; $t->login($mailAddress, 'password'); $t->setCulture('en'); $apiKey = '?apiKey=dummyApiKey'; $t->info('for the first thing, post a entry to delete afterwords'); $title = 'テストタイトル'; $body = 'テスト本文'; $publicFlag = 1; //全員に公開 $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body, 'public_flag' => $publicFlag))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->ok($data['data']['id'], 'should have id'); $t->test()->ok($data['data']['member'], 'should have member info'); $t->test()->is($data['data']['title'], $title, 'should have the same title posted'); $t->test()->is($data['data']['body'], $body, 'should have the same body posted'); $t->test()->is($data['data']['public_flag'], $publicFlag, 'should have the same publid flag posted'); $t->test()->ok($data['data']['created_at'], 'should have the date posted'); $deleteId = $data['data']['id']; $json = ''; $data = array(); $t->info('should be able to delete the entry'); $json = $t->post('/diary/delete.json', array('apiKey' => 'dummyApiKey', 'id' => $deleteId))->getResponse()->getContent(); $data = json_decode($json, true); var_dump($data, $json); $t->test()->is($data['status'], 'success', 'should return status code "success"');
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $mailAddress = '*****@*****.**'; $t->login($mailAddress, 'password'); $t->setCulture('en'); $t->info('should be able to post a new comment'); $diary = Doctrine::getTable('Diary')->findOneByMemberId(1); $body = 'コメントテスト本文'; $json = $t->post('/diary_comment/post.json', array('apiKey' => 'dummyApiKey', 'diary_id' => $diary->getId(), 'body' => $body))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->ok($data['data']['id'], 'should have id'); $t->test()->ok($data['data']['member'], 'should have member info'); $t->test()->is($data['data']['diary_id'], $diary->getId(), 'should have the same diary_id posted'); $t->test()->is($data['data']['body'], $body, 'should have the same body posted'); $t->test()->ok($data['data']['created_at'], 'should have the date posted'); $t->test()->is($data['data']['images'], array(), 'should have the images field which is an empty array'); $t->info('should NOT be able to post a new comment without body'); $diary = Doctrine::getTable('Diary')->findOneByMemberId(1); $body = ''; $json = $t->post('/diary_comment/post.json', array('apiKey' => 'dummyApiKey', 'diary_id' => $diary->getId(), 'body' => $body))->with('response')->begin()->isStatusCode(400)->end(); $json = $t->post('/diary_comment/post.json', array('apiKey' => 'dummyApiKey', 'diary_id' => $diary->getId()))->with('response')->begin()->isStatusCode(400)->end(); $t->info('存在しない日記にコメント'); $json = $t->post('/diary_comment/post.json', array('apiKey' => 'dummyApiKey', 'diary_id' => 0, 'body' => 'コメント本文'))->with('response')->begin()->isStatusCode('400')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $t->info('should be able to post a new topic'); $name = 'テストタイトル'; $body = 'テスト本文'; $json = $t->post('/topic/post.json', array('apiKey' => 'dummyApiKey', 'community_id' => 1, 'name' => $name, 'body' => $body))->getResponse()->getContent(); $data = json_decode($json, true); $postedTopicId = $data['data']['id']; $t->info('others should NOT be able to delete other\'s topic'); $json = $t->post('/topic/delete.json', array('apiKey' => 'dummyApiKey2', 'id' => $postedTopicId))->with('response')->begin()->isStatusCode('400')->end(); $t->info('the author should be able to delete his or her own topic'); $json = $t->post('/topic/delete.json', array('apiKey' => 'dummyApiKey', 'id' => $postedTopicId))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is($data['data']['id'], $postedTopicId, 'should have the samme id'); $t->test()->ok($data['data']['community_id'], 'should have a community id'); $t->test()->ok($data['data']['member'], 'should have a member info'); $t->test()->is($data['data']['name'], $name, 'should have the same name deleted'); $t->test()->is($data['data']['body'], $body, 'should have the same body deleted'); $t->test()->ok($data['data']['created_at'], 'should have the date deleted');
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $mailAddress = '*****@*****.**'; $t->login($mailAddress, 'password'); $t->setCulture('en'); $t->info('should be able to delete a comment'); $comment = Doctrine::getTable('DiaryComment')->findOneByMemberId(1); $body = 'コメントテスト本文'; $json = $t->post('/diary_comment/delete.json', array('apiKey' => 'dummyApiKey', 'id' => $comment->getId()))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->ok($data['data']['id'], 'should have id'); $t->info('should NOT be able to delete a comment of other\'s on other\'s diary'); $diary = Doctrine::getTable('Diary')->findOneByMemberId(5); $comment = new DiaryComment(); $comment->setMemberId(5); $comment->setDiaryId($diary->getId()); $comment->setBody('not to be deleted'); $comment->save(); $json = $t->post('/diary_comment/delete.json', array('apiKey' => 'dummyApiKey', 'id' => $comment->getId()))->with('response')->begin()->isStatusCode(400)->end(); $t->info('存在しないコメントの削除'); $json = $t->post('/diary_comment/delete.json', array('apiKey' => 'dummyApiKey', 'id' => '0'))->with('response')->begin()->isStatusCode('400')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $t->info('should be able to post a new comment'); $body = 'コメント本文'; $json = $t->post('/topic_comment/post.json', array('apiKey' => 'dummyApiKey', 'community_topic_id' => 1, 'body' => $body))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->ok($data['data']['id'], 'should have an id'); $t->test()->ok($data['data']['member'], 'should have a member info'); $t->test()->is($data['data']['body'], $body, 'should have the same body posted'); $t->test()->ok($data['data']['created_at'], 'should have the date posted'); $t->info('non-members should NOT be able to post a new comment on communities with public_flag "auth_commu_member"'); $body = 'コメント本文'; $json = $t->post('/topic_comment/post.json', array('apiKey' => 'dummyApiKey4', 'community_topic_id' => 1, 'body' => $body))->with('response')->begin()->isStatusCode('400')->end(); $t->info('non-members should NOT be able to post a new comment on communities with public_flag "public"'); $body = 'コメント本文'; $json = $t->post('/topic_comment/post.json', array('apiKey' => 'dummyApiKey4', 'community_topic_id' => 32, 'body' => $body))->with('response')->begin()->isStatusCode('400')->end();