diff --git a/sql/data_fr.sql b/sql/data_fr.sql index b4ac5a089d524d9e7ad3ac4721c97e83729619ca..eddb1264cc0af27adcc88469b956dc6e11daf1ee 100755 --- a/sql/data_fr.sql +++ b/sql/data_fr.sql @@ -38,6 +38,9 @@ INSERT INTO usergroups (group_id,group_desc) VALUES ('MAARCHTOGEC', 'Envoi déma DELETE FROM usergroups WHERE group_id = 'SERVICE'; DELETE FROM usergroups_services WHERE group_id = 'SERVICE'; INSERT INTO usergroups (group_id,group_desc) VALUES ('SERVICE', 'Service'); +DELETE FROM usergroups WHERE group_id = 'WEBSERVICE'; +DELETE FROM usergroups_services WHERE group_id = 'WEBSERVICE'; +INSERT INTO usergroups (group_id,group_desc, can_index, indexation_parameters) VALUES ('WEBSERVICE', 'Utilisateurs de WebService', TRUE, '{"actions":["21"], "entities":[], "keywords":["ALL_ENTITIES"]}'); INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'adv_search_mlb'); INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'search_contacts'); INSERT INTO usergroups_services (group_id, service_id) VALUES ('COURRIER', 'my_contacts'); @@ -858,6 +861,7 @@ DELETE FROM users WHERE user_id = 'cchaplin'; INSERT INTO users (user_id, password, firstname, lastname, mail, change_password, status, loginmode) VALUES ('cchaplin', '$2y$10$C.QSslBKD3yNMfRPuZfcaubFwPKiCkqqOUyAdOr5FSGKPaePwuEjG', 'Charlie', 'CHAPLIN', 'support@maarch.fr', 'N', 'OK', 'restMode'); DELETE FROM usergroup_content WHERE user_id = 24; INSERT INTO usergroup_content (user_id, group_id, role) VALUES (24, 11, ''); +INSERT INTO usergroup_content (user_id, group_id, role) VALUES (24, 13, ''); ------------ -- CONTACTS diff --git a/test/unitTests/app/doctype/DoctypeControllerTest.php b/test/unitTests/app/doctype/DoctypeControllerTest.php index e741c5318b195de70e08fcd07818825ae8a4dc7e..ff397dcc2232b889103421af54a93cdc281e8ed5 100755 --- a/test/unitTests/app/doctype/DoctypeControllerTest.php +++ b/test/unitTests/app/doctype/DoctypeControllerTest.php @@ -542,7 +542,7 @@ class DoctypeControllerTest extends TestCase $resController = new \Resource\controllers\ResController(); // CREATE RESOURCE - $GLOBALS['userId'] = 'bbain'; + $GLOBALS['userId'] = 'cchaplin'; $userInfo = \User\models\UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id']]); $GLOBALS['id'] = $userInfo['id']; @@ -553,12 +553,20 @@ class DoctypeControllerTest extends TestCase $encodedFile = base64_encode($fileContent); $aArgs = [ + 'modelId' => 1, 'status' => 'NEW', 'encodedFile' => $encodedFile, 'format' => 'txt', - 'type_id' => $doctypeId, - 'category_id' => 'incoming', - 'subject' => 'subject value test U' + 'confidential' => false, + 'documentDate' => '2019-01-01 17:18:47', + 'arrivalDate' => '2019-01-01 17:18:47', + 'processLimitDate' => '2029-01-01', + 'doctype' => $doctypeId, + 'destination' => 15, + 'initiator' => 15, + 'subject' => 'Breaking News : Aquaman is a fish - PHP unit', + 'typist' => 19, + 'priority' => 'poiuytre1357nbvc', ]; $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); diff --git a/test/unitTests/app/resource/ResControllerTest.php b/test/unitTests/app/resource/ResControllerTest.php index d733815771018ad472ca87e40a81f911ba293127..b47a6d9b739ea62b531c66b0225ef4272469461d 100755 --- a/test/unitTests/app/resource/ResControllerTest.php +++ b/test/unitTests/app/resource/ResControllerTest.php @@ -15,7 +15,7 @@ class ResControllerTest extends TestCase public function testCreate() { - $GLOBALS['userId'] = 'bbain'; + $GLOBALS['userId'] = 'cchaplin'; $userInfo = \User\models\UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id']]); $GLOBALS['id'] = $userInfo['id']; @@ -29,14 +29,19 @@ class ResControllerTest extends TestCase $encodedFile = base64_encode($fileContent); $aArgs = [ + 'modelId' => 1, 'status' => 'NEW', 'encodedFile' => $encodedFile, 'format' => 'txt', - 'type_id' => 102, - 'category_id' => 'incoming', + 'confidential' => false, + 'documentDate' => '2019-01-01 17:18:47', + 'arrivalDate' => '2019-01-01 17:18:47', + 'processLimitDate' => '2029-01-01', + 'doctype' => 102, + 'destination' => 15, + 'initiator' => 15, 'subject' => 'Breaking News : Superman is alive - PHP unit', 'typist' => 19, - 'dest_user' => 'bbain', 'priority' => 'poiuytre1357nbvc', ]; @@ -48,18 +53,17 @@ class ResControllerTest extends TestCase $this->assertInternalType('int', self::$id); // READ - $res = \Resource\models\ResModel::getById(['resId' => self::$id]); + $res = \Resource\models\ResModel::getById(['resId' => self::$id, 'select' => ['*']]); $this->assertInternalType('array', $res); $this->assertSame('Breaking News : Superman is alive - PHP unit', $res['subject']); - $this->assertSame(null, $res['title']); - $this->assertSame(null, $res['description']); $this->assertSame(102, $res['type_id']); $this->assertSame('txt', $res['format']); $this->assertSame('NEW', $res['status']); $this->assertSame(19, $res['typist']); - $this->assertSame(null, $res['destination']); + $this->assertNotNull($res['destination']); + $this->assertNotNull($res['initiator']); $GLOBALS['userId'] = 'superadmin'; $userInfo = \User\models\UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id']]); @@ -81,7 +85,7 @@ class ResControllerTest extends TestCase $response = $resController->getFileContent($request, new \Slim\Http\Response(), ['resId' => -2]); $responseBody = json_decode((string)$response->getBody()); - $this->assertSame('Document out of perimeter', $responseBody->errors); + $this->assertSame('Document does not exist', $responseBody->errors); } public function testGetThumbnailContent() @@ -99,7 +103,7 @@ class ResControllerTest extends TestCase $response = $resController->getThumbnailContent($request, new \Slim\Http\Response(), ['resId' => -2]); $responseBody = json_decode((string)$response->getBody()); - $this->assertSame(null, $responseBody); + $this->assertSame('Document does not exist', $responseBody->errors); } public function testUpdateStatus() @@ -121,7 +125,7 @@ class ResControllerTest extends TestCase $this->assertSame('success', $responseBody->success); // READ - $res = \Resource\models\ResModel::getById(['resId' => self::$id]); + $res = \Resource\models\ResModel::getById(['resId' => self::$id, 'select' => ['*']]); $this->assertInternalType('array', $res); $this->assertSame('EVIS', $res['status']); @@ -141,7 +145,7 @@ class ResControllerTest extends TestCase $this->assertSame('success', $responseBody->success); // READ - $res = \Resource\models\ResModel::getById(['resId' => self::$id]); + $res = \Resource\models\ResModel::getById(['resId' => self::$id, 'select' => ['*']]); $this->assertInternalType('array', $res); $this->assertSame('COU', $res['status']); } @@ -320,14 +324,14 @@ class ResControllerTest extends TestCase \Resource\models\ResModel::delete(['resId' => self::$id]); // READ - $res = \Resource\models\ResModel::getById(['resId' => self::$id]); + $res = \Resource\models\ResModel::getById(['resId' => self::$id, 'select' => ['*']]); $this->assertInternalType('array', $res); $this->assertSame('DEL', $res['status']); } public function testCreateMultipleDocument() { - $GLOBALS['userId'] = 'bbain'; + $GLOBALS['userId'] = 'cchaplin'; $userInfo = \User\models\UserModel::getByLogin(['login' => $GLOBALS['userId'], 'select' => ['id']]); $GLOBALS['id'] = $userInfo['id']; @@ -354,23 +358,25 @@ class ResControllerTest extends TestCase foreach ($aNewDocument as $key => $value) { $environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'POST']); $request = \Slim\Http\Request::createFromEnvironment($environment); - + $fileContent = file_get_contents('test/unitTests/samples/test.txt'); $encodedFile = base64_encode($fileContent); - $aArgs = [ + 'modelId' => 1, 'status' => $value[2], 'encodedFile' => $encodedFile, 'format' => 'txt', - 'type_id' => $value[0], - 'category_id' => 'incoming', - 'subject' => $key . ' Breaking News : 12345 Superman is alive - PHP unit', - 'typist' => 19, - 'dest_user' => 'bbain', - 'priority' => $value[1], - 'destination' => 'PJS' + 'confidential' => false, + 'documentDate' => '2019-01-01 17:18:47', + 'arrivalDate' => '2019-01-01 17:18:47', + 'processLimitDate' => '2029-01-01', + 'doctype' => $value[0], + 'destination' => 15, + 'initiator' => 15, + 'subject' => $key .' Breaking News : Superman is alive - PHP unit', + 'typist' => 19 ]; - + $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); $response = $resController->create($fullRequest, new \Slim\Http\Response()); $responseBody = json_decode((string)$response->getBody());