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/');
 }
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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/');
<?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
0
 * (c) Fabien Potencier <*****@*****.**>
 * 
 * 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
0
/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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
0
<?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
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * 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');
          '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))
<?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
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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
0
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * 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 &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h1>#')
    ->matches('#<h2>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h2>#')
    ->matches('#<h3>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h3>#')
    ->matches('#<h4>Lorem <strong>ipsum</strong> dolor sit amet.</h4>#')
    ->matches('#<h5>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h5>#')
    ->matches('#<h6>Lorem <strong>ipsum</strong> dolor sit amet.</h6>#')
    ->checkElement('span.no', 2)
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
$browser->get('/supportMessages/index')->isStatusCode(200)->isRequestParameter('module', 'supportMessages')->isRequestParameter('action', 'index')->checkResponseElement('body', '!/This is a temporary page/');
Пример #14
0
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * 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');
Пример #15
0
/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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');
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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);
Пример #17
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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')->isStatusCode(200)->isRequestParameter('module', 'escaping')->isRequestParameter('action', 'on')->responseContains('<h1>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h1>')->responseContains('<h2>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h2>');
$b->get('/escaping/off')->isStatusCode(200)->isRequestParameter('module', 'escaping')->isRequestParameter('action', 'off')->responseContains('<h1>Lorem <strong>ipsum</strong> dolor sit amet.</h1>')->responseContains('<h2>Lorem <strong>ipsum</strong> dolor sit amet.</h2>');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
$browser->get('/userchapterregion/index')->isStatusCode(200)->isRequestParameter('module', 'userchapterregion')->isRequestParameter('action', 'index')->checkResponseElement('body', '!/This is a temporary page/');
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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');
Пример #20
0
 *
 * 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')->
  isRequestParameter('action', 'save')->

  // check error messages
  isRedirected(false)->
//$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',
    'password_bis' => '',
    'email' => '',
    'referer' => 'http%3A%2F%2Fregistry%2F',
    'commit' => 'sign+in' ))->
    isRedirected()->
    followRedirect();
//}

//should be on the main page now
//global head settings
Пример #22
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
$browser->get('/themeGroup/index')->isStatusCode(200)->isRequestParameter('module', 'themeGroup')->isRequestParameter('action', 'index')->checkResponseElement('body', '!/This is a temporary page/');
Пример #24
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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);
Пример #25
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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();
// filter
$b->get('/filter')->with('request')->begin()->isParameter('module', 'filter')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('div[class="before"]', 1)->checkElement('div[class="after"]', 1)->end();
// filter with a forward in the same module
$b->get('/filter/indexWithForward')->with('request')->begin()->isParameter('module', 'filter')->isParameter('action', 'indexWithForward')->end()->with('response')->begin()->isStatusCode(200)->checkElement('div[class="before"]', 2)->checkElement('div[class="after"]', 1)->end();
Пример #26
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * 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 &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h1>#')->matches('#<h2>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h2>#')->matches('#<h3>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; dolor sit amet.</h3>#')->matches('#<h4>Lorem <strong>ipsum</strong> dolor sit amet.</h4>#')->matches('#<h5>Lorem &lt;strong&gt;ipsum&lt;/strong&gt; 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();
Пример #27
0
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <*****@*****.**>
 * 
 * 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/');
<?php

include(dirname(__FILE__).'/../../bootstrap/functional.php');

// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();

$browser->
  get('/agent/index')->
  isStatusCode(200)->
  isRequestParameter('module', 'agent')->
  isRequestParameter('action', 'index')->
  checkResponseElement('body', '!/This is a temporary page/')
;
Пример #29
0
 */

$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()
;
Пример #30
0
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

$app = 'i18n';
if (!include(dirname(__FILE__).'/../bootstrap/functional.php'))
{
  return;
}

$b = new sfTestBrowser();

// default culture (en)
$b->
  get('/en/i18n/i18nForm')->
  with('request')->begin()->
    isParameter('module', 'i18n')->
    isParameter('action', 'i18nForm')->
  end()->
  with('user')->isCulture('en')->
  with('response')->begin()->
    isStatusCode(200)->
    checkElement('label', 'First name', array('position' => 0))->
    checkElement('label', 'Last name', array('position' => 1))->
    checkElement('label', 'Email address', array('position' => 2))->
    checkElement('td', '/Put your first name here/i', array('position' => 0))->
  end()->
  setField('i18n[email]', 'foo/bar')->
  click('Submit')->
  with('response')->begin()->