Skip to content

EspoCRM – Open Source CRM Application

baseline role integration test

Yuri Kuznetsovc4a61f9dc3c3
diff --git a/tests/integration/Espo/User/AclTest.php b/tests/integration/Espo/User/AclTest.php
index ee39d653ce..3e6b3c8bb5 100644
--- a/tests/integration/Espo/User/AclTest.php
+++ b/tests/integration/Espo/User/AclTest.php
@@ -44,6 +44,8 @@ use Espo\Core\Select\Where\Item as WhereItem;
use Espo\Core\Exceptions\Forbidden;
+use Espo\Core\Utils\Config\ConfigWriter;
+use Espo\Entities\Role;
use Espo\Entities\Team;
use Espo\Entities\User;
use Espo\Modules\Crm\Entities\Account;
@@ -864,4 +866,47 @@ class AclTest extends \tests\integration\Core\BaseTestCase
$this->assertNotNull($entity3Found);
}
+
+ public function testBaselineRole(): void
+ {
+ $em = $this->getEntityManager();
+
+ $role = $em->getRDBRepositoryByClass(Role::class)->getNew();
+
+ $role->setRawFieldData([
+ Contact::ENTITY_TYPE => [
+ 'address' => [
+ Table::ACTION_READ => Table::LEVEL_YES,
+ Table::ACTION_EDIT => Table::LEVEL_NO,
+ ],
+ ]
+ ]);
+
+ $em->saveEntity($role);
+
+ $configWriter = $this->getInjectableFactory()->create(ConfigWriter::class);
+ $configWriter->set('baselineRoleId', $role->getId());
+ $configWriter->save();
+
+ $this->prepareTestUser();
+
+ $this->auth('test');
+ $this->reCreateApplication();
+
+ $user = $this->getContainer()->getByClass(User::class);
+
+ $aclManager = $this->getContainer()->getByClass(AclManager::class);
+
+ $this->assertTrue(
+ $aclManager->checkField($user, Contact::ENTITY_TYPE, 'address')
+ );
+
+ $this->assertFalse(
+ $aclManager->checkField($user, Contact::ENTITY_TYPE, 'address', Table::ACTION_EDIT)
+ );
+
+ $this->assertTrue(
+ $aclManager->checkScope($user, Contact::ENTITY_TYPE)
+ );
+ }
}