Commit 14fedf01 authored by Fabrice Gangler's avatar Fabrice Gangler 🎨
Browse files

TEST(mapping): add tests on a taxon page

Refs: #822
parent 78e192cb
Pipeline #9501 passed with stage
in 3 minutes and 19 seconds
......@@ -88,5 +88,15 @@ class TaxonomysFixture extends TestFixture
'created' => 1581686273,
'modified' => 1581686273
],
[
// 'id' => 6,
'parent_id' => 2,
'title_i18n_en' => 'Design',
'title_i18n_fr' => 'Design',
'description_i18n_en' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida',
'description_i18n_fr' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida',
'created' => 1581686273,
'modified' => 1581686273
],
];
}
......@@ -110,5 +110,14 @@ class TaxonomysSoftwaresFixture extends TestFixture
'created' => 1581686289,
'modified' => 1581686289
],
[
// 'id' => 9,
'taxonomy_id' => 6,
'software_id' => 4,
'user_id' => null,
'created' => 1581686289,
'modified' => 1581686289
],
];
}
......@@ -376,7 +376,7 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Test mappingTaxon method : main unit tests
* Test mappingTaxon method : a taxon has a software with users (one or more)
*
* URL: /fr/cartographie/<slugPrimaryLevel>/<slugTaxon>/<taxonId>
* /en/mapping/<slugPrimaryLevel>/<slugTaxon>/<taxonId>
......@@ -393,17 +393,23 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
* @group taxonomy_method_mappingTaxon
* @return void
*/
public function testMappingTaxon()
public function testMappingTaxonShouldHaveSoftwareWithUsers()
{
$url = '/fr/cartographie/generiques/bureautique/4';
$htmlTitle = "<title>Bureautique";
$idTaxon = 3;
$idSoftware = 1;
$url = "/fr/cartographie/metiers/urbanisme-espace-public-environnement/$idTaxon";
$htmlTitle = "<title>Urbanisme / Espace public / Environnement";
// Admin user --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this->setAdminSessionOfPersonType();
$r = $this->checkUrlOk($url, ['html']);
$html = $r['html']['data'];
$this->assertContains('<html lang="fr">', $html);
$this->assertContains("$htmlTitle", $html);
$this->assertContains($htmlTitle, $html);
$this->assertContains("id=\"sofwareListForTaxon$idTaxon\"", $html);
$this->assertContains("class=\"item-softwareForTaxon$idTaxon\"", $html);
$this->assertContains("id=\"item-software$idSoftware-forTaxon$idTaxon\"", $html);
$this->assertContains("id=\"link-software$idSoftware-forTaxon$idTaxon\"", $html);
// Connected user
$this->setConnectedUserSession();
......@@ -415,6 +421,78 @@ class TaxonomysControllerTest extends ApiIntegrationTestCase
}
/**
* Test mappingTaxon method : a taxon has a software without user (preselected software)
*
* URL: /fr/cartographie/<slugPrimaryLevel>/<slugTaxon>/<taxonId>
* /en/mapping/<slugPrimaryLevel>/<slugTaxon>/<taxonId>
*
* ex: /fr/cartographie/metiers/sante-social/14 /en/mapping/business/healthcare-social/14
* /fr/cartographie/generiques/bureautique/20 /en/mapping/generics/office-automation/20
*
* @todo WIP
* @todo admin user to be replaced by an anonymous and/or connected user when development is complete.
*
* @group public
* @group taxonomy
* @group taxonomy_public
* @group taxonomy_method_mappingTaxon
* @return void
*/
public function testMappingTaxonShouldHaveSoftwareWithoutUsers()
{
$idTaxon = 6;
$idSoftware = 4;
$url = "/fr/cartographie/generiques/design/$idTaxon";
$htmlTitle = "<title>Design";
// Admin user --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this->setAdminSessionOfPersonType();
$r = $this->checkUrlOk($url, ['html']);
$html = $r['html']['data'];
$this->assertContains('<html lang="fr">', $html);
$this->assertContains($htmlTitle, $html);
$this->assertContains("id=\"sofwareListForTaxon$idTaxon\"", $html);
$this->assertContains("class=\"item-softwareForTaxon$idTaxon\"", $html);
$this->assertContains("id=\"item-software$idSoftware-forTaxon$idTaxon\"", $html);
$this->assertNotContains("id=\"link-software$idSoftware-forTaxon$idTaxon\"", $html);
}
/**
* Test mappingTaxon method : a taxon has no software
*
* URL: /fr/cartographie/<slugPrimaryLevel>/<slugTaxon>/<taxonId>
* /en/mapping/<slugPrimaryLevel>/<slugTaxon>/<taxonId>
*
* ex: /fr/cartographie/metiers/sante-social/14 /en/mapping/business/healthcare-social/14
* /fr/cartographie/generiques/bureautique/20 /en/mapping/generics/office-automation/20
*
* @todo WIP
* @todo admin user to be replaced by an anonymous and/or connected user when development is complete.
*
* @group public
* @group taxonomy
* @group taxonomy_public
* @group taxonomy_method_mappingTaxon
* @return void
*/
public function testMappingTaxonShouldNotHaveSoftware()
{
$idTaxon = 4;
$url = "/fr/cartographie/generiques/bureautique/$idTaxon";
$htmlTitle = "<title>Bureautique";
// Admin user --> to be replaced by an anonymous user and a logged-in user when development is complete.
$this->setAdminSessionOfPersonType();
$r = $this->checkUrlOk($url, ['html']);
$html = $r['html']['data'];
$this->assertContains('<html lang="fr">', $html);
$this->assertContains($htmlTitle, $html);
$this->assertNotContains("id=\"sofwareListForTaxon$idTaxon\"", $html);
$this->assertNotContains("class=\"item-softwareForTaxon$idTaxon\"", $html);
}
/**
* MappingTaxon method
*
......
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