additional binding for tests

This commit is contained in:
Yurii
2026-01-29 09:55:53 +02:00
parent ca1020403d
commit 9ac836dc3e
5 changed files with 50 additions and 13 deletions
+13 -3
View File
@@ -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
+18 -5
View File
@@ -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()