Skip to content

Commit d1c0179

Browse files
committed
Added unit test to has_errors on bound field
1 parent 37171ae commit d1c0179

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Forms/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function hasErrors($field_name)
258258
*/
259259
public function getFieldErrors(string $field_name)
260260
{
261-
if (!$this->hasError($field_name)) {
261+
if (!$this->hasErrors($field_name)) {
262262
return new ErrorList();
263263
}
264264

@@ -271,7 +271,7 @@ public function getFieldErrors(string $field_name)
271271
*/
272272
public function getNonFieldErrors()
273273
{
274-
if (!$this->hasError($this::NON_FIELD_ERRORS)) {
274+
if (!$this->hasErrors($this::NON_FIELD_ERRORS)) {
275275
return new ErrorList();
276276
}
277277

tests/unit/Fields/BoundFieldTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ public function testGetErrors()
5959
$this->assertInstanceOf(ErrorList::class, $bound->errors);
6060
}
6161

62+
public function testHasErrors()
63+
{
64+
$form = $this->getMockForAbstractClass(Form::class);
65+
$bound = new BoundField($form, $this->simple_field, "name");
66+
$this->assertFalse($bound->has_errors);
67+
}
68+
6269
public function testSimpleGet()
6370
{
6471
$form = $this->getMockForAbstractClass(Form::class);

0 commit comments

Comments
 (0)