From aeeab9164aa122fde900c603ca1c0cd6914e26dd Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Mon, 29 Jul 2019 22:27:17 +0100 Subject: [PATCH] FIX #11296 TIME 0:30 fix TU --- src/app/action/models/ActionModelAbstract.php | 14 +++---- .../controllers/FirstLevelController.php | 37 +------------------ .../app/action/ActionControllerTest.php | 14 ++----- .../app/basket/BasketControllerTest.php | 6 +-- .../app/doctype/DoctypeControllerTest.php | 12 ------ .../app/folder/FolderControllerTest.php | 2 +- .../app/group/GroupControllerTest.php | 1 - 7 files changed, 15 insertions(+), 71 deletions(-) diff --git a/src/app/action/models/ActionModelAbstract.php b/src/app/action/models/ActionModelAbstract.php index 2e38aa72f86..bc3dade6fa8 100755 --- a/src/app/action/models/ActionModelAbstract.php +++ b/src/app/action/models/ActionModelAbstract.php @@ -172,11 +172,6 @@ abstract class ActionModelAbstract } else { $label = constant((string) $actionPage->LABEL); } - if (!empty((string) $actionPage->MODULE)) { - $origin = (string) $actionPage->MODULE; - } else { - $origin = 'apps'; - } if (!empty((string) $actionPage->DESC)) { $desc = constant((string) $actionPage->DESC); } else { @@ -189,8 +184,7 @@ abstract class ActionModelAbstract 'label' => $label, 'name' => (string)$actionPage->NAME, 'component' => $component, - 'desc' => $desc, - 'origin' => ucfirst($origin) + 'desc' => $desc ]; } } @@ -199,9 +193,11 @@ abstract class ActionModelAbstract array_map( function ($element) { return $element['label']; - }, $actionsPages + }, + $actionsPages ), - SORT_ASC, $actionsPages + SORT_ASC, + $actionsPages ); return $actionsPages; diff --git a/src/app/doctype/controllers/FirstLevelController.php b/src/app/doctype/controllers/FirstLevelController.php index aa531ce9d0c..63d8e9b05ab 100755 --- a/src/app/doctype/controllers/FirstLevelController.php +++ b/src/app/doctype/controllers/FirstLevelController.php @@ -18,7 +18,6 @@ use Respect\Validation\Validator; use Doctype\models\FirstLevelModel; use Doctype\models\SecondLevelModel; use Doctype\models\DoctypeModel; -use Folder\models\FolderTypeModel; use Group\models\ServiceModel; use Slim\Http\Request; use Slim\Http\Response; @@ -35,8 +34,8 @@ class FirstLevelController public static function getTreeFunction() { $firstLevels = FirstLevelModel::get([ - 'where' => ['enabled = ?'], - 'data' => ['Y'], + 'where' => ['enabled = ?'], + 'data' => ['Y'], 'orderBy' => ['doctypes_first_level_label asc']]); $secondLevels = SecondLevelModel::get([ 'where' => ['enabled = ?'], @@ -97,23 +96,13 @@ class FirstLevelController } else { $obj['firstLevel']['enabled'] = false; } - - $folderTypesSelected = FolderTypeModel::getFolderTypeDocTypeFirstLevel(['doctypes_first_level_id' => $aArgs['id']]); - $aFolderTypesSelected = []; - foreach ($folderTypesSelected as $folderType) { - $aFolderTypesSelected[] = $folderType['foldertype_id']; - } - $obj['firstLevel']['foldertype_id'] = $aFolderTypesSelected; } - $obj['folderTypes'] = FolderTypeModel::get(['select' => ['foldertype_id', 'foldertype_label']]); - return $response->withJson($obj); } public function initDoctypes(Request $request, Response $response) { - $obj['folderTypes'] = FolderTypeModel::get(['select' => ['foldertype_id', 'foldertype_label']]); $obj['firstLevel'] = FirstLevelModel::get([ 'select' => ['doctypes_first_level_id', 'doctypes_first_level_label'], 'where' => ['enabled = ?'], @@ -147,17 +136,9 @@ class FirstLevelController return $response->withStatus(500)->withJson(['errors' => $errors]); } - $folderTypeId = $data['foldertype_id']; unset($data['foldertype_id']); $firstLevelId = FirstLevelModel::create($data); - foreach ($folderTypeId as $value) { - FolderTypeModel::createFolderTypeDocTypeFirstLevel([ - 'doctypes_first_level_id' => $firstLevelId, - 'foldertype_id' => $value, - ]); - } - HistoryController::add([ 'tableName' => 'doctypes_first_level', 'recordId' => $firstLevelId, @@ -189,18 +170,9 @@ class FirstLevelController return $response->withStatus(500)->withJson(['errors' => $errors]); } - $folderTypeId = $obj['foldertype_id']; unset($obj['foldertype_id']); FirstLevelModel::update($obj); - FolderTypeModel::deleteFolderTypeDocTypeFirstLevel(['doctypes_first_level_id' => $obj['doctypes_first_level_id']]); - foreach ($folderTypeId as $value) { - FolderTypeModel::createFolderTypeDocTypeFirstLevel([ - 'doctypes_first_level_id' => $obj['doctypes_first_level_id'], - 'foldertype_id' => $value, - ]); - } - HistoryController::add([ 'tableName' => 'doctypes_first_level', 'recordId' => $obj['doctypes_first_level_id'], @@ -228,7 +200,6 @@ class FirstLevelController FirstLevelModel::update(['doctypes_first_level_id' => $aArgs['id'], 'enabled' => 'N']); SecondLevelModel::disabledFirstLevel(['doctypes_first_level_id' => $aArgs['id'], 'enabled' => 'N']); DoctypeModel::disabledFirstLevel(['doctypes_first_level_id' => $aArgs['id'], 'enabled' => 'N']); - FolderTypeModel::deleteFolderTypeDocTypeFirstLevel(['doctypes_first_level_id' => $aArgs['id']]); $firstLevel = FirstLevelModel::getById(['id' => $aArgs['id']]); HistoryController::add([ @@ -266,10 +237,6 @@ class FirstLevelController $errors[] = 'Invalid doctypes_first_level_label'; } - if (!Validator::notEmpty()->validate($aArgs['foldertype_id'])) { - $errors[] = 'Invalid foldertype_id'; - } - if (empty($aArgs['enabled'])) { $aArgs['enabled'] = 'Y'; } diff --git a/test/unitTests/app/action/ActionControllerTest.php b/test/unitTests/app/action/ActionControllerTest.php index 4d5b6c8a7ac..38c502df400 100755 --- a/test/unitTests/app/action/ActionControllerTest.php +++ b/test/unitTests/app/action/ActionControllerTest.php @@ -28,8 +28,7 @@ class ActionsControllerTest extends TestCase 'label_action' => 'TEST-LABEL', 'id_status' => '_NOSTATUS_', 'actionPageId' => 'close_mail', - 'history' => true, - 'origin' => 'apps', + 'history' => true ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); @@ -46,8 +45,7 @@ class ActionsControllerTest extends TestCase 'label_action' => '', 'id_status' => '', 'actionPageId' => 'close_mail', - 'history' => true, - 'origin' => 'apps', + 'history' => true ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); @@ -75,10 +73,8 @@ class ActionsControllerTest extends TestCase $this->assertSame('TEST-LABEL', $responseBody->action->label_action); $this->assertSame('_NOSTATUS_', $responseBody->action->id_status); $this->assertSame(false, $responseBody->action->is_system); - $this->assertSame('Y', $responseBody->action->enabled); $this->assertSame('close_mail', $responseBody->action->action_page); $this->assertSame(true, $responseBody->action->history); - $this->assertSame('apps', $responseBody->action->origin); // FAIL READ $actionController = new \Action\controllers\ActionController(); @@ -109,8 +105,7 @@ class ActionsControllerTest extends TestCase 'label_action' => 'TEST-LABEL_UPDATED', 'id_status' => 'COU', 'actionPageId' => 'close_mail', - 'history' => false, - 'origin' => 'apps', + 'history' => false ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); @@ -126,8 +121,7 @@ class ActionsControllerTest extends TestCase 'label_action' => 'TEST-LABEL_UPDATED', 'id_status' => 'COU', 'actionPageId' => 'close_mail', - 'history' => false, - 'origin' => 'apps', + 'history' => false ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); diff --git a/test/unitTests/app/basket/BasketControllerTest.php b/test/unitTests/app/basket/BasketControllerTest.php index 8ecc7b3d534..699d0622be3 100755 --- a/test/unitTests/app/basket/BasketControllerTest.php +++ b/test/unitTests/app/basket/BasketControllerTest.php @@ -102,7 +102,7 @@ class BasketControllerTest extends TestCase 'list_display' => [], 'groupActions' => [ [ - 'id' => '112', + 'id' => '1', 'where_clause' => '1=2', 'used_in_basketlist' => false, 'used_in_action_page' => true, @@ -142,8 +142,8 @@ class BasketControllerTest extends TestCase $this->assertInternalType('array', $responseBody->groups[0]->groupActions); $this->assertNotNull($responseBody->groups[0]->groupActions); foreach ($responseBody->groups[0]->groupActions as $groupAction) { - if ($groupAction->id == 112) { - $this->assertSame(112, $groupAction->id); + if ($groupAction->id == 1) { + $this->assertSame(1, $groupAction->id); $this->assertSame('1=2', $groupAction->where_clause); $this->assertSame('N', $groupAction->used_in_basketlist); $this->assertSame('Y', $groupAction->used_in_action_page); diff --git a/test/unitTests/app/doctype/DoctypeControllerTest.php b/test/unitTests/app/doctype/DoctypeControllerTest.php index 7645f7966e0..0c84daa824d 100755 --- a/test/unitTests/app/doctype/DoctypeControllerTest.php +++ b/test/unitTests/app/doctype/DoctypeControllerTest.php @@ -48,10 +48,6 @@ class DoctypeControllerTest extends TestCase $response = $firstLevelController->initDoctypes($request, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody()); - $this->assertNotNull($responseBody->folderTypes); - $this->assertNotNull($responseBody->folderTypes[0]->foldertype_id); - $this->assertNotNull($responseBody->folderTypes[0]->foldertype_label); - $this->assertNotNull($responseBody->firstLevel); $this->assertNotNull($responseBody->firstLevel[0]->doctypes_first_level_id); $this->assertNotNull($responseBody->firstLevel[0]->doctypes_first_level_label); @@ -76,7 +72,6 @@ class DoctypeControllerTest extends TestCase $aArgs = [ 'doctypes_first_level_label' => 'testTUfirstlevel', - 'foldertype_id' => [1], 'css_style' => '#99999', 'enabled' => 'Y', ]; @@ -92,7 +87,6 @@ class DoctypeControllerTest extends TestCase // CREATE FAIL $aArgs = [ 'doctypes_first_level_label' => '', - 'foldertype_id' => [], 'css_style' => '#7777', 'enabled' => 'gaz', ]; @@ -102,7 +96,6 @@ class DoctypeControllerTest extends TestCase $responseBody = json_decode((string)$response->getBody()); $this->assertSame('Invalid doctypes_first_level_label', $responseBody->errors[0]); - $this->assertSame('Invalid foldertype_id', $responseBody->errors[1]); } public function testCreateSecondLevel() @@ -247,7 +240,6 @@ class DoctypeControllerTest extends TestCase $aArgs = [ 'doctypes_first_level_label' => 'testTUfirstlevelUPDATE', - 'foldertype_id' => [1], 'css_style' => '#7777', 'enabled' => 'Y', ]; @@ -263,7 +255,6 @@ class DoctypeControllerTest extends TestCase // UPDATE FAIL $aArgs = [ 'doctypes_first_level_label' => '', - 'foldertype_id' => [], 'css_style' => '#7777', 'enabled' => 'gaz', ]; @@ -275,7 +266,6 @@ class DoctypeControllerTest extends TestCase $this->assertSame('Id is not a numeric', $responseBody->errors[0]); $this->assertSame('Id gaz does not exists', $responseBody->errors[1]); $this->assertSame('Invalid doctypes_first_level_label', $responseBody->errors[2]); - $this->assertSame('Invalid foldertype_id', $responseBody->errors[3]); } public function testUpdateSecondLevel() @@ -430,8 +420,6 @@ class DoctypeControllerTest extends TestCase $this->assertSame('testTUfirstlevelUPDATE', $responseBody->firstLevel->doctypes_first_level_label); $this->assertSame('#7777', $responseBody->firstLevel->css_style); $this->assertSame(true, $responseBody->firstLevel->enabled); - $this->assertNotNull($responseBody->firstLevel->foldertype_id); - $this->assertNotNull($responseBody->folderTypes); // READ FIRST LEVEL FAIL $response = $firstLevelController->getById($request, new \Slim\Http\Response(), ["id" => 'GAZ']); diff --git a/test/unitTests/app/folder/FolderControllerTest.php b/test/unitTests/app/folder/FolderControllerTest.php index 7ec2a3dbcf1..c47743d240c 100755 --- a/test/unitTests/app/folder/FolderControllerTest.php +++ b/test/unitTests/app/folder/FolderControllerTest.php @@ -148,7 +148,7 @@ class FolderControllerTest extends TestCase $request = \Slim\Http\Request::createFromEnvironment($environment); $response = $folderController->delete($request, new \Slim\Http\Response(), ['id' => self::$id]); - $this->assertSame(200, $response->getStatusCode()); + $this->assertSame(204, $response->getStatusCode()); // DELETE ERROR $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'DELETE']); diff --git a/test/unitTests/app/group/GroupControllerTest.php b/test/unitTests/app/group/GroupControllerTest.php index bdde4139215..cfaded03c76 100755 --- a/test/unitTests/app/group/GroupControllerTest.php +++ b/test/unitTests/app/group/GroupControllerTest.php @@ -112,7 +112,6 @@ class GroupControllerTest extends TestCase $this->assertSame(self::$id, $responseBody->group->id); $this->assertSame('TEST-JusticeLeague', $responseBody->group->group_id); $this->assertSame('Beyond the darkness #2', $responseBody->group->group_desc); - $this->assertSame('Y', $responseBody->group->enabled); // ERROR $response = $groupController->getById($request, new \Slim\Http\Response(), ['id' => '123456789']); -- GitLab