<?php /** * This file is part of the OpenPNE package. * (c) OpenPNE Project (http://www.openpne.jp/) * * For the full copyright and license information, please view the LICENSE * file and the NOTICE file that were distributed with this source code. */ include dirname(__FILE__) . '/../../bootstrap/functional.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; include dirname(__FILE__) . '/../../bootstrap/util.php'; setBlogUrl(1, FEED_URL); setBlogUrl(2, FEED_URL); setBlogUrl(3, FEED_URL); addFriend(1, 2); addFriend(1, 3); addFriend(3, 1, true); Doctrine::getTable('BlogRssCache')->updateByMemberId(1); Doctrine::getTable('BlogRssCache')->updateByMemberId(2); Doctrine::getTable('BlogRssCache')->updateByMemberId(3); $test = new opTestFunctional(new sfBrowser()); $test->login('*****@*****.**', 'password'); $test->setCulture('en'); $test->get('/blog')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'index')->end()->with('response')->begin()->checkElement('h3', 'Newest blog')->end()->get('/blog/user')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'user')->end()->with('response')->begin()->checkElement('h3', 'Newest blog of OpenPNE1')->end()->get('/blog/user/2')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'user')->end()->with('response')->begin()->checkElement('h3', 'Newest blog of OpenPNE2')->end()->get('/blog/user/3')->with('response')->begin()->checkElement('h3', NULL)->end()->get('/blog/friend')->with('request')->begin()->isParameter('module', 'blog')->isParameter('action', 'friend')->end()->with('response')->begin()->checkElement('h3', 'Friends Newest blog')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $test = new opTestFunctional(new sfBrowser()); $test->setMobile(); include dirname(__FILE__) . '/../../bootstrap/database.php'; $test->login('*****@*****.**', 'password'); $test->setCulture('en'); $test->get('/diary/1')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'show')->isParameter('id', 1)->end()->with('response')->begin()->isStatusCode(200)->end();
$t->test()->is($data['status'], 'success', 'should return status code "success"'); $t->test()->is($data['data']['id'], $id, 'should have the same 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('only my friends should be able to view my diary entry for friends'); $title = '友人のみに公開するテストタイトル'; $body = '友人のみに公開するテスト本文'; $publicFlag = PluginDiaryTable::PUBLIC_FLAG_FRIEND; //友人のみに公開 $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body, 'public_flag' => $publicFlag))->getResponse()->getContent(); $postedData = json_decode($json, true); $t->login($myFriendMailAddress, 'password'); $json = $t->get('/diary/search.json', array('apiKey' => 'dummyApiKey', 'id' => $postedData['id']))->getResponse()->getContent(); $data = json_decode($json, true); $t->test()->is($postedData['id'], $data['data'], 'my friends can read my entries limited tothem.'); $t->login($notMyFriendMailAddress, 'password'); $json = $t->get('/diary/search.json', array('apiKey' => 'dummyApiKey', 'id' => $postedData['id']))->with('response')->begin()->isStatusCode(400)->end(); $t->info('only myself should be able to view my private diary entry'); $title = '秘密のテストタイトル'; $body = '秘密のテスト本文'; $publicFlag = PluginDiaryTable::PUBLIC_FLAG_PRIVATE; $json = $t->post('/diary/post.json', array('apiKey' => 'dummyApiKey', 'title' => $title, 'body' => $body, 'public_flag' => $publicFlag))->getResponse()->getContent(); $t->login($myFriendMailAddress, 'password'); $json = $t->get('/diary/search.json', array('apiKey' => 'dummyApiKey', 'id' => $postedData['id']))->with('response')->begin()->isStatusCode(400)->end(); $t->login($notMyFriendMailAddress, 'password'); $json = $t->get('/diary/search.json', array('apiKey' => 'dummyApiKey', 'id' => $postedData['id']))->with('response')->begin()->isStatusCode(400)->end(); $t->info('存在しない日記の編集'); $json = $t->post('/diary/post.json', array('id' => '0', 'apiKey' => 'dummyApiKey', 'title' => '日記タイトル', 'body' => '日記本文', 'public_flag' => 'PluginDiaryTable::PUBLIC_FLAG_FRIEND'))->with('response')->begin()->isStatusCode(400)->end();
<?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();
<?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'; $test = new opTestFunctional(new sfBrowser()); include dirname(__FILE__) . '/../../bootstrap/database.php'; $test->login('*****@*****.**', 'password'); $test->setCulture('en'); $test->get('/diary')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'index')->end()->with('response')->begin()->checkElement('h3', 'Recently Posted Diaries')->end(); $countPublicSNS = Doctrine::getTable('Diary')->createQuery()->andWhereIn('public_flag', array(DiaryTable::PUBLIC_FLAG_OPEN, DiaryTable::PUBLIC_FLAG_SNS))->count(); $test->info('Pager Test: diary/list')->get('/diary/list')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of ' . $countPublicSNS)->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 40 of ' . $countPublicSNS)->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', true)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'list')->isParameter('page', 1)->end(); $test->info('Pager Test: diary/listFriend')->get('/diary/listFriend')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 21')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 21 of 21')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listFriend')->isParameter('page', 1)->end(); $test->info('Pager Test: diary/listMember')->get('/diary/listMember/3')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 20')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', false)->end()->get('/diary/listMember/4')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 31')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 31 of 31')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('page', 1)->end()->get('/diary/listMember/4/2009/4')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 26')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 26 of 26')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('page', 1)->end()->get('/diary/listMember/4/2009/4/1')->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '1 - 20 of 21')->checkElement('.pagerRelative .prev', false)->checkElement('.pagerRelative .next', true)->end()->click('Next')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 2)->end()->with('response')->begin()->checkElement('.pagerRelative', 2)->checkElement('.pagerRelative .number', '21 - 21 of 21')->checkElement('.pagerRelative .prev', true)->checkElement('.pagerRelative .next', false)->end()->click('Previous')->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 1)->end()->click('Next', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 2)->end()->click('Previous', array(), array('position' => 2))->with('request')->begin()->isParameter('module', 'diary')->isParameter('action', 'listMember')->isParameter('id', 4)->isParameter('year', 2009)->isParameter('month', 4)->isParameter('day', 1)->isParameter('page', 1)->end()->get('/diary/listMember/4/2009/6')->with('response')->begin()->checkElement('.pagerRelative', false)->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 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 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 $_app = 'pc_backend'; include dirname(__FILE__) . '/../../bootstrap/functional.php'; include dirname(__FILE__) . '/../../bootstrap/database.php'; $browser = new opTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color())); $browser->info('Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302); $browser->get('/opSkinThemePlugin')->isStatusCode(200);
<?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('/skinpreview/index/theme_name/autumn'); $browser->get('/skinpreview/index/theme_name/'); $browser->get('/skinpreview/index/theme_name'); $browser->get('/skinpreview/index'); $browser->get('/skinpreview');