本文整理汇总了PHP中sfTestBrowser类的典型用法代码示例。如果您正苦于以下问题:PHP sfTestBrowser类的具体用法?PHP sfTestBrowser怎么用?PHP sfTestBrowser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfTestBrowser类的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: 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/');
示例3: 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->post('/fillInFilter/forward', array('name' => 'fabien'))->isStatusCode(200)->isRequestParameter('module', 'fillInFilter')->isRequestParameter('action', 'forward')->checkResponseElement('body div', 'foo');
$b->post('/fillInFilter/update', array('first_name' => 'fabien'))->isStatusCode(200)->isRequestParameter('module', 'fillInFilter')->isRequestParameter('action', 'update')->checkResponseElement('input[name="first_name"][value="fabien"]');
示例4: sfTestBrowser
<?php
/*
* This file is part of the symfony package.
* (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
示例5: 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();
// 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
示例6: include
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
//$browser->
// get('/agent/list');
//$loggedIn = (false !== strpos($browser->getResponse()->getContent(),'sign out'));
//$loggedInAsAdmin = (false !== strpos($browser->getResponse()->getContent(),'admin profile'));
//if logged in as another user, sign out and login
//if logged in as admin, skip login
//if ($loggedIn && !$loggedInAsAdmin)
//{
// $browser->click('sign out');
//}
//if (!$loggedIn)
//{
$browser->
get('/login')->
isStatusCode(200);
$browser->post('/login', array(
'nickname' => 'admin',
'password' => 'admin',
示例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->initialize();
// filter
$b->get('/filter')->isStatusCode(200)->isRequestParameter('module', 'filter')->isRequestParameter('action', 'index')->checkResponseElement('div[class="before"]', 1)->checkResponseElement('div[class="after"]', 1);
// filter with a forward in the same module
$b->get('/filter/indexWithForward')->isStatusCode(200)->isRequestParameter('module', 'filter')->isRequestParameter('action', 'indexWithForward')->checkResponseElement('div[class="before"]', 2)->checkResponseElement('div[class="after"]', 1);
示例8: 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')->isStatusCode(200)->isRequestParameter('module', 'autoload')->isRequestParameter('action', 'myAutoload')->checkResponseElement('body div', 'foo');
$t = $b->test();
$t->ok(class_exists('BaseExtendMe'), 'plugin lib directory added to autoload');
$r = new ReflectionClass('ExtendMe');
$t->like($r->getFilename(), '~project/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');
示例9: 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 = 'backend_compat';
$fixtures = 'fixtures/fixtures.yml';
if (!include(dirname(__FILE__).'/../../bootstrap/functional.php'))
{
return;
}
$b = new sfTestBrowser();
// edit page
$b->
get('/validation/edit/id/1')->
isStatusCode(200)->
isRequestParameter('module', 'validation')->
isRequestParameter('action', 'edit')->
// parameters
isRequestParameter('id', 1)->
// save
click('save', array('article' => array('title' => '', 'body' => '')))->
isStatusCode(200)->
isRequestParameter('module', 'validation')->
示例10: dirname
<?php
include dirname(__FILE__) . '/../../bootstrap/functional.php';
try {
// first drop database
$this->runTask('doctrine:drop-db', '--no-confirmation');
$database_file = sfConfig::get('sf_config_dir') . DIRECTORY_SEPARATOR . 'databases.yml';
$database_file_content = file_get_contents($database_file);
$config_file = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . 'config.php';
$config_file_content = file_get_contents($config_file);
$browser = new sfTestBrowser();
$browser->setTester('doctrine', 'sfTesterDoctrine');
$browser->info('Test the first page')->get('/')->with('request')->begin()->isParameter('module', 'static')->isParameter('action', 'step1')->end()->info('Trying to jump steps redirect to my step')->get('/step3')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'static')->isParameter('action', 'step1')->end()->setField('language', 'en')->click('next')->with('response')->begin()->isRedirected()->end()->post('/step2')->followRedirect()->with('request')->begin()->isParameter('module', 'static')->isParameter('action', 'step3')->end()->click('next')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'static')->isParameter('action', 'step4')->end()->setField('db[database]', 'siwapp_test')->setField('db[username]', 'siwapp')->setField('db[password]', 'wappis')->setField('db[host]', 'bbdd')->click('next')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'static')->isParameter('action', 'step5')->end()->setField('config[admin_email]', 'e@test.org')->setField('config[admin_username]', 'test')->setField('config[admin_password', 'test')->setField('config[admin_password_bis]', 'test')->setField('config[preload]', true)->click('next')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'static')->isParameter('action', 'step6')->end()->with('response')->begin()->info('Testing there were no sql errors')->checkElement('ul.error_list li:first-child', false)->end();
$browser->info('Test the data inserted')->with('doctrine')->begin()->check('sfGuardUser', array('username' => 'test', 'is_super_admin' => 1))->check('Profile', array('email' => 'e@test.org', 'language' => 'en'))->end();
// this is to revert always the files modified, because
// with errors there is no 'Finish' button
$browser->info('Test the redirection to the application')->click('Finish')->with('response')->begin()->isRedirected()->end();
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
$browser->info('Reverting modified files');
@file_put_contents($database_file, $database_file_content);
@file_put_contents($config_file, $config_file_content);
$browser->info('Reverting cache and database');
$this->runTask('cc');
$this->runTask('siwapp:test-data-load', '--env=test');
示例11: include
<?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/')
;
示例12: 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->initialize();
// exceptions
$b->get('/exception/noException')->isStatusCode(200)->isRequestParameter('module', 'exception')->isRequestParameter('action', 'noException')->responseContains('foo')->get('/exception/throwsException')->isStatusCode(200)->isRequestParameter('module', 'exception')->isRequestParameter('action', 'throwsException')->throwsException('Exception')->throwsException('Exception', 'Exception message')->throwsException('Exception', '/message/')->throwsException(null, '!/sfException/')->get('/exception/throwsSfException')->isStatusCode(200)->isRequestParameter('module', 'exception')->isRequestParameter('action', 'throwsSfException')->throwsException('sfException')->throwsException('sfException', 'sfException message');
$b->get('/browser')->responseContains('html')->checkResponseElement('h1', 'html')->get('/browser/text')->responseContains('text');
try {
$b->checkResponseElement('h1', 'text');
$b->test()->fail('The DOM is not accessible if the response content type is not HTML');
} catch (sfException $e) {
$b->test()->pass('The DOM is not accessible if the response content type is not HTML');
}
// check response headers
$b->get('/browser/responseHeader')->isStatusCode()->isResponseHeader('content-type', 'text/plain; charset=utf-8')->isResponseHeader('foo', 'bar')->isResponseHeader('foo', 'foobar');
示例13: 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');
示例14: 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('/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)->end();
$b->get('/escaping/off')->with('request')->begin()->isParameter('module', 'escaping')->isParameter('action', 'off')->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>#')->end();
示例15: sfDatabaseManager
require_once $sf_root_dir . '/test/bootstrap/functional.php';
require_once $sf_symfony_lib_dir . '/vendor/lime/lime.php';
if (!defined('TEST_CLASS') || !class_exists(TEST_CLASS) || !defined('TEST_CLASS_2') || !class_exists(TEST_CLASS_2)) {
// Don't run tests
return;
}
// initialize database manager
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$con = Propel::getConnection();
// clean the database
TagPeer::doDeleteAll();
TaggingPeer::doDeleteAll();
call_user_func(array(_create_object()->getPeer(), 'doDeleteAll'));
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
// start tests
$t = new lime_test(66, new lime_output_color());
// these tests check for the tags attachement consistency
$t->diag('tagging consistency');
$object = _create_object();
$t->ok($object->getTags() == array(), 'a new object has no tag.');
$object->addTag('toto');
$object_tags = $object->getTags();
$t->ok(count($object_tags) == 1 && $object_tags['toto'] == 'toto', 'a non-saved object can get tagged.');
$object->addTag('toto');
$object_tags = $object->getTags();
$t->ok(count($object_tags) == 1, 'a tag is only applied once to non-saved objects.');
$object->save();
$object->addTag('toto');