* [ADD] Unit testing. Work in progress

* [MOD] Code refactoring and minor bugfixes
This commit is contained in:
nuxsmin
2018-07-04 01:52:13 +02:00
parent 02f3498eda
commit 0bfebd636a
29 changed files with 1086 additions and 211 deletions

View File

@@ -56,6 +56,8 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
{
$dic = setupContext();
self::$dataset = 'syspass.xml';
// Datos de conexión a la BBDD
self::$databaseConnectionData = $dic->get(DatabaseConnectionData::class);
@@ -255,12 +257,16 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
$this->assertEquals(3, self::$repository->add($accountRequest));
$userGroups = self::$repository->getUserGroupsByAccountId($accountRequest->id);
$result = self::$repository->getUserGroupsByAccountId($accountRequest->id);
$this->assertCount(3, $userGroups);
$this->assertInstanceOf(ItemData::class, $userGroups[0]);
$this->assertInstanceOf(ItemData::class, $userGroups[1]);
$this->assertInstanceOf(ItemData::class, $userGroups[2]);
$this->assertEquals(3, $result->getNumRows());
$data = $result->getDataAsArray();
$this->assertCount(3, $data);
$this->assertInstanceOf(ItemData::class, $data[0]);
$this->assertInstanceOf(ItemData::class, $data[1]);
$this->assertInstanceOf(ItemData::class, $data[2]);
$this->expectException(ConstraintException::class);
@@ -301,11 +307,11 @@ class AccountToUserGroupRepositoryTest extends DatabaseTestCase
*/
public function testGetUserGroupsByUserGroupId()
{
$this->assertCount(2, self::$repository->getUserGroupsByUserGroupId(2)->getNumRows());
$this->assertEquals(2, self::$repository->getUserGroupsByUserGroupId(2)->getNumRows());
$this->assertCount(0, self::$repository->getUserGroupsByUserGroupId(3)->getNumRows());
$this->assertEquals(0, self::$repository->getUserGroupsByUserGroupId(3)->getNumRows());
$this->assertCount(0, self::$repository->getUserGroupsByUserGroupId(10)->getNumRows());
$this->assertEquals(0, self::$repository->getUserGroupsByUserGroupId(10)->getNumRows());
}
/**