TextareaFormFieldTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\DomCrawler\Field;
  11. require_once __DIR__.'/FormFieldTestCase.php';
  12. use Symfony\Component\DomCrawler\Field\TextareaFormField;
  13. class TextareaFormFieldTest extends FormFieldTestCase
  14. {
  15. public function testInitialize()
  16. {
  17. $node = $this->createNode('textarea', 'foo bar');
  18. $field = new TextareaFormField($node);
  19. $this->assertEquals('foo bar', $field->getValue(), '->initialize() sets the value of the field to the textarea node value');
  20. $node = $this->createNode('input', '');
  21. try {
  22. $field = new TextareaFormField($node);
  23. $this->fail('->initialize() throws a \LogicException if the node is not a textarea');
  24. } catch (\LogicException $e) {
  25. $this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea');
  26. }
  27. }
  28. }