本文整理汇总了PHP中sfTestBrowser::get方法的典型用法代码示例。如果您正苦于以下问题:PHP sfTestBrowser::get方法的具体用法?PHP sfTestBrowser::get怎么用?PHP sfTestBrowser::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfTestBrowser
的用法示例。
在下文中一共展示了sfTestBrowser::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_login_success
public function test_login_success()
{
$b = new sfTestBrowser();
$b->initialize();
$b->get('/')->click('Sign In', array('login' => 'isern', 'password' => 'testpassword'))->isRedirected()->followRedirect()->checkResponseElement('body', '/Researchers/');
$b->get('/organization/list')->checkResponseElement('body', '/Organizations/')->checkResponseElement('body', '/Name/');
$b->get('/collaboration/list')->checkResponseElement('body', '/Collaborations/')->checkResponseElement('body', '/Name/');
}
示例2: sfTestBrowser
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'backend';
$fixtures = 'fixtures/fixtures.yml';
if (!(include dirname(__FILE__) . '/../../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
$b->initialize();
// test action method inheritance
$b->get('/inheritance/list?filter=1')->checkResponseElement('table.sf_admin_list tfoot th', '/1 result/');
$b->get('/inheritance/list?sort=1')->checkResponseElement('table.sf_admin_list tbody tr.sf_admin_row_0 a', '/2/')->checkResponseElement('table.sf_admin_list tbody tr.sf_admin_row_1 a', '/1/');
示例3: dirname
<?php
include dirname(__FILE__) . '/../../bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->get('/podcast_feed/index')->isStatusCode(200)->isRequestParameter('module', 'podcast_feed')->isRequestParameter('action', 'index')->checkResponseElement('body', '!/This is a temporary page/');
示例4: sfTestBrowser
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'frontend';
$fixtures = 'fixtures/fixtures.yml';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
// file upload
$fileToUpload = dirname(__FILE__) . '/fixtures/config/databases.yml';
$uploadedFile = sfConfig::get('sf_cache_dir') . '/uploaded.yml';
$name = 'test';
$b->get('/attachment/index')->with('request')->begin()->isParameter('module', 'attachment')->isParameter('action', 'index')->end()->with('response')->isStatusCode(200)->click('submit', array('attachment' => array('name' => $name, 'file' => $fileToUpload)))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->matches('/ok/')->end();
$b->test()->ok(file_exists($uploadedFile), 'file is uploaded');
$b->test()->is(file_get_contents($uploadedFile), file_get_contents($fileToUpload), 'file is correctly uploaded');
$c = new Criteria();
$c->add(AttachmentPeer::NAME, $name);
$attachments = AttachmentPeer::doSelect($c);
$b->test()->is(count($attachments), 1, 'the attachment has been saved in the database');
$b->test()->is($attachments[0]->getFile(), 'uploaded.yml', 'the attachment filename has been saved in the database');
@unlink($uploadedFile);
AttachmentPeer::doDeleteAll();
$b->test()->ok(!file_exists($uploadedFile), 'uploaded file is deleted');
// file upload in embedded form
$b->getAndCheck('attachment', 'embedded')->with('response')->begin()->checkElement('input[name="article[attachment][article_id]"]', false)->checkElement('input[type="file"][name="article[attachment][file]"]')->end()->setField('article[title]', 'Test Article')->setField('article[attachment][name]', $name)->setField('article[attachment][file]', $fileToUpload)->click('submit')->with('form')->hasErrors(false)->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->matches('/ok/')->end();
$b->test()->ok(file_exists($uploadedFile), 'file is uploaded');
$b->test()->is(file_get_contents($uploadedFile), file_get_contents($fileToUpload), 'file is correctly uploaded');
$c = new Criteria();
示例5: sfTestBrowser
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'frontend';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
// default main page
$b->getAndCheck('default', 'index', '/')->with('response')->begin()->checkElement('body', '/congratulations/i')->checkElement('link[href="/sf/sf_default/css/screen.css"]')->checkElement('link[href="/css/main.css"]')->contains('<!--[if lte IE 6]><link rel="stylesheet" type="text/css" media="screen" href="/css/ie6.css" /><![endif]-->')->end();
// default 404
$b->get('/nonexistant')->isStatusCode(404);
/*
$b->
get('/nonexistant/')->
isStatusCode(404)
;
*/
// 404 with ETag enabled must returns 404, not 304
sfConfig::set('sf_cache', true);
sfConfig::set('sf_etag', true);
$b->get('/notfound')->isStatusCode(404)->isRequestParameter('module', 'notfound')->isRequestParameter('action', 'index')->checkResponseElement('body', '/404/')->get('/notfound')->isStatusCode(404)->isRequestParameter('module', 'notfound')->isRequestParameter('action', 'index')->checkResponseElement('body', '/404/');
sfConfig::set('sf_cache', false);
sfConfig::set('sf_etag', false);
// unexistant action
$b->get('/default/nonexistantaction')->isStatusCode(404);
// module.yml: enabled
示例6: dirname
<?php
include dirname(__FILE__) . '/../../bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
$browser->get('/##MODULE_NAME##/index')->isStatusCode(200)->isRequestParameter('module', '##MODULE_NAME##')->isRequestParameter('action', 'index')->checkResponseElement('body', '!/This is a temporary page/');
示例7: sfTestBrowser
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'frontend';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
$b->get('/autoload/myAutoload')->with('request')->begin()->isParameter('module', 'autoload')->isParameter('action', 'myAutoload')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body div', 'foo')->end();
$t = $b->test();
$t->ok(class_exists('BaseExtendMe'), 'plugin lib directory added to autoload');
$r = new ReflectionClass('ExtendMe');
$t->like(str_replace(DIRECTORY_SEPARATOR, '/', $r->getFilename()), '~fixtures/lib/ExtendMe~', 'plugin class can be replaced by project');
$t->ok(class_exists('NotInLib'), 'plugin autoload sets class paths');
$t->ok(!class_exists('ExcludedFromAutoload'), 'plugin autoload excludes directories');
示例8: isRedirected
'email' => '',
'referer' => 'http%3A%2F%2Fregistry%2F',
'commit' => 'sign+in' ))->
isRedirected()->
followRedirect();
}
//is the url an array?
if (!is_array($actionArray['url']))
{
$actionArray['url'] = array('valid' => $actionArray['url']);
}
if (isset($actionArray['roles'][$role][$key]))
{
//get the url
$browser->get($actionArray['url'][$key]);
//if it's forbidden
$forwardTo = $actionArray['roles'][$role][$key]['forwardTo'];
if (is_array($forwardTo))
{
//we should get forwarded to login
$browser->
isStatusCode(200)->
isForwardedTo($forwardTo[0], $forwardTo[1])->
isStatusCode(200)
;
echo "\n****** Forbidden OK -- " . $role . " :: " . $key . " Access :: " . $action . "\n";
}
else if (isset($selectors))
示例9: sfTestBrowser
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
$browser->
get('/concept/index')->
isStatusCode(200)->
isRequestParameter('module', 'concept')->
isRequestParameter('action', 'index')->
checkResponseElement('body', '!/This is a temporary page/')
;
示例10: dirname
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'backend';
$fixtures = 'fixtures';
require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$tests = array('/doctrine/route/test1' => '/Article/', '/doctrine/route/test2' => '/Article/', '/doctrine/route/test3' => '/Doctrine_Collection/', '/doctrine/route/test4' => '/Doctrine_Collection/', '/doctrine/route/test5/1/some_fake_value' => '/Article/', '/doctrine/route/test6/english-title/some_fake_value' => '/Article/', '/doctrine/route/test7/some_fake_value' => '/Doctrine_Collection/', '/doctrine/route/test9/1/english-title/English+Title/test' => '/Article/', '/doctrine/route/test10/1/test' => '/Doctrine_Collection/');
$b = new sfTestBrowser();
foreach ($tests as $url => $check) {
$b->get($url)->with('response')->begin()->isStatusCode('200')->matches($check)->end();
}
$article = Doctrine::getTable('Article')->find(1);
$routes = array('doctrine_route_test5' => array('url' => '/index.php/doctrine/route/test5/1/test-english-title', 'params' => $article), 'doctrine_route_test6' => array('url' => '/index.php/doctrine/route/test6/english-title/test-english-title', 'params' => $article), 'doctrine_route_test7' => array('url' => '/index.php/doctrine/route/test7/w00t', 'params' => array('testing_non_column' => 'w00t')), 'doctrine_route_test8' => array('url' => '/index.php/doctrine/route/test8/1/english-title/English+Title/test', 'params' => array('id' => $article->id, 'slug' => $article->slug, 'title' => $article->title, 'testing_non_column2' => 'test')));
foreach ($routes as $route => $check) {
$url = url_for2($route, $check['params']);
$b->test()->is($url, $check['url'], 'Check "' . $route . '" generates correct url');
}
示例11: sfTestBrowser
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'frontend';
$debug = false;
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
// default main page (without cache)
$b->get('/')->with('request')->begin()->isParameter('module', 'default')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '/congratulations/i')->end();
// default main page (with cache)
$b->get('/')->with('request')->begin()->isParameter('module', 'default')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '/congratulations/i')->end();
// 404
$b->get('/nonexistant')->with('request')->begin()->isForwardedTo('default', 'error404')->end()->with('response')->begin()->isStatusCode(404)->checkElement('body', '!/congratulations/i')->checkElement('link[href="/sf/sf_default/css/screen.css"]')->end();
$b->get('/nonexistant/')->with('request')->begin()->isForwardedTo('default', 'error404')->end()->with('response')->begin()->isStatusCode(404)->checkElement('body', '!/congratulations/i')->checkElement('link[href="/sf/sf_default/css/screen.css"]')->end();
// unexistant action
$b->get('/default/nonexistantaction')->with('request')->begin()->isForwardedTo('default', 'error404')->end()->with('response')->begin()->isStatusCode(404)->checkElement('body', '!/congratulations/i')->checkElement('link[href="/sf/sf_default/css/screen.css"]')->end();
示例12: sfTestBrowser
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'frontend';
if (!include(dirname(__FILE__).'/../bootstrap/functional.php'))
{
return;
}
$b = new sfTestBrowser();
$b->get('/escaping/on')
->with('request')->begin()
->isParameter('module', 'escaping')
->isParameter('action', 'on')
->end()
->with('response')->begin()
->isStatusCode(200)
->matches('#<h1>Lorem <strong>ipsum</strong> dolor sit amet.</h1>#')
->matches('#<h2>Lorem <strong>ipsum</strong> dolor sit amet.</h2>#')
->matches('#<h3>Lorem <strong>ipsum</strong> dolor sit amet.</h3>#')
->matches('#<h4>Lorem <strong>ipsum</strong> dolor sit amet.</h4>#')
->matches('#<h5>Lorem <strong>ipsum</strong> dolor sit amet.</h5>#')
->matches('#<h6>Lorem <strong>ipsum</strong> dolor sit amet.</h6>#')
->checkElement('span.no', 2)
示例13: sfTestBrowser
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'frontend';
if (!include(dirname(__FILE__).'/../bootstrap/functional.php'))
{
return;
}
$b = new sfTestBrowser();
$b->
get('/autoload/myAutoload')->
with('request')->begin()->
isParameter('module', 'autoload')->
isParameter('action', 'myAutoload')->
end()->
with('response')->begin()->
isStatusCode(200)->
checkElement('body div', 'foo')->
end()
;
$t = $b->test();
$autoload = sfAutoload::getInstance();
$t->ok(@file_get_contents($autoload->getClassPath('sfpropel'), FILE_USE_INCLUDE_PATH), '"sfAutoload" is case insensitive');
示例14: sfTestBrowser
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'crud';
$fixtures = 'fixtures/fixtures.yml';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
$b->initialize();
// check symfony throws an exception if model class does not exist
$b->get('/error')->isRequestParameter('module', 'error')->isRequestParameter('action', 'index')->throwsException('sfInitializationException', '/Unable to scaffold unexistant model/');
// list page
$b->get('/simple')->isStatusCode(200)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'index');
$content = $b->getResponse()->getContent();
$b->get('/simple/list')->isStatusCode(200)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'list')->checkResponseElement('body h1', 'simple')->checkResponseElement('body table thead tr th', '/^(Title|Body|Id|Category Id|Created at)$/')->checkResponseElement('body table tbody tr td', 'foo title', array('position' => 1))->checkResponseElement('body table tbody tr td', 'bar body', array('position' => 2))->checkResponseElement('body table tbody tr td', '1', array('position' => 3))->checkResponseElement('body table tbody tr td', '1', array('position' => 4))->checkResponseElement('a[href$="/simple/create"]', 'create')->checkResponseElement('a[href*="/simple/show/id/"]', '/\\d+/', array('count' => 2));
$b->test()->is($b->getResponse()->getContent(), $content, 'simple is an alias for simple/list');
// show page
$b->click('1')->isStatusCode(200)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'show')->isRequestParameter('id', 1)->checkResponseElement('a[href$="/simple/edit/id/1"]', 'edit')->checkResponseElement('a[href$="/simple/list"]', 'list')->checkResponseElement('body table tbody tr', '/Id\\:\\s+1/', array('position' => 0))->checkResponseElement('body table tbody tr', '/Title\\:\\s+foo title/', array('position' => 1))->checkResponseElement('body table tbody tr', '/Body\\:\\s+bar body/', array('position' => 2))->checkResponseElement('body table tbody tr', '/Online\\:\\s+1/', array('position' => 3))->checkResponseElement('body table tbody tr', '/Category\\:\\s+1/', array('position' => 4))->checkResponseElement('body table tbody tr', '/Created at\\:\\s+[0-9\\-\\:\\s]+/', array('position' => 5))->checkResponseElement('body table tbody tr', '/End date\\:\\s+[0-9\\-\\:\\s]+/', array('position' => 6))->checkResponseElement('body table tbody tr', '/Book\\:\\s+/', array('position' => 7));
// edit page
$b->click('edit')->isStatusCode(200)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'edit')->isRequestParameter('id', 1)->checkResponseElement('a[href$="/simple/show/id/1"]', 'cancel')->checkResponseElement('a[href$="/simple/delete/id/1"]', 'delete')->checkResponseElement('a[href$="/simple/delete/id/1"][onclick*="confirm"]')->checkResponseElement('body table tbody th', 'Title:', array('position' => 0))->checkResponseElement('body table tbody th', 'Body:', array('position' => 1))->checkResponseElement('body table tbody th', 'Online:', array('position' => 2))->checkResponseElement('body table tbody th', 'Category*:', array('position' => 3))->checkResponseElement('body table tbody th', 6)->checkResponseElement('body table tbody td', 6)->checkResponseElement('body table tbody td input[id="title"][name="title"][value*="title"][size="80"]')->checkResponseElement('body table tbody td textarea[id="body"][name="body"]', 'bar body')->checkResponseElement('body table tbody td input[id="online"][name="online"][type="checkbox"]', true)->checkResponseElement('body table tbody td select[id="category_id"][name="category_id"]', true)->checkResponseElement('body table tbody td select[id="category_id"][name="category_id"] option[value="1"]', '1')->checkResponseElement('body table tbody td select[id="category_id"][name="category_id"] option[value="2"]', '2');
// create page
$b->get('/simple/create')->isStatusCode(200)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'create')->isRequestParameter('id', null)->checkResponseElement('a[href$="/simple/list"]', 'cancel')->checkResponseElement('body table tbody th', 'Title:', array('position' => 0))->checkResponseElement('body table tbody th', 'Body:', array('position' => 1))->checkResponseElement('body table tbody th', 'Online:', array('position' => 2))->checkResponseElement('body table tbody th', 'Category*:', array('position' => 3))->checkResponseElement('body table tbody th', 6)->checkResponseElement('body table tbody td', 6)->checkResponseElement('body table tbody td input[id="title"][name="title"][value=""]')->checkResponseElement('body table tbody td textarea[id="body"][name="body"]', '')->checkResponseElement('body table tbody td input[id="online"][name="online"][type="checkbox"]', true)->checkResponseElement('body table tbody td select[id="category_id"][name="category_id"]', true)->checkResponseElement('body table tbody td select[id="category_id"][name="category_id"] option[value="1"]', '1')->checkResponseElement('body table tbody td select[id="category_id"][name="category_id"] option[value="2"]', '2');
// save
$b->click('save', array('title' => 'my title', 'body' => 'my body', 'online' => true, 'category_id' => 2))->isStatusCode(302)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'update')->isRedirected();
$b->followRedirect()->isStatusCode(200)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'show')->isRequestParameter('id', 3)->checkResponseElement('a[href$="/simple/edit/id/3"]', 'edit')->checkResponseElement('a[href$="/simple/list"]', 'list')->checkResponseElement('body table tbody tr', '/Id\\:\\s+3/', array('position' => 0))->checkResponseElement('body table tbody tr', '/Title\\:\\s+my title/', array('position' => 1))->checkResponseElement('body table tbody tr', '/Body\\:\\s+my body/', array('position' => 2))->checkResponseElement('body table tbody tr', '/Online\\:\\s+1/', array('position' => 3))->checkResponseElement('body table tbody tr', '/Category\\:\\s+2/', array('position' => 4))->checkResponseElement('body table tbody tr', '/Created at\\:\\s+[0-9\\-\\:\\s]+/', array('position' => 5))->checkResponseElement('body table tbody tr', '/End date\\:\\s+[0-9\\-\\:\\s]+/', array('position' => 6))->checkResponseElement('body table tbody tr', '/Book\\:\\s+$/', array('position' => 7));
$b->click('list')->isStatusCode(200)->isRequestParameter('module', 'simple')->isRequestParameter('action', 'list');
示例15: sfTestBrowser
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$app = 'backend';
$fixtures = 'fixtures/fixtures.yml';
if (!(include dirname(__FILE__) . '/../../bootstrap/functional.php')) {
return;
}
$b = new sfTestBrowser();
$b->initialize();
// edit page
$b->get('/validation/edit/id/1')->isStatusCode(200)->isRequestParameter('module', 'validation')->isRequestParameter('action', 'edit')->isRequestParameter('id', 1)->click('save', array('article' => array('title' => '', 'body' => '')))->isStatusCode(200)->isRequestParameter('module', 'validation')->isRequestParameter('action', 'save')->isRedirected(false)->checkResponseElement('.form-errors dt', 'Title:')->checkResponseElement('.form-errors dt', 'Body:', array('position' => 1))->checkResponseElement('#error_for_article_title', true)->checkResponseElement('#error_for_article_body', true)->checkResponseElement('body form#sf_admin_edit_form input[name="article[title]"][id="article_title"][value=""]')->checkResponseElement('body form#sf_admin_edit_form textarea[name="article[body]"][id="article_body"]', '')->checkResponseElement('body form#sf_admin_edit_form input[name="article[online]"][id="article_online"][type="checkbox"][checked="checked"]', true)->checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="1"][selected="selected"]');
$b->get('/validation/edit/id/2')->isStatusCode(200)->isRequestParameter('module', 'validation')->isRequestParameter('action', 'edit')->isRequestParameter('id', 2)->click('save', array('article' => array('title' => '', 'body' => '', 'online' => false)))->isStatusCode(200)->isRequestParameter('module', 'validation')->isRequestParameter('action', 'save')->checkResponseElement('body form#sf_admin_edit_form input[name="article[title]"][id="article_title"][value=""]')->checkResponseElement('body form#sf_admin_edit_form textarea[name="article[body]"][id="article_body"]', '')->checkResponseElement('body form#sf_admin_edit_form input[name="article[online]"][id="article_online"][type="checkbox"][checked="checked"]', false)->checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="2"][selected="selected"]');
$b->get('/validation/edit/id/2')->isStatusCode(200)->isRequestParameter('module', 'validation')->isRequestParameter('action', 'edit')->isRequestParameter('id', 2)->click('save', array('article' => array('title' => '', 'body' => '', 'online' => '1')))->isStatusCode(200)->isRequestParameter('module', 'validation')->isRequestParameter('action', 'save')->checkResponseElement('body form#sf_admin_edit_form input[name="article[online]"][id="article_online"][type="checkbox"][checked="checked"]', true);