rsFormTesterPlugin - 0.9.0

this plugin lets you test symfony forms with ease

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
rsFormTesterPlugin 0.9.0beta for sf 1.2 MIT
Plugin image
1
user
Sign-in
to change
your status

tests symfony forms against different sets of data

rsFormTesterPlugin

test your symfony forms painless

Installation

git (recommend): git clone git@github.com:digitalkaoz/rsFormTesterPlugin.git

svn: svn co http://svn.github.com/digitalkaoz/rsFormTesterPlugin.git

pear: symfony plugin install rsFormTesterPlugin

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

Configuration

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

pass:
  -
    _ options: {foo: false, bazz: bar}
    _ arguments: {foo: foo}
    foo: bar
    bar: bazz
    bazz:
      bar: foo
      foo: bar
  # ...
fail:
  -
    _expectedErrors: [foo, bazz, bazz/bar]
    foo:
    bar: bazz
    bazz:
      bar:
      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.

Usage

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'));
$tester->setForm($form);

//go on with your tests

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

TODO

  • remove dependency to lime

Developers

Name Status Email
gravatar Robert Schönthal lead ten.xmg <<ta>> leizac

License

Show source

Copyright (c) 2010 Robert Schönthal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.