From ca44b3484f84ae1f05f8fdc5429e6fe60649292a Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Tue, 17 Dec 2013 12:02:41 +0000
Subject: [PATCH] Sauvegarde du type de document avec sa famille

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

diff --git a/application/modules/admin/controllers/TypeDocsController.php b/application/modules/admin/controllers/TypeDocsController.php
index f80ea079d13..c6c47b6e6c2 100644
--- a/application/modules/admin/controllers/TypeDocsController.php
+++ b/application/modules/admin/controllers/TypeDocsController.php
@@ -20,12 +20,16 @@
  */
 
 class Admin_TypeDocsController extends ZendAfi_Controller_Action {
+	use Trait_Translator;
+
 
 	public function getRessourceDefinitions() {
 		return [
 			'model' => ['class' => 'Class_TypeDoc', 
 									'name' => 'type_doc',
 									'order' => 'libelle'],
+			'messages' => ['successful_save' => $this->_('Type de document %s modifié')],
+
 			'actions' => ['edit' => ['title' => 'Modification du type de document:'],
 										'index' => ['title' => 'Types de documents']],
 			'display_groups' => ['definition' => ['legend' => 'Définition',
diff --git a/library/Class/TypeDoc.php b/library/Class/TypeDoc.php
index 75330db1e56..1c8723d3f17 100644
--- a/library/Class/TypeDoc.php
+++ b/library/Class/TypeDoc.php
@@ -262,12 +262,19 @@ class Class_TypeDoc extends Storm_Model_Abstract {
 	}
 
 
-
 	public function getFamilleId() {
 		return $this->getCodifTypeDoc()->getId();
 	}
 
 
+	public function getLibelle() {
+		return $this->getLabel();
+	}
+
+	public function setFamilleId($id) {
+		$this->getCodifTypeDoc()->setFamilleId($id);
+	}
+
 	public function toArray() {
 		return ['id'=> $this->getId(),
 						'famille_id' => $this->getFamilleId()];
diff --git a/tests/application/modules/admin/controllers/TypeDocsControllerTest.php b/tests/application/modules/admin/controllers/TypeDocsControllerTest.php
index 960197ef035..9b141fc56c3 100644
--- a/tests/application/modules/admin/controllers/TypeDocsControllerTest.php
+++ b/tests/application/modules/admin/controllers/TypeDocsControllerTest.php
@@ -70,6 +70,7 @@ class TypeDocsControllerIndexTest extends AbstractTypeDocsControllerTest {
 
 } 
 
+
 class TypeDocsControllerEditTest extends AbstractTypeDocsControllerTest {
  
 	public function setUp() {
@@ -82,10 +83,32 @@ class TypeDocsControllerEditTest extends AbstractTypeDocsControllerTest {
 		$this->assertXPathContentContains('//h1','Modification du type de document',$this->_response->getBody());
 	}
 	
-
 	/** @test */
 	public function livreShouldBeSelected() {
 		$this->assertXPath('//form//select[@name="famille_id"]/option[@value="1"][@selected="selected"]', $this->_response->getBody());
 	}
+
+
+}
+
+
+class TypeDocsControllerEditPostTest extends AbstractTypeDocsControllerTest {
+ 
+	public function setUp() {
+		parent::setUp();
+		$this->postDispatch('/admin/type-docs/edit/id/1', ['id' => '1',
+																											 'famille_id' => '4']);
+
+	}
+
+	/** @test */
+	public function typeDocShouldBe4() {
+		$this->assertEquals(4,Class_CodifTypeDoc::find(1)->getFamilleId());
+	}
+	
+
+
+
 }
+
 ?>
\ No newline at end of file
-- 
GitLab