Author: weaverryan
Date: 2010-01-23 07:49:00 +0100 (Sat, 23 Jan 2010)
New Revision: 27085
Modified:
plugins/sfSympalPlugin/trunk/test/bootstrap/functional.php
plugins/sfSympalPlugin/trunk/test/fixtures/project/data/fresh_test_db.sqlite
plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php
Log:
[1.4][sfSympalPlugin][1.0] updating the Comments test for new changes made to
the comments plugin. Also, moved the app.yml
cleanup to before the bootstrap - after the bootstrap it seemed to cause
inconsistent loads - some test runs ran differently
than others. The test db was updated for the new columns for the comments model.
Modified: plugins/sfSympalPlugin/trunk/test/bootstrap/functional.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/bootstrap/functional.php 2010-01-23
05:43:18 UTC (rev 27084)
+++ plugins/sfSympalPlugin/trunk/test/bootstrap/functional.php 2010-01-23
06:49:00 UTC (rev 27085)
@@ -5,10 +5,11 @@
$app = 'sympal';
}
+require_once(dirname(__FILE__).'/cleanup.php');
+
require_once
dirname(__FILE__).'/../fixtures/project/config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration($app,
'test', isset($debug) ? $debug : true);
-require_once(dirname(__FILE__).'/cleanup.php');
require_once(sfConfig::get('sf_lib_dir').'/sfSympalTestFunctional.class.php');
sfContext::createInstance($configuration);
Modified:
plugins/sfSympalPlugin/trunk/test/fixtures/project/data/fresh_test_db.sqlite
===================================================================
(Binary files differ)
Modified: plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php
===================================================================
--- plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php
2010-01-23 05:43:18 UTC (rev 27084)
+++ plugins/sfSympalPlugin/trunk/test/functional/CommentsTest.php
2010-01-23 06:49:00 UTC (rev 27085)
@@ -1,27 +1,126 @@
<?php
+/**
+ * Functional testing for sfSympalCommentsPlugin
+ *
+ * @author Jon Wage <[email protected]>
+ * @author Ryan Weaver <[email protected]>
+ * @since 2010-01-22
+ * @version svn:$Id$ $Author$
+ */
require_once(dirname(__FILE__).'/../bootstrap/functional.php');
$browser = new sfSympalTestFunctional(new sfBrowser());
+$browser->setTester('doctrine', 'sfTesterDoctrine');
-$browser->
+$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(
- 'subject' => 'Test',
- 'body' => 'Test',
- )), array('_with_csrf' => true))
+ '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()->
- isRedirected()->
- followRedirect()->
+ 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' => '[email protected]',
+ 'body' => 'just another test comment',
+);
+$browser->info('2 - Post some comments anonymously')->
+ signOut()->
+
+ get('/blog-post/sample_blogpost')->
+
with('response')->begin()->
- matches('/comment_1/')->
- matches('/Posted on (.*) by Sympal Admin./')->
+ 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()
;
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.