FormFieldTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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\Component\DomCrawler\Tests\Field;
  11. use Symfony\Component\DomCrawler\Field\InputFormField;
  12. class FormFieldTest extends FormFieldTestCase
  13. {
  14. public function testGetName()
  15. {
  16. $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
  17. $field = new InputFormField($node);
  18. $this->assertEquals('name', $field->getName(), '->getName() returns the name of the field');
  19. }
  20. public function testGetSetHasValue()
  21. {
  22. $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
  23. $field = new InputFormField($node);
  24. $this->assertEquals('value', $field->getValue(), '->getValue() returns the value of the field');
  25. $field->setValue('foo');
  26. $this->assertEquals('foo', $field->getValue(), '->setValue() sets the value of the field');
  27. $this->assertTrue($field->hasValue(), '->hasValue() always returns true');
  28. }
  29. }