Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
b5dc3aa4
Commit
b5dc3aa4
authored
7 years ago
by
Florian Azizian
Browse files
Options
Downloads
Patches
Plain Diff
testU
parent
f33cd44b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/Controllers/ParametersController.php
+1
-1
1 addition, 1 deletion
core/Controllers/ParametersController.php
core/Test/ParametersControllerTest.php
+91
-126
91 additions, 126 deletions
core/Test/ParametersControllerTest.php
sonar-project.properties
+1
-1
1 addition, 1 deletion
sonar-project.properties
with
93 additions
and
128 deletions
core/Controllers/ParametersController.php
+
1
−
1
View file @
b5dc3aa4
...
...
@@ -65,7 +65,7 @@ use Core\Models\ParametersModel;
return
$response
->
withJson
(
$obj
);
}
public
function
update
(
RequestInterface
$request
,
ResponseInterface
$response
)
public
function
update
(
RequestInterface
$request
,
ResponseInterface
$response
,
$aArgs
)
{
$errors
=
$this
->
control
(
$request
,
'update'
);
...
...
This diff is collapsed.
Click to expand it.
core/Test/ParametersControllerTest.php
+
91
−
126
View file @
b5dc3aa4
...
...
@@ -20,112 +20,98 @@ class ParametersControllerTest extends \PHPUnit_Framework_TestCase
$query
.
=
'param_value_string=abcd&'
;
$query
.
=
'description=papa'
;
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'POST'
,
'QUERY_STRING'
=>
$query
,
]
);
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'POST'
,
'QUERY_STRING'
=>
$query
,
]);
$parameter
=
new
\Core\Controllers\ParametersController
();
$response
=
$parameter
->
create
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$response
=
$parameter
->
create
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$compare
=
'[{"id":"TEST",'
.
'"description":"papa",'
.
'"param_value_string":"abcd",'
.
'"param_value_int":null,'
.
'"param_value_date":null}]'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
$client
=
new
\GuzzleHttp\Client
([
'base_uri'
=>
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
// You can set any number of default request options.
'timeout'
=>
2.0
,
]);
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
//TEST EXISTE DEJA
$aArgs
=
[
'id'
=>
'TEST'
,
'description'
=>
null
,
'param_value_string'
=>
null
,
'param_value_int'
=>
1234
,
'param_value_date'
=>
null
];
$response
=
$client
->
request
(
'POST'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
[
'auth'
=>
[
'superadmin'
,
'superadmin'
],
'form_params'
=>
$aArgs
]);
$response
=
$parameter
->
create
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$compare
=
'{"errors":["Identifiant TEST existe d\u00e9j\u00e0 !"]}'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
//AUCUN PARAMETRE
$aArgs
=
[
'id'
=>
'TEST3'
,
'description'
=>
null
,
'param_value_string'
=>
null
,
'param_value_int'
=>
null
,
'param_value_date'
=>
null
];
$response
=
$client
->
request
(
'POST'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
[
'auth'
=>
[
'superadmin'
,
'superadmin'
],
'form_params'
=>
$aArgs
$query
=
'id=TEST3&'
;
$query
.
=
'param_value_string=&'
;
$query
.
=
'param_value_int=&'
;
$query
.
=
'param_value_date=&'
;
$query
.
=
'description='
;
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'POST'
,
'QUERY_STRING'
=>
$query
,
]);
$response
=
$parameter
->
create
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$compare
=
'{"errors":["_PARAM_VALUE_IS_EMPTY"]}'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
//AUCUN ARGUMENTS
$aArgs
=
[
];
$response
=
$client
->
request
(
'POST'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
[
'auth'
=>
[
'superadmin'
,
'superadmin'
],
'form_params'
=>
$aArgs
$query
=
''
;
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'POST'
,
'QUERY_STRING'
=>
$query
,
]);
$response
=
$parameter
->
create
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$compare
=
'{"errors":["_ID_IS_EMPTY_CONTROLLER","_PARAM_VALUE_IS_EMPTY"]}'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
//DATE MAUVAIS FORMAT
$aArgs
=
[
'id'
=>
'TEST4'
,
'description'
=>
null
,
'param_value_string'
=>
null
,
'param_value_int'
=>
null
,
'param_value_date'
=>
'123456'
];
$response
=
$client
->
request
(
'POST'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
[
'auth'
=>
[
'superadmin'
,
'superadmin'
],
'form_params'
=>
$aArgs
$query
=
'id=TEST4&'
;
$query
.
=
'param_value_string=&'
;
$query
.
=
'param_value_int=&'
;
$query
.
=
'param_value_date=123456&'
;
$query
.
=
'description='
;
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'POST'
,
'QUERY_STRING'
=>
$query
,
]);
$response
=
$parameter
->
create
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$compare
=
'{"errors":["PARAMETRE DATE INVALIDE."]}'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
//TEST ID MAUVAIS FORMAT (REGEX)
$aArgs
=
[
'id'
=>
'A*-#=='
,
'description'
=>
"*///*//"
,
'param_value_string'
=>
"//-//**"
,
'param_value_int'
=>
null
,
'param_value_date'
=>
null
];
$response
=
$client
->
request
(
'POST'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
[
'auth'
=>
[
'superadmin'
,
'superadmin'
],
'form_params'
=>
$aArgs
$query
=
'id=A*-#==&'
;
$query
.
=
'param_value_string=//-//**&'
;
$query
.
=
'param_value_int=&'
;
$query
.
=
'param_value_date=&'
;
$query
.
=
'description=*///*//'
;
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'POST'
,
'QUERY_STRING'
=>
$query
,
]);
$compare
=
'{"errors":["ID INVALIDE","DESCRIPTION INVALIDE","PARAM STRING INVALIDE"]}'
;
$response
=
$parameter
->
create
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$compare
=
'{"errors":["ID INVALIDE","DESCRIPTION INVALIDE","PARAM STRING INVALIDE"]}'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
}
...
...
@@ -133,42 +119,35 @@ class ParametersControllerTest extends \PHPUnit_Framework_TestCase
{
$parameters
=
new
\Core\Controllers\ParametersController
();
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'GET'
,
]
);
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'GET'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
new
\Slim\Http\Response
();
$response
=
$parameters
->
getList
(
$request
,
$response
);
$response
=
$parameters
->
getList
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$this
->
assertNotNull
((
string
)
$response
->
getBody
());
}
public
function
testGetById
()
{
{
$query
=
'id=TEST'
;
$aArgs
=
[
'id'
=>
'TEST'
];
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'GET'
,
'QUERY_STRING'
=>
$query
,
]);
$client
=
new
\GuzzleHttp\Client
([
'base_uri'
=>
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
// You can set any number of default request options.
'timeout'
=>
2.0
,
]);
$parameters
=
new
\Core\Controllers\ParametersController
();
$response
=
$parameters
->
getById
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
(),
[
'id'
=>
'TEST'
]);
$response
=
$client
->
request
(
'GET'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters/'
.
$aArgs
[
'id'
],
[
'auth'
=>
[
'superadmin'
,
'superadmin'
]
]);
$compare
=
'[[{"id":"TEST",'
.
'"description":null,'
$compare
=
'[{"id":"TEST",'
.
'"description":"papa",'
.
'"param_value_string":"abcd",'
.
'"param_value_int":null,'
.
'"param_value_date":null}]
]
'
;
.
'"param_value_date":null}]'
;
$this
->
assertNotNull
((
string
)
$response
->
getBody
());
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
}
public
function
testUpdate
()
...
...
@@ -177,40 +156,32 @@ class ParametersControllerTest extends \PHPUnit_Framework_TestCase
$query
=
'id=TEST&'
;
$query
.
=
'description=TEST AFTER UP'
;
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'PUT'
,
'QUERY_STRING'
=>
$query
,
]
);
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'PUT'
,
'QUERY_STRING'
=>
$query
,
]);
$parameter
=
new
\Core\Controllers\ParametersController
();
$response
=
$parameter
->
update
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
());
$response
=
$parameter
->
update
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
()
,
[
'id'
=>
'TEST'
]
);
$compare
=
'[{"id":"TEST",'
.
'"description":"TEST AFTER UP",'
.
'"param_value_string":"abcd",'
.
'"param_value_int":null,'
.
'"param_value_date":null}]'
;
$compare
=
'[{"id":"TEST",'
.
'"description":"TEST AFTER UP",'
.
'"param_value_string":"abcd",'
.
'"param_value_int":null,'
.
'"param_value_date":null}]'
;
$this
->
assertSame
((
string
)
$response
->
getBody
(),
$compare
);
//TEST ID NULL
$query
=
'id=NEWWW'
;
$client
=
new
\GuzzleHttp\Client
([
'base_uri'
=>
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
// You can set any number of default request options.
'timeout'
=>
2.0
,
]);
$aArgs
=
[
'id'
=>
'NEW'
];
$response
=
$client
->
request
(
'PUT'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters/'
.
$aArgs
[
'id'
],
[
'auth'
=>
[
'superadmin'
,
'superadmin'
],
'form_params'
=>
$aArgs
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'PUT'
,
'QUERY_STRING'
=>
$query
,
]);
$response
=
$parameter
->
update
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
(),
[
'id'
=>
'NEWWW'
]);
$compare
=
'{"errors":["Identifiant n\'existe pas"]}'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
...
...
@@ -219,24 +190,18 @@ class ParametersControllerTest extends \PHPUnit_Framework_TestCase
public
function
testDelete
()
{
$aArgs
=
[
'id'
=>
'TEST'
];
$client
=
new
\GuzzleHttp\Client
([
'base_uri'
=>
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters'
,
// You can set any number of default request options.
'timeout'
=>
2.0
,
]);
$response
=
$client
->
request
(
'DELETE'
,
$_SESSION
[
'config'
][
'coreurl'
]
.
'rest/parameters/'
.
$aArgs
[
'id'
],
[
'auth'
=>
[
'superadmin'
,
'superadmin'
],
'form_params'
=>
$aArgs
$query
=
'id=TEST'
;
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'DELETE'
,
'QUERY_STRING'
=>
$query
,
]);
$parameter
=
new
\Core\Controllers\ParametersController
();
$response
=
$parameter
->
delete
(
\Slim\Http\Request
::
createFromEnvironment
(
$environment
),
new
\Slim\Http\Response
(),
[
'id'
=>
'TEST'
]);
$compare
=
'true'
;
$this
->
assertSame
(
$compare
,(
string
)
$response
->
getBody
());
}
}
?>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
sonar-project.properties
+
1
−
1
View file @
b5dc3aa4
...
...
@@ -6,7 +6,7 @@ sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources
=
.
sonar.sources
=
core , apps/maarch_entreprise/Models , modules/visa/Models , modules/visa/Controllers , modules/attachments/Controllers , modules/attachments/Models , modules/basket/Models , modules/entities/Controllers , modules/entities/Models , modules/notes/Models
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment