From 96b4f7a255948773499b5de7658952716a989ef6 Mon Sep 17 00:00:00 2001 From: pbarroca <pbarroca@afi-sa.fr> Date: Thu, 17 May 2018 15:04:51 +0200 Subject: [PATCH] dev #73934 : enhance tests --- VERSIONS_WIP/73934 | 1 + .../PhasePrepareIntegrationsTest.php | 54 +++++++++++++------ 2 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 VERSIONS_WIP/73934 diff --git a/VERSIONS_WIP/73934 b/VERSIONS_WIP/73934 new file mode 100644 index 00000000000..37bb3f952ed --- /dev/null +++ b/VERSIONS_WIP/73934 @@ -0,0 +1 @@ + - ticket #73934 : Cosmogramme : amélioration des tests sur l'import de fichier comportant une date \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php index 62a1a3a5d8e..77df3e6b127 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php @@ -33,17 +33,16 @@ abstract class PhasePrepareIntegrationsWithOAITestCase ->answers(true) ->whenCalled('is_file') - ->with ('ftp/my-library.net/transferts/foo/mylibraryincr.txt') - ->answers(false) + ->with ('ftp/my-library.net/transferts/foo/20180517mylibraryincr.txt') + ->answers(true) ->whenCalled('opendir') ->with ('ftp/my-library.net/transferts/foo/') ->answers('dir_pointer') - ->whenCalled('readdir') ->with ('dir_pointer') - ->answers('mylibraryincr.txt') + ->answers('20180517mylibraryincr.txt') ->whenCalled('closedir') ->with ('dir_pointer') @@ -53,6 +52,11 @@ abstract class PhasePrepareIntegrationsWithOAITestCase ->with('ftp/my-library.net/transferts/foo/mylibrarytotal.txt', 'ftp/my-library.net/integration/integre1179.pan') ->answers(true) + + ->whenCalled('rename') + ->with('ftp/my-library.net/transferts/foo/20180517mylibraryincr.txt', + 'ftp/my-library.net/integration/integre1180.pan') + ->answers(true) ->beStrict(); $this->_http_client = $this->mock() @@ -186,38 +190,56 @@ class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOA /** @test */ - public function twoIntegrationsShouldHaveBeenCreated() { - $this->assertEquals(3, count(Class_Cosmogramme_Integration::findAll())); + public function threeIntegrationsShouldHaveBeenCreated() { + $this->assertEquals(4, count(Class_Cosmogramme_Integration::findAll())); } /** @test */ public function firstIntegrationFileShouldBeIntegre1179DotPan() { - $this->assertEquals('integre1179.pan', Class_Cosmogramme_Integration::find(2)->getFichier()); + $this->assertEquals('integre1179.pan', + Class_Cosmogramme_Integration::find(2)->getFichier()); } /** @test */ public function firstIntegrationFileNameShouldBeMyLibraryTotalDotTxt() { - $this->assertEquals('foo/mylibrarytotal.txt', Class_Cosmogramme_Integration::find(2)->getNomFichier()); + $this->assertEquals('foo/mylibrarytotal.txt', + Class_Cosmogramme_Integration::find(2)->getNomFichier()); } /** @test */ public function firstIntegrationKeyShouldBeHash() { - $this->assertEquals('a7be1b1bbdfe70b6fec563334accab3f', Class_Cosmogramme_Integration::find(2)->getHash()); + $this->assertEquals('a7be1b1bbdfe70b6fec563334accab3f', + Class_Cosmogramme_Integration::find(2)->getHash()); } /** @test */ - public function secondIntegrationURIShouldBeOAIRepository() { - $this->assertEquals('http://oai-repository.fr/oai', Class_Cosmogramme_Integration::find(3)->getFichier()); + public function secondIntegrationShouldBeIncremental() { + $this->assertTrue(Class_Cosmogramme_Integration::find(3)->isIncrement()); } /** @test */ - public function secondIntegrationTransfertDateShouldBeBar() { - $this->assertEquals('2015-03-26', Class_Cosmogramme_Integration::find(3)->getDateTransfert()); + public function secondIntegrationFileShouldContainsDate() { + $this->assertContains('[DATE]', + Class_Cosmogramme_Integration::find(3)->getNomFichier()); + } + + + /** @test */ + public function thirdIntegrationURIShouldBeOAIRepository() { + $this->assertEquals('http://oai-repository.fr/oai', + Class_Cosmogramme_Integration::find(4)->getFichier()); + } + + + /** @test */ + public function thirdIntegrationTransfertDateShouldBeBar() { + $this->assertEquals('2015-03-26', + Class_Cosmogramme_Integration::find(4)->getDateTransfert()); } @@ -265,7 +287,9 @@ class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOA -class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest extends PhasePrepareIntegrationsWithOAITestCase { +class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest + extends PhasePrepareIntegrationsWithOAITestCase { + protected function _prepareFixtures() { parent::_prepareFixtures(); $this->fixture('Class_Cosmogramme_Integration', @@ -281,7 +305,7 @@ class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest extends Ph /** @test */ public function oneIntegrationShouldHaveBeenCreated() { - $this->assertEquals(3, count(Class_Cosmogramme_Integration::findAll())); + $this->assertEquals(4, count(Class_Cosmogramme_Integration::findAll())); } } -- GitLab