public function testTriggersOnErrorCallableWithErrorWhenPresent()
{
$error = (object) ['error' => true];
$triggered = null;
$callback = function ($error, $request, $response) use(&$triggered) {
$triggered = func_get_args();
};
$final = new FinalHandler(['env' => 'production', 'onerror' => $callback]);
$response = $final($this->request, $this->response, $error);
$this->assertInternalType('array', $triggered);
$this->assertEquals(3, count($triggered));
$this->assertSame($error, array_shift($triggered));
$this->assertSame($this->request, array_shift($triggered));
$this->assertSame($response, array_shift($triggered));
}