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\InputFormField;
16 class InputFormFieldTest extends FormFieldTestCase
18 public function testInitialize()
20 $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
21 $field = new InputFormField($node);
23 $this->assertEquals('value', $field->getValue(), '->initialize() sets the value of the field to the value attribute value');
25 $node = $this->createNode('textarea', '');
27 $field = new InputFormField($node);
28 $this->fail('->initialize() throws a \LogicException if the node is not an input');
29 } catch (\LogicException $e) {
30 $this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input');
33 $node = $this->createNode('input', '', array('type' => 'checkbox'));
35 $field = new InputFormField($node);
36 $this->fail('->initialize() throws a \LogicException if the node is a checkbox');
37 } catch (\LogicException $e) {
38 $this->assertTrue(true, '->initialize() throws a \LogicException if the node is a checkbox');
41 $node = $this->createNode('input', '', array('type' => 'file'));
43 $field = new InputFormField($node);
44 $this->fail('->initialize() throws a \LogicException if the node is a file');
45 } catch (\LogicException $e) {
46 $this->assertTrue(true, '->initialize() throws a \LogicException if the node is a file');