diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 43dcfb7d90a7588883bc4c9496f2b4c7193164ca..f9542cea09b4020e1695b06717dba743dd7fb406 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -171,6 +171,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe Class_Url::setBaseUrl(BASE_URL); Class_Url::setPhpMode('apache'); Class_AdminVar::set('NOM_DOMAINE', 'http://localhost'); + Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()->whenCalled('execTimedScript')->answers('')); } diff --git a/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php b/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php index 1c7b275ee5d94eeb3118d9b80214d3eb74af0289..43e36d3060d65b64f1c622060302c89d2c334d53 100644 --- a/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php +++ b/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php @@ -16,41 +16,41 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once 'AdminAbstractControllerTestCase.php'; -abstract class HarvestControllerToutApprendreTestCase extends Admin_AbstractControllerTestCase { - protected $_web_client; +abstract class HarvestControllerToutApprendreTestCase + extends Admin_AbstractControllerTestCase { + + protected + $_storm_default_to_volatile = true, + $_web_client; public function setUp() { parent::setUp(); - - $this->_web_client = Storm_Test_ObjectWrapper::mock() - ->whenCalled('open_url')->answers(''); - - Class_WebService_BibNumerique_ToutApprendre::setDefaultHttpClient($this->_web_client); - Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock() - ->whenCalled('updateAlbum') - ->answers(true)); - + $this->_web_client = $this->mock() + ->whenCalled('open_url')->answers(''); - Class_AlbumCategorie::beVolatile(); - Class_Album::beVolatile(); + Class_WebService_BibNumerique_ToutApprendre::setDefaultHttpClient($this->_web_client); + Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock() + ->whenCalled('execTimedScript') + ->answers('')); + + $this->onLoaderOfModel('Class_AlbumRessource') + ->whenCalled('getNextOrderFor') + ->answers(1) + ->whenCalled('delete') + ->answers(true) + ->whenCalled('save') + ->answers(true); + } +} - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumRessource') - ->whenCalled('getNextOrderFor') - ->answers(1) - ->whenCalled('delete') - ->answers(true) - ->whenCalled('save') - ->answers(true); - } -} abstract class HarvestControllerToutApprendreNotActivatedTestCase extends HarvestControllerToutApprendreTestCase { public function setUp() { parent::setUp(); @@ -105,7 +105,7 @@ class HarvestControllerToutApprendreActivatedWithErrorTest extends HarvestContro ->with('') ->answers(''); - $this->dispatch('/admin/harvest/toutapprendre', true); + $this->dispatch('/admin/harvest/toutapprendre', true); } @@ -125,7 +125,7 @@ class HarvestControllerToutApprendreActivatedWithErrorTest extends HarvestContro class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestControllerToutApprendreWithCoursTestCase { - protected + protected $_albumWrapper; public function setUp() { @@ -135,7 +135,7 @@ class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestContro ->whenCalled('deleteBy') ->answers(null); - $this->dispatch('/admin/harvest/toutapprendre', true); + $this->dispatch('/admin/harvest/toutapprendre', true); } @@ -166,7 +166,7 @@ class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestContro class HarvestControllerToutApprendreBrowse extends HarvestControllerToutApprendreWithCoursTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/admin/harvest/toutapprendre-browse', true); + $this->dispatch('/admin/harvest/toutapprendre-browse', true); } @@ -224,4 +224,3 @@ EOXML; } } - diff --git a/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php b/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php index 680cee0c435860dca9228e6b03f68875a0aef789..40249fe6bf0e205356e1bf2386ffb85690675ff8 100644 --- a/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php +++ b/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php @@ -32,13 +32,14 @@ abstract class HarvestControllerVodeclicTestCase extends Admin_AbstractControlle ->whenCalled('open_url')->answers(''); Class_WebService_BibNumerique_Vodeclic::setDefaultHttpClient($this->_web_client); - Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock() - ->whenCalled('updateAlbum') - ->answers(true)); - + Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock() + ->whenCalled('execTimedScript') + ->answers('')); } - } + + + abstract class HarvestControllerVodeclicNotActivatedTestCase extends HarvestControllerVodeclicTestCase { public function setUp() { parent::setUp(); diff --git a/tests/library/Class/ModelTestCase.php b/tests/library/Class/ModelTestCase.php index d03ff118923fbabf8b1d5f54dcd302eaaa059cbc..8ceda4ff8320031645dc93717bef3fd451bbb495 100644 --- a/tests/library/Class/ModelTestCase.php +++ b/tests/library/Class/ModelTestCase.php @@ -79,6 +79,8 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase { Class_Url::setBaseUrl('/bokeh'); Class_Url::setPhpMode('apache'); Class_AdminVar::set('NOM_DOMAINE', 'http://localhost'); + Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock() + ->whenCalled('execTimedScript')->answers('')); } diff --git a/tests/library/Class/WebService/Album/VignetteTest.php b/tests/library/Class/WebService/Album/VignetteTest.php index a12547382d7d407c5091f531dec7a3c2301d7b14..648f3a3511b6124c6718ef81ba5df8d4f3d260c8 100644 --- a/tests/library/Class/WebService/Album/VignetteTest.php +++ b/tests/library/Class/WebService/Album/VignetteTest.php @@ -25,14 +25,14 @@ abstract class Class_WebService_Album_VignetteTestCase extends Storm_Test_ModelT public function setUp() { parent::setup(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album') - ->whenCalled('save') - ->answers(true); + $this->onLoaderOfModel('Class_Album') + ->whenCalled('save') + ->answers(true); Class_WebService_BibNumerique_Vignette::resetInstance(); $this->_vignette = Class_WebService_BibNumerique_Vignette::getInstance(); - $this->_http_client = Storm_Test_ObjectWrapper::mock(); + $this->_http_client = $this->mock(); Class_WebService_BibNumerique_Vignette::setDefaultHttpClient($this->_http_client); } diff --git a/tests/library/Class/WebService/NumilogTest.php b/tests/library/Class/WebService/NumilogTest.php index e3d7c93c80d88d7fa5526208a2e6123edcedc07e..a4a272971df06cce63dddd2145eb2477ece967ee 100644 --- a/tests/library/Class/WebService/NumilogTest.php +++ b/tests/library/Class/WebService/NumilogTest.php @@ -32,22 +32,20 @@ class NumilogTest extends ModelTestCase { Class_AdminVar::newInstanceWithId('NUMILOG_OAI_URL', ['valeur' => 'http://numilog-oai-url']); Class_AdminVar::newInstanceWithId('NUMILOG_URL', ['valeur' => 'http://numilog-oai-url']); Class_AdminVar::newInstanceWithId('NUMILOG_OAI_IDBIB', ['valeur' => '44']); + $catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_catalogue.xml'); $catalogue_end_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/numilog_end.xml'); - $this->_http_client = Storm_Test_ObjectWrapper::mock(); - $this->_http_client - ->whenCalled('open_url') - ->with('http://numilog-oai-url?verb=ListRecords&metadataPrefix=oai_dc&set=bib%3A44') - ->answers($catalogue_xml) - ->whenCalled('open_url') - ->with('http://numilog-oai-url?verb=ListRecords&resumptionToken=769701498%21500%21oai_dc%21bib%3A44%21') - ->answers($catalogue_end_xml) - ->beStrict(); - Class_WebService_BibNumerique_Numilog::setDefaultHttpClient($this->_http_client); - Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock() - ->whenCalled('updateAlbum') - ->answers(true)); + $this->_http_client = $this->mock() + ->whenCalled('open_url') + ->with('http://numilog-oai-url?verb=ListRecords&metadataPrefix=oai_dc&set=bib%3A44') + ->answers($catalogue_xml) + + ->whenCalled('open_url') + ->with('http://numilog-oai-url?verb=ListRecords&resumptionToken=769701498%21500%21oai_dc%21bib%3A44%21') + ->answers($catalogue_end_xml) + + ->beStrict(); $codif_type_doc = $this->fixture('Class_CodifTypeDoc', ['id' => Class_TypeDoc::NUMILOG, @@ -60,7 +58,6 @@ class NumilogTest extends ModelTestCase { 'codif_type_doc' => $codif_type_doc, 'label'=> 'Livres Numériques']); - Class_Album::beVolatile(); $this->fixture('Class_CodifMatiere', ['id' => '132', 'libelle'=>'Management', 'code_alpha' => 'MANAGEMENT']); @@ -71,20 +68,30 @@ class NumilogTest extends ModelTestCase { 'libelle'=>'Psychologie', 'code_alpha' => 'PSYCHOLOGIE']); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album') - ->whenCalled('deleteBy') - ->answers(true); + $this->onLoaderOfModel('Class_Album') + ->whenCalled('deleteBy') + ->answers(true); $this->_numilog = new Class_WebService_BibNumerique_Numilog(); + Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock() + ->whenCalled('execTimedScript') + ->answers('')); Class_WebService_BibNumerique_Numilog::setDefaultHttpClient($this->_http_client); + $this->_numilog->harvest(''); $this->_first_livre_numerique = $this->_numilog->loadPage(1)->getRessourcesNumeriques()[0]; $this->_first_album = $this->_numilog->getAlbums()[0]; $this->_second_album = $this->_numilog->getAlbums()[1]; $this->_third_album = $this->_numilog->getAlbums()[2]; + } + + public function tearDown() { + Class_WebService_BibNumerique_RessourceNumerique::setCommand(null); + Class_WebService_BibNumerique_Numilog::setDefaultHttpClient(null); + parent::tearDown(); } @@ -149,7 +156,7 @@ class NumilogTest extends ModelTestCase { /** @test */ public function thirdAlbumShouldBeSaved() { - $this->assertEquals(1, count(Class_Album::findFirstBy(['titre' => 'Stress et burnout au travail']))); + $this->assertNotNull(Class_Album::findFirstBy(['titre' => 'Stress et burnout au travail'])); } diff --git a/tests/library/Class/WebService/ToutApprendreTest.php b/tests/library/Class/WebService/ToutApprendreTest.php index 42834a56b493aac03b8d5f92a82a8ee1fff8a2a1..fc57834f1e5b8290bb0064564a96d67d9268db22 100644 --- a/tests/library/Class/WebService/ToutApprendreTest.php +++ b/tests/library/Class/WebService/ToutApprendreTest.php @@ -30,17 +30,16 @@ class ToutApprendreTest extends ModelTestCase { RessourcesNumeriquesFixtures::activateToutApprendre(); $catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/toutapprendre_catalogue.xml'); - $http_client = $this->mock(); - $http_client - ->whenCalled('open_url') - ->with('http://biblio.toutapprendre.com/cours/catalogue.aspx?pk=2100') - ->answers($catalogue_xml) - ->beStrict(); + $http_client = $this->mock() + ->whenCalled('open_url') + ->with('http://biblio.toutapprendre.com/cours/catalogue.aspx?pk=2100') + ->answers($catalogue_xml) + ->beStrict(); Class_WebService_BibNumerique_ToutApprendre::setDefaultHttpClient($http_client); - Class_WebService_BibNumerique_Vignette::setInstance($this->mock() - ->whenCalled('updateAlbum') - ->answers(true)); + Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock() + ->whenCalled('execTimedScript') + ->answers('')); $this->fixture('Class_CosmoVar', ['id' => 'types_docs', 'liste' => '']); diff --git a/tests/library/Class/WebService/VodeclicTest.php b/tests/library/Class/WebService/VodeclicTest.php index d11fc8f03f0b0e6302b852025b0504e4bc4c6e41..797d7a693ed657ba8c4839376f4708c15d54d89c 100644 --- a/tests/library/Class/WebService/VodeclicTest.php +++ b/tests/library/Class/WebService/VodeclicTest.php @@ -16,66 +16,63 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class VodeclicTest extends Storm_Test_ModelTestCase{ - protected static $vodeclic; +class VodeclicTest extends ModelTestCase { + protected + $_storm_default_to_volatile = true, + $_vodeclic, + $_first_album; + + public function setUp() { + parent::setUp(); - 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'); - $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($http_client); - Class_WebService_BibNumerique_Vignette::setInstance(Storm_Test_ObjectWrapper::mock() - ->whenCalled('updateAlbum') - ->answers(true)); + Class_AdminVar::newInstanceWithId('VODECLIC_BIB_ID', ['valeur' => '12']); - Class_Album::beVolatile(); + $catalogue_xml = file_get_contents(__DIR__ . '/../../../fixtures/vodeclic_catalogue.xml'); + $http_client = $this->mock() + ->whenCalled('open_url') + ->with('https://lms.vodeclic.com/api/catalogue.xml?partenaire=api-test&encrypted_partenaire=f13eba4953115a58bdf7952266ecca9fee8f91ddac6ac901042fdb188db02778&bib_id=12') + ->answers($catalogue_xml); - Class_Album::setFileSystem(Storm_Test_ObjectWrapper::mock() - ->whenCalled('rmdir') - ->answers(1)); - Class_AlbumRessource::beVolatile(); - Class_AlbumCategorie::beVolatile(); + Class_WebService_BibNumerique_Vodeclic::setDefaultHttpClient($http_client); + Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock() + ->whenCalled('execTimedScript') + ->answers('')); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumRessource') - ->whenCalled('getNextOrderFor') - ->answers(1); + Class_Album::setFileSystem($this->mock()->whenCalled('rmdir')->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->onLoaderOfModel('Class_AlbumRessource') + ->whenCalled('getNextOrderFor') + ->answers(1); - self::fixture('Class_TypeDoc', ['id' => Class_TypeDoc::VODECLIC, - 'codif_type_doc' => $codif_type_doc, - 'label' => 'Formation Vodéclic']); + $this->fixture('Class_CosmoVar', + ['id' => 'types_docs', + 'liste' => '']); - self::$vodeclic = new Class_WebService_BibNumerique_Vodeclic(); - self::$vodeclic->harvest(''); - } + $codif_type_doc = $this->fixture('Class_CodifTypeDoc', + ['id' => Class_TypeDoc::VODECLIC, + 'famille_id' => Class_CodifTypeDoc::INCONNU, + 'bibliotheques' => '1;8', + 'annexes' => '10;12', + 'sections' => '18;19']); - public function setUp() { - parent::setUp(); - $this->_vodeclic = self::$vodeclic; + $this->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(''); $this->_first_album = $this->_vodeclic->getAlbums()[0]; } - - /** + /** * [[file:~/www/afi-opac/tests/fixtures/vodeclic_catalogue.xml::<titre>Safari%202</titre][formation Safari2]] - * @test + * @test */ public function firstAlbumTitreShouldBeSafari2() { $this->assertEquals('Safari 2', $this->_first_album->getTitre()); @@ -94,40 +91,40 @@ class VodeclicTest extends Storm_Test_ModelTestCase{ } -/** @test */ + /** @test */ public function firstAlbumSafari2LinkShouldBeSet() { $this->assertEquals('https://lms.vodeclic.com/api/catalogue.xml?',$this->_first_album->getUrlOrigine()); } - + /** @test */ public function firstAlbumExternalURIShouldBeSet() { $this->assertEquals('http://biblio.vodeclic.com/formation/1',$this->_first_album->getExternalUri()); } - + /** @test */ public function firstAlbumSafari2DesciptionShouldBeSet() { - $this->assertEquals("Le parcours pédagogiques Safari 2 de A à Z va vous permettre de prendre complètement en main ce navigateur internet installé par défaut sur tous les ordinateurs Apple. Vous y découvrirez une navigation sur Internet simplifiée à l'aide de la barre d'adresse, du champs de recherche Google, des onglets de Safari 2… Nos vidéos-formations vous apprendront également des astuces pour mieux vivre internet au quotidien avec Safari 2. Ainsi vous apprendrez à maîtriser l'historique, vos signets, les formulaires de remplissage automatique et plein d'autres choses !",$this->_first_album->getDescription()); + $this->assertEquals("Le parcours pédagogiques Safari 2 de A à Z va vous permettre de prendre complètement en main ce navigateur internet installé par défaut sur tous les ordinateurs Apple. Vous y découvrirez une navigation sur Internet simplifiée à l'aide de la barre d'adresse, du champs de recherche Google, des onglets de Safari 2… Nos vidéos-formations vous apprendront également des astuces pour mieux vivre internet au quotidien avec Safari 2. Ainsi vous apprendrez à maîtriser l'historique, vos signets, les formulaires de remplissage automatique et plein d'autres choses !", + $this->_first_album->getDescription()); } - + /** @test */ public function firstAlbumSafari2IdLangueShouldBeFre() { $this->assertEquals('fre',$this->_first_album->getIdLangue()); } - + /** @test */ public function firstAlbumSafari2AnneeShouldBe2007 (){ $this->assertEquals('2007',$this->_first_album->getAnnee()); - } + } /** @test */ public function firstAlbumSafari2TypeDocShouldBeFormationVodeclic() { - - $this->assertEquals('Formation Vodéclic',$this->_first_album->getTypeDoc()->getLabel()); + $this->assertEquals('Formation Vodéclic', $this->_first_album->getTypeDoc()->getLabel()); } @@ -144,9 +141,10 @@ class VodeclicTest extends Storm_Test_ModelTestCase{ } - /** @disabledtest */ + /** @test */ public function vignetteShouldHaveBeenUploaded() { - $this->assertTrue(Class_WebService_BibNumerique_Vignette::getInstance()->methodHasBeenCalled('updateAlbum')); + $this->assertTrue(Class_WebService_BibNumerique_RessourceNumerique::getCommand() + ->methodHasBeenCalled('execTimedScript')); } @@ -166,11 +164,4 @@ class VodeclicTest extends Storm_Test_ModelTestCase{ public function sectionsShouldBeImportedInThirdAlbum() { $this->assertEquals('18;19',$this->_vodeclic->getAlbums()[2]->getSections()); } - - - - - } - -?> \ No newline at end of file diff --git a/tests/phpunit.xml b/tests/phpunit.xml index eb6bc26e667609cf4c1823b5aff6992a9c842c98..75a1e00089fa87569f6b82ff2ffb045f6118f104 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -19,9 +19,6 @@ <testsuite name="DigitalResourcesTestSuite"> <directory>../library/digital_resources/</directory> </testsuite> - <testsuite name="StormTestSuite"> - <directory>../library/storm/tests/Storm/</directory> - </testsuite> </testsuites> <filter> <whitelist>