title: PHPUnit DataProvider for functional test in symfony2
body: <p>I am trying to do a functional test on a form as following</p>
  
  <p>// happy scenario</p>
  
  <pre><code>public function testRegisterActionInvalidCase($password, $confPassword, $gender, $country, $city, $schoo, $schoolName, $shortName, $keyWords, $expectedMessage) {
      $user = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_userService, 'FOS\UserBundle\Model\User');
      $token = $user-&gt;getConfirmationToken();
      $url = $this-&gt;generateUrl('teacher_register', array('token' =&gt; $token));
      $crawler = $this-&gt;client-&gt;request('POST', $url);
      $crawlerResponse = $this-&gt;client-&gt;getResponse();
  
      //[ASSERTIONS] Page is loaded ok
      $this-&gt;assertEquals(200, $crawlerResponse-&gt;getStatusCode());
      //[ASSERTIONS] that the loaded page is the correct one
      $this-&gt;assertContains($this-&gt;Translator-&gt;trans('Teacher Registration'), $this-&gt;client-&gt;getResponse()-&gt;getContent());
      $form = $crawler-&gt;selectButton('Save')-&gt;form();
      $confPassword = $password = $this-&gt;Faker-&gt;password();
  
      if ($gender === 'GENDER') {
          $gender = $this-&gt;Faker-&gt;randomElement([Gender::FEMALE, Gender::MALE]);
      }
      if ($gender === 'COUNTRY') {
          $country = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_countryService, '\ITJari\GeneralBundle\Entity\Country');
      }
      if ($gender === 'CITY') {
          $city = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_cityService, '\ITJari\GeneralBundle\Entity\City');
      }
      if ($gender === 'SCHOOL') {
          $schoo = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_schoolService, '\ITJari\SchoolBundle\Entity\School');
      }
  
      // fill in the form to be submitted
      $form["plainPassword['first']"] = $password;
      $form["plainPassword['second']"] = $confPassword;
      $form["gender"] = $gender;
      $form["country"] = $country;
      $form["city"] = $city;
      $form["school"] = $schoo;
      $form["school_name"] = $schoolName;
      $form["short_name"] = $shortName;
      $form["key_words"] = $keyWords;
      $crawler = $this-&gt;client-&gt;submit($form);
      //[ASSERTIONS] that the form submitted successfully
      $this-&gt;assertTrue($crawler-&gt;filter('html:contains("Teacher has been created successfully")')-&gt;count() &gt; 0);
  }
  </code></pre>
  
  <p>//invalid case
  How can i use data provider to test invalid case for functional test?
  here is my try:</p>
  
  <pre><code> /** 
   * @dataProvider provideDataForRegistrationActionInvalidCase
   * @assertions Assert for exception asserted on "exception message"
   * 
   */
  public function testRegisterActionInvalidCase($password, $confPassword, $gender, $country, $city, $schoo, $schoolName, $shortName, $keyWords, $expectedMessage) {
      $user = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_userService, 'FOS\UserBundle\Model\User');
      $token = $user-&gt;getConfirmationToken();
      $url = $this-&gt;generateUrl('teacher_register', array('token' =&gt; $token));
      $crawler = $this-&gt;client-&gt;request('POST', $url);
      $crawlerResponse = $this-&gt;client-&gt;getResponse();
  
      //[ASSERTIONS] Page is loaded ok
      $this-&gt;assertEquals(200, $crawlerResponse-&gt;getStatusCode());
      //[ASSERTIONS] that the loaded page is the correct one
      $this-&gt;assertContains($this-&gt;Translator-&gt;trans('Teacher Registration'), $this-&gt;client-&gt;getResponse()-&gt;getContent());
      $form = $crawler-&gt;selectButton('Save')-&gt;form();
      $confPassword = $password = $this-&gt;Faker-&gt;password();
  
      if ($gender === 'GENDER') {
          $gender = $this-&gt;Faker-&gt;randomElement([Gender::FEMALE, Gender::MALE]);
      }
      if ($gender === 'COUNTRY') {
          $country = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_countryService, '\ITJari\GeneralBundle\Entity\Country');
      }
      if ($gender === 'CITY') {
          $city = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_cityService, '\ITJari\GeneralBundle\Entity\City');
      }
      if ($gender === 'SCHOOL') {
          $schoo = $this-&gt;_testUtilityService-&gt;getRandomEntity($this-&gt;_schoolService, '\ITJari\SchoolBundle\Entity\School');
      }
  
      // fill in the form to be submitted
      $form["plainPassword['first']"] = $password;
      $form["plainPassword['second']"] = $confPassword;
      $form["gender"] = $gender;
      $form["country"] = $country;
      $form["city"] = $city;
      $form["school"] = $schoo;
      $form["school_name"] = $schoolName;
      $form["short_name"] = $shortName;
      $form["key_words"] = $keyWords;
      $crawler = $this-&gt;client-&gt;submit($form);
      //[ASSERTIONS] that the form submitted successfully
      $this-&gt;assertTrue($crawler-&gt;filter('html:contains("Teacher has been created successfully")')-&gt;count() &gt; 0);
  }
  
  /**
   * @description prepare data to be used as providers for test cases
   * @author Mohamed Ragab Dahab &lt;mdahab@treze.co.uk&gt;
   * @access public
   * 
   * @covers TeacherService::submitSubscriptionFormData
   * 
   * @return array arguments array passed to each test case scenario 
   */
  public function provideDataForRegistrationActionInvalidCase() {
      [
          //password
          ["password", "differentPassword", 'GENDER', 'COUNTRY', 'CITY', 'SCHOOL', 'my school name', 'my short  name', 'my key words', 'password does not match'],
          //Gender
          ["password", "password", 'invalid value', 'COUNTRY', 'CITY', 'SCHOOL', 'my school name', 'my short  name', 'my key words', 'Gender invalid value'],
          //Country
          ["password", "password", 'GENDER', 'invalid value', 'CITY', 'SCHOOL', 'my school name', 'my short  name', 'my key words', 'Country Invalid value'],
          //City
          ["password", "password", 'GENDER', 'COUNTRY', 'invalid value', 'SCHOOL', 'my school name', 'my short  name', 'my key words', 'City Invalid value'],
          //School
          ["password", "password", 'GENDER', 'COUNTRY', 'CITY', 'invalid value', 'my school name', 'my short  name', 'my key words', 'School Invalid value'],
          // School Name
          ["password", "password", 'GENDER', 'COUNTRY', 'CITY', 'SCHOOL', '112233Invalid Value', 'my short  name', 'my key words', 'School name invalid value'],
          // Short Name
          ["password", "password", 'GENDER', 'COUNTRY', 'CITY', 'SCHOOL', 'my school name', '112233Invalid Value', 'my key words', 'Short name invalid value'],
          // Key Words
          ["password", "password", 'GENDER', 'COUNTRY', 'CITY', 'SCHOOL', 'my school name', 'my short  name', 'TOO_MUCH_TEXT', 'Too much text'],
      ];
  }
  </code></pre>
  
  <p>however i don't know how to assign the form validation message to using the data provider</p>