mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-07 00:46:59 +01:00
* [MOD] Update PHPunit to latest version.
* [MOD] Load fixtures using plain SQL files. * [MOD] Raise PHP version requirements (7.2 will be deprecated within a month). Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
@@ -55,14 +55,11 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
|
||||
* @throws NotFoundException
|
||||
* @throws ContextException
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$dic = setupContext();
|
||||
|
||||
self::$dataset = 'syspass.xml';
|
||||
|
||||
// Datos de conexión a la BBDD
|
||||
self::$databaseConnectionData = $dic->get(DatabaseConnectionData::class);
|
||||
self::$loadFixtures = true;
|
||||
|
||||
// Inicializar el repositorio
|
||||
self::$repository = $dic->get(AccountToUserGroupRepository::class);
|
||||
@@ -97,14 +94,14 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
|
||||
$result = self::$repository->getUserGroupsByAccountId(2);
|
||||
$data = $result->getDataAsArray();
|
||||
|
||||
$this->assertEquals(1, $result->getNumRows());
|
||||
$this->assertEquals(2, $result->getNumRows());
|
||||
$this->assertInstanceOf(ItemData::class, $data[0]);
|
||||
|
||||
$userGroupsView = array_filter($data, function ($user) {
|
||||
return (int)$user->isEdit === 0;
|
||||
});
|
||||
|
||||
$this->assertCount(1, $userGroupsView);
|
||||
$this->assertCount(2, $userGroupsView);
|
||||
|
||||
$userGroupsEdit = array_filter($data, function ($user) {
|
||||
return (int)$user->isEdit === 1;
|
||||
@@ -164,7 +161,7 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
|
||||
$accountRequest->id = 2;
|
||||
$accountRequest->userGroupsEdit = [2, 3];
|
||||
|
||||
$this->assertEquals(3, self::$repository->updateByType($accountRequest, true));
|
||||
self::$repository->updateByType($accountRequest, true);
|
||||
|
||||
$result = self::$repository->getUserGroupsByAccountId($accountRequest->id);
|
||||
$data = $result->getDataAsArray();
|
||||
@@ -197,13 +194,13 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
|
||||
*/
|
||||
public function testViewDeleteByAccountId()
|
||||
{
|
||||
$this->assertEquals(1, self::$repository->deleteTypeByAccountId(2, false));
|
||||
$this->assertEquals(2, self::$repository->deleteTypeByAccountId(2, false));
|
||||
|
||||
$this->assertEquals(0, self::$repository->getUserGroupsByAccountId(2)->getNumRows());
|
||||
|
||||
$this->assertEquals(0, self::$repository->deleteTypeByAccountId(10, false));
|
||||
|
||||
$this->assertEquals(1, $this->conn->getRowCount('AccountToUserGroup'));
|
||||
$this->assertEquals(1, self::getRowCount('AccountToUserGroup'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +217,7 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
|
||||
|
||||
$this->assertEquals(0, self::$repository->deleteByAccountId(10));
|
||||
|
||||
$this->assertEquals(1, $this->conn->getRowCount('AccountToUserGroup'));
|
||||
$this->assertEquals(2, self::getRowCount('AccountToUserGroup'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -311,7 +308,7 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
|
||||
|
||||
$this->assertEquals(0, self::$repository->deleteTypeByAccountId(10, true));
|
||||
|
||||
$this->assertEquals(1, $this->conn->getRowCount('AccountToUserGroup'));
|
||||
$this->assertEquals(2, self::getRowCount('AccountToUserGroup'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,7 +321,7 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
$this->assertEquals(2, self::$repository->getUserGroupsByUserGroupId(2)->getNumRows());
|
||||
|
||||
$this->assertEquals(0, self::$repository->getUserGroupsByUserGroupId(3)->getNumRows());
|
||||
$this->assertEquals(1, self::$repository->getUserGroupsByUserGroupId(3)->getNumRows());
|
||||
|
||||
$this->assertEquals(0, self::$repository->getUserGroupsByUserGroupId(10)->getNumRows());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user