Skip to content

Commit 6bd447a

Browse files
author
Christian Leucht
committed
Form // fix handling of isValid when the Form has errors. Add missing method mock in FormTest::testIsValid().
1 parent 699c974 commit 6bd447a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Element/Form.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ public function isValid(): bool
124124

125125
// Either on "submit" we have erroneous Elements, or the
126126
// Form itself has errors assigned through Form::withErrors().
127-
return $this->hasErrors() || $this->isValid;
127+
if ($this->hasErrors()) {
128+
return false;
129+
}
130+
131+
return $this->isValid;
128132
}
129133

130134
/**

tests/phpunit/Unit/Element/FormTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public function testIsValid(): void
6161
->andReturn($expected_value);
6262
$element->allows('withErrors')
6363
->with($expected_error);
64+
$element->allows('hasErrors')
65+
->andReturnTrue();
6466
$element->allows('validate')
6567
->andReturnFalse();
6668

0 commit comments

Comments
 (0)