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'); $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body, 'public_flag' => ''))->with('response')->begin()->isStatusCode('400')->end(); $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body))->with('response')->begin()->isStatusCode('400')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color())); $browser->info('0. Login')->get('/member/login')->click('ログイン', array('authMailAddress' => array('mail_address' => '*****@*****.**', 'password' => 'password')))->isStatusCode(302)->info('1. Community list is shown on the member\'s home.')->get('member/home'); $selector = new sfDomCssSelector($browser->getResponseDom()); $list = $selector->matchAll('#Left h3:contains("コミュニティリスト")')->getNodes(); $browser->test()->ok($list, 'a community list gadget exists'); $photoLink = ''; $textLink = ''; $xpath = new DOMXPath($browser->getResponseDom()); foreach ($xpath->query('../../table/tr', $list[0]) as $item) { if ($item->getAttribute('class') === 'photo') { $photoLink = $item->firstChild->getElementsByTagName('a')->item(0)->getAttribute('href'); } elseif ($item->getAttribute('class') === 'text') { $textLink = $item->firstChild->getElementsByTagName('a')->item(0)->getAttribute('href'); } } $browser->test()->ok($photoLink, 'photo link exists'); $browser->test()->ok($textLink, 'text link exists'); $browser->info('links in a community list is a valid (ref. #3546)')->info('photo link is a valid')->get($photoLink)->isStatusCode(200)->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end()->info('text link is a valid')->get($textLink)->isStatusCode(200)->with('request')->begin()->isParameter('module', 'community')->isParameter('action', 'home')->end();
<?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 = '*****@*****.**'; $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();
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"'); $t->test()->is($deleteId, $data['data']['id'], 'should have the same id posted');
<?php $executeLoader = false; include dirname(__FILE__) . '/../../bootstrap/functional.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; $numOfTests = 15; $tester = new opTestFunctional(new opBrowser(), new lime_test($numOfTests, new lime_output_color())); $t = $tester->test(); Doctrine_Core::getTable('SnsConfig')->set('enable_jsonapi', true); $apiKeyMember1 = Doctrine_Core::getTable('Member')->find(1)->getApiKey(); if (in_array('opTimelinePlugin', ProjectConfiguration::getActive()->getPlugins())) { // opTimelinePlugin breaks standard JSON APIs (activity/*.json) $tester->test()->fail('unable to run tests if opTimelinePlugin is installed'); return; } $tester->info('/activity/post.json - single image upload')->postWithFiles('/activity/post.json', array('apiKey' => $apiKeyMember1, 'body' => 'hogehoge'), array('images[0]' => dirname(__FILE__) . '/uploads/dot.gif'))->with('response')->isStatusCode(200); $response = json_decode($tester->getResponse()->getContent(), true); $t->is($response['status'], 'success'); $activityImage = Doctrine_Core::getTable('ActivityImage')->findByActivityDataId($response['data']['id']); $t->is(count($activityImage), 1); $t->is(count($response['data']['image_uris']), 1); $t->is($response['data']['image_uris'][0]['small_size'], 'http://localhost/cache/img/gif/w48_h48/' . $activityImage[0]->File->name . '.gif'); $t->is($response['data']['image_uris'][0]['full_size'], 'http://localhost/cache/img/gif/w_h/' . $activityImage[0]->File->name . '.gif'); $tester->info('/activity/post.json - invalid image')->postWithFiles('/activity/post.json', array('apiKey' => $apiKeyMember1, 'body' => 'hogehoge'), array('images[0]' => dirname(__FILE__) . '/uploads/plaintext.txt'))->with('response')->isStatusCode(400); $tester->info('/activity/post.json - multiple image upload')->postWithFiles('/activity/post.json', array('apiKey' => $apiKeyMember1, 'body' => 'hogehoge'), array('images[0]' => dirname(__FILE__) . '/uploads/dot.gif', 'images[1]' => dirname(__FILE__) . '/uploads/white.jpg'))->with('response')->isStatusCode(200); $response = json_decode($tester->getResponse()->getContent(), true); $t->is($response['status'], 'success'); $activityImage = Doctrine_Core::getTable('ActivityImage')->findByActivityDataId($response['data']['id']); $t->is(count($activityImage), 2); $t->is(count($response['data']['image_uris']), 2); $t->is($response['data']['image_uris'][0]['small_size'], 'http://localhost/cache/img/gif/w48_h48/' . $activityImage[0]->File->name . '.gif');
<?php $executeLoader = false; $app = 'api'; include dirname(__FILE__) . '/../../bootstrap/functional.php'; $task = new sfDoctrineBuildTask($configuration->getEventDispatcher(), new sfFormatter()); $task->setConfiguration($configuration); $task->run(array(), array('no-confirmation' => true, 'db' => true, 'and-load' => dirname(__FILE__) . '/fixtures/member_search.yml', 'application' => $app, 'env' => 'test')); $browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color())); Doctrine::getTable('SnsConfig')->set('enable_jsonapi', true); $key = Doctrine::getTable('Member')->find(1)->getApiKey(); $browser->get('member/search.json', array('apiKey' => $key, 'target' => 'friend', 'target_id' => 1))->with('request')->begin()->isParameter('module', 'member')->isParameter('action', 'search')->end()->with('response')->isStatusCode(200); $json = $browser->getResponse()->getContent(); $data = json_decode($json, true); $t = $browser->test(); $t->is($data['status'], 'success', 'status is "success".'); $t->is(count($data['data']), 1, 'returned member count is 1(NOT including blocking_member and prefriend_member).'); $t->is($data['data'][0]['name'], 'Already-friend', 'only including friend member');
<?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 return entries'); $json = $t->get('/diary/search.json', array('apiKey' => 'dummyApiKey', 'format' => 'mini'))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is(count($data['data']), 15, 'should return 15 articles'); $t->test()->is($data['next'], 2, 'should return next page number 2 '); $t->info('should return next page entries'); $json = $t->get('/diary/search.json', array('apiKey' => 'dummyApiKey', 'format' => 'mini', 'page' => 2))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is(count($data['data']), 15, 'should return 15 articles'); $t->test()->is($data['next'], 3, 'should return next page number 3 '); $t->info('fetch one diary entry'); $diary = Doctrine::getTable('Diary')->findOneById('1'); $images = $diary->getDiaryImages(); $comments = $diary->getDiaryComments(); $prev = $diary->getPrevious($diary->getMemberId()); $next = $diary->getNext($diary->getMemberId()); $json = $t->get('/diary/search.json', array('apiKey' => 'dummyApiKey', 'id' => 1))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is($data['data']['id'], 1, 'should return id 1'); $t->test()->is(count($data['data']['images']), count($images), 'should have ' . count($images) . ' images');
<?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 return events'); $json = $t->get('event/search.json', array('apiKey' => 'dummyApiKey', 'target' => 'community', 'target_id' => 1, 'format' => 'mini'))->with('response')->begin()->isstatuscode('200')->end()->getresponse()->getcontent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is(count($data['data']), 15, 'should return 15 events'); $t->test()->ok($data['data'][0], 'event 0 should have latest comment '); $t->test()->is($data['data'][0]['latest_comment'], 'こんにちは', 'latest comment of event 0 should have body "こんにちは"'); $t->info('should be able to limit numbers of event by a parameter "count"'); $json = $t->get('event/search.json', array('apiKey' => 'dummyApiKey', 'format' => 'mini', 'target' => 'community', 'target_id' => 1, 'count' => 5))->with('response')->begin()->isstatuscode('200')->end()->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 return 5 events'); $t->info('should return events with parameters, max_id and since_id'); $json = $t->get('event/search.json', array('apiKey' => 'dummyApiKey', 'format' => 'mini', 'target' => 'community', 'target_id' => 1, 'max_id' => 4, 'since_id' => 1))->with('response')->begin()->isstatuscode('200')->end()->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 events'); $t->test()->is($data['data'][0]['id'], '3', 'data 0 should have event 3 '); $t->test()->is($data['data'][1]['id'], '4', 'data 1 should have event 4 '); $t->info('should return a event'); $json = $t->get('event/search.json', array('apiKey' => 'dummyApiKey', 'target' => 'event', 'target_id' => 1))->with('response')->begin()->isstatuscode('200')->end()->getresponse()->getcontent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is($data['data'][0]['id'], '1', 'should return id 1'); $t->test()->is($data['data'][0]['community_id'], '1', 'should return community id 1'); $t->test()->is($data['data'][0]['name'], '_aイベ主', 'should return name _aトピ主');
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $t->info('should return topics'); $json = $t->get('topic/search.json', array('apiKey' => 'dummyApiKey', 'target' => 'community', 'target_id' => 1, 'format' => 'mini'))->with('response')->begin()->isStatusCode('200')->end()->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is(count($data['data']), 15, 'should return 15 topics'); $t->test()->ok($data['data'][1], 'topic 1 should have latest comment '); $t->test()->is($data['data'][1]['latest_comment'], 'トピック a 10', 'latest comment of topic 1 should have body "トピック a 10"'); $t->info('should be able to limit numbers of topic by a parameter "count"'); $json = $t->get('topic/search.json', array('apiKey' => 'dummyApiKey', 'format' => 'mini', 'target' => 'community', 'target_id' => 1, 'count' => 5))->with('response')->begin()->isStatusCode('200')->end()->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 return 5 topics'); $t->info('should return topics with parameters, max_id and since_id'); $json = $t->get('topic/search.json', array('apiKey' => 'dummyApiKey', 'format' => 'mini', 'target' => 'community', 'target_id' => 1, 'max_id' => 3, 'since_id' => 1))->with('response')->begin()->isStatusCode('200')->end()->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'], '3', 'data 0 should have topic 3 '); $t->test()->is($data['data'][1]['id'], '2', 'data 2 should have topic 2 '); $t->info('should return a topic'); $json = $t->get('topic/search.json', array('apiKey' => 'dummyApiKey', 'target' => 'topic', 'target_id' => 1))->with('response')->begin()->isStatusCode('200')->end()->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is($data['data'][0]['id'], '1', 'should return id 1'); $t->test()->is($data['data'][0]['community_id'], '1', 'should return community id 1'); $t->test()->is($data['data'][0]['name'], '_aトピ主', 'should return name _aトピ主');
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $t = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $t->info('should be able to delete his or her own 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); $postedCommentId = $data['data']['id']; $json = $t->post('/topic_comment/delete.json', array('apiKey' => 'dummyApiKey', 'id' => $postedCommentId))->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 the same id deleted'); $t->test()->ok($data['data']['member'], 'should have a member info'); $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'); $t->info('topic owners should be able to delete comments on his or her own topics'); $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']; $body = '他メンバーのコメント本文'; $json = $t->post('/topic_comment/post.json', array('apiKey' => 'dummyApiKey2', 'community_topic_id' => $postedTopicId, 'body' => $body))->getResponse()->getContent(); $data = json_decode($json, true); $postedCommentId = $data['data']['id']; $json = $t->post('/topic_comment/delete.json', array('apiKey' => 'dummyApiKey', 'id' => $postedCommentId))->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 the same id deleted');
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new opTestFunctional(new sfBrowser(), new lime_test(null, new lime_output_color())); include dirname(__FILE__) . '/../../bootstrap/database.php'; $browser->login('*****@*****.**', 'password'); $browser->setCulture('en'); $browser->get('/')->with('user')->isAuthenticated(); $gadget = Doctrine::getTable('Gadget')->findOneByName('timelineAll'); $html = get_component('timeline', 'timelineAll', array('gadget' => $gadget)); $browser->test()->ok(false !== strpos($html, '\'count\': \'5\''));