Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (68 sloc) 2.79 KB


test your symfony forms painless


git (recommend): git clone

svn: svn co

pear: symfony plugin install rsFormTesterPlugin

enable the plugin in your config/ProjectConfiguration.class.php !


  unset: [foo, bazz/foo, bazz/bazz/bar]
  options: {foo: bar, bazz: foo}
  arguments: {foo: bazz}
  withSave: true
  formClass: fooForm
  verbose: true

    _options: {foo: false, bazz: bar}
    _arguments: {foo: foo}
    foo: bar
    bar: bazz
      bar: foo
      foo: bar
  # ...
    _expectedErrors: [foo, bazz, bazz/bar]
    bar: bazz
      foo: bar
  # ...
  • The unset options unsets specific widgets (i.e. captchas)

  • The formClass option defines which form the tester should instanciate.

  • The options defines a set of options passed to the form instanciation, can be overriden per set

  • The arguments defines a set of arguments passed to the form instanciation, can be overriden per set

  • The withSave option tests the invokation of sfForm::save.

  • The verbose option enables more detailed information on each test (recommended)

  • The pass options holds all different datasets which should pass the form validation.

  • The fail options holds all different datasets which should fail the form validation. the _expectedErrors options defines the errors you expect from the form. the verbose will show other errors as well.

Notice the foo/bar/bazz notation, thats how you define errors in embedded forms.


in your tests you are able to use the tester this way:

/* @var $t lime_test */

$tester = rsFormTester::create('path/to/config.yml');
$tester->testData($t);         #for both set
$tester->testData($t,'valid'); # for valid sets only
$tester->testData($t,'invalid'); # for invalid sets only

//or the short way
$tester = rsFormTester::create('path/to/config.yml')->testData($t);

Dont forget to increase the test count if you defined one!

If you will you can pass an already instanciated form to the tester (before runnning your tests)

$form = new FooBarForm($object,array('special_option'=>'foo'),array('special_arg'=>'bar'));

//go on with your tests

That's it! All the different sets of data will be iterated and compared to what you expect


  • remove dependency to lime