4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DomCrawler\Tests\Field;
14 use Symfony\Component\DomCrawler\Field\TextareaFormField;
16 class TextareaFormFieldTest extends FormFieldTestCase
18 public function testInitialize()
20 $node = $this->createNode('textarea', 'foo bar');
21 $field = new TextareaFormField($node);
23 $this->assertEquals('foo bar', $field->getValue(), '->initialize() sets the value of the field to the textarea node value');
25 $node = $this->createNode('input', '');
27 $field = new TextareaFormField($node);
28 $this->fail('->initialize() throws a \LogicException if the node is not a textarea');
29 } catch (\LogicException $e) {
30 $this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea');
33 // Ensure that valid HTML can be used on a textarea.
34 $node = $this->createNode('textarea', 'foo bar <h1>Baz</h1>');
35 $field = new TextareaFormField($node);
37 $this->assertEquals('foo bar <h1>Baz</h1>', $field->getValue(), '->initialize() sets the value of the field to the textarea node value');
39 // Ensure that we don't do any DOM manipulation/validation by passing in
41 $node = $this->createNode('textarea', 'foo bar <h1>Baz</h2>');
42 $field = new TextareaFormField($node);
44 $this->assertEquals('foo bar <h1>Baz</h2>', $field->getValue(), '->initialize() sets the value of the field to the textarea node value');