Skip to content
Snippets Groups Projects
Commit d4014960 authored by gloas's avatar gloas
Browse files

category form et decorator tests

parent 689573d4
Branches
Tags
No related merge requests found
......@@ -2785,6 +2785,7 @@ library/ZendAfi/View/Helper/Admin/MenuGaucheAdmin.php -text
library/ZendAfi/View/Helper/Admin/MenuHorizontalAdmin.php -text
library/ZendAfi/View/Helper/Admin/ProfileSelect.php -text
library/ZendAfi/View/Helper/Admin/SubscribeUsers.php -text
library/ZendAfi/View/Helper/Admin/TagCategory.php -text
library/ZendAfi/View/Helper/Admin/TagListeCoches.php -text
library/ZendAfi/View/Helper/Admin/TagListeSuggestion.php -text
library/ZendAfi/View/Helper/Admin/TagSelectionChamps.php -text
......@@ -6171,6 +6172,7 @@ tests/library/ZendAfi/View/Helper/Accueil/SitoTest.php -text
tests/library/ZendAfi/View/Helper/Accueil/TagsTest.php -text
tests/library/ZendAfi/View/Helper/Admin/AdminHelpLinkTest.php -text
tests/library/ZendAfi/View/Helper/Admin/ImageViewersOptionsTest.php -text
tests/library/ZendAfi/View/Helper/Admin/TagCategoryTest.php -text
tests/library/ZendAfi/View/Helper/Admin/TagSelectionChampsTest.php -text
tests/library/ZendAfi/View/Helper/AudioJSPlayerTest.php -text
tests/library/ZendAfi/View/Helper/AvisTest.php -text
......
......@@ -25,10 +25,7 @@ class ZendAfi_Form_Decorator_Category extends Zend_Form_Decorator_HtmlTag {
* @return string
*/
public function render($content) {
$attribs = array_intersect_key($this->_element->getAttribs(), ['target' => '',
'title' => '',
'onclick' => '']);
return parent::render($this->_element->getView()->comboCategories($this->_element->getMultiOptions()));
return $this->_element->getView()->tagCategory($this->_element->getCategories());
}
}
?>
\ No newline at end of file
......@@ -18,37 +18,31 @@
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Form_Element_Category extends ZendAfi_Form_Element_Xhtml {
abstract class ZendAfi_Form_Element_Category extends ZendAfi_Form_Element_Xhtml {
protected $categories;
public function __construct($spec, $options = null) {
parent::___construct($spec,$options);
$decorators = $this->_decorators;
$this->_decorators = array('Link' => new ZendAfi_Form_Decorator_Category());
$this->_decorators = ['Category' => new ZendAfi_Form_Decorator_Category()];
foreach ($decorators as $name => $value) {
$this->_decorators[$name] = $value;
}
$this->removeDecorator('ViewHelper');
$this->removeDecorator('Label');
}
public function isValid($value, $context = null) {
return true;
public function getCategories() {
return $this->categories;
}
public function render(Zend_View_Interface $view = null) {
if (null !== $view) {
$this->setView($view);
}
if (is_array($this->_value))
$this->setValue($this->_view->url($this->_value));
return parent::render($view);
public function setCategories($categories) {
$this->categories = $categories;
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_Admin_TagCategory extends ZendAfi_View_Helper_BaseHelper {
protected $_categories;
/**
* @param $categories = array
**/
public function tagCategory($categories) {
$this->_categories = $categories;
return $html='<div>'.$this->getCategoriesHtml($this->_categories).'</div>';
}
protected function getCategoriesHtml($categories) {
$html='';
foreach($categories as $category) {
$html.= $this->getCategoryHtml($category);
}
return $html;
}
protected function getCategoryHtml($category) {
$html ='';
return $html;
}
}
?>
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php';
class ZendAfi_View_Helper_Admin_TagCategoryTest extends ViewHelperTestCase {
protected $_html;
public function setUp() {
parent::setUp();
$categories=
['gr1' => ['gr1 - 1',
'gr1 - 2',
['gr1 - 3' => ['gr1 - 3 - 1',
'gr1 - 3 - 2']]]];
$helper = new ZendAfi_View_Helper_Admin_TagCategory();
$this->_html = $helper->tagCategory($categories);
}
/** @test **/
public function gr1ShouldBeInDt() {
$this->assertXPathContentContains($this->_html, '//dl//dt', 'gr1');
}
}
?>
\ No newline at end of file
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