193d301de691ea003d9145f6c8226a6618f178c9
[yaffs-website] / vendor / symfony / dom-crawler / Tests / Field / InputFormFieldTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DomCrawler\Tests\Field;
13
14 use Symfony\Component\DomCrawler\Field\InputFormField;
15
16 class InputFormFieldTest extends FormFieldTestCase
17 {
18     public function testInitialize()
19     {
20         $node = $this->createNode('input', '', array('type' => 'text', 'name' => 'name', 'value' => 'value'));
21         $field = new InputFormField($node);
22
23         $this->assertEquals('value', $field->getValue(), '->initialize() sets the value of the field to the value attribute value');
24
25         $node = $this->createNode('textarea', '');
26         try {
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');
31         }
32
33         $node = $this->createNode('input', '', array('type' => 'checkbox'));
34         try {
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');
39         }
40
41         $node = $this->createNode('input', '', array('type' => 'file'));
42         try {
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');
47         }
48     }
49 }