Skip to content
Snippets Groups Projects
Verified Commit 4a891309 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #11271 TIME 1 TU indexing actions and entities

parent d9c321b7
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<file>test/unitTests/app/group/GroupControllerTest.php</file> <file>test/unitTests/app/group/GroupControllerTest.php</file>
<file>test/unitTests/app/entity/ListTemplateControllerTest.php</file> <file>test/unitTests/app/entity/ListTemplateControllerTest.php</file>
<file>test/unitTests/app/indexingModel/IndexingModelControllerTest.php</file> <file>test/unitTests/app/indexingModel/IndexingModelControllerTest.php</file>
<file>test/unitTests/app/indexing/IndexingControllerTest.php</file>
<file>test/unitTests/app/notification/NotificationControllerTest.php</file> <file>test/unitTests/app/notification/NotificationControllerTest.php</file>
<file>test/unitTests/app/notification/NotificationScheduleControllerTest.php</file> <file>test/unitTests/app/notification/NotificationScheduleControllerTest.php</file>
<file>test/unitTests/app/parameter/ParameterControllerTest.php</file> <file>test/unitTests/app/parameter/ParameterControllerTest.php</file>
......
...@@ -219,7 +219,8 @@ abstract class GroupModelAbstract ...@@ -219,7 +219,8 @@ abstract class GroupModelAbstract
public static function getGroupByLogin(array $aArgs = []) public static function getGroupByLogin(array $aArgs = [])
{ {
ValidatorModel::notEmpty($aArgs, ['login', 'groupId']); ValidatorModel::notEmpty($aArgs, ['login', 'groupId']);
ValidatorModel::stringType($aArgs, ['login', 'groupId']); ValidatorModel::stringType($aArgs, ['login']);
ValidatorModel::intVal($aArgs, ['groupId']);
$aGroups = DatabaseModel::select([ $aGroups = DatabaseModel::select([
'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'],
......
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
use PHPUnit\Framework\TestCase;
class IndexingControllerTest extends TestCase
{
public function testGetIndexingActions()
{
$GLOBALS['userId'] = 'bbain';
$indexingController = new \Resource\controllers\IndexingController();
// GET
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
$request = \Slim\Http\Request::createFromEnvironment($environment);
$response = $indexingController->getIndexingActions($request, new \Slim\Http\Response(), ['groupId' => 2]);
$this->assertSame(200, $response->getStatusCode());
$responseBody = json_decode((string)$response->getBody());
$this->assertNotEmpty($responseBody->actions);
foreach ($responseBody->actions as $action) {
$this->assertNotEmpty($action->id);
$this->assertInternalType('int', $action->id);
$this->assertNotEmpty($action->label_action);
$this->assertNotEmpty($action->component);
}
//ERROR
$response = $indexingController->getIndexingActions($request, new \Slim\Http\Response(), ['groupId' => 99999]);
$responseBody = json_decode((string)$response->getBody());
$this->assertSame('This user is not in this group', $responseBody->errors);
$GLOBALS['userId'] = 'superadmin';
}
public function testGetIndexingEntities()
{
$GLOBALS['userId'] = 'bbain';
$indexingController = new \Resource\controllers\IndexingController();
// GET
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'GET']);
$request = \Slim\Http\Request::createFromEnvironment($environment);
$response = $indexingController->getIndexingEntities($request, new \Slim\Http\Response(), ['groupId' => 2]);
$this->assertSame(200, $response->getStatusCode());
$responseBody = json_decode((string)$response->getBody());
$this->assertNotEmpty($responseBody->entities);
foreach ($responseBody->entities as $entity) {
$this->assertNotEmpty($entity->id);
$this->assertInternalType('int', $entity->id);
$this->assertNotEmpty($entity->entity_label);
$this->assertNotEmpty($entity->entity_id);
}
//ERROR
$response = $indexingController->getIndexingActions($request, new \Slim\Http\Response(), ['groupId' => 99999]);
$responseBody = json_decode((string)$response->getBody());
$this->assertSame('This user is not in this group', $responseBody->errors);
$GLOBALS['userId'] = 'superadmin';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment