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
232c4c06
Verified
Commit
232c4c06
authored
7 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
FEAT
#34
Reports unit test
parent
d0b0d6b1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/Test/ReportControllerTest.php
+100
-0
100 additions, 0 deletions
core/Test/ReportControllerTest.php
phpunit.xml
+3
-2
3 additions, 2 deletions
phpunit.xml
with
103 additions
and
2 deletions
core/Test/ReportControllerTest.php
0 → 100644
+
100
−
0
View file @
232c4c06
<?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
ReportControllerTest
extends
TestCase
{
private
static
$id
=
null
;
public
function
testGetGroups
()
{
$reportController
=
new
\Report\controllers\ReportController
();
// GET
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'GET'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
$reportController
->
getGroups
(
$request
,
new
\Slim\Http\Response
());
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertInternalType
(
'array'
,
$responseBody
->
groups
);
self
::
$id
=
$responseBody
->
groups
[
0
]
->
group_id
;
}
public
function
testUpdateForGroupId
()
{
$reportController
=
new
\Report\controllers\ReportController
();
// GET
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'GET'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
$reportController
->
getByGroupId
(
$request
,
new
\Slim\Http\Response
(),
[
'groupId'
=>
self
::
$id
]);
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertInternalType
(
'array'
,
$responseBody
->
reports
);
foreach
(
$responseBody
->
reports
as
$key
=>
$report
)
{
$responseBody
->
reports
[
$key
]
->
checked
=
true
;
}
// PUT
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'PUT'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$fullRequest
=
\httpRequestCustom
::
addContentInBody
(
$responseBody
->
reports
,
$request
);
$response
=
$reportController
->
updateForGroupId
(
$fullRequest
,
new
\Slim\Http\Response
(),
[
'groupId'
=>
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
=
$reportController
->
getByGroupId
(
$request
,
new
\Slim\Http\Response
(),
[
'groupId'
=>
self
::
$id
]);
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertInternalType
(
'array'
,
$responseBody
->
reports
);
foreach
(
$responseBody
->
reports
as
$key
=>
$report
)
{
$this
->
assertSame
(
true
,
$report
->
checked
);
if
(
$key
%
2
)
{
$responseBody
->
reports
[
$key
]
->
checked
=
false
;
}
}
// PUT
$environment
=
\Slim\Http\Environment
::
mock
([
'REQUEST_METHOD'
=>
'PUT'
]);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$fullRequest
=
\httpRequestCustom
::
addContentInBody
(
$responseBody
->
reports
,
$request
);
$response
=
$reportController
->
updateForGroupId
(
$fullRequest
,
new
\Slim\Http\Response
(),
[
'groupId'
=>
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
=
$reportController
->
getByGroupId
(
$request
,
new
\Slim\Http\Response
(),
[
'groupId'
=>
self
::
$id
]);
$responseBody
=
json_decode
((
string
)
$response
->
getBody
());
$this
->
assertInternalType
(
'array'
,
$responseBody
->
reports
);
foreach
(
$responseBody
->
reports
as
$key
=>
$report
)
{
if
(
$key
%
2
)
{
$this
->
assertSame
(
false
,
$report
->
checked
);
}
else
{
$this
->
assertSame
(
true
,
$report
->
checked
);
}
}
}
}
This diff is collapsed.
Click to expand it.
phpunit.xml
+
3
−
2
View file @
232c4c06
...
@@ -5,10 +5,11 @@
...
@@ -5,10 +5,11 @@
<!--directory>core/Test</directory-->
<!--directory>core/Test</directory-->
<!--file>core/Test/ActionControllerTest.php</file-->
<!--file>core/Test/ActionControllerTest.php</file-->
<file>
core/Test/ResControllerTest.php
</file>
<file>
core/Test/ResControllerTest.php
</file>
<file>
core/Test/PriorityControllerTest.php
</file>
<file>
core/Test/StatusControllerTest.php
</file>
<file>
core/Test/UserControllerTest.php
</file>
<file>
core/Test/UserControllerTest.php
</file>
<file>
core/Test/BasketControllerTest.php
</file>
<file>
core/Test/BasketControllerTest.php
</file>
<file>
core/Test/PriorityControllerTest.php
</file>
<file>
core/Test/StatusControllerTest.php
</file>
<file>
core/Test/ReportControllerTest.php
</file>
<file>
modules/convert/Test/ProcessConvertTest.php
</file>
<file>
modules/convert/Test/ProcessConvertTest.php
</file>
<file>
modules/convert/Test/ProcessFulltextTest.php
</file>
<file>
modules/convert/Test/ProcessFulltextTest.php
</file>
<file>
modules/convert/Test/ProcessThumbnailsTest.php
</file>
<file>
modules/convert/Test/ProcessThumbnailsTest.php
</file>
...
...
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