From eb6782177af57c130e9e8726cbb50dd8313c20d6 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@afi-sa.fr>
Date: Mon, 11 Aug 2014 16:28:05 +0200
Subject: [PATCH] dev #155265 : fix tests

---
 library/Class/SuggestionAchat.php                 |  3 ++-
 .../admin/controllers/ModoControllerTest.php      |  4 ++--
 .../controllers/SuggestionAchatControllerTest.php |  4 ++--
 tests/library/Class/SuggestionAchatTest.php       | 15 +++++++++++++++
 4 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/library/Class/SuggestionAchat.php b/library/Class/SuggestionAchat.php
index 2a0d0789ad7..91bfd4deb06 100644
--- a/library/Class/SuggestionAchat.php
+++ b/library/Class/SuggestionAchat.php
@@ -83,7 +83,8 @@ class Class_SuggestionAchat extends Storm_Model_Abstract {
 
 
 	public function getDocumentType() {
-		($type_doc = $this->getTypeDoc()) ? $type_doc->getLibelle() : '';
+		return ($type_doc = $this->getTypeDoc()) ? $type_doc->getLibelle() : '';
+		
 	}
 
 	public function sendMail($from) {
diff --git a/tests/application/modules/admin/controllers/ModoControllerTest.php b/tests/application/modules/admin/controllers/ModoControllerTest.php
index 581ba60790f..d4a72ba5adf 100644
--- a/tests/application/modules/admin/controllers/ModoControllerTest.php
+++ b/tests/application/modules/admin/controllers/ModoControllerTest.php
@@ -298,8 +298,8 @@ class ModoControllerSuggestionAchatEditHarryPotterPostTest extends ModoControlle
 	/** @test */
 	public function withValidDataShouldHaveNoError() {
 		$this->postDispatch('/admin/modo/suggestion-achat-edit/id/2', 
-												['titre' => 'Star Wars', 'auteur' => 'G.Lucas', 'isbn' => ''],
-												true);
+		['titre' => 'Star Wars', 'auteur' => 'G.Lucas', 'isbn' => '', 'type_doc_id' => 2],
+		true);
 		$this->assertRedirect();
 	}
 }
diff --git a/tests/application/modules/admin/controllers/SuggestionAchatControllerTest.php b/tests/application/modules/admin/controllers/SuggestionAchatControllerTest.php
index 393c4fdb4de..f3c085370a3 100644
--- a/tests/application/modules/admin/controllers/SuggestionAchatControllerTest.php
+++ b/tests/application/modules/admin/controllers/SuggestionAchatControllerTest.php
@@ -141,8 +141,8 @@ class Admin_SuggestionAchatControllerEditHarryPotterPostTest extends Admin_Sugge
 	/** @test */
 	public function withValidDataShouldHaveNoError() {
 		$this->postDispatch('/admin/suggestion-achat/edit/id/2', 
-												['titre' => 'Star Wars', 'auteur' => 'G.Lucas', 'isbn' => ''],
-												true);
+		['titre' => 'Star Wars', 'auteur' => 'G.Lucas', 'isbn' => '','type_doc_id' => 2],
+		true);
 		$this->assertRedirect();
 	}
 }
diff --git a/tests/library/Class/SuggestionAchatTest.php b/tests/library/Class/SuggestionAchatTest.php
index c9db9e97458..a0002edfd41 100644
--- a/tests/library/Class/SuggestionAchatTest.php
+++ b/tests/library/Class/SuggestionAchatTest.php
@@ -37,11 +37,21 @@ abstract class SuggestionAchatTestCase extends Storm_Test_ModelTestCase {
 			->setTitreSite('PHP Unit')
 			->setMailSuggestionAchat('laurent@afi-sa.fr, patrick@afi-sa.fr ; estelle@afi-sa.fr');
 		Class_Profil::setCurrentProfil($profil);
+		$codif_type_doc=$this->fixture('Class_CodifTypeDoc', ['id' => 102,
+		'famille_id' => Class_CodifTypeDoc::LIVRE,
+		'bibliotheques' => '2;3',
+		'annexes' => '4;8',
+		'sections' => '9;10']);
+
+		$type_doc=$this->fixture('Class_TypeDoc', ['id'=>Class_TypeDoc::LIVRE, 
+		'codif_type_doc' =>  $codif_type_doc,
+		'label'=> 'Livres Numériques']);
 
 		$this->_suggestion = Class_SuggestionAchat::newInstanceWithId(2)
 			->setDateCreation('2012-03-01')
 			->setTitre('Harry emPotté')
 			->setAuteur('J.K.Rowling')
+			->setTypeDoc($type_doc)
 			->setIsbn('1234567890')
 			->setDescriptionUrl('http://harrypotter.fr')
 			->setCommentaire('Je veux le lire')
@@ -85,6 +95,11 @@ class SuggestionAchatMailTest extends SuggestionAchatTestCase {
 		$this->assertBodyContains('Auteur: J.K.Rowling');
 	}
 
+	/** @test */
+	public function mailBodyTextShouldContainsLivresNumeriques() {
+		$this->assertBodyContains('Type de document: Livres Numériques');
+	}
+
 
 	/** @test */
 	public function mailBodyTextShouldContainsISBN1234567890() {
-- 
GitLab