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
e3fc7d5a
Commit
e3fc7d5a
authored
8 years ago
by
Giovannoni Laurent
Browse files
Options
Downloads
Patches
Plain Diff
FEAT add unit test skell
parent
5c1ee6f1
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/StatusControllerTest.php
+132
-0
132 additions, 0 deletions
core/Test/StatusControllerTest.php
core/Test/define.php
+65
-0
65 additions, 0 deletions
core/Test/define.php
with
197 additions
and
0 deletions
core/Test/StatusControllerTest.php
0 → 100644
+
132
−
0
View file @
e3fc7d5a
<?php
require_once
__DIR__
.
'/define.php'
;
class
StatusControllerTest
extends
PHPUnit_Framework_TestCase
{
public
function
testGetList
()
{
$action
=
new
\Core\Controllers\StatusController
();
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'GET'
,
//'REQUEST_URI' => '/status',
//'QUERY_STRING'=>'foo=bar',
]
);
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
new
\Slim\Http\Response
();
$response
=
$action
->
getList
(
$request
,
$response
,
[]);
$this
->
assertNotNull
((
string
)
$response
->
getBody
());
}
public
function
testGetById
()
{
$action
=
new
\Core\Controllers\StatusController
();
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'GET'
,
]
);
$aArgs
=
[
'id'
=>
'NEW'
];
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
new
\Slim\Http\Response
();
$response
=
$action
->
getById
(
$request
,
$response
,
$aArgs
);
$compare
=
'[{"status":[{"id":"NEW","label_status":"Nouveau",'
.
'"is_system":"Y","is_folder_status":"N","img_filename":'
.
'"fm-letter-status-new","maarch_module":"apps",'
.
'"can_be_searched":"Y","can_be_modified":"Y"}]}]'
;
$this
->
assertSame
((
string
)
$response
->
getBody
(),
$compare
);
}
public
function
testCreate
()
{
$action
=
new
\Core\Controllers\StatusController
();
$query
=
'id=TEST&'
;
$query
.
=
'label_status=TEST'
;
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'POST'
,
'QUERY_STRING'
=>
$query
,
]
);
$aArgs
=
[
'id'
=>
'NEW'
];
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
new
\Slim\Http\Response
();
$response
=
$action
->
create
(
$request
,
$response
,
$aArgs
);
$compare
=
'[{"status":[{"id":"TEST","label_status":"TEST",'
.
'"is_system":"Y","is_folder_status":"N","img_filename":null,'
.
'"maarch_module":"apps","can_be_searched":"Y",'
.
'"can_be_modified":"Y"}]}]'
;
$this
->
assertSame
((
string
)
$response
->
getBody
(),
$compare
);
}
public
function
testUpdate
()
{
$action
=
new
\Core\Controllers\StatusController
();
$query
=
'id=TEST&'
;
$query
.
=
'label_status=TEST AFTER UP'
;
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'PUT'
,
'QUERY_STRING'
=>
$query
,
]
);
$aArgs
=
[
'id'
=>
'NEW'
];
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
new
\Slim\Http\Response
();
$response
=
$action
->
update
(
$request
,
$response
,
$aArgs
);
$compare
=
'[{"status":[{"id":"TEST","label_status":"TEST AFTER UP",'
.
'"is_system":"Y","is_folder_status":"N","img_filename":null,'
.
'"maarch_module":"apps","can_be_searched":"Y",'
.
'"can_be_modified":"Y"}]}]'
;
$this
->
assertSame
((
string
)
$response
->
getBody
(),
$compare
);
}
public
function
testDelete
()
{
$action
=
new
\Core\Controllers\StatusController
();
$environment
=
\Slim\Http\Environment
::
mock
(
[
'REQUEST_METHOD'
=>
'DELETE'
,
]
);
$aArgs
=
[
'id'
=>
'TEST'
];
$request
=
\Slim\Http\Request
::
createFromEnvironment
(
$environment
);
$response
=
new
\Slim\Http\Response
();
$response
=
$action
->
delete
(
$request
,
$response
,
$aArgs
);
$this
->
assertSame
((
string
)
$response
->
getBody
(),
'[{"status":true}]'
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
core/Test/define.php
0 → 100644
+
65
−
0
View file @
e3fc7d5a
<?php
require_once
'vendor/autoload.php'
;
require_once
'core/class/class_functions.php'
;
include_once
(
'core/init.php'
);
require_once
(
'core/class/class_portal.php'
);
require_once
(
'core/class/class_db.php'
);
require_once
(
'core/class/class_request.php'
);
require_once
(
'core/class/class_core_tools.php'
);
require_once
(
'core/class/web_service/class_web_service.php'
);
require_once
(
'core/services/CoreConfig.php'
);
//for auth
$_SERVER
[
'PHP_AUTH_USER'
]
=
'superadmin'
;
$_SERVER
[
'PHP_AUTH_PW'
]
=
'superadmin'
;
//load Maarch session vars
$portal
=
new
portal
();
$portal
->
unset_session
();
$portal
->
build_config
();
$coreTools
=
new
core_tools
();
$_SESSION
[
'custom_override_id'
]
=
$coreTools
->
get_custom_id
();
if
(
isset
(
$_SESSION
[
'custom_override_id'
])
&&
!
empty
(
$_SESSION
[
'custom_override_id'
])
&&
isset
(
$_SESSION
[
'config'
][
'corepath'
])
&&
!
empty
(
$_SESSION
[
'config'
][
'corepath'
])
)
{
$path
=
$_SESSION
[
'config'
][
'corepath'
]
.
'custom'
.
DIRECTORY_SEPARATOR
.
$_SESSION
[
'custom_override_id'
]
.
DIRECTORY_SEPARATOR
;
set_include_path
(
$path
.
PATH_SEPARATOR
.
$_SESSION
[
'config'
][
'corepath'
]
.
PATH_SEPARATOR
.
get_include_path
()
);
}
else
if
(
isset
(
$_SESSION
[
'config'
][
'corepath'
])
&&
!
empty
(
$_SESSION
[
'config'
][
'corepath'
])
)
{
set_include_path
(
$_SESSION
[
'config'
][
'corepath'
]
.
PATH_SEPARATOR
.
get_include_path
()
);
}
// Load configuration from xml into session
Core_CoreConfig_Service
::
buildCoreConfig
(
'core'
.
DIRECTORY_SEPARATOR
.
'xml'
.
DIRECTORY_SEPARATOR
.
'config.xml'
);
$_SESSION
[
'config'
][
'app_id'
]
=
$_SESSION
[
'businessapps'
][
0
][
'appid'
];
require_once
'apps/'
.
$_SESSION
[
'businessapps'
][
0
][
'appid'
]
.
'/class/class_business_app_tools.php'
;
Core_CoreConfig_Service
::
buildBusinessAppConfig
();
// Load Modules configuration from xml into session
Core_CoreConfig_Service
::
loadModulesConfig
(
$_SESSION
[
'modules'
]);
Core_CoreConfig_Service
::
loadAppServices
();
Core_CoreConfig_Service
::
loadModulesServices
(
$_SESSION
[
'modules'
]);
//login management
require_once
(
'apps/maarch_entreprise/class/class_login.php'
);
$loginObj
=
new
login
();
$loginMethods
=
$loginObj
->
build_login_method
();
require_once
(
'core/services/Session.php'
);
$oSessionService
=
new
\Core_Session_Service
();
$loginObj
->
execute_login_script
(
$loginMethods
,
true
);
if
(
$_SESSION
[
'error'
])
{
//TODO : return http bad authent error
echo
$_SESSION
[
'error'
];
exit
();
}
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