From f5f1ef405a8dcbcc3b7907c5d23ef9e8a5f0b051 Mon Sep 17 00:00:00 2001 From: pbarroca <pbarroca@afi-sa.fr> Date: Fri, 30 Oct 2015 10:34:09 +0100 Subject: [PATCH] rel #28103 : reset http auth between batch runs --- VERSIONS_HOTLINE/28103 | 1 + .../Cosmogramme/Integration/PhaseBatchs.php | 16 ++++++++++--- .../Integration/PhaseBatchsTest.php | 24 ++++++++++++++++++- 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 VERSIONS_HOTLINE/28103 diff --git a/VERSIONS_HOTLINE/28103 b/VERSIONS_HOTLINE/28103 new file mode 100644 index 00000000000..9e229b1b29c --- /dev/null +++ b/VERSIONS_HOTLINE/28103 @@ -0,0 +1 @@ + - ticket #28103 : Correction de l'exécution des batchs qui empêchait le moissonage des vignettes d'album 1dtouch \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhaseBatchs.php b/library/Class/Cosmogramme/Integration/PhaseBatchs.php index 887bd37f63b..8bb8714e42e 100644 --- a/library/Class/Cosmogramme/Integration/PhaseBatchs.php +++ b/library/Class/Cosmogramme/Integration/PhaseBatchs.php @@ -38,15 +38,25 @@ class Class_Cosmogramme_Integration_PhaseBatchs return; } - $batchs = Class_Batch::findAllBy(['order' => 'id']); - foreach($batchs as $batch) { + foreach(Class_Batch::findAllBy(['order' => 'id']) as $batch) { if ($this->_getData('pointeur_reprise') > $batch->getId()) continue; - $this->_runOne($batch); + + $this->_resetHttpClient() + ->_runOne($batch); } } + protected function _resetHttpClient() { + if (!$client = Zend_Registry::get('httpClient')) + return $this; + + $client->setAuth(null); + return $this; + } + + protected function _runOne($batch) { $this->_log->ecrire('<span class="vert">' . $batch->getLibelle().':'); $this->_setData('pointeur_reprise', $batch->getId()); diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseBatchsTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseBatchsTest.php index 6463d52559a..5814fa6d115 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseBatchsTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseBatchsTest.php @@ -21,7 +21,7 @@ abstract class PhaseBatchsTestCase extends Class_Cosmogramme_Integration_PhaseTestCase { - protected $_batch; + protected $_batch, $_registry_http_client, $_mock_http_client; protected function _prepareFixtures() { $this->fixture('Class_Batch', @@ -41,8 +41,20 @@ abstract class PhaseBatchsTestCase extends Class_Cosmogramme_Integration_PhaseTe public function setUp() { parent::setUp(); + + $this->_registry_http_client = Zend_Registry::get('httpClient'); + $this->_mock_http_client = $this->mock(); + $this->_mock_http_client->whenCalled('setAuth')->answers($this->_mock_http_client); + Zend_Registry::set('httpClient', $this->_mock_http_client); + $this->_buildPhase('Batchs')->run(); } + + + public function tearDown() { + Zend_Registry::set('httpClient', $this->_registry_http_client); + parent::tearDown(); + } } @@ -102,6 +114,16 @@ class PhaseBatchsCronRunTest extends PhaseBatchsTestCase { public function shouldDisplayElapsedTime() { $this->assertLogContains('Temps de traitement'); } + + + /** + * @test + * @see http://forge.afi-sa.fr/issues/28103 + */ + public function httpAuthShouldHaveBeenReset() { + $this->assertTrue($this->_mock_http_client + ->methodHasBeenCalled('setAuth')); + } } -- GitLab