From 96fb66143dce68526cfb640627e89533fe0b78f0 Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@afi-sa.fr>
Date: Tue, 21 Jan 2014 14:25:01 +0100
Subject: [PATCH] Optimisation tests: passage de fixtures en beforeClass

---
 .../library/Class/WebService/VodeclicTest.php | 39 +++++++++----------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/tests/library/Class/WebService/VodeclicTest.php b/tests/library/Class/WebService/VodeclicTest.php
index 42e99577705..23f39c61101 100644
--- a/tests/library/Class/WebService/VodeclicTest.php
+++ b/tests/library/Class/WebService/VodeclicTest.php
@@ -20,49 +20,48 @@
  */
 
 class VodeclicTest extends Storm_Test_ModelTestCase{
-	
-
-	public function setUp() {
-		parent::setUp();
+	protected static $vodeclic;
 
+	public static function setUpBeforeClass() {
 		Class_AdminVar::newInstanceWithId('VODECLIC_ID', ['valeur' => 'api-test']);
 		Class_AdminVar::newInstanceWithId('VODECLIC_KEY', ['valeur' => '6m5js1dPpFNrtAJbsfXO']);
 		Class_AdminVar::newInstanceWithId('VODECLIC_BIB_ID', ['valeur' => '12']); 
 
-
 		$catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/vodeclic_catalogue.xml');
-		$this->_http_client = Storm_Test_ObjectWrapper::mock();
-		$this->_http_client
+		$http_client = Storm_Test_ObjectWrapper::mock();
+		$http_client
 			->whenCalled('open_url')
 			->with('https://lms.vodeclic.com/api/catalogue.xml?partenaire=api-test&encrypted_partenaire=f13eba4953115a58bdf7952266ecca9fee8f91ddac6ac901042fdb188db02778&bib_id=12')
 			->answers($catalogue_xml);
 		
-		Class_WebService_BibNumerique_Vodeclic::setDefaultHttpClient($this->_http_client);
+		Class_WebService_BibNumerique_Vodeclic::setDefaultHttpClient($http_client);
 		Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock()
 																												->whenCalled('updateAlbum')
 																												->answers(true));
 
 		Class_Album::beVolatile();
 
-		$codif_type_doc=$this->fixture('Class_CodifTypeDoc', ['id' => Class_TypeDoc::VODECLIC,
+		Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumRessource')
+			->whenCalled('getNextOrderFor')
+			->answers(1);
+
+		$codif_type_doc = self::fixture('Class_CodifTypeDoc', ['id' => Class_TypeDoc::VODECLIC,
 																													'famille_id' => Class_CodifTypeDoc::INCONNU,
 																													'bibliotheques' => '1;8',
 																													'annexes' => '10;12',
 																													'sections' => '18;19']);
 
-		$this->fixture('Class_TypeDoc', ['id'=>Class_TypeDoc::VODECLIC, 
-																		 'codif_type_doc' => $codif_type_doc,
-																		 'label'=> 'Formation Vodéclic'
- 										 ]);
+		self::fixture('Class_TypeDoc', ['id' => Class_TypeDoc::VODECLIC, 
+																		'codif_type_doc' => $codif_type_doc,
+																		'label' => 'Formation Vodéclic']);
 
-		$this->_vodeclic = new Class_WebService_BibNumerique_Vodeclic();
-		
-/*		$this->_vodeclic->harvest(['partenaire_id'=>$this->_partenaire_id,
-															 'key'=> $this->_key, 
-															 'bib_id'=>$this->_bib_id]);*/
-		
-		$this->_vodeclic->harvest('');
+		self::$vodeclic = new Class_WebService_BibNumerique_Vodeclic();
+		self::$vodeclic->harvest('');
+	}
 
+	public function setUp() {
+		parent::setUp();
+		$this->_vodeclic = self::$vodeclic;
 		$this->_first_album = $this->_vodeclic->getAlbums()[0];
 	}
 
-- 
GitLab