additional binding for tests
This commit is contained in:
@@ -32,6 +32,7 @@ namespace tests\integration\Core;
|
||||
use Espo\Core\Api\RequestWrapper;
|
||||
use Espo\Core\Api\ResponseWrapper;
|
||||
use Espo\Core\Application;
|
||||
use Espo\Core\Binding\BindingProcessor;
|
||||
use Espo\Core\Container;
|
||||
use Espo\Core\DataManager;
|
||||
use Espo\Core\InjectableFactory;
|
||||
@@ -75,9 +76,18 @@ abstract class BaseTestCase extends TestCase
|
||||
*/
|
||||
protected $initData = null;
|
||||
|
||||
protected function createApplication(bool $clearCache = true, ?string $portalId = null): Application
|
||||
{
|
||||
return $this->espoTester->getApplication(true, $clearCache, $portalId);
|
||||
protected function createApplication(
|
||||
bool $clearCache = true,
|
||||
?string $portalId = null,
|
||||
?BindingProcessor $binding = null,
|
||||
): Application {
|
||||
|
||||
return $this->espoTester->getApplication(
|
||||
reload: true,
|
||||
clearCache: $clearCache,
|
||||
portalId: $portalId,
|
||||
binding: $binding,
|
||||
);
|
||||
}
|
||||
|
||||
protected function setApplication(Application $application): void
|
||||
|
||||
@@ -34,6 +34,9 @@ use Espo\Core\Authentication\Authentication;
|
||||
use Espo\Core\Authentication\AuthenticationData;
|
||||
|
||||
use Espo\Core\Application;
|
||||
use Espo\Core\Binding\BindingProcessor;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\ORM\DatabaseParamsFactory;
|
||||
use Espo\Core\Portal\Application as PortalApplication;
|
||||
@@ -190,7 +193,8 @@ class Tester
|
||||
public function getApplication(
|
||||
bool $reload = false,
|
||||
bool $clearCache = true,
|
||||
?string $portalId = null
|
||||
?string $portalId = null,
|
||||
?BindingProcessor $binding = null,
|
||||
): Application {
|
||||
|
||||
$portalId = $portalId ?? $this->portalId ?? null;
|
||||
@@ -200,11 +204,20 @@ class Tester
|
||||
$this->clearCache();
|
||||
}
|
||||
|
||||
$applicationParams = new Application\ApplicationParams(noErrorHandler: true);
|
||||
$applicationParams = new Application\ApplicationParams(
|
||||
noErrorHandler: true,
|
||||
binding: $binding,
|
||||
);
|
||||
|
||||
$this->application = !$portalId ?
|
||||
new Application($applicationParams) :
|
||||
new PortalApplication($portalId, $applicationParams);
|
||||
if ($portalId) {
|
||||
try {
|
||||
$this->application = new PortalApplication($portalId, $applicationParams);
|
||||
} catch (Forbidden|NotFound $e) {
|
||||
throw new RuntimeException(previous: $e);
|
||||
}
|
||||
} else {
|
||||
$this->application = new Application($applicationParams);
|
||||
}
|
||||
|
||||
$auth = $this->application
|
||||
->getContainer()
|
||||
|
||||
Reference in New Issue
Block a user