From 762abaf23a23b2b45f0ad086007bbf46a1beb245 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@afi-sa.fr>
Date: Thu, 5 Feb 2015 18:13:24 +0100
Subject: [PATCH] Parser fix

---
 .../Class/WebService/BibNumerique/ArteVOD/Film.php  |  7 +++----
 .../WebService/BibNumerique/RessourceNumerique.php  |  2 +-
 library/Class/WebService/XMLParser.php              | 13 +++++++++----
 .../library/Class/WebService/Dilicom/ParserTest.php |  5 +++++
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/library/Class/WebService/BibNumerique/ArteVOD/Film.php b/library/Class/WebService/BibNumerique/ArteVOD/Film.php
index 7e8a64821ba..a696741e471 100644
--- a/library/Class/WebService/BibNumerique/ArteVOD/Film.php
+++ b/library/Class/WebService/BibNumerique/ArteVOD/Film.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 
 class Class_WebService_BibNumerique_ArteVOD_Film  extends Class_WebService_BibNumerique_RessourceNumerique {
@@ -26,7 +26,6 @@ class Class_WebService_BibNumerique_ArteVOD_Film  extends Class_WebService_BibNu
 	protected $_title;
 	protected $_description;
 	protected $_year;
-	protected $_authors = [];
 	protected $_posters = [];
 	protected $_trailers = [];
 	protected $_photos = [];
@@ -52,7 +51,7 @@ class Class_WebService_BibNumerique_ArteVOD_Film  extends Class_WebService_BibNu
 		$this->duration = $duration;
 	}
 
-	
+
 	public function getDuration() {
 		return $this->duration;
 	}
@@ -64,7 +63,7 @@ class Class_WebService_BibNumerique_ArteVOD_Film  extends Class_WebService_BibNu
 	public function getTags() {
 		return implode($this->_tags,';');
 	}
-	
+
 	public function addActor($actor) {
 		$this->_actors[] = $actor;
 		return $this;
diff --git a/library/Class/WebService/BibNumerique/RessourceNumerique.php b/library/Class/WebService/BibNumerique/RessourceNumerique.php
index 05250688d4f..42553ecfeb4 100644
--- a/library/Class/WebService/BibNumerique/RessourceNumerique.php
+++ b/library/Class/WebService/BibNumerique/RessourceNumerique.php
@@ -42,7 +42,7 @@ class Class_WebService_BibNumerique_RessourceNumerique {
 	protected $_ressources = [];
 	protected $_zones = [];
 	protected $_bibliotheques='';
-
+	protected $_authors = [];
 
 	public function setId($id) {
 		$this->_id = $id;
diff --git a/library/Class/WebService/XMLParser.php b/library/Class/WebService/XMLParser.php
index 083fcaf22a2..7eba80f3d70 100644
--- a/library/Class/WebService/XMLParser.php
+++ b/library/Class/WebService/XMLParser.php
@@ -152,11 +152,16 @@ class Class_WebService_XMLParser {
 
 
 	protected function _callFuncOrClosure($method_name, $data) {
-		$callable = property_exists($this->_element_handler, $method_name)
-			? $this->_element_handler->$method_name
-			: [$this->_element_handler, $method_name];
+		$callable  = null;
 
-		call_user_func($callable, $data);
+		if (property_exists($this->_element_handler, $method_name))
+			$callable = $this->_element_handler->$method_name;
+
+		if (method_exists($this->_element_handler, $method_name))
+			$callable = [$this->_element_handler, $method_name];
+
+		if ($callable)
+			call_user_func($callable, $data);
 	}
 
 
diff --git a/tests/library/Class/WebService/Dilicom/ParserTest.php b/tests/library/Class/WebService/Dilicom/ParserTest.php
index bea8a9f6889..760d01f5edc 100644
--- a/tests/library/Class/WebService/Dilicom/ParserTest.php
+++ b/tests/library/Class/WebService/Dilicom/ParserTest.php
@@ -30,6 +30,11 @@ class DilicomONIXParserTest extends Storm_Test_ModelTestCase {
 		$this->_book = Class_WebService_BibNumerique_Dilicom_ONIXFile::bookFromXML($xml);
 	}
 
+	public function tearDown() {
+		Storm_Model_Loader::defaultToDb();
+		parent::tearDown();
+	}
+
 
 	/** @test */
 	public function bookShouldNotBeNull() {
-- 
GitLab