diff --git a/application/modules/admin/controllers/OpdsController.php b/application/modules/admin/controllers/OpdsController.php index 5768d62fdb452b7c500a9e8bb8443553564d3b01..58eb1b6cd85236fed9d13110555fa9fbfca363ad 100644 --- a/application/modules/admin/controllers/OpdsController.php +++ b/application/modules/admin/controllers/OpdsController.php @@ -90,7 +90,7 @@ class Admin_OpdsController extends ZendAfi_Controller_Action { $catalog = $catalog->newForEntry($this->_getParam('feed')); if (!$entry = $catalog->getEntry($this->_getParam('entry'))) return; - + $album = $entry->import(); $this->_redirect('/admin/album/edit_album/id/' . $album->getId()); diff --git a/application/modules/admin/views/scripts/opds/browse.phtml b/application/modules/admin/views/scripts/opds/browse.phtml index 0047bb2bf6077805204be1091457ee1669e56779..436859d14df879d5aeea3a3f3e41b5a169f2af61 100644 --- a/application/modules/admin/views/scripts/opds/browse.phtml +++ b/application/modules/admin/views/scripts/opds/browse.phtml @@ -16,9 +16,9 @@ <?php echo $this->escape($entry->getTitle());?> <?php if ($entry->getAuthor()) echo '(' . $this->escape($entry->getAuthor()) . ')';?> <?php if ($entry->hasFiles()) { ?> - - <a href="<?php echo $this->url(array('action' => 'import'));?>?feed=<?php echo urlencode($this->catalog->getUrl());?>&entry=<?php echo urlencode($entry->getId());?>">Importer</a> + - <a href="<?php echo $this->url(array('action' => 'import'));?>?feed=<?php echo urlencode($this->catalog->getUrl());?>&entry=<?php echo urlencode($entry->getExternalUri());?>">Importer</a> - - <a data-popup="true" href="<?php echo $this->url(array('action' => 'previsu-epub'));?>?feed=<?php echo urlencode($this->catalog->getUrl());?>&entry=<?php echo urlencode($entry->getId());?>">Prévisualiser</a> + - <a data-popup="true" href="<?php echo $this->url(array('action' => 'previsu-epub'));?>?feed=<?php echo urlencode($this->catalog->getUrl());?>&entry=<?php echo urlencode($entry->getExternalUri());?>">Prévisualiser</a> <?php } ?> <?php } else { ?> <a href="<?php echo $this->url();?>?entry=<?php echo urlencode($entry->getLink()); ?>"> diff --git a/cosmogramme/php/_menu.php b/cosmogramme/php/_menu.php index a10bbac8b9329cae9ecbb521f38339c0ff6962ec..92abaecade6dc93aa1c1594a2dc722b5c880ff40 100644 --- a/cosmogramme/php/_menu.php +++ b/cosmogramme/php/_menu.php @@ -126,7 +126,6 @@ else ligneMenu("Logs des erreurs SQL","integre_log_sql.php"); ligneMenu("Réindexation des identifiants","util_indexation.php"); ligneMenu("Réindexation phonétique","util_fulltext.php?action=PARAM"); - ligneMenu("Traitements ponctuels","util_divers.php"); ?> </body> </html> diff --git a/cosmogramme/php/classes/classe_abonne.php b/cosmogramme/php/classes/classe_abonne.php index d82e0488b8fb5a9855167e9d5c8bb8d4fc41a92b..5356b07ee20c77336ce36b6ab5547f5e99f50266 100644 --- a/cosmogramme/php/classes/classe_abonne.php +++ b/cosmogramme/php/classes/classe_abonne.php @@ -64,10 +64,21 @@ class abonne else $this->importFicheAscii($data); } + + public function clean_email($email) { + $email = trim($email); + $email = str_replace(" ", "", $email); + $email = preg_replace("#[\;\#\n\r\*\'\"<>&\%\!\(\)\{\}\[\]\?\\/\s]#", "", $email); + return $email; + } + + // ---------------------------------------------------------------- // Import d'une fiche en ASCII // ---------------------------------------------------------------- public function importFicheAscii($data) { + xdebug_break(); + // Transco accents $data=$this->changeAccents($data); $enreg['MAIL'] = ''; @@ -79,7 +90,6 @@ class abonne $enreg[$colonne]=$data[$i]; } - $this->importFicheArray(array_filter($enreg)); } @@ -99,7 +109,7 @@ class abonne if(!$enreg["PASSWORD"] and $enreg["NAISSANCE"]) $enreg["PASSWORD"]=rendDate($enreg["NAISSANCE"],1); - + $enreg['MAIL']=$this->clean_email($enreg['MAIL']); $this->saveorUpdateInDB($enreg); } @@ -116,10 +126,11 @@ class abonne foreach($this->champs as $champ => $balise) { if($balise){ $cmd="\$enreg['$champ']=(string)\$data->".addslashes($balise).";"; - eval($cmd); + $balise=addslashes($balise); + $enreg[$champ]=(string)$data->$balise; } } - + $enreg['MAIL']=$this->clean_email($enreg['MAIL']); $enreg = $this->prepareData($enreg); $this->saveOrUpdateInDB($enreg); } diff --git a/cosmogramme/php/classes/classe_sql.php b/cosmogramme/php/classes/classe_sql.php index 13e867cca6825fa435b74f5e986f5be9cdd4b9c7..d62a90e750c009aa9eb17b27182d71e8d6144ebc 100644 --- a/cosmogramme/php/classes/classe_sql.php +++ b/cosmogramme/php/classes/classe_sql.php @@ -144,9 +144,10 @@ class sql $statement = isset($this->statements[$table][$cols]) ? $this->statements[$table][$cols] : $this->statements[$table][$cols] = $this->createInsertPrepareStatement($table, $data); - - foreach($data as $col => $valeur) - $statement->bindParam(":$col", trim($valeur)); + + foreach($data as $col => $valeur) { + $statement->bindValue(":$col", trim($valeur)); + } try { $result = $statement->execute(); diff --git a/cosmogramme/php/integre_generation_pergame.php b/cosmogramme/php/integre_generation_pergame.php index ac873ca2cf53ad176b8a2c3de2521c2745cf7594..003328ee020fbcf66a7efafb5264af3825deff5e 100644 --- a/cosmogramme/php/integre_generation_pergame.php +++ b/cosmogramme/php/integre_generation_pergame.php @@ -143,8 +143,8 @@ if($_REQUEST["action"]=="CONTROLE") sqlExecute("delete from int_bib where id_bib=".$enreg["ID_SITE"]); $enreg1["id_bib"]=$enreg["ID_SITE"]; - $enreg1["nom"]=$enreg["LIBELLE"]; - $enreg1["nom_court"]=$enreg["LIBELLE"]; + $enreg1["nom"]=trim($enreg["LIBELLE"]); + $enreg1["nom_court"]=trim($enreg["LIBELLE"]); $enreg1["qualite"]=5; $enreg1["sigb"]=$type_sigb; $enreg1["planif_mode"]="r"; @@ -160,7 +160,8 @@ if($_REQUEST["action"]=="CONTROLE") $enreg1["comm_sigb"]=1; $enreg1["comm_params"]=serialize(array("Autoriser_docs_disponibles"=>"0","Max_par_carte"=>"3","Max_par_document"=>"3")); } - sqlInsert("int_bib", $enreg1); + + (new Class_IntBib)->updateAttributes($enreg1)->save(); $nb_bibs++; } print('</table></div>'); @@ -216,7 +217,7 @@ if($_REQUEST["action"]=="CONTROLE") $enreg["type_operation"]=1; $enreg["nom_fichier"]=$path_fichier."site".$id_bib."/suppressions.txt"; $enreg["rang"]=$id_prog; - sqlInsert("int_maj_auto", $enreg); + (new Class_IntMajAuto)->updateAttributes($enreg)->save(); } // notices total @@ -229,7 +230,8 @@ if($_REQUEST["action"]=="CONTROLE") $enreg["type_operation"]=2; $enreg["nom_fichier"]=$path_fichier."site".$id_bib."/notices_total.txt"; $enreg["rang"]=$id_prog; - sqlInsert("int_maj_auto", $enreg); + (new Class_IntMajAuto)->updateAttributes($enreg)->save(); + // notices incrémentiel echo '<tr><td class="blank"> </td><td class="blank">Import incrémentiel des notices</td></tr>'; @@ -241,7 +243,7 @@ if($_REQUEST["action"]=="CONTROLE") $enreg["type_operation"]=0; $enreg["nom_fichier"]=$path_fichier."site".$id_bib."/notices.txt"; $enreg["rang"]=$id_prog; - sqlInsert("int_maj_auto", $enreg); + (new Class_IntMajAuto)->updateAttributes($enreg)->save(); // abonnés echo '<tr><td class="blank"> </td><td class="blank">Import des abonnés</td></tr>'; @@ -253,7 +255,7 @@ if($_REQUEST["action"]=="CONTROLE") $enreg["type_operation"]=2; $enreg["nom_fichier"]=$path_fichier."site".$id_bib."/abonnes.txt"; $enreg["rang"]=$id_prog; - sqlInsert("int_maj_auto", $enreg); + (new Class_IntMajAuto)->updateAttributes($enreg)->save(); // prêts echo '<tr><td class="blank"> </td><td class="blank">Import des prêts</td></tr>'; @@ -264,7 +266,7 @@ if($_REQUEST["action"]=="CONTROLE") $enreg["type_operation"]=2; $enreg["nom_fichier"]=$path_fichier."site".$id_bib."/prets.txt"; $enreg["rang"]=$id_prog; - sqlInsert("int_maj_auto", $enreg); + (new Class_IntMajAuto)->updateAttributes($enreg)->save(); // réservations (pergame uniquement) if($type_sigb==1) @@ -277,7 +279,7 @@ if($_REQUEST["action"]=="CONTROLE") $enreg["type_operation"]=2; $enreg["nom_fichier"]=$path_fichier."site".$id_bib."/reservations.txt"; $enreg["rang"]=$id_prog; - sqlInsert("int_maj_auto", $enreg); + (new Class_IntMajAuto)->updateAttributes($enreg)->save(); } } print('</table></div>'); diff --git a/cosmogramme/tests/php/classes/AbonneIntegrationTest.php b/cosmogramme/tests/php/classes/AbonneIntegrationTest.php index 723e48d3e6fc2940e4df6d22472ebbc2e680d7a0..e9fefd3d1cf4811aecdd6235ff68cd99860c36bc 100644 --- a/cosmogramme/tests/php/classes/AbonneIntegrationTest.php +++ b/cosmogramme/tests/php/classes/AbonneIntegrationTest.php @@ -64,10 +64,6 @@ abstract class AbonneIntegrationXMLTestCase extends AbonneIntegrationTestCase { public function setup(){ parent::setup(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users') - ->whenCalled('save') - ->answers(true); - $this->abon_config->setChamps(['IDABON'=>'LECTNUM', 'ID_SIGB'=>'LECTNUM', @@ -207,7 +203,7 @@ class AbonneIntegrationASCIIWithRoutoInDbTest extends AbonneIntegrationTestCase 'Routo', 'Pierre', 'la', - 'rp@afi-sa.fr']); + '"rp@afi-sa.fr "']); $this->abon_config->importFicheAscii($champs_sigb_ascii); @@ -215,12 +211,17 @@ class AbonneIntegrationASCIIWithRoutoInDbTest extends AbonneIntegrationTestCase $this->users = Class_Users::findAllBy(['login' => '5 5']); } - + /** @test */ public function onlyOneUserShouldHaveLogin55() { $this->assertEquals(1, count($this->users)); } + /** @test */ + public function mailShouldBeCleaned() { + $this->assertEquals('rp@afi-sa.fr',$this->users[0]->getMail()); + } + /** @test **/ public function withRoutoInDbImportShouldUpdateRoutoWithIdabon55() { $this->assertEquals('5 5',$this->users[0]->getIdabon()); @@ -271,6 +272,8 @@ class AbonneIntegrationASCIIWithTwoUsersSameLoginDifferentPasswordAndOrdreAbonTe $jsmith2 = Class_Users::findFirstBy(['login' => 'jsmith', 'ordreabon' => 2]); $this->assertEquals('1977-06-25', $jsmith2->getNaissance()); + $this->assertEquals('js@afi-sa.fr', $jsmith2->getMail()); + } @@ -341,7 +344,8 @@ class AbonneIntegrationASCIIWithIDSigbInDataAndNotInBaseTest extends AbonneInteg $this->abon_config->importFicheArray(['IDABON' => 'jsmith', 'NOM' => 'johnny', - 'ID_SIGB' => 24]); + 'ID_SIGB' => 24, + 'MAIL' => ' " jsmith!@nomail.org "']); $this->johny = Class_Users::findFirstBy(['id_sigb' => 24]); } @@ -361,6 +365,12 @@ class AbonneIntegrationASCIIWithIDSigbInDataAndNotInBaseTest extends AbonneInteg public function userWithIdFourShouldBeJohnny() { $this->assertEquals('johnny', Class_Users::find(4)->getNom()); } + + /** @test */ + public function mailJohnnyShouldBeCleaned() { + $this->assertEquals('jsmith@nomail.org',$this->johny->getMail()); + } + } @@ -374,7 +384,7 @@ class AbonneIntegrationXMLWithNoUsersInDbTest extends AbonneIntegrationXMLTestCa $champs_sigb_xml = '<Item><TYPE_ABONNE>I</TYPE_ABONNE><LECTNUM>00003090</LECTNUM><LASTNAME>Pirly</LASTNAME><FIRSTNAME>Coco</FIRSTNAME><FULLNAME>Pirly, Coco</FULLNAME><DATEBIRTH>12/31/1982</DATEBIRTH><MOT_DE_PASSE>zoom</MOT_DE_PASSE></Item>'; $this->abon_config->importFicheXml($champs_sigb_xml); - $this->user_tom = Class_Users::getFirstAttributeForLastCallOn('save'); + $this->user_tom = Class_Users::findFirstBy(['nom'=> 'Pirly']); } @@ -395,21 +405,19 @@ class AbonneIntegrationXMLWithRoutoInDbTest extends AbonneIntegrationXMLTestCase public function setup(){ parent::setup(); - $this->user_zozio = Class_Users::newInstanceWithId(5,['nom'=>'poirreau', - 'prenom'=>'Zozio', - 'login'=>'01003080', - 'password'=>'allez les bleus']); + $this->user_zozio = $this->fixture('Class_Users',['id'=>5, + 'nom'=>'poirreau', + 'prenom'=>'Zozio', + 'login'=>'01003080', + 'password'=>'allez les bleus']); - Class_Users::whenCalled('findFirstBy') - ->with(['login'=>'0100 3080', - 'id_site'=>2]) - ->answers($this->user_zozio); - - $champs_sigb_xml = '<Item><TYPE_ABONNE>I</TYPE_ABONNE><LECTNUM>0100 3080</LECTNUM><LASTNAME>poirreau</LASTNAME><FIRSTNAME>Zozio</FIRSTNAME><FULLNAME>Piou Piou</FULLNAME><DATEBIRTH>12/31/2012</DATEBIRTH><MOT_DE_PASSE>allez les bleus</MOT_DE_PASSE></Item>'; + + $champs_sigb_xml = '<Item><TYPE_ABONNE>I</TYPE_ABONNE><LECTNUM>0100 3080</LECTNUM><LASTNAME>poirreau</LASTNAME><FIRSTNAME>Zozio</FIRSTNAME><FULLNAME>Piou Piou</FULLNAME><DATEBIRTH>12/31/2012</DATEBIRTH><MOT_DE_PASSE>poum</MOT_DE_PASSE><EMAIL>" ##zozio@nomail.org "</EMAIL></Item>'; $this->abon_config->importFicheXml($champs_sigb_xml); - $this->zozio_after_import = Class_Users::getFirstAttributeForLastCallOn('save'); + $this->zozio_after_import = Class_Users::findFirstby(['login'=>'0100 3080', + 'id_site' => 2]); } /** @test **/ @@ -419,8 +427,14 @@ class AbonneIntegrationXMLWithRoutoInDbTest extends AbonneIntegrationXMLTestCase /** @test **/ - public function routoInDbAndRoutoAfterImportShouldBeTheSame() { - $this->assertSame($this->user_zozio, $this->zozio_after_import); + public function passwordAfterImportXmlShouldBePoum() { + $this->assertEquals('poum', $this->zozio_after_import->getPassword()); + } + + /** @test */ + public function mailImportXmlShouldBeCleaned() { + $this->assertEquals('zozio@nomail.org',$this->zozio_after_import->getMail()); } + } diff --git a/library/Class/IntMajAuto.php b/library/Class/IntMajAuto.php new file mode 100644 index 0000000000000000000000000000000000000000..2b6da0f462e664ca9af7a8d0bb6d0d6dae79c2d4 --- /dev/null +++ b/library/Class/IntMajAuto.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class Class_IntMajAuto extends Storm_Model_Abstract { + protected $_table_name = 'int_maj_auto'; + protected $_table_primary = 'id_prog'; +} + +?> \ No newline at end of file diff --git a/library/Class/OpdsCatalog.php b/library/Class/OpdsCatalog.php index 7691d51ccedf0d7bea50161e3dfbfb7054a647af..ac8cdc2136174add8f3d36fd80b9ceaf6727953d 100644 --- a/library/Class/OpdsCatalog.php +++ b/library/Class/OpdsCatalog.php @@ -23,11 +23,6 @@ class Class_OpdsCatalog extends Storm_Model_Abstract { protected $_table_name = 'opds_catalogs'; protected $_web_client; - public static function getLoader() { - return parent::getLoaderFor(__CLASS__); - } - - public function getEntries() { return $this->getCatalogueReader()->getEntries(); } @@ -50,7 +45,7 @@ class Class_OpdsCatalog extends Storm_Model_Abstract { public function getEntry($id) { $entries = $this->getEntries(); foreach($entries as $entry) { - if ($id == $entry->getId()) + if ($entry->matchId($id)) return $entry; } return null; diff --git a/library/Class/WebService/BibNumerique/RessourceNumerique.php b/library/Class/WebService/BibNumerique/RessourceNumerique.php index 10797783184dde4dc5de7ea84250a55c64c5fc25..3c31f6bb62598aa8e4f757c6baabffe28a4d2b3f 100644 --- a/library/Class/WebService/BibNumerique/RessourceNumerique.php +++ b/library/Class/WebService/BibNumerique/RessourceNumerique.php @@ -237,7 +237,7 @@ ->setTitre($this->getTitle()) ->setDescription($this->getDescription()) ->setAnnee($this->getYear()) - ->setIdOrigine(hash('adler32',$this->getId())) + ->setIdOrigine($this->getId()) ->setUrlOrigine($this->getBaseUrl()) ->setCategorie($categorie) ->setRessources($this->getRessources()); diff --git a/library/Class/WebService/OPDS/CatalogEntry.php b/library/Class/WebService/OPDS/CatalogEntry.php index aa614209a2f8692e970d23ffa2582db9ed78a9f2..95d6363730c1381f19f233bf5770418000af693e 100644 --- a/library/Class/WebService/OPDS/CatalogEntry.php +++ b/library/Class/WebService/OPDS/CatalogEntry.php @@ -35,6 +35,17 @@ class Class_WebService_OPDS_CatalogEntry extends Class_WebService_BibNumerique_R $this->_files = []; } + + public function matchId($other_id) { + return $this->getId() === hash('adler32',$other_id); + } + + + public function setId($id) { + parent::setId(hash('adler32',$id)); + return $this; + } + public function addFile($url, $mimeType) { $this->_files[] = Class_WebService_OPDS_EntryFile::newWith($url, $mimeType); diff --git a/library/Class/WebService/OPDS/CatalogReader.php b/library/Class/WebService/OPDS/CatalogReader.php index 6648aa5ee84361ce74f6c55ec5379a31da5a4b3f..916c51fa4a5ae40ee11252d8b3b09cdd2ad5fe69 100644 --- a/library/Class/WebService/OPDS/CatalogReader.php +++ b/library/Class/WebService/OPDS/CatalogReader.php @@ -28,6 +28,7 @@ class Class_WebService_OPDS_CatalogReader { protected $_search; protected $_xml_parser; + public static function fromXML($xml) { $instance = new self(); return $instance->parse($xml); @@ -167,6 +168,7 @@ class Class_WebService_OPDS_CatalogReader { return; $this->_current_entry->setId($data); + $this->_current_entry->setExternalUri($data); } diff --git a/scripts/emacs/phafi-mode.el b/scripts/emacs/phafi-mode.el index c660c88452c938cd6877d766cbe55f1e90a95474..b8a11f36918cfc22200edd30b17cee26c020bb05 100644 --- a/scripts/emacs/phafi-mode.el +++ b/scripts/emacs/phafi-mode.el @@ -103,9 +103,9 @@ (add-hook 'after-save-hook (lambda () (if (and (equal (phafi-file-is-geben) nil) (equal phafi-debug-in-progress nil)) - (if (phafi-file-is-test) - (phafi-phpunit-command-for-test) - (phafi-phpunit-command-for-file))) + (if (phafi-file-is-test) + (phafi-phpunit-command-for-test) + (phafi-phpunit-command-for-file))) ) ) ) @@ -591,7 +591,7 @@ "update variables set valeur='./cosmogramme/fichiers/integration/' where clef='integration_path';" "update variables set valeur='admin' where clef='admin_login';" "update variables set valeur='admin' where clef='admin_pwd';" - "update mysql.trig set definer='root@localhost';" + "update mysql.proc set definer='root@localhost';" "drop trigger datemaj_notices_update;") mysql-connection-info) diff --git a/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php b/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php index 086c2528bc72d6257745060e0ecfe2ff69acd98d..e133f950adbfca97145b52a8d93cb460abea95ba 100644 --- a/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php +++ b/tests/application/modules/admin/controllers/HarvestControllerToutApprendreTest.php @@ -22,9 +22,8 @@ require_once 'AdminAbstractControllerTestCase.php'; abstract class HarvestControllerToutApprendreTestCase extends Admin_AbstractControllerTestCase { - protected $_web_client; - protected $_albumWrapper; + public function setUp() { parent::setUp(); @@ -36,12 +35,11 @@ abstract class HarvestControllerToutApprendreTestCase extends Admin_AbstractCont ->whenCalled('updateAlbum') ->answers(true)); - $this->_albumWrapper =Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album') - ->whenCalled('delete') - ->answers(true) - ->whenCalled('save')->answers(true) - ->whenCalled('findFirstBy')->answers(null) - ->whenCalled('deleteBy')->answers(null); + + + Class_AlbumCategorie::beVolatile(); + Class_Album::beVolatile(); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumRessource') ->whenCalled('getNextOrderFor') ->answers(1) @@ -63,8 +61,6 @@ abstract class HarvestControllerToutApprendreNotActivatedTestCase extends Harves abstract class HarvestControllerToutApprendreActivatedTestCase extends HarvestControllerToutApprendreTestCase { - - public function setUp() { parent::setUp(); RessourcesNumeriquesFixtures::activateToutApprendre(); @@ -74,30 +70,13 @@ abstract class HarvestControllerToutApprendreActivatedTestCase extends HarvestCo abstract class HarvestControllerToutApprendreWithCoursTestCase extends HarvestControllerToutApprendreActivatedTestCase { - - protected $_categoryWrapper; - protected $_albumWrapper; - public function setUp(){ parent::setUp(); - $this->_web_client - ->whenCalled('open_url') - ->with('http://biblio.toutapprendre.com/cours/catalogueLecons.asp?complet=yes&id=2100') - ->answers(HarvestToutApprendreFixtures::catalogueXML()); - - - $this->_categoryWrapper = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_AlbumCategorie') - ->whenCalled('findFirstBy')->answers(null) - ->whenCalled('save')->answers(true); - - - $this->_albumWrapper =Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album') - ->whenCalled('delete') - ->answers(true) - ->whenCalled('save')->answers(true) - ->whenCalled('findFirstBy')->answers(null) - ->whenCalled('deleteBy')->answers(null); + $this->_web_client + ->whenCalled('open_url') + ->with('http://biblio.toutapprendre.com/cours/catalogueLecons.asp?complet=yes&id=2100') + ->answers(HarvestToutApprendreFixtures::catalogueXML()); } } @@ -146,8 +125,16 @@ class HarvestControllerToutApprendreActivatedWithErrorTest extends HarvestContro class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestControllerToutApprendreWithCoursTestCase { + protected + $_albumWrapper; + public function setUp() { parent::setUp(); + + $this->_albumWrapper =Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Album') + ->whenCalled('deleteBy') + ->answers(null); + $this->dispatch('/admin/harvest/toutapprendre', true); } @@ -169,7 +156,7 @@ class HarvestControllerToutApprendreActivatedWithCoursTest extends HarvestContro $parameter = $this->_albumWrapper->getFirstAttributeForLastCallOn('deleteBy'); $this->assertEquals(1, count($parameter)); $this->assertTrue(false !== strpos($parameter['where'], Class_WebService_BibNumerique_ToutApprendre::BASE_URL)); - $this->assertTrue(false !== strpos($parameter['where'], "not in ('021700d3', '021200d5')")); + $this->assertTrue(false !== strpos($parameter['where'], "not in ('5904', '5519')")); } } diff --git a/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php b/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php index 256405ce05ac2b755dbbe33300270aa39feede3f..44de9e5cb4f6817ed049a30fa06b6d9793ce0065 100644 --- a/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php +++ b/tests/application/modules/admin/controllers/HarvestControllerVodeclicTest.php @@ -156,7 +156,7 @@ class HarvestControllerVodeclicActivatedWithFormationsTest extends HarvestContro $parameter = $this->_albumWrapper->getFirstAttributeForLastCallOn('deleteBy'); $this->assertEquals(1, count($parameter)); $this->assertTrue(false !== strpos($parameter['where'], Class_WebService_BibNumerique_Vodeclic::BASE_URL)); - $this->assertTrue(false !== strpos($parameter['where'], "not in ('00350035', '009d0069')")); + $this->assertTrue(false !== strpos($parameter['where'], "not in ('4', '35')")); } } diff --git a/tests/application/modules/admin/controllers/OpdsControllerTest.php b/tests/application/modules/admin/controllers/OpdsControllerTest.php index 56f1eefa99da80dea4f8471ea8068ab6996a208d..a063ac74bae38f739bde2ed99a1e8b66f2c52127 100644 --- a/tests/application/modules/admin/controllers/OpdsControllerTest.php +++ b/tests/application/modules/admin/controllers/OpdsControllerTest.php @@ -480,7 +480,7 @@ class Admin_OpdsControllerBrowseEbooksGratuitsLastUpdatedTest extends Admin_Opds ->with('http://www.opacsgratuits.com/opds/feed.php?mode=maj') ->answers(OPDSFeedFixtures::ebooksGratuitsLastUpdatedXml()); - $this->dispatch('/admin/opds/browse/id/1?entry=' . urlencode('http://www.opacsgratuits.com/opds/feed.php?mode=maj')); + $this->dispatch('/admin/opds/browse/id/1?entry=' . urlencode('http://www.opacsgratuits.com/opds/feed.php?mode=maj'), true); } @@ -501,7 +501,8 @@ class Admin_OpdsControllerBrowseEbooksGratuitsLastUpdatedTest extends Admin_Opds $this->assertXPathContentContains(sprintf('//a[contains(@href, "admin/opds/import/id/1?feed=%s&entry=%s")]', urlencode('http://www.opacsgratuits.com/opds/feed.php?mode=maj'), urlencode('http://www.ebooksgratuits.com/details.php?book=592')), - 'Importer'); + 'Importer', + $this->_response->getBody()); } diff --git a/tests/library/Class/WebService/NumilogTest.php b/tests/library/Class/WebService/NumilogTest.php index e4417035d9c3e5d6827df1ce2b56c6f552cd0703..793dc6efd0b39798f999dcbcf57181475766f026 100644 --- a/tests/library/Class/WebService/NumilogTest.php +++ b/tests/library/Class/WebService/NumilogTest.php @@ -89,7 +89,7 @@ class NumilogTest extends Storm_Test_ModelTestCase{ /** @test */ public function firstAlbumIdOrigineShouldBe9782246804383() { - $this->assertEquals('130a02b1', $this->_first_album->getIdOrigine()); + $this->assertEquals('9782246804383', $this->_first_album->getIdOrigine()); } diff --git a/tests/library/Class/WebService/ToutApprendreTest.php b/tests/library/Class/WebService/ToutApprendreTest.php index 2169d079afeb602057d83ebbf60ee93db18b45a9..42bd095c901a851407958d07e8e9b9b8bf1e77be 100644 --- a/tests/library/Class/WebService/ToutApprendreTest.php +++ b/tests/library/Class/WebService/ToutApprendreTest.php @@ -93,7 +93,7 @@ class ToutApprendreTest extends Storm_Test_ModelTestCase{ /** @test */ public function firstAlbumLibreOfficeIdOrigineShouldBe4742() { - $this->assertEquals('021300d2', $this->_first_album->getIdOrigine()); + $this->assertEquals('4742', $this->_first_album->getIdOrigine()); } diff --git a/tests/library/Class/WebService/VodeclicTest.php b/tests/library/Class/WebService/VodeclicTest.php index 45f09f4af7e07559337c63682c93bc65a34f2255..02b3743920bdd29a3212553ac862ebc6a35ef803 100644 --- a/tests/library/Class/WebService/VodeclicTest.php +++ b/tests/library/Class/WebService/VodeclicTest.php @@ -40,7 +40,10 @@ class VodeclicTest extends Storm_Test_ModelTestCase{ ->answers(true)); Class_Album::beVolatile(); - Class_Album::setFileSystem(Storm_Test_ObjectWrapper::mock()->whenCalled('rmdir')->answers(true)); + + Class_Album::setFileSystem(Storm_Test_ObjectWrapper::mock() + ->whenCalled('rmdir') + ->answers(1)); Class_AlbumRessource::beVolatile(); Class_AlbumCategorie::beVolatile(); @@ -87,7 +90,7 @@ class VodeclicTest extends Storm_Test_ModelTestCase{ /** @test */ public function firstAlbumSafari2IdOrigineShouldBe1() { - $this->assertEquals('00320032', $this->_first_album->getIdOrigine()); + $this->assertEquals('1', $this->_first_album->getIdOrigine()); }