public function test_captures_silenced_error() { $lambda = new CaptureErrors(function ($x) { @trigger_error($x); }); $lambda('foo'); $errors = $lambda->getCapturedErrors(); $this->assertSame(1, $errors->count()); $this->assertSame(5, count($errors[0])); $this->assertSame('foo', $errors[0]['message']); }
public function test_converts_with_customs() { $ex = new \Exception('Boom!', 242); // set up the conversion $convert = new ExceptionToError(function () use($ex) { throw $ex; return true; }); $convert->setErrorMessageFormat('xxx'); $convert->setErrorCode(E_USER_NOTICE); // capture $capture = new CaptureErrors($convert); $result = $capture(); // ensure we match on the custom values $this->assertSame('xxx', $capture->getCapturedErrors()->get(0)->get('message')); $this->assertSame(E_USER_NOTICE, $capture->getCapturedErrors()->get(0)->get('code')); }