diff --git a/src/Exceptions/SnapshotDataIncomplete.php b/src/Exceptions/SnapshotDataIncomplete.php new file mode 100644 index 0000000..d61b7a8 --- /dev/null +++ b/src/Exceptions/SnapshotDataIncomplete.php @@ -0,0 +1,10 @@ +repository->create($event->getData()); + $data = $event->getData(); + if (!array_key_exists('trace', $data)) { + throw new SnapshotDataIncomplete; + } + $this->repository->create($data); } } diff --git a/tests/Unit/Events/SnapshotCapturedTest.php b/tests/Unit/Events/SnapshotCapturedTest.php index 1eea6b9..7d268e1 100644 --- a/tests/Unit/Events/SnapshotCapturedTest.php +++ b/tests/Unit/Events/SnapshotCapturedTest.php @@ -19,6 +19,17 @@ public function testCaptureSnapshot($data) $this->app->instance('Matthewbdaly\LaravelErrorSnapshot\Contracts\Repositories\Snapshot', $repo); event(new SnapshotCaptured($data)); } + /** + * @dataProvider dataProvider + * @expectedException Matthewbdaly\LaravelErrorSnapshot\Exceptions\SnapshotDataIncomplete + */ + public function testCaptureSnapshotIncompleteData($data) + { + unset($data['trace']); + $repo = m::mock('Matthewbdaly\LaravelErrorSnapshot\Contracts\Repositories\Snapshot'); + $this->app->instance('Matthewbdaly\LaravelErrorSnapshot\Contracts\Repositories\Snapshot', $repo); + event(new SnapshotCaptured($data)); + } public function dataProvider() {