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/');
 }
 /**
  * Initializes the browser tester instance.
  *
  * @param sfBrowserBase $browser A sfBrowserBase instance
  * @param lime_test     $lime    A lime instance
  */
 public function __construct(sfBrowserBase $browser = null, lime_test $lime = null, $testers = array())
 {
     if (null === $browser) {
         $browser = new sfBrowser();
     }
     parent::__construct($browser, $lime, $testers);
 }
  public function __construct()
  {
    parent::__construct();
    $this->setTester('doctrine', 'sfTesterDoctrine');

    $this->_generateAdminGenModules();
  }
 /**
  * Initializes the browser tester instance.
  *
  * @param string $hostname  Hostname
  * @param string $remote    Remote IP address
  * @param array  $options   Options
  */
 public function initialize($hostname = null, $remote = null, $options = array())
 {
     parent::initialize($hostname, $remote, $options);
     $output = isset($options['output']) ? $options['output'] : new lime_output_color();
     if (is_null(self::$test)) {
         self::$test = new lime_test(null, $output);
     }
 }
<?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/');
<?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->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"]');
Example #7
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';
$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
Example #8
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();
// 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
<?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',
<?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);
Example #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';
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->get('/community/index')->isStatusCode(200)->isRequestParameter('module', 'community')->isRequestParameter('action', 'index')->checkResponseElement('body', '!/This is a temporary page/');
Example #13
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 = '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')->
Example #14
0
<?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]', '*****@*****.**')->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' => '*****@*****.**', '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');
<?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/')
;
<?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');
Example #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('/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');
Example #18
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();
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');
<?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/')
;
<?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();
// default main page
$b->get('/')->isStatusCode(200)->isRequestParameter('module', 'default')->isRequestParameter('action', 'index')->checkResponseElement('body', '/congratulations/i')->checkResponseElement('link[href="/sf/sf_default/css/screen.css"]');
// default 404
$b->get('/nonexistant')->isStatusCode(404)->isForwardedTo('default', 'error404')->checkResponseElement('body', '!/congratulations/i')->checkResponseElement('link[href="/sf/sf_default/css/screen.css"]');
// unexistant action
$b->get('/default/nonexistantaction')->isStatusCode(404)->isForwardedTo('default', 'error404')->checkResponseElement('link[href="/sf/sf_default/css/screen.css"]');
// available
sfConfig::set('sf_available', false);
$b->get('/')->isStatusCode(200)->isForwardedTo('default', 'unavailable')->checkResponseElement('body', '/unavailable/i')->checkResponseElement('body', '!/congratulations/i')->checkResponseElement('link[href="/sf/sf_default/css/screen.css"]');
sfConfig::set('sf_available', true);
// module.yml: enabled
$b->get('/configModuleDisabled')->isStatusCode(200)->isForwardedTo('default', 'disabled')->checkResponseElement('body', '/module is unavailable/i')->checkResponseElement('body', '!/congratulations/i')->checkResponseElement('link[href="/sf/sf_default/css/screen.css"]');
// view.yml: has_layout
$b->get('/configViewHasLayout/withoutLayout')->isStatusCode(200)->checkResponseElement('body', '/no layout/i')->checkResponseElement('head title', false);
// security.yml: is_secure
$b->get('/configSecurityIsSecure')->isStatusCode(200)->isForwardedTo('default', 'login')->checkResponseElement('body', '/Login Required/i')->checkResponseElement('body', 1)->checkResponseElement('link[href="/sf/sf_default/css/screen.css"]');
Example #22
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 = '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))->
Example #23
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();
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/../../../..'));
define('SF_APP', 'frontend');
include dirname(__FILE__) . '/../../../../test/bootstrap/functional.php';
$b = new sfTestBrowser();
$b->initialize();
$t = new lime_test(15, new lime_output_color());
$enclosureParams = array('url' => 'foo.com', 'length' => '1234', 'mimeType' => 'foobarmimetype');
$enclosure = new sfFeedEnclosure();
$enclosure->initialize($enclosureParams);
$item_params = array('title' => 'foo', 'link' => 'http://www.example.com', 'description' => 'foobar baz', 'content' => 'hey, do you foo, bar?', 'authorName' => 'francois', 'authorEmail' => '*****@*****.**', 'authorLink' => 'http://francois.toto.com', 'pubDate' => '12345', 'comments' => 'this is foo bar baz', 'uniqueId' => 'hello world', 'enclosure' => $enclosure, 'categories' => array('foo', 'bar'));
$item = new sfFeedItem();
$t->isa_ok($item->initialize($item_params), 'sfFeedItem', 'initialize() returns the current feed item object');
$t->is($item->getTitle(), $item_params['title'], 'getTitle() gets the item title');
$t->is($item->getLink(), $item_params['link'], 'getLink() gets the item link');
$t->is($item->getDescription(), $item_params['description'], 'getDescription() gets the item description');
$t->is($item->getContent(), $item_params['content'], 'getContent() gets the item content');
$t->is($item->getAuthorName(), $item_params['authorName'], 'getAuthorName() gets the item author name');
$t->is($item->getAuthorEmail(), $item_params['authorEmail'], 'getAuthorEmail() gets the item author email');
$t->is($item->getAuthorLink(), $item_params['authorLink'], 'getAuthorLink() gets the item author link');
$t->is($item->getPubDate(), $item_params['pubDate'], 'getPubDate() gets the item publication date');
$t->is($item->getComments(), $item_params['comments'], 'getComments() gets the item comments');
$t->is($item->getUniqueId(), $item_params['uniqueId'], 'getUniqueId() gets the item unique id');
$t->is($item->getEnclosure(), $item_params['enclosure'], 'getEnclosure() gets the item enclosure');
$t->is($item->getCategories(), $item_params['categories'], 'getCategories() gets the item categories');
$item_params = array('title' => 'foo', 'link' => 'http://www.example.com', 'content' => 'hey, do you <strong>foo</strong>, my dear bar?');
$item = new sfFeedItem();
$item->initialize($item_params);
$t->is($item->getDescription(), strip_tags($item_params['content']), 'getDescription() gets the stripped item content when no description is defined');
sfConfig::set('app_feed_item_max_length', 5);
Example #25
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

/*
 * 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);
Example #27
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
$browser->get('/messages/index')->isStatusCode(200)->isRequestParameter('module', 'messages')->isRequestParameter('action', 'index')->checkResponseElement('body', '!/This is a temporary page/');
Example #28
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>');
Example #29
0
/*
 * 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';
$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()->
      }

      //get the diff between $tempSelectors and $selectors
      if (isset($tempSelectors))
      {
        $diff = array_diff_key($tempSelectors, $selectors);
        foreach ($diff as $diffKey => $selector)
        {
          $selector[$diffKey][1] = false;
        }
      }

      echo "\n==========\nTesting -- "  . $role . " :: " . $key . " Access :: " . $action . "\n";
      flush();

      $browser = new sfTestBrowser();
      $browser->initialize();

      if (isset($config['roles'][$role]['login']))
      {

        //$browser->setAuth($config['roles'][$role]['login'], $config['roles'][$role]['password']);
        //login as role
  //      $browser->
  //        get('/login')->
  //        isStatusCode(200);

        $browser->post('/login', array(
          'nickname' => $config['roles'][$role]['login'],
          'password' => $config['roles'][$role]['password'],
          'password_bis' => '',