Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Comptoir
Comptoir-srv
Commits
299e55eb
Commit
299e55eb
authored
Apr 19, 2020
by
Fabrice Gangler
🎨
Committed by
Fabrice Gangler
Apr 20, 2020
Browse files
REFACTOR(test): rename setAdminSession()
parent
655331cc
Changes
4
Hide whitespace changes
Inline
Side-by-side
tests/TestCase/Controller/Api/V1/ApiIntegrationTestCase.php
View file @
299e55eb
...
...
@@ -140,16 +140,16 @@ abstract class ApiIntegrationTestCase extends IntegrationTestCase
}
/**
* Set session for a admin user
* Set session for a admin user
with user type = 'Person'
*/
final
protected
function
setAdminSession
()
final
protected
function
setAdminSession
OfPersonType
()
{
$this
->
_session
=
[];
$this
->
session
([
'Auth'
=>
[
'User'
=>
[
'id'
=>
2
,
"user_type_id"
=>
2
,
"user_type_id"
=>
4
,
// Person
"role"
=>
'admin'
,
]
]
...
...
tests/TestCase/Controller/Api/V1/TagsControllerTest.php
View file @
299e55eb
...
...
@@ -288,7 +288,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
$this
->
assertEquals
(
'/users/login'
,
$headers
[
'Location'
]);
// Check if the new tag is NOT added
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
assertResponseSuccess
();
$tag
=
TableRegistry
::
get
(
'Tags'
);
$query
=
$tag
->
find
()
->
where
([
'name'
=>
$data
[
'name'
]]);
...
...
@@ -326,7 +326,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
public
function
testEdit
()
{
// Edit a tag
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
commonEdit
();
// Check if the tag is updated
...
...
@@ -417,7 +417,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
private
function
commonCheckFailEdit
()
{
// Check that the tag is not updated
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
get
(
'/api/v1/tags/4.json'
);
$expected
=
[
...
...
@@ -536,7 +536,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
*/
public
function
testDeleteIfNoRelationshipBetweenSoftwareAndTag
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
commonDelete
();
...
...
@@ -703,7 +703,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
*/
public
function
testDeleteTagLinkedToSoftware
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
configRequest
([
'headers'
=>
[
'Accept'
=>
'application/json'
]
]);
...
...
tests/TestCase/Controller/Api/V1/TaxonomysControllerTest.php
View file @
299e55eb
...
...
@@ -77,7 +77,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
$title
=
"<title>Cartographie des logiciels métiers pour les collectivités</title>"
;
// Admin user --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$r
=
$this
->
checkUrlOk
(
$url
,
[
'html'
]);
$html
=
$r
[
'html'
][
'data'
];
$this
->
assertContains
(
'<html lang="fr">'
,
$html
);
...
...
@@ -115,7 +115,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
{
// Admin user
// --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// French user:
$expectedUrl
=
'/fr/cartographie/'
;
...
...
@@ -170,7 +170,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
$url
=
'/api/v1/taxonomys/mapping'
;
// Admin user ---> to be replaced by an anonymous and/or connected user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// JSON format
$this
->
checkUrlNotFound
(
$url
,
[
'json'
]);
...
...
@@ -220,7 +220,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
$htmlTitle
=
"<title>Métiers"
;
// Admin user --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$r
=
$this
->
checkUrlOk
(
$url
,
[
'html'
]);
$html
=
$r
[
'html'
][
'data'
];
$this
->
assertContains
(
'<html lang="fr">'
,
$html
);
...
...
@@ -262,7 +262,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
{
// Admin user
// --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// French user:
$expectedUrl
=
'/fr/cartographie/metiers/'
;
...
...
@@ -317,7 +317,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
{
// Admin user
// --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// French user:
$expectedUrl
=
'/fr/cartographie/'
;
...
...
@@ -350,7 +350,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
$url
=
'/api/v1/taxonomys/mappingPrimaryLevel/1'
;
// Admin user ---> to be replaced by an anonymous and/or connected user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// JSON format
$this
->
checkUrlNotFound
(
$url
,
[
'json'
]);
...
...
@@ -399,7 +399,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
$htmlTitle
=
"<title>Bureautique"
;
// Admin user --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$r
=
$this
->
checkUrlOk
(
$url
,
[
'html'
]);
$html
=
$r
[
'html'
][
'data'
];
$this
->
assertContains
(
'<html lang="fr">'
,
$html
);
...
...
@@ -442,7 +442,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
{
// Admin user
// --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// French user:
$expectedUrl
=
'/fr/cartographie/generiques/bureautique/4'
;
...
...
@@ -496,7 +496,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
{
// Admin user
// --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// French user:
$expectedUrl
=
'/fr/cartographie/'
;
...
...
@@ -529,7 +529,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
$url
=
'/api/v1/taxonomys/mappingTaxon/4'
;
// Admin user ---> to be replaced by an anonymous and/or connected user when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// JSON format
$this
->
checkUrlNotFound
(
$url
,
[
'json'
]);
...
...
@@ -573,7 +573,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public
function
testIndexForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
checkUrlOk
(
'/api/v1/taxonomys'
);
}
...
...
@@ -591,7 +591,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public
function
testViewForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
checkUrlOk
(
'/api/v1/taxonomys/view/1'
);
}
...
...
@@ -610,7 +610,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public
function
testAddForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
checkUrlOk
(
'/api/v1/taxonomys/add'
);
$this
->
markTestIncomplete
(
'Not implemented yet.'
);
...
...
@@ -631,7 +631,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public
function
testEditForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
checkUrlOk
(
'/api/v1/taxonomys/edit/1'
);
$this
->
markTestIncomplete
(
'Not implemented yet.'
);
...
...
@@ -652,7 +652,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public
function
testDeleteForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
markTestIncomplete
(
'Not implemented yet.'
);
}
...
...
tests/TestCase/Controller/Api/V1/TaxonomysSoftwaresControllerTest.php
View file @
299e55eb
...
...
@@ -77,7 +77,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
$title
=
"<title>Formulaire cartographie</title>"
;
// Admin user --> to be replaced by a connected user (type = "Administration") when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$r
=
$this
->
checkUrlOk
(
$url
,
[
'html'
]);
$html
=
$r
[
'html'
][
'data'
];
$this
->
assertContains
(
'<html lang="fr">'
,
$html
);
...
...
@@ -114,7 +114,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
$url
=
'/fr/mappingForm/888'
;
// software ID 888 ---> not in database
// Admin user --> to be replaced by a connected user (type = "Administration") when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
get
(
"/fr/"
);
// force user language to french
$expectedUrl
=
'/fr/cartographie/'
;
$this
->
checkUrlRedirectToAnotherUrl
(
$url
,
$expectedUrl
,
[
'html'
],
301
);
...
...
@@ -147,7 +147,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
$url
=
"
$urlBase
/2"
;
// software ID 2
// Admin user ---> to be replaced by a connected user (type = "Administration") when development is complete.
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
// JSON format
$this
->
checkUrlNotFound
(
$urlBase
,
[
'json'
]);
...
...
@@ -194,7 +194,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
*/
public
function
testIndexForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$result
=
$this
->
checkUrlOk
(
'/api/v1/taxonomys-softwares'
);
$json
=
$result
[
'json'
];
$html
=
$result
[
'html'
];
...
...
@@ -213,7 +213,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
*/
public
function
testViewForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$result
=
$this
->
checkUrlOk
(
'/api/v1/taxonomys-softwares/view/1'
);
}
...
...
@@ -231,7 +231,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
*/
public
function
testAddForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$result
=
$this
->
checkUrlOk
(
'/api/v1/taxonomys-softwares/add'
);
$this
->
markTestIncomplete
(
'Not implemented yet.'
);
...
...
@@ -251,7 +251,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
*/
public
function
testEditForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$result
=
$this
->
checkUrlOk
(
'/api/v1/taxonomys-softwares/edit/1'
);
$this
->
markTestIncomplete
(
'Not implemented yet.'
);
...
...
@@ -271,7 +271,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
*/
public
function
testDeleteForAdminUser
()
{
$this
->
setAdminSession
();
$this
->
setAdminSession
OfPersonType
();
$this
->
markTestIncomplete
(
'Not implemented yet.'
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment