mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-27 22:46:04 +00:00
SelectManager support removal
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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 Espo\Core\Di;
|
||||
|
||||
use Espo\Core\Select\SelectManagerFactory;
|
||||
|
||||
interface SelectManagerFactoryAware
|
||||
{
|
||||
public function setSelectManagerFactory(SelectManagerFactory $selectManagerFactory): void;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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 Espo\Core\Di;
|
||||
|
||||
use Espo\Core\Select\SelectManagerFactory;
|
||||
|
||||
/**
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
trait SelectManagerFactorySetter
|
||||
{
|
||||
/**
|
||||
* @var SelectManagerFactory
|
||||
*/
|
||||
protected $selectManagerFactory;
|
||||
|
||||
public function setSelectManagerFactory(SelectManagerFactory $selectManagerFactory): void
|
||||
{
|
||||
$this->selectManagerFactory = $selectManagerFactory;
|
||||
}
|
||||
}
|
||||
@@ -29,14 +29,10 @@
|
||||
|
||||
namespace Espo\Core\Select\AccessControl;
|
||||
|
||||
use Espo\Core\Select\OrmSelectBuilder;
|
||||
use Espo\Core\Select\AccessControl\FilterFactory as AccessControlFilterFactory;
|
||||
use Espo\Core\Select\AccessControl\FilterResolverFactory as AccessControlFilterResolverFactory;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class Applier
|
||||
@@ -46,21 +42,10 @@ class Applier
|
||||
private User $user,
|
||||
private AccessControlFilterFactory $accessControlFilterFactory,
|
||||
private AccessControlFilterResolverFactory $accessControlFilterResolverFactory,
|
||||
private SelectManager $selectManager
|
||||
) {}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
// For backward compatibility.
|
||||
if (
|
||||
$this->selectManager->hasInheritedAccessMethod() &&
|
||||
$queryBuilder instanceof OrmSelectBuilder
|
||||
) {
|
||||
$this->selectManager->applyAccessToQueryBuilder($queryBuilder);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->applyMandatoryFilter($queryBuilder);
|
||||
|
||||
$accessControlFilterResolver = $this->accessControlFilterResolverFactory
|
||||
@@ -72,16 +57,6 @@ class Applier
|
||||
return;
|
||||
}
|
||||
|
||||
// For backward compatibility.
|
||||
if (
|
||||
$this->selectManager->hasInheritedAccessFilterMethod($filterName) &&
|
||||
$queryBuilder instanceof OrmSelectBuilder
|
||||
) {
|
||||
$this->selectManager->applyAccessFilterToQueryBuilder($queryBuilder, $filterName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->accessControlFilterFactory->has($this->entityType, $filterName)) {
|
||||
$filter = $this->accessControlFilterFactory
|
||||
->create($this->entityType, $this->user, $filterName);
|
||||
|
||||
@@ -44,8 +44,6 @@ use Espo\Core\Binding\Binder;
|
||||
use Espo\Core\Binding\BindingContainer;
|
||||
use Espo\Core\Binding\BindingData;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
use Espo\Core\Select\SelectManagerFactory;
|
||||
|
||||
use Espo\Core\Utils\Acl\UserAclManagerProvider;
|
||||
use Espo\Entities\User;
|
||||
@@ -81,16 +79,12 @@ class Factory
|
||||
public function __construct(
|
||||
private InjectableFactory $injectableFactory,
|
||||
private UserAclManagerProvider $userAclManagerProvider,
|
||||
private SelectManagerFactory $selectManagerFactory,
|
||||
) {}
|
||||
|
||||
private function create(string $entityType, User $user, string $type): object
|
||||
{
|
||||
$className = $this->getDefaultClassName($type);
|
||||
|
||||
// SelectManager is used for backward compatibility.
|
||||
$selectManager = $this->selectManagerFactory->create($entityType, $user);
|
||||
|
||||
$aclManager = $this->userAclManagerProvider->get($user);
|
||||
$acl = $aclManager->createUserAcl($user);
|
||||
|
||||
@@ -101,13 +95,11 @@ class Factory
|
||||
$binder
|
||||
->bindInstance(User::class, $user)
|
||||
->bindInstance(AclManager::class, $aclManager)
|
||||
->bindInstance(Acl::class, $acl)
|
||||
->bindInstance(SelectManager::class, $selectManager);
|
||||
->bindInstance(Acl::class, $acl);
|
||||
|
||||
$binder
|
||||
->for($className)
|
||||
->bindValue('$entityType', $entityType)
|
||||
->bindValue('$selectManager', $selectManager);
|
||||
->bindValue('$entityType', $entityType);
|
||||
|
||||
$bindingContainer = new BindingContainer($bindingData);
|
||||
|
||||
|
||||
@@ -30,13 +30,10 @@
|
||||
namespace Espo\Core\Select\Bool;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Select\OrmSelectBuilder;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
use Espo\Core\Select\Bool\FilterFactory as BoolFilterFactory;
|
||||
use Espo\ORM\Query\Select;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
@@ -46,7 +43,6 @@ class Applier
|
||||
private string $entityType,
|
||||
private User $user,
|
||||
private BoolFilterFactory $boolFilterFactory,
|
||||
private SelectManager $selectManager
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -93,20 +89,6 @@ class Applier
|
||||
return;
|
||||
}
|
||||
|
||||
// For backward compatibility.
|
||||
if (
|
||||
$this->selectManager->hasBoolFilter($filterName) &&
|
||||
$queryBuilder instanceof OrmSelectBuilder
|
||||
) {
|
||||
$rawWhereClause = $this->selectManager->applyBoolFilterToQueryBuilder($queryBuilder, $filterName);
|
||||
|
||||
$whereItem = WhereClause::fromRaw($rawWhereClause);
|
||||
|
||||
$orGroupBuilder->add($whereItem);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new BadRequest("No bool filter '$filterName' for '$this->entityType'.");
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
namespace Espo\Core\Select\Primary;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
use Espo\Core\Select\OrmSelectBuilder;
|
||||
use Espo\ORM\Query\SelectBuilder;
|
||||
use Espo\Entities\User;
|
||||
|
||||
@@ -41,7 +39,6 @@ class Applier
|
||||
private string $entityType,
|
||||
private User $user,
|
||||
private FilterFactory $primaryFilterFactory,
|
||||
private SelectManager $selectManager
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -57,16 +54,6 @@ class Applier
|
||||
return;
|
||||
}
|
||||
|
||||
// For backward compatibility.
|
||||
if (
|
||||
$this->selectManager->hasPrimaryFilter($filterName) &&
|
||||
$queryBuilder instanceof OrmSelectBuilder
|
||||
) {
|
||||
$this->selectManager->applyPrimaryFilterToQueryBuilder($queryBuilder, $filterName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new BadRequest("No primary filter '$filterName' for '$this->entityType'.");
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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 Espo\Core\Select;
|
||||
|
||||
use Espo\Core\Utils\Acl\UserAclManagerProvider;
|
||||
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Utils\ClassFinder;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
/**
|
||||
* @deprecated Use SelectBuilder instead.
|
||||
*
|
||||
* Creates select managers for specific entity types. You can specify a user whose ACL will be applied to queries.
|
||||
* If user is not specified, then the current one will be used.
|
||||
*/
|
||||
class SelectManagerFactory
|
||||
{
|
||||
/**
|
||||
* @var class-string
|
||||
*/
|
||||
protected string $defaultClassName = SelectManager::class;
|
||||
|
||||
private $user;
|
||||
|
||||
private $acl;
|
||||
|
||||
private $aclManagerProvider;
|
||||
|
||||
private $injectableFactory;
|
||||
|
||||
private $classFinder;
|
||||
|
||||
public function __construct(
|
||||
User $user,
|
||||
Acl $acl,
|
||||
UserAclManagerProvider $aclManagerProvider,
|
||||
InjectableFactory $injectableFactory,
|
||||
ClassFinder $classFinder
|
||||
) {
|
||||
$this->user = $user;
|
||||
$this->acl = $acl;
|
||||
$this->aclManagerProvider = $aclManagerProvider;
|
||||
$this->injectableFactory = $injectableFactory;
|
||||
$this->classFinder = $classFinder;
|
||||
}
|
||||
|
||||
public function create(string $entityType, ?User $user = null): SelectManager
|
||||
{
|
||||
$className = $this->classFinder->find('SelectManagers', $entityType);
|
||||
|
||||
if (!$className || !class_exists($className)) {
|
||||
$className = $this->defaultClassName;
|
||||
}
|
||||
|
||||
/** @var class-string<SelectManager> $className */
|
||||
|
||||
if ($user) {
|
||||
$acl = $this->aclManagerProvider->get($user)->createUserAcl($user);
|
||||
} else {
|
||||
$acl = $this->acl;
|
||||
$user = $this->user;
|
||||
}
|
||||
|
||||
$selectManager = $this->injectableFactory->createWith($className, [
|
||||
'user' => $user,
|
||||
'acl' => $acl,
|
||||
]);
|
||||
|
||||
$selectManager->setEntityType($entityType);
|
||||
|
||||
return $selectManager;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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 Espo\Core\SelectManagers;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo Remove in v10.0.
|
||||
*/
|
||||
class Base extends \Espo\Core\Select\SelectManager
|
||||
{
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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 Espo\Core\Templates\SelectManagers;
|
||||
|
||||
/**
|
||||
* @deprecated As of v7.0. For backward compatibility.
|
||||
*/
|
||||
class Event extends \Espo\Core\Select\SelectManager
|
||||
{}
|
||||
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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\Core\Select;
|
||||
|
||||
use Espo\Core\Application;
|
||||
use Espo\Core\Select\SelectManagerFactory;
|
||||
use tests\integration\Core\BaseTestCase;
|
||||
|
||||
class LegacyTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* @var SelectManagerFactory
|
||||
*/
|
||||
private $selectManagerFactory;
|
||||
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$injectableFactory = $this->getContainer()->get('injectableFactory');
|
||||
|
||||
$this->selectManagerFactory = $injectableFactory->create(SelectManagerFactory::class);
|
||||
}
|
||||
|
||||
protected function initTest(array $aclData = [], bool $skipLogin = false, bool $isPortal = false): Application
|
||||
{
|
||||
$this->createUser('tester', [
|
||||
'data' => $aclData,
|
||||
]);
|
||||
|
||||
if (!$skipLogin) {
|
||||
$this->auth('tester');
|
||||
}
|
||||
|
||||
$app = $this->createApplication();
|
||||
|
||||
$injectableFactory = $app->getContainer()->get('injectableFactory');
|
||||
|
||||
$this->selectManagerFactory = $injectableFactory->create(SelectManagerFactory::class);
|
||||
|
||||
$app->getContainer()->get('user');
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
|
||||
public function testAccess1(): void
|
||||
{
|
||||
$app = $this->initTest(
|
||||
[
|
||||
'Account' => [
|
||||
'read' => 'own',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$container = $app->getContainer();
|
||||
|
||||
$userId = $container->get('user')->getId();
|
||||
|
||||
$selectManager = $this->selectManagerFactory->create('Account');
|
||||
|
||||
$result = $selectManager->getEmptySelectParams();
|
||||
|
||||
$selectManager->applyAccess($result);
|
||||
|
||||
$this->assertEquals(['assignedUserId' => $userId], $result['whereClause']);
|
||||
}
|
||||
|
||||
public function testGetSelectParams(): void
|
||||
{
|
||||
$app = $this->initTest(
|
||||
[
|
||||
'Opportunity' => [
|
||||
'read' => 'own',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$container = $app->getContainer();
|
||||
|
||||
$userId = $container->get('user')->getId();
|
||||
|
||||
$selectManager = $this->selectManagerFactory->create('Opportunity');
|
||||
|
||||
$params = [
|
||||
'primaryFilter' => 'open',
|
||||
];
|
||||
|
||||
$result = $selectManager->getSelectParams($params, true, true, true);
|
||||
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'assignedUserId' => $userId,
|
||||
'stage!=' => ['Closed Won', 'Closed Lost'],
|
||||
],
|
||||
$result['whereClause']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ use Espo\Core\Select\AccessControl\Filter as AccessControlFilter;
|
||||
use Espo\Core\Select\AccessControl\FilterFactory as AccessControlFilterFactory;
|
||||
use Espo\Core\Select\AccessControl\FilterResolver;
|
||||
use Espo\Core\Select\AccessControl\FilterResolverFactory as AccessControlFilterResolverFactory;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
@@ -45,7 +44,6 @@ class AccessControlFilterApplierTest extends TestCase
|
||||
private $filterFactory;
|
||||
private $filterResolverFactory;
|
||||
private $user;
|
||||
private $selectManager;
|
||||
private $queryBuilder;
|
||||
private $filterResolver;
|
||||
private $filter;
|
||||
@@ -58,7 +56,6 @@ class AccessControlFilterApplierTest extends TestCase
|
||||
$this->filterFactory = $this->createMock(AccessControlFilterFactory::class);
|
||||
$this->filterResolverFactory = $this->createMock(AccessControlFilterResolverFactory::class);
|
||||
$this->user = $this->createMock(User::class);
|
||||
$this->selectManager = $this->createMock(SelectManager::class);
|
||||
$this->queryBuilder = $this->createMock(QueryBuilder::class);
|
||||
$this->filterResolver = $this->createMock(FilterResolver::class);
|
||||
$this->filter = $this->createMock(AccessControlFilter::class);
|
||||
@@ -67,11 +64,10 @@ class AccessControlFilterApplierTest extends TestCase
|
||||
$this->entityType = 'Test';
|
||||
|
||||
$this->applier = new AccessControlFilterApplier(
|
||||
$this->entityType,
|
||||
$this->user,
|
||||
$this->filterFactory,
|
||||
$this->filterResolverFactory,
|
||||
$this->selectManager
|
||||
entityType: $this->entityType,
|
||||
user: $this->user,
|
||||
accessControlFilterFactory: $this->filterFactory,
|
||||
accessControlFilterResolverFactory: $this->filterResolverFactory,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,11 +94,6 @@ class AccessControlFilterApplierTest extends TestCase
|
||||
|
||||
protected function initApplierTest(bool $resolve, bool $hasFilter)
|
||||
{
|
||||
$this->selectManager
|
||||
->expects($this->once())
|
||||
->method('hasInheritedAccessMethod')
|
||||
->willReturn(false);
|
||||
|
||||
$this->filterResolverFactory
|
||||
->expects($this->once())
|
||||
->method('create')
|
||||
@@ -128,12 +119,6 @@ class AccessControlFilterApplierTest extends TestCase
|
||||
return;
|
||||
}
|
||||
|
||||
$this->selectManager
|
||||
->expects($this->once())
|
||||
->method('hasInheritedAccessFilterMethod')
|
||||
->with('test')
|
||||
->willReturn(false);
|
||||
|
||||
$this->filterFactory
|
||||
->expects($this->once())
|
||||
->method('has')
|
||||
|
||||
@@ -33,7 +33,6 @@ use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Select\Bool\Applier as BoolFilterListApplier;
|
||||
use Espo\Core\Select\Bool\Filter as BoolFilter;
|
||||
use Espo\Core\Select\Bool\FilterFactory as BoolFilterFactory;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Query\Part\Where\OrGroupBuilder;
|
||||
@@ -45,7 +44,6 @@ class BoolFilterListApplierTest extends TestCase
|
||||
{
|
||||
private $boolFilterFactory;
|
||||
private $user;
|
||||
private $selectManager;
|
||||
private $queryBuilder;
|
||||
private $entityType;
|
||||
private $applier;
|
||||
@@ -54,16 +52,14 @@ class BoolFilterListApplierTest extends TestCase
|
||||
{
|
||||
$this->boolFilterFactory = $this->createMock(BoolFilterFactory::class);
|
||||
$this->user = $this->createMock(User::class);
|
||||
$this->selectManager = $this->createMock(SelectManager::class);
|
||||
$this->queryBuilder = $this->createMock(QueryBuilder::class);
|
||||
|
||||
$this->entityType = 'Test';
|
||||
|
||||
$this->applier = new BoolFilterListApplier(
|
||||
$this->entityType,
|
||||
$this->user,
|
||||
$this->boolFilterFactory,
|
||||
$this->selectManager
|
||||
entityType: $this->entityType,
|
||||
user: $this->user,
|
||||
boolFilterFactory: $this->boolFilterFactory,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,12 +100,6 @@ class BoolFilterListApplierTest extends TestCase
|
||||
|
||||
$this->initApplierTest($boolFilterList, [null], [false]);
|
||||
|
||||
$this->selectManager
|
||||
->expects($this->once())
|
||||
->method('hasBoolFilter')
|
||||
->with('test1')
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(BadRequest::class);
|
||||
|
||||
$this->applier->apply($this->queryBuilder, $boolFilterList);
|
||||
|
||||
@@ -33,7 +33,6 @@ use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Select\Primary\Applier as PrimaryFilterApplier;
|
||||
use Espo\Core\Select\Primary\Filter as PrimaryFilter;
|
||||
use Espo\Core\Select\Primary\FilterFactory as PrimaryFilterFactory;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
|
||||
@@ -43,7 +42,6 @@ class PrimaryFilterApplierTest extends TestCase
|
||||
{
|
||||
private $filterFactory;
|
||||
private $user;
|
||||
private $selectManager;
|
||||
private $queryBuilder;
|
||||
private $entityType;
|
||||
private $applier;
|
||||
@@ -52,16 +50,14 @@ class PrimaryFilterApplierTest extends TestCase
|
||||
{
|
||||
$this->filterFactory = $this->createMock(PrimaryFilterFactory::class);
|
||||
$this->user = $this->createMock(User::class);
|
||||
$this->selectManager = $this->createMock(SelectManager::class);
|
||||
$this->queryBuilder = $this->createMock(QueryBuilder::class);
|
||||
|
||||
$this->entityType = 'Test';
|
||||
|
||||
$this->applier = new PrimaryFilterApplier(
|
||||
$this->entityType,
|
||||
$this->user,
|
||||
$this->filterFactory,
|
||||
$this->selectManager
|
||||
entityType: $this->entityType,
|
||||
user: $this->user,
|
||||
primaryFilterFactory: $this->filterFactory,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,8 +91,6 @@ class PrimaryFilterApplierTest extends TestCase
|
||||
{
|
||||
$filterName = 'test';
|
||||
|
||||
$filter = $this->createMock(PrimaryFilter::class);
|
||||
|
||||
$this->filterFactory
|
||||
->expects($this->once())
|
||||
->method('has')
|
||||
@@ -107,12 +101,6 @@ class PrimaryFilterApplierTest extends TestCase
|
||||
->expects($this->never())
|
||||
->method('create');
|
||||
|
||||
$this->selectManager
|
||||
->expects($this->once())
|
||||
->method('hasPrimaryFilter')
|
||||
->with($filterName)
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(BadRequest::class);
|
||||
|
||||
$this->applier->apply($this->queryBuilder, $filterName);
|
||||
|
||||
@@ -43,8 +43,6 @@ use Espo\Core\Select\Bool\Applier as BoolFilterListApplier;
|
||||
use Espo\Core\Select\Order\Applier as OrderApplier;
|
||||
use Espo\Core\Select\Primary\Applier as PrimaryFilterApplier;
|
||||
use Espo\Core\Select\Select\Applier as SelectApplier;
|
||||
use Espo\Core\Select\SelectManager;
|
||||
use Espo\Core\Select\SelectManagerFactory;
|
||||
use Espo\Core\Select\Text\Applier as TextFilterApplier;
|
||||
use Espo\Core\Select\Where\Applier as WhereApplier;
|
||||
|
||||
@@ -57,19 +55,14 @@ class FactoryTest extends TestCase
|
||||
private $aclManager;
|
||||
private $acl;
|
||||
private $injectableFactory;
|
||||
private $selectManagerFactory;
|
||||
private $user;
|
||||
private $selectManager;
|
||||
private $factory;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->injectableFactory = $this->createMock(InjectableFactory::class);
|
||||
$this->selectManagerFactory = $this->createMock(SelectManagerFactory::class);
|
||||
$this->user = $this->createMock(User::class);
|
||||
|
||||
$this->selectManager = $this->createMock(SelectManager::class);
|
||||
|
||||
$userAclManagerProvider = $this->createMock(UserAclManagerProvider::class);
|
||||
|
||||
$this->aclManager = $this->createMock(AclManager::class);
|
||||
@@ -82,7 +75,6 @@ class FactoryTest extends TestCase
|
||||
$this->factory = new ApplierFactory(
|
||||
$this->injectableFactory,
|
||||
$userAclManagerProvider,
|
||||
$this->selectManagerFactory
|
||||
);
|
||||
|
||||
$this->acl = $this->createMock(Acl::class);
|
||||
@@ -145,12 +137,6 @@ class FactoryTest extends TestCase
|
||||
{
|
||||
$entityType = 'Test';
|
||||
|
||||
$this->selectManagerFactory
|
||||
->expects($this->once())
|
||||
->method('create')
|
||||
->with('Test', $this->user)
|
||||
->willReturn($this->selectManager);
|
||||
|
||||
$applierClassName = $className ?? $defaultClassName;
|
||||
|
||||
$applier = $this->createMock($defaultClassName);
|
||||
@@ -161,12 +147,10 @@ class FactoryTest extends TestCase
|
||||
|
||||
$binder
|
||||
->bindInstance(User::class, $this->user)
|
||||
->bindInstance(SelectManager::class, $this->selectManager)
|
||||
->bindInstance(AclManager::class, $this->aclManager)
|
||||
->bindInstance(Acl::class, $this->acl)
|
||||
->for($applierClassName)
|
||||
->bindValue('$entityType', $entityType)
|
||||
->bindValue('$selectManager', $this->selectManager);
|
||||
->bindValue('$entityType', $entityType);
|
||||
|
||||
$bindingContainer = new BindingContainer($bindingData);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user