Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Created August 12, 2011 13:12
Show Gist options
  • Select an option

  • Save robertbasic/1142003 to your computer and use it in GitHub Desktop.

Select an option

Save robertbasic/1142003 to your computer and use it in GitHub Desktop.
Unit testing symfony2 forms
<?php
class ContactTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
$ext = new CoreExtension();
$message = new Message();
$factory = new FormFactory(array(
$ext
));
$this->form = $factory->create(new Contact(), $message);
}
public function testFormNameIsContact()
{
$this->assertEquals('contact', $this->form->getName());
}
public function testFormHasAllTheFields()
{
$this->assertTrue($this->form->has('name'));
$this->assertTrue($this->form->has('email'));
$this->assertTrue($this->form->has('subject'));
$this->assertTrue($this->form->has('message'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment