2020-10-02 11:59:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This Software is the property of Data Development and is protected
|
|
|
|
* by copyright law - it is NOT Freeware.
|
|
|
|
*
|
|
|
|
* Any unauthorized use of this software without a valid license
|
|
|
|
* is a violation of the license agreement and will be prosecuted by
|
|
|
|
* civil and criminal law.
|
|
|
|
*
|
|
|
|
* https://www.d3data.de
|
|
|
|
*
|
|
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
|
|
|
|
* @link https://www.oxidmodule.com
|
|
|
|
*/
|
2021-10-04 13:52:09 +02:00
|
|
|
|
2020-10-02 11:59:22 +02:00
|
|
|
namespace D3\Usermanager\tests\integration\Actions;
|
|
|
|
|
|
|
|
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
|
|
|
|
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
2023-01-02 10:58:57 +01:00
|
|
|
use D3\ModCfg\Application\Model\Log\d3NullLogger;
|
2020-10-02 11:59:22 +02:00
|
|
|
use D3\Usermanager\Application\Model\d3usermanager;
|
2021-10-04 13:52:09 +02:00
|
|
|
use Doctrine\DBAL\Exception as DoctrineException;
|
|
|
|
use Doctrine\DBAL\Query\QueryBuilder;
|
2020-10-02 11:59:22 +02:00
|
|
|
use Exception;
|
|
|
|
use OxidEsales\Eshop\Application\Model\Object2Group;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
|
|
|
use OxidEsales\Eshop\Core\Model\ListModel;
|
2021-10-04 13:52:09 +02:00
|
|
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
|
|
|
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
|
2020-10-02 11:59:22 +02:00
|
|
|
|
|
|
|
class actionAdd2GroupTest extends d3ActionIntegrationTestCase
|
|
|
|
{
|
2021-10-04 13:52:09 +02:00
|
|
|
public string $sManagerId = 'managerTestId';
|
|
|
|
public array $aUserIdList = [
|
2020-10-02 11:59:22 +02:00
|
|
|
'userTestIdNo1',
|
2021-10-04 13:52:09 +02:00
|
|
|
];
|
|
|
|
public array $aO2GroupIdList = [
|
2020-10-02 11:59:22 +02:00
|
|
|
'o2groupTestIdNo1',
|
2021-10-04 13:52:09 +02:00
|
|
|
];
|
|
|
|
public array $aGroupsIdList = [
|
2020-10-02 11:59:22 +02:00
|
|
|
'groupTestIdNo1',
|
|
|
|
'groupTestIdNo2',
|
2021-10-04 13:52:09 +02:00
|
|
|
];
|
2020-10-02 11:59:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function createTestData()
|
|
|
|
{
|
|
|
|
$this->createManager($this->sManagerId);
|
|
|
|
|
|
|
|
$this->createGroup($this->aGroupsIdList[0]);
|
|
|
|
$this->createGroup($this->aGroupsIdList[1]);
|
|
|
|
|
|
|
|
$this->createUser($this->aUserIdList[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-04 13:52:09 +02:00
|
|
|
* @throws DoctrineException
|
2020-10-02 11:59:22 +02:00
|
|
|
*/
|
|
|
|
public function cleanTestData()
|
|
|
|
{
|
|
|
|
$this->deleteManager($this->sManagerId);
|
|
|
|
$this->deleteUser($this->aUserIdList[0]);
|
2021-10-04 13:52:09 +02:00
|
|
|
$this->deleteObject('d3ox.usermanager.' . Object2Group::class, $this->aO2GroupIdList[0]);
|
|
|
|
|
|
|
|
foreach ([$this->aGroupsIdList[0], $this->aGroupsIdList[1]] as $groupId) {
|
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->delete('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->eq('oxgroupsid', $queryBuilder->createNamedParameter($groupId)),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$queryBuilder->execute();
|
2020-10-02 11:59:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3usermanager
|
|
|
|
*/
|
2021-10-04 13:52:09 +02:00
|
|
|
public function getConfiguredManagerSingleGroupsExists(): d3usermanager
|
2020-10-02 11:59:22 +02:00
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blActionCust2Group_status', true);
|
2021-10-04 13:52:09 +02:00
|
|
|
$oManager->setValue('aCustAddGroup', [$this->aGroupsIdList[0]]);
|
2020-10-02 11:59:22 +02:00
|
|
|
$oManager->setValue('blItemExecute', true);
|
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3usermanager
|
|
|
|
*/
|
2021-10-04 13:52:09 +02:00
|
|
|
public function getConfiguredManagerMultiGroupsExists(): d3usermanager
|
2020-10-02 11:59:22 +02:00
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blActionCust2Group_status', true);
|
2021-10-04 13:52:09 +02:00
|
|
|
$oManager->setValue('aCustAddGroup', [$this->aGroupsIdList[0], $this->aGroupsIdList[1]]);
|
2020-10-02 11:59:22 +02:00
|
|
|
$oManager->setValue('blItemExecute', true);
|
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3usermanager
|
|
|
|
*/
|
2021-10-04 13:52:09 +02:00
|
|
|
public function getConfiguredManagerSingleGroupsNotExistsNotAssigned(): d3usermanager
|
2020-10-02 11:59:22 +02:00
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blActionCust2Group_status', true);
|
2021-10-04 13:52:09 +02:00
|
|
|
$oManager->setValue('aCustAddGroup', ['unknownGroupId']);
|
2020-10-02 11:59:22 +02:00
|
|
|
$oManager->setValue('blItemExecute', true);
|
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3usermanager
|
|
|
|
*/
|
2021-10-04 13:52:09 +02:00
|
|
|
public function getConfiguredManagerNoGroups(): d3usermanager
|
2020-10-02 11:59:22 +02:00
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blActionCust2Group_status', true);
|
2021-10-04 13:52:09 +02:00
|
|
|
$oManager->setValue('aCustAddGroup', []);
|
2020-10-02 11:59:22 +02:00
|
|
|
$oManager->setValue('blItemExecute', true);
|
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return ListModel
|
|
|
|
*/
|
2021-10-04 13:52:09 +02:00
|
|
|
public function getFilledResultList(): ListModel
|
2020-10-02 11:59:22 +02:00
|
|
|
{
|
2021-10-04 13:52:09 +02:00
|
|
|
return $this->getResultList([$this->aUserIdList[0]]);
|
2020-10-02 11:59:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
2021-10-04 13:52:09 +02:00
|
|
|
* @throws DoctrineException
|
2020-10-02 11:59:22 +02:00
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
|
|
|
public function actionChangeConcernedUserSingleGroupsExistsNotAssigned()
|
|
|
|
{
|
|
|
|
$oExecute = $this->getExecuteMock($this->getConfiguredManagerSingleGroupsExists());
|
|
|
|
$oExecute->startJobItemExecution();
|
|
|
|
|
|
|
|
// check assignment pass
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->eq('oxgroupsid', $queryBuilder->createNamedParameter($this->aGroupsIdList[0]))
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
1,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// check other assignments
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->notIn('oxgroupsid', [$queryBuilder->createNamedParameter($this->aGroupsIdList[0])])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->neq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->in('oxgroupsid', [$queryBuilder->createNamedParameter($this->aGroupsIdList[0])])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
2021-10-04 13:52:09 +02:00
|
|
|
* @throws DoctrineException
|
2020-10-02 11:59:22 +02:00
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
|
|
|
public function actionChangeConcernedUserMultiGroupsExistsNotAssigned()
|
|
|
|
{
|
|
|
|
$oExecute = $this->getExecuteMock($this->getConfiguredManagerMultiGroupsExists());
|
|
|
|
$oExecute->startJobItemExecution();
|
|
|
|
|
|
|
|
// check assignment pass
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->in('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[0]),
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[1]),
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
2,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// check other assignments
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->notIn('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[0]),
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[1]),
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->neq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->in('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[0]),
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[1]),
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
2021-10-04 13:52:09 +02:00
|
|
|
* @throws DoctrineException
|
2020-10-02 11:59:22 +02:00
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
|
|
|
public function actionChangeConcernedUserSingleGroupsExistsAlreadyAssigned()
|
|
|
|
{
|
|
|
|
$this->createObject(
|
2021-10-04 13:52:09 +02:00
|
|
|
'd3ox.usermanager.' . Object2Group::class,
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->aO2GroupIdList[0],
|
2021-10-04 13:52:09 +02:00
|
|
|
[
|
|
|
|
'oxshopid' => 1,
|
|
|
|
'oxobjectid' => $this->aUserIdList[0],
|
|
|
|
'oxgroupsid' => $this->aGroupsIdList[0],
|
|
|
|
]
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$oExecute = $this->getExecuteMock($this->getConfiguredManagerSingleGroupsExists());
|
|
|
|
$oExecute->startJobItemExecution();
|
|
|
|
|
|
|
|
// check assignment pass
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->in('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[0])
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
1,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// check other assignments
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->notIn('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[0])
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->neq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->in('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter($this->aGroupsIdList[0])
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
2021-10-04 13:52:09 +02:00
|
|
|
* @throws DoctrineException
|
2020-10-02 11:59:22 +02:00
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
|
|
|
public function actionChangeConcernedUserSingleGroupsNotExistsNotAssigned()
|
|
|
|
{
|
2023-01-02 10:58:57 +01:00
|
|
|
d3GetModCfgDIC()->set('d3ox.usermanager.Logger', d3GetModCfgDIC()->get(d3NullLogger::class));
|
|
|
|
|
2020-10-02 11:59:22 +02:00
|
|
|
$oExecute = $this->getExecuteMock($this->getConfiguredManagerSingleGroupsNotExistsNotAssigned());
|
|
|
|
$oExecute->startJobItemExecution();
|
|
|
|
|
|
|
|
// check assignment pass
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->in('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter('unknownGroupId')
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// check other assignments
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->notIn('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter('unknownGroupId')
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->and(
|
|
|
|
$queryBuilder->expr()->neq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
$queryBuilder->expr()->in('oxgroupsid', [
|
|
|
|
$queryBuilder->createNamedParameter('unknownGroupId')
|
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
2021-10-04 13:52:09 +02:00
|
|
|
* @throws DoctrineException
|
2020-10-02 11:59:22 +02:00
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
*/
|
|
|
|
public function actionChangeConcernedUserNoGroups()
|
|
|
|
{
|
2023-01-02 10:58:57 +01:00
|
|
|
d3GetModCfgDIC()->set('d3ox.usermanager.Logger', d3GetModCfgDIC()->get(d3NullLogger::class));
|
|
|
|
|
2020-10-02 11:59:22 +02:00
|
|
|
$oExecute = $this->getExecuteMock($this->getConfiguredManagerNoGroups());
|
|
|
|
$oExecute->startJobItemExecution();
|
|
|
|
|
2021-10-04 13:52:09 +02:00
|
|
|
/** @var QueryBuilder $queryBuilder */
|
|
|
|
$queryBuilder = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
|
|
|
|
$queryBuilder->select('count(*)')
|
|
|
|
->from('oxobject2group')
|
|
|
|
->where(
|
|
|
|
$queryBuilder->expr()->eq('oxobjectid', $queryBuilder->createNamedParameter($this->aUserIdList[0])),
|
|
|
|
);
|
2020-10-02 11:59:22 +02:00
|
|
|
$this->assertSame(
|
|
|
|
0,
|
2021-10-04 13:52:09 +02:00
|
|
|
(int)$queryBuilder->execute()->fetchOne()
|
2020-10-02 11:59:22 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|