Fix ErrorHandler sliceErrors not returning errors

Signed-off-by: Craig McNeill <craig@mmddata.ca>
This commit is contained in:
Craig McNeill 2021-08-18 14:40:52 -04:00
parent 7b77d07622
commit af835bc52c
2 changed files with 12 additions and 6 deletions

View File

@ -160,7 +160,7 @@ class ErrorHandler
$errors = $this->getErrors(false);
$this->errors = array_splice($errors, 0, $count);
return array_splice($errors, $count);
return $errors;
}
/**

View File

@ -181,6 +181,12 @@ class ErrorHandlerTest extends AbstractTestCase
*/
public function testSliceErrors(): void
{
$this->object->addError(
'Compile Error',
E_WARNING,
'error.txt',
15
);
$this->object->addError(
'Compile Error',
E_WARNING,
@ -188,23 +194,23 @@ class ErrorHandlerTest extends AbstractTestCase
15
);
$this->assertEquals(
1,
2,
$this->object->countErrors()
);
$this->assertEquals(
[],
$this->object->sliceErrors(1)
$this->object->sliceErrors(2)
);
$this->assertEquals(
1,
2,
$this->object->countErrors()
);
$this->assertCount(
1,
$this->object->sliceErrors(0)
$this->object->sliceErrors(1)
);
$this->assertEquals(
0,
1,
$this->object->countErrors()
);
}