@@ -39,14 +39,14 @@ public function testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor()
39
39
$ nodes = $ dom ->getElementsByTagName ('input ' );
40
40
41
41
try {
42
- $ form = new Form ($ nodes ->item (0 ), 'http://example.com ' );
42
+ new Form ($ nodes ->item (0 ), 'http://example.com ' );
43
43
$ this ->fail ('__construct() throws a \\LogicException if the node has no form ancestor ' );
44
44
} catch (\LogicException $ e ) {
45
45
$ this ->assertTrue (true , '__construct() throws a \\LogicException if the node has no form ancestor ' );
46
46
}
47
47
48
48
try {
49
- $ form = new Form ($ nodes ->item (1 ), 'http://example.com ' );
49
+ new Form ($ nodes ->item (1 ), 'http://example.com ' );
50
50
$ this ->fail ('__construct() throws a \\LogicException if the input type is not submit, button, or image ' );
51
51
} catch (\LogicException $ e ) {
52
52
$ this ->assertTrue (true , '__construct() throws a \\LogicException if the input type is not submit, button, or image ' );
@@ -55,19 +55,27 @@ public function testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor()
55
55
$ nodes = $ dom ->getElementsByTagName ('button ' );
56
56
57
57
try {
58
- $ form = new Form ($ nodes ->item (0 ), 'http://example.com ' );
58
+ new Form ($ nodes ->item (0 ), 'http://example.com ' );
59
59
$ this ->fail ('__construct() throws a \\LogicException if the node has no form ancestor ' );
60
60
} catch (\LogicException $ e ) {
61
61
$ this ->assertTrue (true , '__construct() throws a \\LogicException if the node has no form ancestor ' );
62
62
}
63
63
}
64
64
65
65
/**
66
- * __construct() should throw \\LogicException if the form attribute is invalid.
66
+ * @dataProvider constructorThrowsExceptionIfNoRelatedFormProvider
67
+ *
68
+ * __construct() should throw a \LogicException if the form attribute is invalid.
67
69
*/
68
- public function testConstructorThrowsExceptionIfNoRelatedForm ()
70
+ public function testConstructorThrowsExceptionIfNoRelatedForm (\ DOMElement $ node )
69
71
{
70
72
$ this ->expectException ('LogicException ' );
73
+
74
+ new Form ($ node , 'http://example.com ' );
75
+ }
76
+
77
+ public function constructorThrowsExceptionIfNoRelatedFormProvider ()
78
+ {
71
79
$ dom = new \DOMDocument ();
72
80
$ dom ->loadHTML ('
73
81
<html>
@@ -81,8 +89,10 @@ public function testConstructorThrowsExceptionIfNoRelatedForm()
81
89
82
90
$ nodes = $ dom ->getElementsByTagName ('input ' );
83
91
84
- $ form = new Form ($ nodes ->item (0 ), 'http://example.com ' );
85
- $ form = new Form ($ nodes ->item (1 ), 'http://example.com ' );
92
+ return [
93
+ [$ nodes ->item (0 )],
94
+ [$ nodes ->item (1 )],
95
+ ];
86
96
}
87
97
88
98
public function testConstructorLoadsOnlyFieldsOfTheRightForm ()
0 commit comments