Skip to content
Snippets Groups Projects
Commit 96b4f7a2 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #73934 : enhance tests

parent e68c0e9f
Branches
Tags
1 merge request!2662dev #73934 : enhance tests
Pipeline #4170 passed with stage
in 34 minutes and 36 seconds
- ticket #73934 : Cosmogramme : amélioration des tests sur l'import de fichier comportant une date
\ No newline at end of file
...@@ -33,17 +33,16 @@ abstract class PhasePrepareIntegrationsWithOAITestCase ...@@ -33,17 +33,16 @@ abstract class PhasePrepareIntegrationsWithOAITestCase
->answers(true) ->answers(true)
->whenCalled('is_file') ->whenCalled('is_file')
->with ('ftp/my-library.net/transferts/foo/mylibraryincr.txt') ->with ('ftp/my-library.net/transferts/foo/20180517mylibraryincr.txt')
->answers(false) ->answers(true)
->whenCalled('opendir') ->whenCalled('opendir')
->with ('ftp/my-library.net/transferts/foo/') ->with ('ftp/my-library.net/transferts/foo/')
->answers('dir_pointer') ->answers('dir_pointer')
->whenCalled('readdir') ->whenCalled('readdir')
->with ('dir_pointer') ->with ('dir_pointer')
->answers('mylibraryincr.txt') ->answers('20180517mylibraryincr.txt')
->whenCalled('closedir') ->whenCalled('closedir')
->with ('dir_pointer') ->with ('dir_pointer')
...@@ -53,6 +52,11 @@ abstract class PhasePrepareIntegrationsWithOAITestCase ...@@ -53,6 +52,11 @@ abstract class PhasePrepareIntegrationsWithOAITestCase
->with('ftp/my-library.net/transferts/foo/mylibrarytotal.txt', ->with('ftp/my-library.net/transferts/foo/mylibrarytotal.txt',
'ftp/my-library.net/integration/integre1179.pan') 'ftp/my-library.net/integration/integre1179.pan')
->answers(true) ->answers(true)
->whenCalled('rename')
->with('ftp/my-library.net/transferts/foo/20180517mylibraryincr.txt',
'ftp/my-library.net/integration/integre1180.pan')
->answers(true)
->beStrict(); ->beStrict();
$this->_http_client = $this->mock() $this->_http_client = $this->mock()
...@@ -186,38 +190,56 @@ class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOA ...@@ -186,38 +190,56 @@ class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOA
/** @test */ /** @test */
public function twoIntegrationsShouldHaveBeenCreated() { public function threeIntegrationsShouldHaveBeenCreated() {
$this->assertEquals(3, count(Class_Cosmogramme_Integration::findAll())); $this->assertEquals(4, count(Class_Cosmogramme_Integration::findAll()));
} }
/** @test */ /** @test */
public function firstIntegrationFileShouldBeIntegre1179DotPan() { public function firstIntegrationFileShouldBeIntegre1179DotPan() {
$this->assertEquals('integre1179.pan', Class_Cosmogramme_Integration::find(2)->getFichier()); $this->assertEquals('integre1179.pan',
Class_Cosmogramme_Integration::find(2)->getFichier());
} }
/** @test */ /** @test */
public function firstIntegrationFileNameShouldBeMyLibraryTotalDotTxt() { 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 */ /** @test */
public function firstIntegrationKeyShouldBeHash() { public function firstIntegrationKeyShouldBeHash() {
$this->assertEquals('a7be1b1bbdfe70b6fec563334accab3f', Class_Cosmogramme_Integration::find(2)->getHash()); $this->assertEquals('a7be1b1bbdfe70b6fec563334accab3f',
Class_Cosmogramme_Integration::find(2)->getHash());
} }
/** @test */ /** @test */
public function secondIntegrationURIShouldBeOAIRepository() { public function secondIntegrationShouldBeIncremental() {
$this->assertEquals('http://oai-repository.fr/oai', Class_Cosmogramme_Integration::find(3)->getFichier()); $this->assertTrue(Class_Cosmogramme_Integration::find(3)->isIncrement());
} }
/** @test */ /** @test */
public function secondIntegrationTransfertDateShouldBeBar() { public function secondIntegrationFileShouldContainsDate() {
$this->assertEquals('2015-03-26', Class_Cosmogramme_Integration::find(3)->getDateTransfert()); $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 ...@@ -265,7 +287,9 @@ class PhasePrepareIntegrationsWithOAITest extends PhasePrepareIntegrationsWithOA
class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest extends PhasePrepareIntegrationsWithOAITestCase { class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest
extends PhasePrepareIntegrationsWithOAITestCase {
protected function _prepareFixtures() { protected function _prepareFixtures() {
parent::_prepareFixtures(); parent::_prepareFixtures();
$this->fixture('Class_Cosmogramme_Integration', $this->fixture('Class_Cosmogramme_Integration',
...@@ -281,7 +305,7 @@ class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest extends Ph ...@@ -281,7 +305,7 @@ class PhasePrepareIntegrationsWithOAIIntegrationAlreadyRegisteredTest extends Ph
/** @test */ /** @test */
public function oneIntegrationShouldHaveBeenCreated() { public function oneIntegrationShouldHaveBeenCreated() {
$this->assertEquals(3, count(Class_Cosmogramme_Integration::findAll())); $this->assertEquals(4, 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