Darkstarone
Darkstarone

Reputation: 4730

Symfony test get form errors

If I have a functional test like:

public function testCreate()
{

    $client = $this->makeClient();
    $crawler = $client->request('POST', "/post/new");

    $form = $crawler->selectButton("Create Post")->form();
    $values = $form->getPhpValues();

    $values['post']['title'] = 'test';
    $values['post']['content'] = null; // Should fail because it isn't a string.


    $crawler = $client->request($form->getMethod(), $form->getUri(), $values,
        $form->getPhpFiles());
    assertEquals() // What goes here?
}

How do I use the crawler to get the form errors and compare them?

Upvotes: 1

Views: 969

Answers (1)

xabbuh
xabbuh

Reputation: 5881

I see two possible solutions for you:

  1. Use the crawler to check for the actually rendered form errors in your rendered HTML code.
  2. Make use of the profiler and access the form data collector: http://symfony.com/doc/current/testing/profiling.html

Upvotes: 2

Related Questions