You are here

public function FormTest::testGetSetValue in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/dom-crawler/Tests/FormTest.php \Symfony\Component\DomCrawler\Tests\FormTest::testGetSetValue()

File

vendor/symfony/dom-crawler/Tests/FormTest.php, line 323

Class

FormTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testGetSetValue() {
  $form = $this
    ->createForm('<form><input type="text" name="foo" value="foo" /><input type="submit" /></form>');
  $this
    ->assertEquals('foo', $form['foo']
    ->getValue(), '->offsetGet() returns the value of a form field');
  $form['foo'] = 'bar';
  $this
    ->assertEquals('bar', $form['foo']
    ->getValue(), '->offsetSet() changes the value of a form field');
  try {
    $form['foobar'] = 'bar';
    $this
      ->fail('->offsetSet() throws an \\InvalidArgumentException exception if the field does not exist');
  } catch (\InvalidArgumentException $e) {
    $this
      ->assertTrue(true, '->offsetSet() throws an \\InvalidArgumentException exception if the field does not exist');
  }
  try {
    $form['foobar'];
    $this
      ->fail('->offsetSet() throws an \\InvalidArgumentException exception if the field does not exist');
  } catch (\InvalidArgumentException $e) {
    $this
      ->assertTrue(true, '->offsetSet() throws an \\InvalidArgumentException exception if the field does not exist');
  }
}