From a74fb3ec84f51a8a65cf3e834eba6ea7df6aad4a Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Mon, 18 Nov 2013 22:04:26 +0000 Subject: [PATCH] Correction test liste des domaines / articles --- .../admin/controllers/CatalogueController.php | 2 +- library/Class/Catalogue.php | 34 +++++++++++++++++++ .../admin/controllers/CmsControllerTest.php | 8 +++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/application/modules/admin/controllers/CatalogueController.php b/application/modules/admin/controllers/CatalogueController.php index 73ea4964a1b..007ab9013a3 100644 --- a/application/modules/admin/controllers/CatalogueController.php +++ b/application/modules/admin/controllers/CatalogueController.php @@ -162,7 +162,7 @@ use Trait_Translator; public function domainesAction() { $this->_helper->viewRenderer->setNoRender(); $data = []; - $data[] = (new Class_Catalogue())->getDomainesJson(); + $data[] = (new Class_Catalogue())->getDomainesJsonWithoutPaniers(); $JSON = json_encode($data); $this->getResponse()->setHeader('Content-Type', 'application/json; charset=utf-8'); diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index 0e3c7c0382c..a47fbc9005b 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -929,6 +929,23 @@ class Class_Catalogue extends Storm_Model_Abstract { 'options' => array_merge(['ico' => URL_ADMIN_IMG.'picto/domaines_16.png'],$options)]; } + + public function toDataForJsonWithoutPaniers($options = []) { + $data_domaines = []; + $data_panier = []; + $data_items = []; + $domaines= $this->getSousDomaines(); + foreach ($domaines as $domaine) { + $data_domaines []= $domaine->toDataForJsonWithoutPaniers($options); + } + + return ['id' => $this->getId(), + 'label' => htmlspecialchars($this->getLibelle()), + 'categories' => $data_domaines, + 'items' => $data_panier, + 'options' => array_merge(['ico' => URL_ADMIN_IMG.'picto/domaines_16.png'],$options)]; + } + public function afterSave(){ $this->saveThesaurus(); @@ -1098,6 +1115,23 @@ class Class_Catalogue extends Storm_Model_Abstract { } + + public function getDomainesJsonWithoutPaniers($options = []) { + $domaines = Class_Catalogue::getLoader()->findTopCatalogues(); + $data_domaines=[]; + foreach($domaines as $domaine) { + $data_domaines [] = $domaine->toDataForJsonWithoutPaniers($options); + } + + return $data = ['id' => 'domaines', + 'label' => $this->_('Domaines'), + 'categories' => $data_domaines, + 'items' => [], + 'options' => ['ico' => URL_ADMIN_IMG.'picto/domaines_16.png', + 'multipleSelection' => false]]; + + } + } diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index 4c0fc983b7e..7d443fd71c9 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -798,8 +798,12 @@ class CmsControllerArticleConcertEditActionPostTest extends CmsControllerTestCas }], "items": []}] JSON; - $this->assertJsonStringEqualsJsonString($expectedJSON, - $this->_response->getBody()); + + $json = json_decode($this->_response->getBody(), true); + $this->assertEquals('Histoire', $json[0]['categories'][0]['label']); + $this->assertEquals(10, $json[0]['categories'][0]['id']); + $this->assertEquals('Art', $json[0]['categories'][0]['categories'][0]['label']); + $this->assertEquals(11, $json[0]['categories'][0]['categories'][0]['id']); } -- GitLab