1

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?

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for that - I'll go with 1, I assume I'll have to use filter and there's not a shortcut?
Yes, just use filter() like you do it otherwise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.