diff --git a/application/modules/admin/controllers/AccueilController.php b/application/modules/admin/controllers/AccueilController.php index 733a9ce0d67f2ad7f4ad0b28b668941ca48f7b59..b4b8830e12b0598918ccab9a06b6f54488ee4fac 100644 --- a/application/modules/admin/controllers/AccueilController.php +++ b/application/modules/admin/controllers/AccueilController.php @@ -114,6 +114,7 @@ class Admin_AccueilController extends Zend_Controller_Action { } public function sitothequeAction() { $this->preprocessSitoCategories(); + $this->_request->setPost('group_by_categorie','0'); $this->_simpleAction('SITO'); } diff --git a/application/modules/admin/views/scripts/accueil/sitotheque.phtml b/application/modules/admin/views/scripts/accueil/sitotheque.phtml index b7601c1865c74d8712a8a4ddf69cd1456f2ca46d..fd9d3f91417c0a4c45360589696166228911fb5b 100644 --- a/application/modules/admin/views/scripts/accueil/sitotheque.phtml +++ b/application/modules/admin/views/scripts/accueil/sitotheque.phtml @@ -34,7 +34,7 @@ <td class="droite" width="90px">Type </td> <td class="gauche"> <?php - $onchange="$('.treeselect').treeselect('toggleVisibility', (this.value == '1' || this.value=='3'));"; + $onchange="(this.value=='3') ? $('.group_cat').hide(): $('.group_cat').show(); $('.treeselect').treeselect('toggleVisibility', (this.value == '1' || this.value=='3'));"; echo $this->formSelect("type_aff", $this->preferences["type_aff"], ["onchange" => $onchange], @@ -79,7 +79,7 @@ <td class="gauche"><input type="text" name="nb_aff" size="3" maxlength="3" value="<?php print($this->preferences["nb_aff"]); ?>"></td> </tr> - <tr> + <tr class='group_cat' <?php if ($this->preferences['type_aff']==3) echo " style='display:none;' "; ?> > <td class="droite" width="90px">Grouper par catégorie </td> <td class="gauche"> <?php diff --git a/application/modules/opac/controllers/DomainsController.php b/application/modules/opac/controllers/DomainsController.php index 89623455126484128b5756bf8a5ff4025ee3f070..cdc9eb5374f4821ee287e7e86b7e94b1776e956e 100644 --- a/application/modules/opac/controllers/DomainsController.php +++ b/application/modules/opac/controllers/DomainsController.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class DomainsController extends ZendAfi_Controller_Action { @@ -41,7 +41,6 @@ class DomainsController extends ZendAfi_Controller_Action { $this->view->current_domain = $catalog; $this->view->id_module = $id_module; - $this->view->current_breadcrumb = $this->_getParam('parents'); } } ?> \ No newline at end of file diff --git a/application/modules/opac/controllers/SitoController.php b/application/modules/opac/controllers/SitoController.php index 4c9cffe76372c5e0b7264eafde03fe7cb3c363ef..d1cbfb51ea43c5cea3c0c3a90236c089f4e1ee08 100644 --- a/application/modules/opac/controllers/SitoController.php +++ b/application/modules/opac/controllers/SitoController.php @@ -61,7 +61,16 @@ class SitoController extends Zend_Controller_Action { } public function viewcategoryAction() { - $this->view->id_category=$this->_getParam('id_category'); + $this->view->id_category=$this->_getParam('id_cat'); + $search = $this->_getParam('title_search', ''); + $this->view->list = $this->_helper->listViewMode( + ['model' => Class_SitothequeCategorie::find($this->view->id_category), + 'strategy_label' => 'sitotheque', + 'search_value' => $search, + 'id_cat'=>$this->view->id_category, + 'page' => $this->_getParam('page',1)]); +// return $this->getHelper('ViewRenderer')->renderScript('admin/listViewMode.phtml'); + } public function viewselectionAction() { diff --git a/application/modules/opac/views/scripts/pagination.phtml b/application/modules/opac/views/scripts/pagination.phtml new file mode 100644 index 0000000000000000000000000000000000000000..aa60d29e84bb94ec33efdc50d615f44afade7f5b --- /dev/null +++ b/application/modules/opac/views/scripts/pagination.phtml @@ -0,0 +1,27 @@ +<?php if (1 >= $this->pageCount) return;?> +<?php if ($this->pageCount): ?> +<div class="paginationControl"> +<!-- Previous page link --> +<?php if (isset($this->previous)): ?> + <a href="<?php echo $this->url(['page' => $this->previous]); ?>">< <?php echo $this->_('Précédent'); ?></a> | +<?php else: ?> + <span class="disabled">< <?php echo $this->_('Précédent'); ?></span> | +<?php endif; ?> + +<!-- Numbered page links --> +<?php foreach ($this->pagesInRange as $page): ?> + <?php if ($page != $this->current): ?> + <a href="<?php echo $this->url(['page' => $page]); ?>"><?php echo $page; ?></a> | + <?php else: ?> + <?= $page; ?> | + <?php endif; ?> +<?php endforeach; ?> + +<!-- Next page link --> +<?php if (isset($this->next)): ?> + <a href="<?php echo $this->url(array('page' => $this->next)); ?>"><?php echo $this->_('Suivant'); ?> ></a> +<?php else: ?> + <span class="disabled"><?php echo $this->_('Suivant'); ?> ></span> +<?php endif; ?> +</div> +<?php endif; ?> diff --git a/application/modules/opac/views/scripts/sito/viewcategory.phtml b/application/modules/opac/views/scripts/sito/viewcategory.phtml index b0c40fb7ccc01862f3b1ad4b67583690c6cf9dfb..b93542e70556ec53447af1c07562545f3b2d2790 100644 --- a/application/modules/opac/views/scripts/sito/viewcategory.phtml +++ b/application/modules/opac/views/scripts/sito/viewcategory.phtml @@ -1,3 +1,6 @@ + <?php - echo $this->sitoTree($this->id_category); + +echo $this->publicListViewMode($this->list); +// echo $this->sitoTree($this->id_category); ?> diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php new file mode 100644 index 0000000000000000000000000000000000000000..3057a1b1f8ad1435cb8da8464cf8e555690fd42a --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Strategy/Sitotheque.php @@ -0,0 +1,126 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_Controller_Action_Helper_ListViewMode_Strategy_Sitotheque extends ZendAfi_Controller_Action_Helper_ListViewMode_Strategy { + + const ITEMS_PAGINATION = 5; + protected $_filtred_categories, + $_filtred_categories_ids, + $_current_bib; + + public function getBaseUrl() { + return ['module' => 'opac', + 'controller' => 'sito', + 'action' => 'viewcategory']; + } + + + public function getSearchUrl() { + return $this->getBaseUrl() + [ + 'title_search' => '']; + } + + + public function getBreadcrumbUrl() { + return ['module' => 'opac', + 'controller' => 'sito', + 'action' => 'viewcategory']; + } + + + public function getParamKey() { + return 'id_cat'; + } + + + public function getCategories() { + $categories = []; + + $categories = (!$id_cat = $this->_visitor->getParams()['id_cat']) + ? Class_SitothequeCategorie::findAll() + : Class_SitothequeCategorie::findAllBy(['id_cat_mere' => $id_cat]); + + return $categories; + } + + + public function getItems() { + return Class_Sitotheque::findAllBy($this->getItemsParams()); + } + + + + public function getCountSearchResult() { + return Class_Article::countBy(parent::getSearchParams()); + } + + + public function getBreadcrumb() { + $breadcrumb = []; + if($this->_visitor->getSearchValue()) + return $breadcrumb; + + return array_merge($breadcrumb, $this->getBreadcrumbFor($this->_visitor->getModel())); + } + + + + public function getDefaultModel() { + return Class_SitothequeCategorie::find($this->_visitor->getParams()['id_cat']); + + } + + + public function countItemsFor($model) { + $id = $model ? $model->getId() : 0; + return Class_Sitotheque::countBy([$this->getParamKey() => $id]); + } + + + public function getCategoriesCols() { + return [$this->_('Catégories d\'articles')]; + } + + + public function getCategoriesLabelAttrib() { + return 'libelle'; + } + + public function getCategoriesId() { + return 'sitotheque'; + } + + public function getItemsId() { + return 'sitotheque'; + } + + + public function getItemsCols() { + return [$this->_('Liste des articles')]; + } + + + public function getItemsLabelAttrib() { + return 'titre'; + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Accueil/Sito.php b/library/ZendAfi/View/Helper/Accueil/Sito.php index 3ad001cf9f7c003c878a0f32b63238102aa488b2..8a656d279d4a5f36433452344ea4bea617dddbc2 100644 --- a/library/ZendAfi/View/Helper/Accueil/Sito.php +++ b/library/ZendAfi/View/Helper/Accueil/Sito.php @@ -42,7 +42,7 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base $box_title = $this->preferences['titre'] ? $this->preferences['titre'] : 'Derniers sites ajoutés'; if ($this->isHierarchicalDisplay()) { - $this->contenu = $this->sitotree_helper->sitoTree($this->preferences['id_categorie']); + $this->contenu = $this->sitotree_helper->sitoTree($this->preferences['id_categorie'],$nb_aff); $this->titre = $box_title; return $this->getHtmlArray(); } @@ -60,7 +60,10 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base $this->titre = $this->renderTitleLink($box_title, 'Sélection de sites', - BASE_URL.'/opac/sito/viewselection/id_module/'.$this->id_module); + $this->view->url(['module' => 'opac', + 'controller' => 'sito', + 'action' => 'viewselection', + 'id_module' => $this->id_module],null,true)); } @@ -72,13 +75,20 @@ class ZendAfi_View_Helper_Accueil_Sito extends ZendAfi_View_Helper_Accueil_Base $this->titre = $this->renderTitleLink($box_title, 'Liste des derniers sites ajoutés', - BASE_URL.'/opac/sito/viewrecent/nb/50'); + $this->view->url(['controller' => 'sito', + 'action' => 'viewrecent', + 'nb' => 50],null,true)); } $this->contenu = $this->renderSitesSlice($sites, $nb_aff); return $this->getHtmlArray(); } + public function renderTitleLink($content, $title, $url) { + return $this->view->tagAnchor($url, $content, ['title' => $this->translate()->_($title)]); + + } + public function isTypeAffichageSelection() { return $this->preferences['type_aff'] == 1; diff --git a/library/ZendAfi/View/Helper/Admin/ListViewMode.php b/library/ZendAfi/View/Helper/Admin/ListViewMode.php index 4b39f5c405ea83bed44dfd62fc98eb7a6c487798..32f451b8131301990fbd94ebbcccd11b48fe56c3 100644 --- a/library/ZendAfi/View/Helper/Admin/ListViewMode.php +++ b/library/ZendAfi/View/Helper/Admin/ListViewMode.php @@ -37,6 +37,7 @@ class ZendAfi_View_Helper_Admin_ListViewMode extends ZendAfi_View_Helper_BaseHel } + protected function getSearchFormHTML() { if(!$this->_list->isSearchEnabled()) return ''; diff --git a/library/ZendAfi/View/Helper/PublicListViewMode.php b/library/ZendAfi/View/Helper/PublicListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..2759f31b076eebdc4d521aad479095bf193027fd --- /dev/null +++ b/library/ZendAfi/View/Helper/PublicListViewMode.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_PublicListViewMode extends ZendAfi_View_Helper_Admin_ListViewMode { + public function publicListViewMode($list) { + if(!$this->_list = $list) + return ''; + + $html = $this->getSearchFormHTML() + .$this->getBreadcrumbHTML() + .$this->getCategoriesHTML() + . $this->getItemsHTML() + . $this->getItemsPaginatorHTML(); + return $html; + + } + + + protected function getCategoriesHTML() { + if($this->_list->getSearchValue()) + return ''; + + $labelWithCount = function($model, $attrib) { + return $this->view->tagAnchor($this->view->url(array_merge($this->_list->getBaseUrl(), + [ $this->_list->getParamKey() => $model->getId()]), null, true), + $model->$attrib + . ' (' . $this->_list->countItemsFor($model) . ')');}; + + return $this->view->tagList($this->_list->getCategories(), + $this->_list->getCategoriesAttribs(), + + $this->_list->getCategoriesId(), + [$this->_list->getCategoriesLabelAttrib() => $labelWithCount] + + ); + } + + + protected function getItemsHTML() { + if(!$this->_list->getModel() && !$this->_list->getSearchValue()) + return ''; + $labelWithThumbnail = function($model, $attrib) { + $html=''; + if ($img_url = $this->getThumbnail($model->getUrl())) + $html.= $this->view->tagImg($img_url,['alt' => $this->_('vignette site '.$model->$attrib)]); + + return $html.$this->view->tagAnchor($model->getUrl(),$model->$attrib, + ['title' => 'Aller sur le site']); + }; + + return $this->view->tagList($this->_list->getItems(), + $this->_list->getItemsAttribs(), + $this->_list->getItemsId(), + [$this->_list->getItemsLabelAttrib() => $labelWithThumbnail]); + + + + + } + + + public function getThumbnail($url) { + if (!isset($this->thumbnails_helper)) + $this->thumbnails_helper = (new ZendAfi_View_Helper_WebThumbnail()) + ->setView($this->view); + return $this->thumbnails_helper->webThumbnail($url); + } + +} +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/SitoTree.php b/library/ZendAfi/View/Helper/SitoTree.php index 1ded83850ab44a10e8b6c4a7dec21ad0d2aa6336..b1bd493e3b4356a11677cdfcfb321d1037829a7c 100644 --- a/library/ZendAfi/View/Helper/SitoTree.php +++ b/library/ZendAfi/View/Helper/SitoTree.php @@ -24,19 +24,12 @@ class ZendAfi_View_Helper_SitoTree extends Zend_View_Helper_Abstract { use Trait_Translator; protected $titre,$contenu,$preferences,$division; - public function renderTitleLink($content, $title, $url) { - return sprintf('<a href="%s" title="%s">%s</a>', - htmlspecialchars($url), - $this->translate()->_($title), - $content); - } - - public function sitoTree($id_category) { + public function sitoTree($id_category,$max_display=10) { $category = Class_SitothequeCategorie::find($id_category); - return $this->renderHierarchicalCategories($category); + return $this->renderHierarchicalCategories($category,$max_display); } - protected function renderSite($site) { + public function renderSite($site) { $html = sprintf('<h2><a href="%s" title="%s">', $site->getUrl(), @@ -52,12 +45,13 @@ class ZendAfi_View_Helper_SitoTree extends Zend_View_Helper_Abstract { } - protected function renderHierarchicalCategories($category) { + protected function renderHierarchicalCategories($category,$max_display) { $html = ''; - foreach ($category->getChildren() as $child_category) + $children=$category->getChildren(); + foreach (array_slice($children,0, $max_display) as $child_category) $html .= $this->renderHierarchicalCategory($child_category); - foreach ($category->getItems() as $site) + foreach (array_slice($category->getItems(),0, $max_display - count($children)) as $site) $html .= '<li>'.$this->renderSite($site).'</li>'; return '<ul class="sitotheque">'.$html.'</ul>'; @@ -69,8 +63,8 @@ class ZendAfi_View_Helper_SitoTree extends Zend_View_Helper_Abstract { return ''; return '<li><h2><a href="'.$this->view->url(['controller' => 'sito', - 'action' => 'viewcategory', - 'id_category' => $category->getId()],null,true).'">' . $category->getLibelle() . '</a></h2>'; + 'action' => 'viewcategory', + 'id_cat' => $category->getId()],null,true).'">' . $category->getLibelle() . '</a></h2>'; } diff --git a/library/ZendAfi/View/Helper/TagList.php b/library/ZendAfi/View/Helper/TagList.php new file mode 100644 index 0000000000000000000000000000000000000000..34261c8be7ebbb69039f297bdf367e8ad6622402 --- /dev/null +++ b/library/ZendAfi/View/Helper/TagList.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +class ZendAfi_View_Helper_TagList extends Zend_View_Helper_HtmlElement { + protected $id_list; + + public function tagList($models, $attribs, $id, $callbacks = []) { + $this->id_list=$id; + return $this->renderModelsAsUlLi($models, $attribs, $callbacks); + } + + + + + public function renderModelsAsUlLi($models, $attribs, $callbacks) { + $rows = ''; + + foreach ($models as $model) { + $rows .= $this->renderModelAsUlLi($model, $attribs,$callbacks); + } + + return $rows; + } + + + public function renderModelAsUlLi($model, $attribs, $callbacks) { + $cols = ''; + + $default_callback = function ($model, $attrib) { + return $this->view->escape($model->callGetterByAttributeName($attrib)); + }; + + foreach ($attribs as $attrib) { + $callback = (array_key_exists($attrib, $callbacks)) ? $callbacks[$attrib] : $default_callback; + $cols .= $this->tag('li', $callback($model, $attrib)); + } + + return $this->tag('ul', $cols,['class' => $this->id_list]); + } + + + /** shortcut to $this->view->tag() */ + protected function tag() { + return call_user_func_array([$this->view, 'tag'], func_get_args()); + } +} + +?> diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index 86e0ff1bd25d57bc8b037f270fa1506380a37ec0..25620bc3fa7e73df35f7440d972d2cdaac66d2f1 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -229,7 +229,7 @@ class AccueilControllerConfigSitothequePostTest extends Admin_AbstractController [ 'type_aff' => 3, 'nb_aff' => 2, - 'group_by_categorie' => 0, + 'group_by_categorie' => true, 'id_categorie' => '12-17' ]); @@ -237,6 +237,20 @@ class AccueilControllerConfigSitothequePostTest extends Admin_AbstractController } + /** @test */ + public function selectHierachicalDisplayShouldForceGroupByCategoryToFalse() { + $this->postDispatch('/admin/accueil/sitotheque?config=accueil&id_profil=1&type_module=SITO&id_module=25', + [ + 'type_aff' => 3, + 'nb_aff' => 2, + 'group_by_categorie' => true, + 'id_categorie' => '12-17' + ]); + + + $this->assertEquals('0', Class_Profil::find(1)->getModuleAccueilConfig(25,'SITO')['preferences']['group_by_categorie']); + + } /** @test */ public function selectHierachicalDisplayWithEmptyCategoriesShouldSaveOnlyFirstCategory() { $this->postDispatch('/admin/accueil/sitotheque?config=accueil&id_profil=1&type_module=SITO&id_module=25', diff --git a/tests/application/modules/opac/controllers/SitoControllerTest.php b/tests/application/modules/opac/controllers/SitoControllerTest.php index 03abe813e90f7173d8ab5845ec3b341a74958c41..7ac150750efe2d6c7a2df5a8ffe7b55429a67980 100644 --- a/tests/application/modules/opac/controllers/SitoControllerTest.php +++ b/tests/application/modules/opac/controllers/SitoControllerTest.php @@ -95,19 +95,19 @@ class SitoControllerHierarchicViewTest extends SitoControllerTestCase { ], 'options' => []]); - $this->dispatch('/sito/viewcategory/id_category/12', true); + $this->dispatch('/sito/viewcategory/id_cat/12', true); } /** @test */ public function LinuxFrShouldNotBeShown() { - $this->assertNotXPath('//div[@class="contenu"]//div[@class="sitotheque"]//a[@href="http://linuxfr.org"]', + $this->assertNotXPath('//ul[@class="sitotheque"]//a[@href="http://linuxfr.org"]', $this->_response->getBody()); } /** @test */ public function FramasoftShouldBeShown() { - $this->assertNotXPath('//div[@class="contenu"]//div[@class="sitotheque"]//a[@href="http://framasoft.org"]', + $this->assertXPath('//ul[@class="sitotheque"]//a[@href="http://framasoft.org"]', $this->_response->getBody()); } } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php index 2383bfb61ccd03e65d8cdec13d0b32d6337627a8..fabdf2a7ee582d4d1641d9e733c1a5cd465378c9 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php @@ -61,18 +61,21 @@ abstract class SitoViewHelperTestCase extends ViewHelperTestCase { 'url' => 'http://www.fosdem.org', 'categorie' => $this->_belgique]); - $this->fixture('Class_Sitotheque', ['id' => 150, - 'titre'=>'Des veaux', - 'description' => 'des veaux', - 'url' => 'http://www.desveaux.info', - 'categorie' => $this->_creuse]); - - $site_rmll = $this->fixture('Class_Sitotheque', ['id' => 15, - 'titre'=>'RMLL', - 'description' => 'du vin du vin!', - 'url' => 'http://www.rmll.info', - 'categorie' => $this->_france]); - xdebug_break(); + + $this->fixture('Class_Sitotheque', ['id' => 15, + 'titre'=>'RMLL', + 'description' => 'du vin du vin!', + 'url' => 'http://www.rmll.info', + 'categorie' => $this->_france]); + + for ($id=16;$id<25;$id++) { + $this->fixture('Class_Sitotheque', ['id' => $id, + 'titre'=> 'Sito numero '.$id, + 'description' => 'lien dupliques', + 'url' => 'http://www.unlien.info', + 'categorie' => $this->_france]); + + } $this->_helper = new ZendAfi_View_Helper_Accueil_Sito(2, ['division' => '1', 'type_module' => 'SITO', @@ -239,7 +242,7 @@ class SitoViewHelperHierarchicalCategoryTest extends SitoViewHelperTestCase { 'type_aff' => 3, 'id_items' => '', 'id_categorie' => '9', - 'nb_aff' => 0, + 'nb_aff' => 5, 'display_order' => 'Selection']; public function setUp() { @@ -279,10 +282,19 @@ class SitoViewHelperHierarchicalCategoryTest extends SitoViewHelperTestCase { } + + /** @test */ + public function sito17ShouldNotBeDisplayed() { + $this->assertNotXPathContentContains($this->html, + '//ul[@class="sitotheque"]//li', + 'Sito numero 18',$this->html); + + } + /** @test */ public function urlShouldRedirectToViewPage() { $this->assertXPathContentContains($this->html, - '//h2//a[contains(@href, "/sito/viewcategory/id_category/23")]', + '//h2//a[contains(@href, "/sito/viewcategory/id_cat/23")]', 'La Creuse'); }