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


PHP sfTestFunctional::getResponse方法代码示例

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


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

示例1: sfTestFunctional

<?php

include sfConfig::get('sf_test_dir') . '/bootstrap/functional.php';
$browser = new sfTestFunctional(new sfBrowser());
$config = sfConfig::get('app_cacophony');
$browser->info('Twitter Connect')->get('/oauth/connect/twitter')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'connect')->isParameter('provider', 'twitter')->end()->with('response')->begin()->isStatusCode(302)->end();
$response = $browser->getResponse();
$browser->test()->like($response->getHttpHeader('Location'), '@' . $config['providers']['twitter']['authorize_url'] . '@', 'Connect redirects to correct URL');
//$browser->info(parse_url($response->getHttpHeader('Location'), PHP_URL_QUERY));
$browser->info('Twitter Callback')->get('/oauth/callback/twitter?oauth_token=1234&oauth_verifier=5678')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'callback')->isParameter('provider', 'twitter')->isParameter('oauth_token', '1234')->isParameter('oauth_verifier', '5678')->end()->with('response')->begin()->isStatusCode(302)->end()->with('user')->begin()->isFlash('error', 'Failed to retrieve access token: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)')->end();
$browser->info('Vimeo Connect')->get('/oauth/connect/vimeo')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'connect')->isParameter('provider', 'vimeo')->end()->with('response')->begin()->isStatusCode(302)->end();
$response = $browser->getResponse();
$browser->test()->like($response->getHttpHeader('Location'), '@' . $config['providers']['vimeo']['authorize_url'] . '@', 'Connect redirects to correct URL');
//$browser->info(parse_url($response->getHttpHeader('Location'), PHP_URL_QUERY));
$browser->info('Vimeo Callback')->get('/oauth/callback/vimeo?oauth_token=1234&oauth_verifier=5678')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'callback')->isParameter('provider', 'vimeo')->isParameter('oauth_token', '1234')->isParameter('oauth_verifier', '5678')->end()->with('response')->begin()->isStatusCode(302)->end()->with('user')->begin()->isFlash('error', 'Failed to retrieve access token: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)')->end();
$browser->info('Facebook Connect')->get('/oauth/connect/facebook')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'connect')->isParameter('provider', 'facebook')->end()->with('response')->begin()->isStatusCode(302)->end();
$response = $browser->getResponse();
$browser->test()->like($response->getHttpHeader('Location'), '@' . $config['providers']['facebook']['authorize_url'] . '@', 'Connect redirects to correct URL');
//$browser->info(parse_url($response->getHttpHeader('Location'), PHP_URL_QUERY));
parse_str(parse_url(urldecode($response->getHttpHeader('Location')), PHP_URL_QUERY), $query_string);
$browser->info('Facebook Callback')->get(sprintf('/oauth/callback/facebook?code=1234&state=%s', $query_string['state']))->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'callback')->isParameter('provider', 'facebook')->isParameter('code', '1234')->isParameter('state', $query_string['state'])->end()->with('response')->begin()->isStatusCode(302)->end()->with('user')->begin()->isFlash('error', 'Failed to retrieve access token: ')->end();
开发者ID:nixilla,项目名称:sfCacophonyPlugin,代码行数:21,代码来源:sfCacophonyConsumerActionsTest.php

示例2:

$browser->info('1 - Surf to a url with a complex menu and check several things.')->get('/big-menu');
$pretty = '<ul class="root">
  <li class="first">
    <a href="' . url_for('@homepage', true) . '">Parent 1</a>
    <ul class="menu_level_1">
      <li class="first">
        <a href="' . url_for('/parent1/ch1', true) . '?test=1">Child 1</a>
      </li>
      <li class="last">
        <a href="' . url_for('/parent1/ch2') . '">Child 2</a>
      </li>
    </ul>
  </li>
  <li class="current_ancestor last">
    Parent 2
    <ul class="menu_level_1">
      <li class="current first last">
        <a href="' . url_for('@test_menu') . '">Child 4</a>
        <ul class="menu_level_2">
          <li class="first last">
            Grandchild 1
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>
';
$browser->info("Rendered Menu: \n" . $pretty);
$browser->test()->is($browser->getResponse()->getContent(), $pretty, 'The full rendered menu is correct with the uncompressed spacing.');
开发者ID:vicb,项目名称:ioMenuPlugin,代码行数:30,代码来源:MenuTest.php

示例3: dirname

<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new sfTestFunctional(new sfBrowser());
$browser->get('es/politicos')->with('request')->begin()->isParameter('module', 'politico')->isParameter('action', 'ranking')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '/Ranking de pol/')->end();
$browser->get('es/politicos/PSOE')->with('request')->begin()->isParameter('module', 'politico')->isParameter('action', 'ranking')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '/Ranking de pol/')->checkElement('body', '/Todas las instituciones/')->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ticos, PSOE/');
$browser->get('es/politicos/all/Congreso')->with('request')->begin()->isParameter('module', 'politico')->isParameter('action', 'ranking')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '/Ranking de pol/')->end();
$browser->test()->like($browser->getResponse()->getContent(), '/<a class="flechita" href="\\/(.*)es\\/politicos\\/all\\/Congreso">Congreso<\\/a>/');
$browser->get('es/politicos/PSOE/Congreso')->with('request')->begin()->isParameter('module', 'politico')->isParameter('action', 'ranking')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '/Ranking de pol/')->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ticos, Congreso, PSOE/');
$browser->test()->like($browser->getResponse()->getContent(), '/<a class="flechita" href="\\/(.*)es\\/politicos\\/PSOE\\/Congreso">Congreso<\\/a>/');
$browser->get('es/politico/Campos-Arteseros')->with('request')->begin()->isParameter('module', 'politico')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '/Campos Arteseros/')->end();
开发者ID:voota,项目名称:voota,代码行数:13,代码来源:politicoActionsTest.php

示例4: BlogForm

$blog->body = 'Lorem ipsum';
$blog->save();
$browser->info('1 - Visit page, but not logged in')->info('  1.1 - Start by being logged out.')->get('/blog')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'blog')->end()->with('response')->begin()->info('  1.2 - The title should be empty - we are not logged in, so no default text for the empty title field.')->checkElement('.test_title h1', '')->info('  1.3 - The title tag should not have the editable class, or any extra markup')->checkElement('.test_title h1[class="test_editable_class_name"]', false)->end();
$context = $browser->getContext(true);
$context->getUser()->setAuthenticated(true);
$context->getUser()->addCredential('test_credential');
$context->getUser()->shutdown();
$context->getStorage()->shutdown();
$browser->info('2 - Goto a page, now logged in with the correct credential')->get('/blog')->with('response')->begin()->isStatusCode(200)->info('  2.1 - The title has the configured placeholder text')->checkElement('.test_title h1', '[Test edit]')->info('  2.2 - Check for the markup for the editor - should be present now')->checkElement('.test_title h1.test_editable_class_name', 1)->checkElement('.test_body div div:last', 'Lorem ipsum')->end();
$blog->title = 'test blog';
$blog->save();
$form = new BlogForm($blog);
$form->useFields(array('title'));
$browser->info('3 - Display and submit a simple form')->get('/service/content/form?model=Blog&pk=2&fields[]=title')->with('request')->begin()->isParameter('module', 'ioEditableContent')->isParameter('action', 'form')->end()->with('response')->begin()->isStatusCode(200)->checkForm($form)->checkElement('input[type=hidden][name=model][value=Blog]', 1)->checkElement('input[type=hidden][name=pk][value=' . $blog->id . ']', 1)->checkElement('input[type=hidden][name=form][value="BlogForm"]', 1)->checkElement('input[type=hidden][name=form_partial][value=ioEditableContent/formFields]', 1)->checkElement('input[type=hidden][name=partial][value=]', 1)->checkElement('input[type=hidden][name="method"][value=]', 1)->checkElement('input[type=hidden][name="fields[]"][value=title]', 1)->end()->info('  3.1 - Submit with errors')->click('save', array('blog' => array('fake_field' => 'val')))->with('request')->begin()->isParameter('module', 'ioEditableContent')->isParameter('action', 'update')->end()->with('response')->begin()->isStatusCode(200)->end();
$browser->info('  3.2 - check the json response');
$response = $browser->getResponse()->getContent();
$json = json_decode($response);
$browser->test()->is($json->error, 'There were 1 errors when submitting the form.', 'The ->error key comes back correctly');
$browser->test()->like($json->response, '/id\\=\\"blog_title\\"/', 'The ->respones key contains the re-rendered form fields');
$browser->test()->like($json->response, '/Unexpected extra form field named \\"fake_field\\"/', '->respones contains the global errors');
$browser->get('/service/content/form?model=Blog&pk=2&fields[]=title')->info('  3.3 - Submit a valid form')->click('save', array('blog' => array('title' => 'new title')))->with('doctrine')->begin()->check('Blog', array('title' => 'new title'), 1)->end();
$browser->info('  3.4 - check the json response');
$response = $browser->getResponse()->getContent();
$json = json_decode($response);
$browser->test()->is($json->error, '', '->error is blank because the form submitted successfully');
$browser->test()->like($json->response, '/id\\=\\"blog_title\\"/', 'The ->respones key contains the re-rendered form fields');
$browser->info('  3.5 - Goto the show page for this content area')->get('/service/content/show?model=Blog&pk=2&fields%5B%5D=title')->with('request')->begin()->isParameter('module', 'ioEditableContent')->isParameter('action', 'show')->end()->with('response')->begin()->isStatusCode(200)->matches('/new title/')->end();
$form = new BlogBodyForm($blog);
$browser->info('4 - Display and submit a complex form')->get('/service/content/form?model=Blog&pk=2&form=BlogBodyForm&form_partial=test%2FbodyForm&partial=test%2Fbody&method=getTestValue')->with('request')->begin()->isParameter('module', 'ioEditableContent')->isParameter('action', 'form')->end()->with('response')->begin()->isStatusCode(200)->checkForm($form)->checkElement('input[type=hidden][name=model][value=Blog]', 1)->checkElement('input[type=hidden][name=pk][value=' . $blog->id . ']', 1)->checkElement('input[type=hidden][name=form][value="BlogBodyForm"]', 1)->checkElement('input[type=hidden][name=form_partial][value=test/bodyForm]', 1)->checkElement('input[type=hidden][name="method"][value=getTestValue]', 1)->checkElement('input[type=hidden][name=partial][value=test/body]', 1)->end()->info('  4.1 - Submit a valid form')->click('save', array('blog' => array('body' => 'new body')))->with('response')->begin()->isStatusCode('200')->end()->with('doctrine')->begin()->check('Blog', array('body' => 'new body'), 1)->end();
$browser->info('  4.2 - check the json response');
$response = $browser->getResponse()->getContent();
开发者ID:kimbrelas,项目名称:ioEditableContentPlugin,代码行数:31,代码来源:EditableContentTest.php

示例5: dirname

<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new sfTestFunctional(new sfBrowser());
$browser->get('/bugs/index')->with('request')->begin()->isParameter('module', 'bugs')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '!/This is a temporary page/')->end()->get('account/login')->end();
$browser->get('account/login')->setField('username', 'admin')->setField('password', 'admin')->click('login')->isRedirected()->followRedirect();
$browser->test()->like($browser->getResponse(), 'defualt/index');
开发者ID:rsanders16,项目名称:NexusPlus,代码行数:7,代码来源:bugsActionsTest.php

示例6: sfTestFunctional

$browser = new sfTestFunctional(new sfBrowser());
$email = rand() . '@example.com';
$password = rand();
$user = new QubitUser();
$user->email = $email;
$user->setPassword($password);
$user->save();
$relation = new QubitUserRoleRelation();
$relation->userId = $user->id;
$relation->roleId = QubitRole::ADMINISTRATOR_ID;
$relation->save();
$browser->post(';user/login', array('login' => array('email' => $email, 'password' => $password)));
$scopeAndContent = rand();
$identifier = rand();
$title = rand();
$informationObject = new QubitInformationObject();
$informationObject->parentId = QubitInformationObject::ROOT_ID;
$informationObject->scopeAndContent = $scopeAndContent;
$informationObject->identifier = $identifier;
$informationObject->title = $title;
$informationObject->save();
$browser->get('/' . $informationObject->id . ';dc?sf_format=xml');
$user->delete();
$informationObject->delete();
$doc = new DOMDocument();
$doc->loadXML($browser->getResponse()->getContent());
$xpath = new DOMXPath($doc);
$xpath->registerNamespace('dc', 'http://purl.org/dc/elements/1.1/');
$browser->test()->is($xpath->evaluate('string(/*/dc:description)', $doc->documentElement), $scopeAndContent, 'description');
$browser->test()->is($xpath->evaluate('string(/*/dc:identifier)', $doc->documentElement), $identifier, 'identifier');
$browser->test()->is($xpath->evaluate('string(/*/dc:title)', $doc->documentElement), $title, 'title');
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:31,代码来源:dcTest.php


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