Skip to content

Instantly share code, notes, and snippets.

@haruta
Created September 5, 2012 05:16
Show Gist options
  • Save haruta/3630938 to your computer and use it in GitHub Desktop.
Save haruta/3630938 to your computer and use it in GitHub Desktop.
assert input field and value by symfony2 unit test
protected function assertInuptValue($crawler, $key, $val)
{
$input = $crawler->filter('input[name="'.$key.'"]');
$this->assertEquals(
$val, $input->attr('value'), $key.' failed'
);
}
protected function assertSelectValue($crawler, $key, $val)
{
$input = $crawler->filter('select[name="'.$key.'"]');
$selected_option = $input->filter('option[selected="selected"]');
$this->assertEquals($val, $selected_option->attr('value'), $key.' failed');
}
protected function assertTextAreaValue($crawler, $key, $val)
{
$input = $crawler->filter('textarea[name="'.$key.'"]');
$this->assertEquals(
$val, $input->text(), $key.' failed'
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment