EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Tester ref
Yurii0830025699fa
diff --git a/tests/integration/Core/BaseTestCase.php b/tests/integration/Core/BaseTestCase.phpindex e55448b5d8..dc91f8e40b 100644--- a/tests/integration/Core/BaseTestCase.php+++ b/tests/integration/Core/BaseTestCase.php@@ -35,6 +35,7 @@ use Espo\Core\Application;use Espo\Core\Binding\BindingProcessor;use Espo\Core\Container;use Espo\Core\DataManager;+use Espo\Core\Exceptions\Error;use Espo\Core\InjectableFactory;use Espo\Core\Utils\Config;use Espo\Core\Utils\File\Manager as FileManager;@@ -44,6 +45,7 @@ use Espo\ORM\EntityManager;use PHPUnit\Framework\TestCase;+use RuntimeException;use Slim\Psr7\Factory\RequestFactory;use Slim\Psr7\Factory\ResponseFactory;use Slim\Psr7\Factory\StreamFactory;@@ -176,7 +178,12 @@ abstract class BaseTestCase extends TestCase$this->beforeSetUp();- $this->espoTester->initialize();+ try {+ $this->espoTester->initialize();+ } catch (Error $e) {+ throw new RuntimeException("Initialization error.", previous: $e);+ }+$this->auth($this->userName, $this->password, null, $this->authenticationMethod);$this->beforeStartApplication();@@ -217,12 +224,15 @@ abstract class BaseTestCase extends TestCaseprotected function afterStartApplication(): void{}+ /**+ * @param array<string, mixed> $queryParams+ */protected function createRequest(string $method,array $queryParams = [],array $headers = [],?string $body = null,- array $routeParams = []+ array $routeParams = [],): RequestWrapper {$request = (new RequestFactory())@@ -248,11 +258,6 @@ abstract class BaseTestCase extends TestCase);}- /*protected function setData(array $data): void- {- $this->espoTester->setData($data);- }*/-/*** @todo Revise whether needed.*/diff --git a/tests/integration/Core/Tester.php b/tests/integration/Core/Tester.phpindex f81744f546..debf3e04d3 100644--- a/tests/integration/Core/Tester.php+++ b/tests/integration/Core/Tester.php@@ -137,7 +137,7 @@ class Testerreturn null;}- public function setParam($name, $value)+ public function setParam(string $name, mixed $value): void{$this->params[$name] = $value;}@@ -177,11 +177,11 @@ class Tester}public function auth(- $userName,- $password = null,- $portalId = null,- $authenticationMethod = null,- $request = null,+ ?string $userName,+ ?string $password = null,+ ?string $portalId = null,+ ?string $authenticationMethod = null,+ ?RequestWrapper $request = null,): void {$this->userName = $userName;@@ -421,7 +421,7 @@ class Tester}}- private function reset($fileManager, $latestEspoDir): void+ private function reset(FileManager $fileManager, string $latestEspoDir): void{$configData = $this->getTestConfigData();@@ -513,9 +513,7 @@ class Tester{$this->clearVars();- $fileManager = new FileManager();-- $fileManager->removeInDir('data/cache');+ (new FileManager())->removeInDir('data/cache');}private function clearVars(): void@@ -527,9 +525,9 @@ class Tester/*** Create a user with roles.*- * @param string|array $userData If $userData is a string, then it's a userName with default password.+ * @param string|array<string, mixed> $userData If string, then it's a userName with the default password.*/- public function createUser($userData, ?array $roleData = null, $isPortal = false): User+ public function createUser($userData, ?array $roleData = null, bool $isPortal = false): User{if (!is_array($userData)) {$userData = [@@ -572,7 +570,7 @@ class Tester}$user = $entityManager->getNewEntity(User::ENTITY_TYPE);- $user->set($userData);+ $user->setMultiple($userData);$entityManager->saveEntity($user);