Skip to content

Commit 6bcffd2

Browse files
committed
Remove unused local variables in tests
1 parent 29cffc3 commit 6bcffd2

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

Tests/Field/ChoiceFormFieldTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ public function testInitialize()
1919
{
2020
$node = $this->createNode('textarea', '');
2121
try {
22-
$field = new ChoiceFormField($node);
22+
new ChoiceFormField($node);
2323
$this->fail('->initialize() throws a \LogicException if the node is not an input or a select');
2424
} catch (\LogicException $e) {
2525
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input or a select');
2626
}
2727

2828
$node = $this->createNode('input', '', ['type' => 'text']);
2929
try {
30-
$field = new ChoiceFormField($node);
30+
new ChoiceFormField($node);
3131
$this->fail('->initialize() throws a \LogicException if the node is an input with a type different from checkbox or radio');
3232
} catch (\LogicException $e) {
3333
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is an input with a type different from checkbox or radio');

Tests/Field/FileFormFieldTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public function testInitialize()
2424

2525
$node = $this->createNode('textarea', '');
2626
try {
27-
$field = new FileFormField($node);
27+
new FileFormField($node);
2828
$this->fail('->initialize() throws a \LogicException if the node is not an input field');
2929
} catch (\LogicException $e) {
3030
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input field');
3131
}
3232

3333
$node = $this->createNode('input', '', ['type' => 'text']);
3434
try {
35-
$field = new FileFormField($node);
35+
new FileFormField($node);
3636
$this->fail('->initialize() throws a \LogicException if the node is not a file input field');
3737
} catch (\LogicException $e) {
3838
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a file input field');

Tests/Field/InputFormFieldTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ public function testInitialize()
2424

2525
$node = $this->createNode('textarea', '');
2626
try {
27-
$field = new InputFormField($node);
27+
new InputFormField($node);
2828
$this->fail('->initialize() throws a \LogicException if the node is not an input');
2929
} catch (\LogicException $e) {
3030
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not an input');
3131
}
3232

3333
$node = $this->createNode('input', '', ['type' => 'checkbox']);
3434
try {
35-
$field = new InputFormField($node);
35+
new InputFormField($node);
3636
$this->fail('->initialize() throws a \LogicException if the node is a checkbox');
3737
} catch (\LogicException $e) {
3838
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is a checkbox');
3939
}
4040

4141
$node = $this->createNode('input', '', ['type' => 'file']);
4242
try {
43-
$field = new InputFormField($node);
43+
new InputFormField($node);
4444
$this->fail('->initialize() throws a \LogicException if the node is a file');
4545
} catch (\LogicException $e) {
4646
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is a file');

Tests/Field/TextareaFormFieldTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testInitialize()
2424

2525
$node = $this->createNode('input', '');
2626
try {
27-
$field = new TextareaFormField($node);
27+
new TextareaFormField($node);
2828
$this->fail('->initialize() throws a \LogicException if the node is not a textarea');
2929
} catch (\LogicException $e) {
3030
$this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea');

Tests/FormTest.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public function testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor()
3939
$nodes = $dom->getElementsByTagName('input');
4040

4141
try {
42-
$form = new Form($nodes->item(0), 'http://example.com');
42+
new Form($nodes->item(0), 'http://example.com');
4343
$this->fail('__construct() throws a \\LogicException if the node has no form ancestor');
4444
} catch (\LogicException $e) {
4545
$this->assertTrue(true, '__construct() throws a \\LogicException if the node has no form ancestor');
4646
}
4747

4848
try {
49-
$form = new Form($nodes->item(1), 'http://example.com');
49+
new Form($nodes->item(1), 'http://example.com');
5050
$this->fail('__construct() throws a \\LogicException if the input type is not submit, button, or image');
5151
} catch (\LogicException $e) {
5252
$this->assertTrue(true, '__construct() throws a \\LogicException if the input type is not submit, button, or image');
@@ -55,19 +55,27 @@ public function testConstructorThrowsExceptionIfTheNodeHasNoFormAncestor()
5555
$nodes = $dom->getElementsByTagName('button');
5656

5757
try {
58-
$form = new Form($nodes->item(0), 'http://example.com');
58+
new Form($nodes->item(0), 'http://example.com');
5959
$this->fail('__construct() throws a \\LogicException if the node has no form ancestor');
6060
} catch (\LogicException $e) {
6161
$this->assertTrue(true, '__construct() throws a \\LogicException if the node has no form ancestor');
6262
}
6363
}
6464

6565
/**
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.
6769
*/
68-
public function testConstructorThrowsExceptionIfNoRelatedForm()
70+
public function testConstructorThrowsExceptionIfNoRelatedForm(\DOMElement $node)
6971
{
7072
$this->expectException('LogicException');
73+
74+
new Form($node, 'http://example.com');
75+
}
76+
77+
public function constructorThrowsExceptionIfNoRelatedFormProvider()
78+
{
7179
$dom = new \DOMDocument();
7280
$dom->loadHTML('
7381
<html>
@@ -81,8 +89,10 @@ public function testConstructorThrowsExceptionIfNoRelatedForm()
8189

8290
$nodes = $dom->getElementsByTagName('input');
8391

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+
];
8696
}
8797

8898
public function testConstructorLoadsOnlyFieldsOfTheRightForm()

0 commit comments

Comments
 (0)