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); + + }); + }); });