This commit is contained in:
xdrm-brackets 2017-09-23 14:54:58 +02:00
parent ce9fa0705c
commit 51038b2901
1 changed files with 20 additions and 0 deletions

View File

@ -7,6 +7,7 @@
use api\core\Checker; use api\core\Checker;
use api\core\AuthSystem; use api\core\AuthSystem;
use api\core\AuthSystemDefault; use api\core\AuthSystemDefault;
use api\core\ModuleFactory;
use error\core\Error; use error\core\Error;
use error\core\Err; 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);
});
}); });
}); });