本文整理汇总了PHP中sfTestFunctional::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP sfTestFunctional::getContext方法的具体用法?PHP sfTestFunctional::getContext怎么用?PHP sfTestFunctional::getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfTestFunctional
的用法示例。
在下文中一共展示了sfTestFunctional::getContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateUrl
/**
* Generate URL from route name
*
* Example:
* $this->generateUrl('homepage');
* -> "/"
* $this->generateUrl('article_edit', $articleObject);
* -> "/article/1/edit"
* $this->generateUrl('custom_route', $arrRouteParams);
*
* @see sfPatternRouting::generate()
*
* @param string $name - Route name from routing.yml
* @param array|Model $params - Routing params
* @param bool $absolute - Make absolute url
* @return string
*/
protected function generateUrl($name, $params = array(), $absolute = false)
{
return $this->browser->getContext()->getRouting()->generate($name, $params, $absolute);
}
示例2: dirname
<?php
$app = 'frontend';
include dirname(__FILE__) . '/../bootstrap/functional.php';
new sfDatabaseManager($configuration);
$task = new sfDoctrineBuildTask($configuration->getEventDispatcher(), new sfFormatter());
$task->run(array(), array('sql', 'db', 'and-load', 'no-confirmation', 'application' => $app));
$conn = Doctrine::getConnectionByTableName('Author');
$conn->beginTransaction();
$browser = new sfTestFunctional(new sfBrowser());
$browser->test()->info('Updating first author');
$firstAuthor = Doctrine::getTable('Author')->findOneBySlug('niko');
$browser->get('/author/' . $firstAuthor->slug . '/view')->with('response')->begin()->checkElement('h1', '/niko/')->checkElement('ul#comments li', 1)->end()->with('view_cache')->begin()->isCached(true, false)->end();
$browser->getContext(true)->switchTo('backend');
$firstAuthor->name = 'n1k0';
$firstAuthor->save($conn);
$browser->get('/author/' . $firstAuthor->slug . '/view')->with('response')->begin()->checkElement('h1', '/n1k0/')->checkElement('ul#comments li', 1)->end()->with('view_cache')->begin()->isCached(true, false)->end();
$conn->rollback();
示例3: dirname
<?php
// test the process of viewing and saving editable areas
require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$browser = new sfTestFunctional(new sfBrowser());
$browser->setTester('doctrine', 'sfTesterDoctrine');
Doctrine_Query::create()->from('Blog')->delete()->execute();
$blog = new Blog();
$blog->title = '';
$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');