Skip to content
Snippets Groups Projects
Commit e3b689ff authored by Patrick Barroca's avatar Patrick Barroca
Browse files

rel RF #12805 : ModoController refactoring test coverage

parent 4947de67
Branches
Tags
2 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!32Ft/Rf12808
......@@ -70,30 +70,32 @@ class Admin_ModoController extends ZendAfi_Controller_Action {
public function tagnoticeAction() {
$view_liste_tags=array();
$class_modo = new Class_Moderer();
$liste_tags = $class_modo->getAllTagsAModerer();
$view_liste_tags = [];
// Completer les infos
$cls_notice = new Class_Notice();
for ($i = 0; $i < count($liste_tags); $i++) {
if (!$model = Class_Notice::find($liste_tags[$i]['id_notice']))
foreach ((new Class_Moderer())->getAllTagsAModerer() as $tag) {
if (!$model = Class_Notice::find($tag['id_notice']))
continue;
$notice = $model->getNotice('JA');
$liste_tags[$i]["NOTICE"] = '<a href="'.BASE_URL.'/recherche/viewnotice/id/'.$notice["id_notice"].'?type_doc='.$notice["type_doc"].'" target="_blank">';
$liste_tags[$i]["NOTICE"] .= '<img src="'.URL_ADMIN_IMG.'supports/support_'.$notice["type_doc"].'.gif" border="0" style="float:left">&nbsp;<b>'.trim($notice["J"]);
if ($notice["A"] > '')
$liste_tags[$i]["NOTICE"] .= " / ".$notice["A"];
$liste_tags[$i]["NOTICE"] .= '</b></a>';
$view_liste_tags[] = $liste_tags[$i];
$tag['NOTICE'] = $this->_noticeLink($model);
$view_liste_tags[] = $tag;
}
$this->view->subview = $this->view->partial('modo/tagnotice.phtml',
array('title' => 'Tags',
'liste_tags' => $view_liste_tags));
['title' => 'Tags',
'liste_tags' => $view_liste_tags]);
$this->_forward('index');
}
protected function _noticeLink($model) {
$notice = $model->getNotice('JA');
$link = '<a href="'.BASE_URL.'/recherche/viewnotice/id/'.$notice["id_notice"].'?type_doc='.$notice["type_doc"].'" target="_blank">'
. '<img src="'.URL_ADMIN_IMG.'supports/support_'.$notice["type_doc"].'.gif" border="0" style="float:left">&nbsp;<b>'.trim($notice["J"]);
if ($notice["A"] > '')
$link .= " / ".$notice["A"];
return $link . '</b></a>';
}
public function updatetagnoticeAction() {
......
......@@ -19,12 +19,13 @@ else
</tr>
<?php
}
foreach ($this->liste_tags as $tag)
{
$ligne ++ ; if ($ligne & 1) $class="first"; else $class="second";
print('<tr class="'.$class.'">');
print('<td valign="top">'.$ligne.'</td>');
}
$ligne = 0;
foreach ($this->liste_tags as $tag) {
$ligne ++ ;
$class = ($ligne & 1) ? "first" : "second";
print('<tr class="'.$class.'">');
print('<td valign="top">'.$ligne.'</td>');
// Bloc avis
print('<td valign="top">');
......
<?php
/**
* Copyright (c) 2012-2014, 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 Class_CodifTags extends Storm_Model_Abstract {
protected $_table_name = 'codif_tags';
protected $_table_primary = 'id_tag';
}
?>
\ No newline at end of file
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Moderer {
private $_session = null; // Session
private $_session = null;
private $sql;
private $_moderation_avis;
......@@ -43,17 +43,17 @@ class Class_Moderer {
public function getAllTagsAModerer() {
$liste = fetchAll("select * from codif_tags where a_moderer > ''");
$liste = Class_CodifTags::findAllBy(['where' => 'a_moderer > \'\'']);
if (empty($liste))
return array();
return [];
foreach ($liste as $tag) {
$notices = explode(';', $tag['a_moderer']);
$notices = explode(';', $tag->getAModerer());
foreach ($notices as $id_notice) {
if (!$id_notice)
continue;
$r['id_tag'] = $tag['id_tag'];
$r['libelle'] = $tag['libelle'];
$r['id_tag'] = $tag->getId();
$r['libelle'] = $tag->getLibelle();
$r['id_notice'] = $id_notice;
$tags[] = $r;
}
......
......@@ -18,6 +18,8 @@
* 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 realpath(dirname(__FILE__)) . '/AdminAbstractControllerTestCase.php';
class ModoControllerIndexActionTest extends Admin_AbstractControllerTestCase {
public function setUp() {
......@@ -60,8 +62,35 @@ class ModoControllerIndexActionTest extends Admin_AbstractControllerTestCase {
public function linkToModerateSuggestionAchatShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/admin/modo/suggestion-achat")]');
}
}
class ModoControllerTagnoticeActionTest extends Admin_AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Notice', ['id' => 999,
'titre_principal' => 'Captain Harlock']);
$this->fixture('Class_CodifTags', ['id' => 1,
'a_moderer' => '999',
'libelle' => 'Manga',
'code_alpha' => 'MANGA']);
$this->dispatch('/admin/modo/tagnotice', true);
}
/** @test */
public function shouldContainsCaptainHarlock() {
$this->assertXPathContentContains('//div', 'Captain Harlock');
}
/** @test */
public function shouldContainsManga() {
$this->assertXPathContentContains('//div', 'Manga');
}
}
......
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