FormFieldTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\InputFormField;
  13. class FormFieldTest extends FormFieldTestCase
  14. {
  15. public function testGetName()
  16. {
  17. $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
  18. $field = new InputFormField($node);
  19. $this->assertEquals('name', $field->getName(), '->getName() returns the name of the field');
  20. }
  21. public function testGetSetHasValue()
  22. {
  23. $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
  24. $field = new InputFormField($node);
  25. $this->assertEquals('value', $field->getValue(), '->getValue() returns the value of the field');
  26. $field->setValue('foo');
  27. $this->assertEquals('foo', $field->getValue(), '->setValue() sets the value of the field');
  28. $this->assertTrue($field->hasValue(), '->hasValue() always returns true');
  29. }
  30. }