From 56e3805341d2a9826e9f277a6a661cafef396d23 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Mon, 8 Apr 2013 11:36:15 +0000
Subject: [PATCH] Correction selection catalogue dans les newsletters

---
 library/Class/Catalogue.php                          |  4 +++-
 .../admin/controllers/NewsletterControllerTest.php   | 12 ++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php
index 87b0960c505..0c852eedc76 100644
--- a/library/Class/Catalogue.php
+++ b/library/Class/Catalogue.php
@@ -705,8 +705,10 @@ class Class_Catalogue extends Storm_Model_Abstract {
 	// liste des catalogues pour une combo
 	//-------------------------------------------------------------------------------
 	static function getCataloguesForCombo()	{
+		if (!$catalogues = Class_Catalogue::findTopCatalogues())
+			return [];
+
 		$liste = [''];
-		$catalogues = Class_Catalogue::findTopCatalogues();
 		foreach($catalogues as $catalogue) {
 			self::addCataloguePathAndChildrenTo($catalogue, $liste);
 		}
diff --git a/tests/application/modules/admin/controllers/NewsletterControllerTest.php b/tests/application/modules/admin/controllers/NewsletterControllerTest.php
index 6248008a3ca..353a95fa131 100644
--- a/tests/application/modules/admin/controllers/NewsletterControllerTest.php
+++ b/tests/application/modules/admin/controllers/NewsletterControllerTest.php
@@ -140,13 +140,9 @@ class Admin_NewsletterControllerAddActionTest extends Admin_NewsletterController
 	public function setUp() {
 		parent::setUp();
 
-		$this->mock_sql = $this->getSqlMock();
-		$this->mock_sql
-			->expects($this->any())
-			->method('fetchAll')
-			->with("select * from catalogue order by libelle")
-			->will($this->returnValue(false));
-
+		Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue')
+			->whenCalled('findTopCatalogues')
+			->answers([]);
 
 		$this->dispatch('/admin/newsletter/add');		
 	}
@@ -154,7 +150,7 @@ class Admin_NewsletterControllerAddActionTest extends Admin_NewsletterController
 
 	/** @test */
 	function catalogueComboShouldBeEmpty() {
-		$this->assertNotXPath("//select[@id='id_catalogue']/option");
+		$this->assertNotXPath("//select[@id='id_catalogue']/option", $this->_response->getBody());
 	}
 
 	public function testAddActionFound() {
-- 
GitLab