Commit 299e55eb authored by Fabrice Gangler's avatar Fabrice Gangler 🎨 Committed by Fabrice Gangler
Browse files

REFACTOR(test): rename setAdminSession()

parent 655331cc
......@@ -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 setAdminSessionOfPersonType()
{
$this->_session = [];
$this->session([
'Auth' => [
'User' => [
'id' => 2,
"user_type_id" => 2,
"user_type_id" => 4, // Person
"role" => 'admin',
]
]
......
......@@ -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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$this->get('/api/v1/tags/4.json');
$expected =
[
......@@ -536,7 +536,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
*/
public function testDeleteIfNoRelationshipBetweenSoftwareAndTag()
{
$this->setAdminSession();
$this->setAdminSessionOfPersonType();
$this->commonDelete();
......@@ -703,7 +703,7 @@ class TagsControllerTest extends ApiIntegrationTestCase
*/
public function testDeleteTagLinkedToSoftware()
{
$this->setAdminSession();
$this->setAdminSessionOfPersonType();
$this->configRequest([
'headers' => ['Accept' => 'application/json']
]);
......
......@@ -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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
// 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->setAdminSessionOfPersonType();
// 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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
// 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->setAdminSessionOfPersonType();
// 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->setAdminSessionOfPersonType();
// 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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
// 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->setAdminSessionOfPersonType();
// 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->setAdminSessionOfPersonType();
// JSON format
$this->checkUrlNotFound($url, ['json']);
......@@ -573,7 +573,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public function testIndexForAdminUser()
{
$this->setAdminSession();
$this->setAdminSessionOfPersonType();
$this->checkUrlOk('/api/v1/taxonomys');
}
......@@ -591,7 +591,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public function testViewForAdminUser()
{
$this->setAdminSession();
$this->setAdminSessionOfPersonType();
$this->checkUrlOk('/api/v1/taxonomys/view/1');
}
......@@ -610,7 +610,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
*/
public function testAddForAdminUser()
{
$this->setAdminSession();
$this->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$this->markTestIncomplete('Not implemented yet.');
}
......
......@@ -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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
// JSON format
$this->checkUrlNotFound($urlBase, ['json']);
......@@ -194,7 +194,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
*/
public function testIndexForAdminUser()
{
$this->setAdminSession();
$this->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$result = $this->checkUrlOk('/api/v1/taxonomys-softwares/view/1');
}
......@@ -231,7 +231,7 @@ class TaxonomysSoftwaresControllerTest extends ApiIntegrationTestCase
*/
public function testAddForAdminUser()
{
$this->setAdminSession();
$this->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$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->setAdminSessionOfPersonType();
$this->markTestIncomplete('Not implemented yet.');
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment