. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace tests\integration\Espo\Tools\Lock; use Espo\Core\Action\ActionFactory; use Espo\Core\Action\Data; use Espo\Core\Action\Params; use Espo\Core\Name\Field; use Espo\Modules\Crm\Entities\Account; use Espo\ORM\Exceptions\ValidationException; use tests\integration\Core\BaseTestCase; class LockTest extends BaseTestCase { /** @noinspection PhpUnhandledExceptionInspection */ public function testLock1(): void { $em = $this->getEntityManager(); $account = $em->getRDBRepositoryByClass(Account::class)->getNew(); $account->setName('Test'); $em->saveEntity($account); $account->set(Field::IS_LOCKED, true); $em->saveEntity($account); $this->expectException(ValidationException::class); $account->setName('Test 1'); $em->saveEntity($account); // $actionFactory = $this->getInjectableFactory()->create(ActionFactory::class); $actionFactory->create('Unlock', Account::ENTITY_TYPE)->process( params: new Params( entityType: Account::ENTITY_TYPE, id: $account->getId(), ), data: Data::fromRaw((object) []) ); $em->refreshEntity($account); $this->assertFalse($account->get(Field::IS_LOCKED)); // $actionFactory->create('Lock', Account::ENTITY_TYPE)->process( params: new Params( entityType: Account::ENTITY_TYPE, id: $account->getId(), ), data: Data::fromRaw((object) []) ); $em->refreshEntity($account); $this->assertTrue($account->get(Field::IS_LOCKED)); } }