From 2e57909146020516977191c81764102f9793e31b Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Wed, 18 Dec 2013 08:55:27 +0000
Subject: [PATCH] =?UTF-8?q?Les=20libell=C3=A9s=20des=20types=20de=20docume?=
 =?UTF-8?q?nts=20sont=20modifiables=20c=C3=B4t=C3=A9=20OPAC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../admin/controllers/TypeDocsController.php  | 21 ++++++++++++++-----
 library/Class/TypeDoc.php                     |  3 ++-
 .../controllers/TypeDocsControllerTest.php    | 21 ++++++++++++++++---
 3 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/application/modules/admin/controllers/TypeDocsController.php b/application/modules/admin/controllers/TypeDocsController.php
index 17f5274a903..bd0b240e39e 100644
--- a/application/modules/admin/controllers/TypeDocsController.php
+++ b/application/modules/admin/controllers/TypeDocsController.php
@@ -32,11 +32,22 @@ class Admin_TypeDocsController extends ZendAfi_Controller_Action {
 
 			'actions' => ['edit' => ['title' => 'Modification du type de document: %s'],
 										'index' => ['title' => 'Types de documents']],
-			'display_groups' => ['definition' => ['legend' => 'Définition',
-																						'elements' => ['famille_id' => ['element' => 'select',
-																																			'options' => ['multiOptions' =>  Class_CodifTypeDoc::getFamillesLibelles(),
-																																			'label' => 'Famille du document: ',
-																																										'required' => true]] ]]],
+
+			'display_groups' => [
+				'definition' => [
+					'legend' => 'Définition',
+					'elements' => [
+						'label' => ['element' => 'text',
+												'options' => ['label' => 'Libellé: ',
+																			'required' => true]],
+
+						'famille_id' => ['element' => 'select',
+														 'options' => ['multiOptions' =>  Class_CodifTypeDoc::getFamillesLibelles(),
+																					 'label' => 'Famille du document: ',
+																					 'required' => true]]
+						]
+					]
+				],
 			'after_edit' => function() {$this->_redirect('/admin/type-docs');}
 
 			];
diff --git a/library/Class/TypeDoc.php b/library/Class/TypeDoc.php
index 10bc9de27cc..ab22b9350f2 100644
--- a/library/Class/TypeDoc.php
+++ b/library/Class/TypeDoc.php
@@ -286,7 +286,8 @@ class Class_TypeDoc extends Storm_Model_Abstract {
 
 	public function toArray() {
 		return ['id'=> $this->getId(),
-						'famille_id' => $this->getFamilleId()];
+						'famille_id' => $this->getFamilleId(),
+						'label' => $this->getLabel()];
 	}
 
 }
diff --git a/tests/application/modules/admin/controllers/TypeDocsControllerTest.php b/tests/application/modules/admin/controllers/TypeDocsControllerTest.php
index e88872baacd..1dbe3ff79ce 100644
--- a/tests/application/modules/admin/controllers/TypeDocsControllerTest.php
+++ b/tests/application/modules/admin/controllers/TypeDocsControllerTest.php
@@ -24,6 +24,7 @@
 abstract class AbstractTypeDocsControllerTestCase extends AbstractControllerTestCase {
 	public function setUp() {
 		parent::setUp();
+		Class_CosmoVar::beVolatile();
 		Class_CosmoVar::newInstanceWithId('types_docs', ['liste' => "0:non identifié\r\n1:Livres\r\n2:périodiques"]);
 		$this->fixture('Class_CodifTypeDoc', ['id' => 1,
 																					'famille_id' => Class_CodifTypeDoc::LIVRE]);
@@ -104,12 +105,19 @@ class TypeDocsControllerEditEPubTest extends AbstractTypeDocsControllerTestCase
 
 	/** @test */
 	public function titreShouldBeModificationDuTypeDocEPUB() {
-		$this->assertXPathContentContains('//h1','Modification du type de document: E-Books',$this->_response->getBody());
+		$this->assertXPathContentContains('//h1','Modification du type de document: E-Books');
+	}
+
+
+	/** @test */
+	public function inputLibelleShouldContainsEPUB() {
+		$this->assertXPath('//form//input[@name="label"][@value="E-Books"]');
 	}
 	
+
 	/** @test */
 	public function livreShouldBeSelected() {
-		$this->assertXPath('//form//select[@name="famille_id"]/option[@value="1"][@selected="selected"]', $this->_response->getBody());
+		$this->assertXPath('//form//select[@name="famille_id"]/option[@value="1"][@selected="selected"]');
 	}
 
 }
@@ -118,7 +126,8 @@ class TypeDocsControllerEditEPubTest extends AbstractTypeDocsControllerTestCase
 class TypeDocsControllerEditLivrePostTest extends AbstractTypeDocsControllerTestCase {
 	public function setUp() {
 		parent::setUp();
-		$this->postDispatch('/admin/type-docs/edit/id/1', [ 'famille_id' => '4']);
+		$this->postDispatch('/admin/type-docs/edit/id/1', [ 'famille_id' => '4',
+																												'label' => 'Book']);
 
 		Class_CodifTypeDoc::clearCache();
 	}
@@ -128,6 +137,12 @@ class TypeDocsControllerEditLivrePostTest extends AbstractTypeDocsControllerTest
 		$this->assertEquals(4,Class_CodifTypeDoc::find(1)->getFamilleId());
 	}
 
+	
+	/** @test */
+	public function labelShouldBeBook() {
+		$this->assertEquals('Book', Class_TypeDoc::find(1)->getLabel());
+	}
+
 	/** @test */
 	public function pageShouldBeRedirectedOnIndex() {
 		$this->assertRedirectTo('/admin/type-docs');
-- 
GitLab