From 50e28b8d9c3b08289a020c2fddb49195bbf774b2 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Thu, 25 Apr 2013 10:14:25 +0000
Subject: [PATCH] Correction export CSV formulaires

---
 .../View/Helper/Article/FormulairesCsvVisitor.php     | 11 +++++++++--
 .../controllers/ModoControllerFormulaireTest.php      | 11 +++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php b/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php
index e56089c3791..4a57c6a1a49 100644
--- a/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php
+++ b/library/ZendAfi/View/Helper/Article/FormulairesCsvVisitor.php
@@ -31,8 +31,15 @@ class ZendAfi_View_Helper_Article_FormulairesCsvVisitor extends Zend_View_Helper
 
 		fputcsv($fp_csv, $attributes,';');
 
-		foreach($formulaires as $formulaire)
-		fputcsv($fp_csv, $formulaire->attributeValues($attributes),';');
+		foreach($formulaires as $formulaire) {
+			$datas = [$formulaire->getDateCreation(), 
+								$formulaire->getCompte(), 
+								$formulaire->getLibelleBib()];
+			foreach($attributes as $name)
+				$datas[]=$formulaire->getDataNamed($name);
+
+		  fputcsv($fp_csv, $datas,';');
+		}
 
 		fclose($fp_csv);
 
diff --git a/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php b/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php
index 7ccbf4b8488..3c8bb93a290 100644
--- a/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php
+++ b/tests/application/modules/admin/controllers/ModoControllerFormulaireTest.php
@@ -232,14 +232,21 @@ class ModoControllerFormulaireExportCSVForArticlTest extends ModoControllerFormu
 	
 	/** @test */
 	public function secondFormulaireShouldBeCSV() {
-		$this->assertContains('"2012-12-06 10:00:01";zork;Annecy;Bougie;Mireille',
+		$this->assertContains('"2012-12-06 10:00:01";zork;Annecy;;;;Bougie;Mireille;;;;',
+													$this->_response->getBody());
+	}
+
+
+	/** @test */
+	public function thirdFormulaireShouldBeCSV() {
+		$this->assertContains('"2012-11-06 17:00:01";;;;;;;Nono;Lefort;12;789;"budget régional"',
 													$this->_response->getBody());
 	}
 
 
 	/** @test */
 	public function csvShouldContainsAttributeNames() {
-		$this->assertContains('date_creation;compte;libelle_bib;nom;prenom;name;age',
+		$this->assertContains('date_creation;compte;libelle_bib;nom;prenom;name;age;securite-sociale;budget_(totem)_régional',
 													$this->_response->getBody());
 	}
 
-- 
GitLab