Skip to content
Snippets Groups Projects
Commit c4b6002c authored by Alex Arnaud's avatar Alex Arnaud
Browse files

dev #17871 oaista la vista

Do not create OAI integration if one in progress
parent 7193b9c4
Branches
Tags
2 merge requests!917Dev#17871 oaista la vista,!904Dev#17871 oaista la vista
......@@ -67,6 +67,11 @@ class Class_Cosmogramme_Integration_PhasePrepareIntegrations extends Class_Cosmo
if (false !== strpos($majauto->getNomFichier(), 'http://')) {
$uri = $majauto->getNomFichier();
xdebug_break();
if (Class_Cosmogramme_Integration::findFirstBy(['traite' => 'non',
'fichier' => $uri]))
return $this;
$this->_log->ecrire('<span class="vert">Création de l\'intégration pour '. $uri .'</span></td>');
$this->_newIntegration($uri, $majauto);
return $this;
......
......@@ -19,7 +19,31 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class PhasePrepareIntegrationsTest extends Class_Cosmogramme_Integration_PhaseTestCase {
class PhasePrepareIntegrationsWithOAITestCase extends Class_Cosmogramme_Integration_PhaseTestCase {
public function setUp() {
parent::setUp();
$file_system = Storm_Test_ObjectWrapper::mock();
$file_system
->whenCalled('is_file')
->with ('ftp/my-library.net/transferts/foo/mylibrarytotal.txt')
->answers(true)
->whenCalled('is_file')
->with ('ftp/my-library.net/transferts/foo/mylibraryincr.txt')
->answers(false)
->whenCalled('rename')
->with('ftp/my-library.net/transferts/foo/mylibrarytotal.txt',
'ftp/my-library.net/integration/integre1179.pan')
->answers(true)
->beStrict();
Class_Cosmogramme_Integration_PhasePrepareIntegrations::setFileSystem($file_system);
$this->_phase = $this->_buildPhase('PrepareIntegrations')->run();
}
protected function _prepareFixtures() {
$this->fixture('Class_CosmoVar',
['id' => 'ID_upload', 'valeur' => 1178]);
......@@ -90,47 +114,45 @@ class PhasePrepareIntegrationsTest extends Class_Cosmogramme_Integration_PhaseTe
'nom_fichier' => 'http://oai-repository.fr/oai',
'rang' => 102,
'taille_min_import_total' => 0]);
$this->fixture('Class_Cosmogramme_Integration',
['id' => 1,
'id_bib' => 2,
'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL,
'profil' => 103,
'traite' => 'oui',
'fichier' => 'http://oai-repository.fr/oai',
'pointeur_reprise' => 'SCD01@000195008000000979marc21-18]']);
}
public function setUp() {
parent::setUp();
$file_system = Storm_Test_ObjectWrapper::mock();
$file_system
->whenCalled('is_file')
->with ('ftp/my-library.net/transferts/foo/mylibrarytotal.txt')
->answers(true)
->whenCalled('is_file')
->with ('ftp/my-library.net/transferts/foo/mylibraryincr.txt')
->answers(false)
->whenCalled('rename')
->with('ftp/my-library.net/transferts/foo/mylibrarytotal.txt',
'ftp/my-library.net/integration/integre1179.pan')
->answers(true)
->beStrict();
Class_Cosmogramme_Integration_PhasePrepareIntegrations::setFileSystem($file_system);
$this->_phase = $this->_buildPhase('PrepareIntegrations')->run();
protected function _getPreviousPhase() {
return (new Class_Cosmogramme_Integration_Phase(0))
->beCron();
}
}
class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOAITestCase {
/** @test */
public function twoIntegrationsShouldHaveBeenCreated() {
$this->assertEquals(2, count(Class_Cosmogramme_Integration::findAll()));
$this->assertEquals(3, count(Class_Cosmogramme_Integration::findAll()));
}
/** @test */
public function firstIntegrationURIShouldBeIntegre1179DotPan() {
$this->assertEquals('integre1179.pan', Class_Cosmogramme_Integration::find(1)->getFichier());
$this->assertEquals('integre1179.pan', Class_Cosmogramme_Integration::find(2)->getFichier());
}
/** @test */
public function secondIntegrationURIShouldBeOAIRepository() {
$this->assertEquals('http://oai-repository.fr/oai', Class_Cosmogramme_Integration::find(2)->getFichier());
$this->assertEquals('http://oai-repository.fr/oai', Class_Cosmogramme_Integration::find(3)->getFichier());
}
......@@ -160,10 +182,26 @@ class PhasePrepareIntegrationsTest extends Class_Cosmogramme_Integration_PhaseTe
Class_CosmoVar::setValueOf('integration_path', '');
$this->_phase = $this->_buildPhase('PrepareIntegrations')->run();
}
}
protected function _getPreviousPhase() {
return (new Class_Cosmogramme_Integration_Phase(0))
->beCron();
class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest extends PhasePrepareIntegrationsWithOAITestCase {
protected function _prepareFixtures() {
parent::_prepareFixtures();
$this->fixture('Class_Cosmogramme_Integration',
['id' => 2,
'id_bib' => 2,
'type_operation' => Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL,
'profil' => 103,
'traite' => 'non',
'fichier' => 'http://oai-repository.fr/oai',
'pointeur_reprise' => 'SCD01@000195008000000979marc21-18]']);
}
/** @test */
public function oneIntegrationShouldHaveBeenCreated() {
$this->assertEquals(3, count(Class_Cosmogramme_Integration::findAll()));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment