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


PHP sfTestBrowser::getAndCheck方法代码示例

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


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

示例1: Criteria

$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()->
开发者ID:nurhidayatullah,项目名称:inventory,代码行数:32,代码来源:formTest.php

示例2: dirname

$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();
$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()->ok($attachments[0]->getArticleId(), 'the attachment is tied to an article');
$b->test()->is($attachments[0]->getFile(), 'uploaded.yml', 'the attachment filename has been saved in the database');
// sfValidatorPropelUnique
// create a category with a unique name
$b->get('/unique/category')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'category')->end()->with('response')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo')))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->matches('/ok/')->end();
// create another category with the same name
// we must have an error
$b->get('/unique/category')->with('request')->begin()->isParameter('module', 'unique')->isParameter('action', 'category')->end()->with('response')->isStatusCode(200)->click('submit', array('category' => array('name' => 'foo')))->with('form')->begin()->hasErrors(1)->hasGlobalError(false)->isError('name', 'invalid')->end()->with('response')->begin()->checkElement('td[colspan="2"] .error_list li', 0)->checkElement('.error_list li', 'An object with the same "name" already exist.')->checkElement('.error_list li', 1)->end();
// same thing but with a global error
开发者ID:cuongnv540,项目名称:jobeet,代码行数:31,代码来源:formTest.php

示例3: 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';
if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) {
    return;
}
$b = new sfTestBrowser();
$b->get('/format_test.js')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('js')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'application/javascript')->matches('!/<body>/')->matches('/Some js headers/')->matches('/This is a js file/')->end();
$b->get('/format_test.css')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('css')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/css; charset=utf-8')->matches('/This is a css file/')->end();
$b->get('/format_test')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('html')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/html; charset=utf-8')->checkElement('body #content', 'This is an HTML file')->end();
$b->get('/format_test.xml')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('xml')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/xml; charset=utf-8')->checkElement('sentences sentence:first', 'This is a XML file')->end();
$b->get('/format_test.foo')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'index')->isFormat('foo')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/html; charset=utf-8')->isHeader('x-foo', 'true')->checkElement('body #content', 'This is an HTML file')->end();
$b->get('/format/js')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'js')->isFormat('js')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'application/javascript')->matches('/A js file/')->end();
$b->setHttpHeader('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3')->get('/format/forTheIPhone')->with('request')->begin()->isParameter('module', 'format')->isParameter('action', 'forTheIPhone')->isFormat('iphone')->end()->with('response')->begin()->isStatusCode(200)->isHeader('content-type', 'text/html; charset=utf-8')->checkElement('#content', 'This is an HTML file for the iPhone')->checkElement('link[href*="iphone.css"]')->end();
$b->getAndCheck('format', 'throwsException', null, 500)->throwsException('Exception', '/message/');
开发者ID:sensorsix,项目名称:app,代码行数:22,代码来源:formatTest.php

示例4: sfTestBrowser

 * (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"]')->
    matches('#'.preg_quote('<!--[if lte IE 6]><link rel="stylesheet" type="text/css" media="screen" href="/css/ie6.css" /><![endif]-->').'#')->
  end()
;

// default 404
$b->
  get('/nonexistant')->
  with('response')->isStatusCode(404)
;
/*
$b->
开发者ID:nationalfield,项目名称:symfony,代码行数:32,代码来源:genericTest.php

示例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
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:31,代码来源:genericTest.php

示例6: get

  get('/i18n/movie')->
  click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen (1)'), 'fr' => array('title' => 'Les Douze Salopards (1)'))))->

  with('form')->begin()->
    hasErrors(2)->
  end()->

  click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen'), 'fr' => array('title' => 'Les Douze Salopards'))))->

  with('form')->begin()->
    hasErrors(false)->
  end()->
  with('response')->begin()->
    isRedirected()->
    followRedirect()->
  end()->
  with('response')->begin()->
    checkElement('input[value="Robert Aldrich"]')->
    checkElement('input[value="The Dirty Dozen"]')->
    checkElement('input[value="Les Douze Salopards"]')->
  end()
  // END: Bug #7486
;

$b->getAndCheck('i18n', 'products')
  ->with('response')->begin()
    ->checkElement('ul#products li.toString', 'PRIMARY STRING')
  ->end()
;
开发者ID:nationalfield,项目名称:symfony,代码行数:29,代码来源:i18nTest.php

示例7: sfTestBrowser

 *
 * 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(new sfBrowser());
$b->setTester('propel', 'sfTesterPropel');
// en
$b->get('/i18n/default')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'default')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#movies .toString:first', '')->checkElement('#movies .default:first', '')->checkElement('#movies .it:first', 'La Vita è bella')->checkElement('#movies .fr:first', 'La Vie est belle')->end();
// it
$b->get('/i18n/queryPropel')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'queryPropel')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#movies .propel_it:first', 'La Vita è bella')->end();
// fr
$b->get('/i18n/index')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#movies .toString:first', 'La Vie est belle')->checkElement('#movies .default:first', 'La Vie est belle')->checkElement('#movies .it:first', 'La Vita è bella')->checkElement('#movies .fr:first', 'La Vie est belle')->end();
// still fr
$b->get('/i18n/default')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'default')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#movies .toString:first', 'La Vie est belle')->checkElement('#movies .default:first', 'La Vie est belle')->checkElement('#movies .it:first', 'La Vita è bella')->checkElement('#movies .fr:first', 'La Vie est belle')->end();
// SfPropelBehaviorI18n (part of sfPropelORMPlugin)
$b->get('/i18n/movie')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'movie')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#movie_fr_id', false)->checkElement('#movie_fr_culture', false)->end()->click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen'), 'fr' => array('title' => 'Les Douze Salopards'))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="Robert Aldrich"]')->checkElement('input[value="The Dirty Dozen"]')->checkElement('input[value="Les Douze Salopards"]')->checkElement('#movie_fr_id', true)->checkElement('#movie_fr_culture', true)->end()->with('propel')->begin()->check('Movie', array(), 2)->check('Movie', array('director' => 'Robert Aldrich', 'id' => 2))->check('MovieI18N', array(), 4)->check('MovieI18N', array('id' => 2), 2)->check('MovieI18N', array('culture' => 'fr', 'id' => 2, 'title' => 'Les Douze Salopards'))->check('MovieI18N', array('culture' => 'en', 'id' => 2, 'title' => 'The Dirty Dozen'))->end()->click('submit', array('movie' => array('director' => 'Robert Aldrich (1)', 'en' => array('title' => 'The Dirty Dozen (1)'), 'fr' => array('title' => 'Les Douze Salopards (1)'))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="Robert Aldrich (1)"]')->checkElement('input[value="The Dirty Dozen (1)"]')->checkElement('input[value="Les Douze Salopards (1)"]')->end()->with('propel')->begin()->check('Movie', array(), 2)->check('Movie', array('director' => 'Robert Aldrich (1)', 'id' => 2))->check('MovieI18N', array(), 4)->check('MovieI18N', array('id' => 2), 2)->check('MovieI18N', array('culture' => 'fr', 'id' => 2, 'title' => 'Les Douze Salopards (1)'))->check('MovieI18N', array('culture' => 'en', 'id' => 2, 'title' => 'The Dirty Dozen (1)'))->end()->click('submit')->with('form')->begin()->hasErrors(false)->end()->get('/i18n/movie')->click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen (1)'), 'fr' => array('title' => 'Les Douze Salopards (1)'))))->with('form')->begin()->hasErrors(2)->end()->click('submit', array('movie' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen'), 'fr' => array('title' => 'Les Douze Salopards'))))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="Robert Aldrich"]')->checkElement('input[value="The Dirty Dozen"]')->checkElement('input[value="Les Douze Salopards"]')->end();
// Symfony integration with BehaviorI18n (part of Propel)
$b->get('/i18n/moviePropel')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'moviePropel')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#movie_propel_fr_id', false)->checkElement('#movie_propel_fr_locale', false)->end()->click('submit', array('movie_propel' => array('director' => 'Robert Aldrich', 'en' => array('title' => 'The Dirty Dozen'), 'fr' => array('title' => 'Les Douze Salopards'))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="Robert Aldrich"]')->checkElement('input[value="The Dirty Dozen"]')->checkElement('input[value="Les Douze Salopards"]')->checkElement('#movie_propel_fr_id', true)->checkElement('#movie_propel_fr_locale', true)->end()->with('propel')->begin()->check('MoviePropel', array(), 2)->check('MoviePropel', array('director' => 'Robert Aldrich', 'id' => 2))->check('MoviePropelI18N', array(), 4)->check('MoviePropelI18N', array('id' => 2), 2)->check('MoviePropelI18N', array('locale' => 'fr', 'id' => 2, 'title' => 'Les Douze Salopards'))->check('MoviePropelI18N', array('locale' => 'en', 'id' => 2, 'title' => 'The Dirty Dozen'))->end()->click('submit', array('movie_propel' => array('director' => 'Robert Aldrich (1)', 'en' => array('title' => 'The Dirty Dozen (1)'), 'fr' => array('title' => 'Les Douze Salopards (1)'))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="Robert Aldrich (1)"]')->checkElement('input[value="The Dirty Dozen (1)"]')->checkElement('input[value="Les Douze Salopards (1)"]')->end()->with('propel')->begin()->check('MoviePropel', array(), 2)->check('MoviePropel', array('director' => 'Robert Aldrich (1)', 'id' => 2))->check('MoviePropelI18N', array(), 4)->check('MoviePropelI18N', array('id' => 2), 2)->check('MoviePropelI18N', array('locale' => 'fr', 'id' => 2, 'title' => 'Les Douze Salopards (1)'))->check('MoviePropelI18N', array('locale' => 'en', 'id' => 2, 'title' => 'The Dirty Dozen (1)'))->end();
// https://github.com/propelorm/sfPropelORMPlugin/issues/38
// SfPropelBehaviorI18n (part of sfPropelORMPlugin)
$b->get('/i18n/movie')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'movie')->end()->click('submit', array('movie' => array('director' => 'James McTeigue', 'en' => array('title' => 'V For Vendetta'), 'fr' => array('title' => 'V Pour Vendetta'), 'Toy' => array('newToy1' => array('ref' => '04212', 'en' => array('name' => 'V mask'), 'fr' => array('name' => 'masque de V'))))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="James McTeigue"]')->checkElement('input[value="V For Vendetta"]')->checkElement('input[value="V Pour Vendetta"]')->checkElement('input[name="movie[Toy][1][ref]"][value="04212"]')->checkElement('input[name="movie[Toy][1][en][name]"][value="V mask"]')->checkElement('input[name="movie[Toy][1][fr][name]"][value="masque de V"]')->end()->with('propel')->begin()->check('Movie', array(), 4)->check('Movie', array('director' => 'James McTeigue', 'id' => 4))->check('MovieI18N', array(), 8)->check('MovieI18N', array('id' => 4), 2)->check('MovieI18N', array('culture' => 'fr', 'id' => 4, 'title' => 'V Pour Vendetta'))->check('MovieI18N', array('culture' => 'en', 'id' => 4, 'title' => 'V For Vendetta'))->check('Toy', array(), 1)->check('Toy', array('ref' => '04212'))->check('ToyI18N', array(), 2)->check('ToyI18N', array('id' => 1), 2)->check('ToyI18N', array('culture' => 'fr', 'id' => 1, 'name' => 'masque de V'))->check('ToyI18N', array('culture' => 'en', 'id' => 1, 'name' => 'V mask'))->end();
// https://github.com/propelorm/sfPropelORMPlugin/issues/38
// Symfony integration with BehaviorI18n (part of Propel)
$b->get('/i18n/moviePropel')->with('request')->begin()->isParameter('module', 'i18n')->isParameter('action', 'moviePropel')->end()->click('submit', array('movie_propel' => array('director' => 'James McTeigue (1)', 'en' => array('title' => 'V For Vendetta (1)'), 'fr' => array('title' => 'V Pour Vendetta (1)'), 'ToyPropel' => array('newToyPropel1' => array('ref' => '04212', 'en' => array('name' => 'V mask'), 'fr' => array('name' => 'masque de V'))))))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('response')->begin()->checkElement('input[value="James McTeigue (1)"]')->checkElement('input[value="V For Vendetta (1)"]')->checkElement('input[value="V Pour Vendetta (1)"]')->checkElement('input[name="movie_propel[ToyPropel][1][ref]"][value="04212"]')->checkElement('input[name="movie_propel[ToyPropel][1][en][name]"][value="V mask"]')->checkElement('input[name="movie_propel[ToyPropel][1][fr][name]"][value="masque de V"]')->end()->with('propel')->begin()->check('MoviePropel', array(), 3)->check('MoviePropel', array('director' => 'James McTeigue (1)', 'id' => 3))->check('MoviePropelI18N', array(), 6)->check('MoviePropelI18N', array('id' => 3), 2)->check('MoviePropelI18N', array('locale' => 'fr', 'id' => 3, 'title' => 'V Pour Vendetta (1)'))->check('MoviePropelI18N', array('locale' => 'en', 'id' => 3, 'title' => 'V For Vendetta (1)'))->check('ToyPropel', array(), 1)->check('Toy', array('ref' => '04212'))->check('ToyPropelI18N', array(), 2)->check('ToyPropelI18N', array('id' => 1), 2)->check('ToyPropelI18N', array('locale' => 'fr', 'id' => 1, 'name' => 'masque de V'))->check('ToyPropelI18N', array('locale' => 'en', 'id' => 1, 'name' => 'V mask'))->end();
$b->getAndCheck('i18n', 'products')->with('response')->begin()->checkElement('ul#products li.toString', 'PRIMARY STRING')->end();
开发者ID:kcornejo,项目名称:estadistica,代码行数:30,代码来源:i18nTest.php

示例8: isParameter

    isParameter('action', 'js')->
    isFormat('js')->
  end()->
  with('response')->begin()->
    isStatusCode(200)->
    isHeader('content-type', 'application/javascript')->
    matches('/A js file/')->
  end()
;

$b->
  setHttpHeader('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3')->
  get('/format/forTheIPhone')->
  with('request')->begin()->
    isParameter('module', 'format')->
    isParameter('action', 'forTheIPhone')->
    isFormat('iphone')->
  end()->
  with('response')->begin()->
    isStatusCode(200)->
    isHeader('content-type', 'text/html; charset=utf-8')->
    checkElement('#content', 'This is an HTML file for the iPhone')->
    checkElement('link[href*="iphone.css"]')->
  end()
;

$b->
  getAndCheck('format', 'throwsException', null, 500)->
  throwsException('Exception', '/message/')
;
开发者ID:nationalfield,项目名称:symfony,代码行数:30,代码来源:formatTest.php

示例9: 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"]')->checkElement('link[href="/css/multiple_media.css"][media="print,handheld"]')->matches('#' . preg_quote('<!--[if lte IE 6]><link rel="stylesheet" type="text/css" media="screen" href="/css/ie6.css" /><![endif]-->') . '#')->end();
// default 404
$b->get('/nonexistant')->with('response')->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')->with('request')->begin()->isParameter('module', 'notfound')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(404)->checkElement('body', '/404/')->end()->get('/notfound')->with('request')->begin()->isParameter('module', 'notfound')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(404)->checkElement('body', '/404/')->end();
sfConfig::set('sf_cache', false);
sfConfig::set('sf_etag', false);
// unexistant action
开发者ID:sensorsix,项目名称:app,代码行数:31,代码来源:genericTest.php

示例10: get

;

// list page
$b->
  get('/article')->
  isStatusCode(200)->
  isRequestParameter('module', 'article')->
  isRequestParameter('action', 'index')->
  checkResponseElement('script', false)->
  checkResponseElement('link[href="/sf/sf_admin/css/main.css"]')->
  checkResponseElement('link[href][media]', 2)
;

$content = $b->getResponse()->getContent();

$b->
  getAndCheck('article', 'list')->

  // title
  checkResponseElement('body h1', 'article list')->

  // headers
  checkResponseElement('body table thead tr th[id="sf_admin_list_th_id"]', true)->
  checkResponseElement('body table thead tr th[id="sf_admin_list_th_id"] a[href*="/sort/"]', 'Id')-> // sortable

  checkResponseElement('body table thead tr th[id="sf_admin_list_th_title"]', true)->
  checkResponseElement('body table thead tr th[id="sf_admin_list_th_title"] a[href*="/sort/"]', 'Title')->

  checkResponseElement('body table thead tr th[id="sf_admin_list_th_body"]', true)->
  checkResponseElement('body table thead tr th[id="sf_admin_list_th_body"] a[href*="/sort/"]', 'Body')->

  checkResponseElement('body table thead tr th[id="sf_admin_list_th_online"]', true)->
开发者ID:nationalfield,项目名称:symfony,代码行数:32,代码来源:browseTest.php

示例11: sfTestBrowser

 *
 * 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();
// check symfony throws an exception if model class does not exist
$b->get('/error')->isStatusCode(200)->isRequestParameter('module', 'error')->isRequestParameter('action', 'index')->throwsException('sfInitializationException', '/Unable to scaffold nonexistent model/');
// list page
$b->get('/article')->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'index')->checkResponseElement('script', false)->checkResponseElement('link[href="/sf/sf_admin/css/main.css"]')->checkResponseElement('link[href][media]', 2);
$content = $b->getResponse()->getContent();
$b->getAndCheck('article', 'list')->checkResponseElement('body h1', 'article list')->checkResponseElement('body table thead tr th[id="sf_admin_list_th_id"]', true)->checkResponseElement('body table thead tr th[id="sf_admin_list_th_id"] a[href*="/sort/"]', 'Id')->checkResponseElement('body table thead tr th[id="sf_admin_list_th_title"]', true)->checkResponseElement('body table thead tr th[id="sf_admin_list_th_title"] a[href*="/sort/"]', 'Title')->checkResponseElement('body table thead tr th[id="sf_admin_list_th_body"]', true)->checkResponseElement('body table thead tr th[id="sf_admin_list_th_body"] a[href*="/sort/"]', 'Body')->checkResponseElement('body table thead tr th[id="sf_admin_list_th_online"]', true)->checkResponseElement('body table thead tr th[id="sf_admin_list_th_online"] a[href*="/sort/"]', 'Online')->checkResponseElement('body table thead tr th[id="sf_admin_list_th_category_id"]', true)->checkResponseElement('body table thead tr th[id="sf_admin_list_th_category_id"] a[href*="/sort/"]', 'Category')->checkResponseElement('body table thead tr th[id="sf_admin_list_th_created_at"]', true)->checkResponseElement('body table thead tr th[id="sf_admin_list_th_created_at"] a[href*="/sort/"]', 'Created at')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(0)', '1')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(1)', 'foo title')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(2)', 'bar body')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(3) img', true)->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(4)', 'foo excerpt')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td:nth(5)', '1')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td a[href$="/article/edit/id/1"]', '1')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(0)', '2')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(1)', 'foo foo title')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(2)', 'bar bar body')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(3) img', false)->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(4)', 'foo excerpt')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(5)', '2')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td a[href$="/article/edit/id/2"]', '2')->checkResponseElement('body table tfoot tr th', '/^\\s*2 results\\s*$/')->checkResponseElement('body input[class="sf_admin_action_create"][onclick*="/article/create"]', true);
$b->test()->is($b->getResponse()->getContent(), $content, 'article is an alias for article/list');
// sort
$b->click('Body')->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'list')->isRequestParameter('sort', 'body')->isRequestParameter('type', 'asc')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td', '2')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', '1')->getAndCheck('article', 'list')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td', '2')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', '1')->click('Body')->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'list')->isRequestParameter('sort', 'body')->isRequestParameter('type', 'desc')->checkResponseElement('body table tbody tr[class="sf_admin_row_0"] td', '1')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td', '2');
// edit page
$b->click('1')->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'edit')->checkResponseElement('script[src*="calendar"]', 3)->checkResponseElement('script[src]', 3)->checkResponseElement('link[href*="calendar"]')->checkResponseElement('link[href="/sf/sf_admin/css/main.css"]')->checkResponseElement('link[href][media]', 3)->checkResponseElement('body h1', 'edit article')->isRequestParameter('id', 1)->checkResponseElement('body form#sf_admin_edit_form label[for="article_title"]', 'Title:')->checkResponseElement('body form#sf_admin_edit_form label[for="article_body"]', 'Body:')->checkResponseElement('body form#sf_admin_edit_form label[for="article_online"]', 'Online:')->checkResponseElement('body form#sf_admin_edit_form label[for="article_category_id"]', 'Category:')->checkResponseElement('body form#sf_admin_edit_form label[for="article_created_at"]', 'Created at:')->checkResponseElement('body form#sf_admin_edit_form input[name="article[title]"][id="article_title"][value="foo title"]')->checkResponseElement('body form#sf_admin_edit_form textarea[name="article[body]"][id="article_body"]', 'bar 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"]', true)->checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="1"]', 'Category 1')->checkResponseElement('body form#sf_admin_edit_form select[name="article[category_id]"][id="article_category_id"] option[value="2"]', 'Category 2')->checkResponseElement('body form#sf_admin_edit_form input[name="article[created_at]"][id="article_created_at"][value*="-"]')->checkResponseElement('body input[class="sf_admin_action_list"][onclick*="/article/list"]', true)->checkResponseElement('body input[name="save_and_add"]', true)->checkResponseElement('body input[name="save"]', true)->checkResponseElement('body input[class="sf_admin_action_delete"][onclick*="confirm"]', true);
// save
$b->click('save', array('article' => array('title' => 'my title', 'body' => 'my body', 'category_id' => 2)))->isStatusCode(302)->isRequestParameter('module', 'article')->isRequestParameter('action', 'save')->isRedirected()->followRedirect()->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'edit')->isRequestParameter('id', 1)->checkResponseElement('input[id="article_title"][value="my title"]')->checkResponseElement('#article_body', 'my body')->checkResponseElement('input[id="article_online"][checked="checked"]', true)->checkResponseElement('#article_category_id option[selected="selected"]', 'Category 2');
// save and add
$b->click('save and add')->isStatusCode(302)->isRequestParameter('module', 'article')->isRequestParameter('action', 'save')->isRedirected()->followRedirect()->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'create')->isRequestParameter('id', '');
// create
$b->getAndCheck('article', 'create')->isRequestParameter('id', '')->checkResponseElement('body form#sf_admin_edit_form label[for="article_title"]', 'Title:')->checkResponseElement('body form#sf_admin_edit_form input[name="article[title]"][id="article_title"][value=""]')->click('save', array('article' => array('title' => 'new title', 'body' => 'new body', 'category_id' => 2)))->isStatusCode(302)->isRequestParameter('module', 'article')->isRequestParameter('action', 'save')->isRedirected()->followRedirect()->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'edit')->isRequestParameter('id', 3)->checkResponseElement('input[id="article_title"][value="new title"]')->checkResponseElement('#article_body', 'new body')->checkResponseElement('#article_category_id option[selected="selected"]', 'Category 2')->getAndCheck('article', 'list')->checkResponseElement('body table tbody tr[class="sf_admin_row_1"] td:nth(7)', '')->checkResponseElement('body table tfoot tr th', '/^\\s*3 results\\s*$/');
// delete
$b->post('/article/delete/id/3')->isStatusCode(302)->isRequestParameter('module', 'article')->isRequestParameter('action', 'delete')->isRedirected()->followRedirect()->isStatusCode(200)->isRequestParameter('module', 'article')->isRequestParameter('action', 'list')->get('/article/edit/id/3')->isStatusCode(404)->getAndCheck('article', 'list')->checkResponseElement('body table tfoot tr th', '/^\\s*2 results\\s*$/');
// add some entries to test pagination
$b->get('/article/create');
开发者ID:ajith24,项目名称:ajithworld,代码行数:31,代码来源:browseTest.php

示例12: dirname

<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
$t = $browser->test();
$prefix = 'app_sf_google_analytics_plugin_';
$urchinVars = explode(',', 'dn,link,Osr,Okw,tcp,fsc,hash,flash,title,timeout,cto,ccn,cmd,csr,ctr,cct,cid,cno,anchor,Ono,Rno,sample,serv');
$googleSetters = explode(',', 'DomainName,AllowLinker,CookiePath,ClientInfo,AllowHash,DetectFlash,DetectTitle,SessionTimeout,CookieTimeout,CampNameKey,CampMediumKey,CampSourceKey,CampTermKey,CampContentKey,CampIdKey,CampNOKey,AllowAnchor,SampleRate,LocalRemoteServerMode');
$googleAdders = explode(',', 'Organic,IgnoredOrganic,IgnoredRef');
$params = array('page_name' => '/virtual/page', 'domain_name' => 'example.com', 'linker_policy' => true, 'organic_referers' => array(array('name' => 'example.com', 'param' => 'q')), 'vars' => array('customer'), 'cookie_path' => '/subdir', 'client_info_policy' => false, 'hash_policy' => false, 'detect_flash_policy' => false, 'detect_title_policy' => false, 'session_timeout' => 60, 'cookie_timeout' => 600, 'campaign_keys' => array('name' => 'cnk', 'medium' => 'cmk', 'source' => 'csk', 'term' => 'ctk', 'content' => 'cck', 'id' => 'cik', 'no_override' => 'cnok'), 'anchor_policy' => true, 'ignored_organics' => array('keyword'), 'ignored_referers' => array('example.com'), 'sample_rate' => 10, 'local_remote_server_policy' => true);
$browser->getAndCheck('main', 'index');
$t->unlike($browser->getResponse()->getContent(), '/google-analytics\\.com/', 'disabled urchin ok');
sfConfig::set($prefix . 'enabled', true);
$browser->getAndCheck('main', 'index')->responseContains('google-analytics.com')->responseContains('urchinTracker()');
$content = $browser->getResponse()->getContent();
$t->unlike($content, '/_u(' . join('|', $urchinVars) . ')/', 'no params ok');
$t->unlike($content, '/__utmSetVar/', 'no vars ok');
sfConfig::set($prefix . 'params', $params);
$browser->getAndCheck('main', 'index')->responseContains('google-analytics.com')->responseContains('urchinTracker("\\/virtual\\/page")');
$content = $browser->getResponse()->getContent();
foreach ($urchinVars as $var) {
    $t->like($content, '/^_u' . $var . '(\\[\\d*\\])?=[^;]+;$/m', 'u' . $var . ' ok');
}
sfConfig::set($prefix . 'tracker', 'google');
sfConfig::set($prefix . 'params', array());
$browser->getAndCheck('main', 'index')->responseContains('google-analytics.com')->responseContains('pageTracker');
$content = $browser->getResponse()->getContent();
$t->unlike($content, '/set(' . join('|', $googleSetters) . ')/', 'no setters ok');
$t->unlike($content, '/add(' . join('|', $googleAdders) . ')/', 'no adders ok');
开发者ID:bshaffer,项目名称:Symplist,代码行数:31,代码来源:mainActionsTest.php


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