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
395a693a
Commit
395a693a
authored
7 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #5987 Groups Administration test
parent
7f014bcd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/Test/GroupControllerTest.php
+114
-0
114 additions, 0 deletions
core/Test/GroupControllerTest.php
with
114 additions
and
0 deletions
core/Test/GroupControllerTest.php
0 → 100644
+
114
−
0
View file @
395a693a
<?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.
*
*/
namespace
MaarchTest
;
use
PHPUnit\Framework\TestCase
;
class
GroupControllerTest
extends
TestCase
{
private
static
$id
=
null
;
public
function
testCreate
()
{
$groupController
=
new
\Core\Controllers\GroupController
();
// CREATE
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'POST'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$aArgs
=
[
'group_id'
=>
'TEST-Justice League'
,
'group_desc'
=>
'Beyond the darkness'
,
'security'
=>
[
'where_clause'
=>
'1=2'
,
'maarch_comment'
=>
'commentateur du dimanche'
]
];
$fullRequest
=
\httpRequestCustom
::
addContentInBody
(
$aArgs
,
$request
);
$response
=
$groupController
->
create
(
$fullRequest
,
new
\Slim\Http\Response
());
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
self
::
$id
=
$responseBody
->
group
->
id
.
''
;
$this
->
assertInternalType
(
'int'
,
$responseBody
->
group
->
id
);
// READ
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'GET'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
$groupController
->
getDetailledById
(
$request
,
new
\Slim\Http\Response
(),
[
'id'
=>
self
::
$id
]);
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertSame
(
'TEST-Justice League'
,
$responseBody
->
group
->
group_id
);
$this
->
assertSame
(
'Beyond the darkness'
,
$responseBody
->
group
->
group_desc
);
$this
->
assertSame
(
'Y'
,
$responseBody
->
group
->
enabled
);
$this
->
assertSame
(
'1=2'
,
$responseBody
->
group
->
security
->
where_clause
);
$this
->
assertSame
(
'commentateur du dimanche'
,
$responseBody
->
group
->
security
->
maarch_comment
);
$this
->
assertSame
(
null
,
$responseBody
->
group
->
security
->
mr_start_date
);
$this
->
assertSame
(
null
,
$responseBody
->
group
->
security
->
mr_stop_date
);
}
public
function
testUpdate
()
{
$groupController
=
new
\Core\Controllers\GroupController
();
// UPDATE
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'PUT'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$aArgs
=
[
'description'
=>
'Beyond the darkness #2'
,
'security'
=>
[
'where_clause'
=>
'1=3'
,
'maarch_comment'
=>
'commentateur du dimanche #2'
]
];
$fullRequest
=
\httpRequestCustom
::
addContentInBody
(
$aArgs
,
$request
);
$response
=
$groupController
->
update
(
$fullRequest
,
new
\Slim\Http\Response
(),
[
'id'
=>
self
::
$id
]);
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertSame
(
'success'
,
$responseBody
->
success
);
// READ
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'GET'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
$groupController
->
getDetailledById
(
$request
,
new
\Slim\Http\Response
(),
[
'id'
=>
self
::
$id
]);
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertSame
(
'TEST-Justice League'
,
$responseBody
->
group
->
group_id
);
$this
->
assertSame
(
'Beyond the darkness #2'
,
$responseBody
->
group
->
group_desc
);
$this
->
assertSame
(
'Y'
,
$responseBody
->
group
->
enabled
);
$this
->
assertSame
(
'1=3'
,
$responseBody
->
group
->
security
->
where_clause
);
$this
->
assertSame
(
'commentateur du dimanche #2'
,
$responseBody
->
group
->
security
->
maarch_comment
);
$this
->
assertSame
(
null
,
$responseBody
->
group
->
security
->
mr_start_date
);
$this
->
assertSame
(
null
,
$responseBody
->
group
->
security
->
mr_stop_date
);
}
public
function
testDelete
()
{
$groupController
=
new
\Core\Controllers\GroupController
();
// DELETE
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'DELETE'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
$groupController
->
delete
(
$request
,
new
\Slim\Http\Response
(),
[
'id'
=>
self
::
$id
]);
// READ
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'GET'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
$groupController
->
getDetailledById
(
$request
,
new
\Slim\Http\Response
(),
[
'id'
=>
self
::
$id
]);
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertSame
(
null
,
$responseBody
->
id
);
}
}
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