From 51038b2901fbd4ecc8a527a9accb07dfaea08152 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 23 Sep 2017 14:54:58 +0200 Subject: [PATCH] minmod --- spec/build/api/core/RequestSpec.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/build/api/core/RequestSpec.php b/spec/build/api/core/RequestSpec.php index 7332de4..ab5849c 100644 --- a/spec/build/api/core/RequestSpec.php +++ b/spec/build/api/core/RequestSpec.php @@ -7,6 +7,7 @@ use api\core\Checker; use api\core\AuthSystem; use api\core\AuthSystemDefault; + use api\core\ModuleFactory; use error\core\Error; use error\core\Err; @@ -771,6 +772,25 @@ }); + it('fail when ModuleFactory have an error', function(){ + + // bypass constructor + allow(Request::class)->toReceive('buildRequestObject')->andRun(function(){ + $this->error = new Error(Err::UnknownError); + }); + + // bypass ModuleFactory + allow(ModuleFactory::class)->toReceive('::getModule')->andRun(function(){ + return new Error(Err::UnknownError); + }); + + $req = new Request(); + $res = $req->dispatch(); + expect($res)->toBeAnInstanceOf('\\api\\core\\Response'); + expect($res->error->get())->toBe(Err::UnknownError); + + }); + }); });