Ejemplo n.º 1
0
<?php

/**
 * Functional testing for sfSympalCommentsPlugin
 * 
 * @author      Jon Wage <*****@*****.**>
 * @author      Ryan Weaver <*****@*****.**>
 * @since       2010-01-22
 * @version     svn:$Id$ $Author$
 */
require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$browser = new sfSympalTestFunctional(new sfBrowser());
$browser->setTester('doctrine', 'sfTesterDoctrine');
$goodValues = array('website' => 'http://www.sympalphp.org', 'body' => 'Hey, nice test comment!');
$browser->info('1 - Sign in and post some comments')->signInAsAdmin()->get('/blog-post/sample_blogpost')->with('response')->begin()->isStatusCode(200)->checkElement('#sympal_comments', true)->checkForm('sfSympalNewCommentForm')->end()->info('  1.1 - Submit a bad form, count the errors')->click('Save Comment', array('sf_sympal_comment' => array('website' => 'bad site')))->with('form')->begin()->hasErrors(2)->isError('body', 'required')->isError('website', 'invalid')->end()->click('Save Comment', array('sf_sympal_comment' => $goodValues))->with('form')->begin()->hasErrors(0)->end()->with('request')->begin()->isParameter('module', 'sympal_comments')->isParameter('action', 'create')->end();
Doctrine_Core::getTable('sfSympalBlogPost')->getConnection()->clear();
$sympalAdmin = Doctrine_Core::getTable('sfGuardUser')->findOneByUsername('admin');
$browser->with('response')->isRedirected()->followRedirect()->with('response')->begin()->matches('/comment_1/')->matches('/Posted on (.*) by/')->info('  1.2 - Check that the website is surrounded by a nofollow')->checkElement('a[rel="nofollow"][href="' . $goodValues['website'] . '"]', '/Sympal Admin/')->end()->with('doctrine')->begin()->check('sfSympalComment', array_merge($goodValues, array('user_id' => $sympalAdmin->id)))->end();
$goodValues = array('email_address' => '*****@*****.**', 'body' => 'just another test comment');
$browser->info('2 - Post some comments anonymously')->signOut()->get('/blog-post/sample_blogpost')->with('response')->begin()->isStatusCode(200)->checkElement('#sympal_comments', true)->checkForm('sfSympalNewCommentForm')->end()->info('  2.1 - Submit a bad form, count the errors')->click('Save Comment')->with('form')->begin()->hasErrors(2)->isError('body', 'required')->isError('email_address', 'required')->end()->click('Save Comment', array('sf_sympal_comment' => $goodValues))->with('form')->begin()->hasErrors(0)->end()->with('request')->begin()->isParameter('module', 'sympal_comments')->isParameter('action', 'create')->end();
Doctrine_Core::getTable('sfSympalBlogPost')->getConnection()->clear();
$browser->with('response')->isRedirected()->followRedirect()->with('response')->begin()->matches('/comment_2/')->matches('/Posted on (.*) by[\\s]+ anonymous\\./')->end()->with('doctrine')->begin()->check('sfSympalComment', $goodValues)->end();
Ejemplo n.º 2
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/functional.php';
$browser = new sfSympalTestFunctional(new sfBrowser());
$browser->signInAsAdmin();
$browser->get('/test/ask_confirmation')->click('Yes')->with('request')->begin()->isParameter('sympal_ask_confirmation', 1)->isParameter('yes', 'Yes')->end()->with('response')->begin()->matches('/Ok!/')->end()->get('/admin/dashboard')->get('/test/ask_confirmation')->click('No')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_dashboard')->isParameter('action', 'index')->end();
$browser->get('/test/forward_to_route')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'route_to_forward_to')->isParameter('param1', 'value1')->isParameter('param2', 'value2')->end();
$browser->get('/test/forward_to_route2')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'route_to_forward_to')->isParameter('param1', 'value1')->isParameter('param2', 'value2')->end();
$browser->get('/test/start_go_back')->get('/test/go_back')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'start_go_back')->end();
$browser->get('/test/change_layout');
$response = $browser->getResponse();
$stylesheets = $response->getStylesheets();
$browser->test()->is(isset($stylesheets['test']), true);
$browser->with('response')->begin()->matches('/Test Layout/')->end();