diff --git a/VERSIONS_WIP/dev19572_miop_typo3_import_vignettes b/VERSIONS_WIP/dev19572_miop_typo3_import_vignettes new file mode 100644 index 0000000000000000000000000000000000000000..7b7d1e07dc1e2ec6f5d9651734803cd3ba130337 --- /dev/null +++ b/VERSIONS_WIP/dev19572_miop_typo3_import_vignettes @@ -0,0 +1,2 @@ + - dev#19572: Possibilité d'import des vignettes des sites web depuis typo3 vers bokeh. + php scripts/import_typo3.ph sito diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index d0ae3ef64c61f6ead94a7264126cdfdcced9c20b..2371fa4e4e9ffa714e9fc2246c26fac2611423a8 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -50,7 +50,6 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { . (int)$this->_getParam('cat_id') . ';' . 'var treeViewAjaxBaseUrl = "' . $this->view->url(['action' => 'items-of']) . '"'); $this->view->headScript()->appendFile(URL_ADMIN_JS . 'tree-view.js'); - } diff --git a/application/modules/opac/controllers/ModulesController.php b/application/modules/opac/controllers/ModulesController.php index 54262af62eee6e507bd1b683527ac421c23dd2b7..9ec04d325eee9c12693585098a72d1641b73dc5c 100644 --- a/application/modules/opac/controllers/ModulesController.php +++ b/application/modules/opac/controllers/ModulesController.php @@ -79,8 +79,8 @@ class ModulesController extends Zend_Controller_Action { public function mycowAction() { $mycow = new Class_Systeme_ModulesMenu_MyCow(); $mycow->afterLoginRedirectTo($this->_request->getServer('HTTP_REFERER')); - $this->checkNotifyMessage($mycow, $mycow->getDynamiqueUrl()); - } + $this->checkNotifyMessage($mycow, $mycow->getDynamiqueUrl()); + } public function mycowSsoAction() { diff --git a/cosmogramme/sql/patch/patch_242.php b/cosmogramme/sql/patch/patch_242.php index 3b5012374ae80f2d347716fd5f223176af47dae3..c4239c7dcc4542b40df8bf48b4cdaf0e49093f30 100644 --- a/cosmogramme/sql/patch/patch_242.php +++ b/cosmogramme/sql/patch/patch_242.php @@ -7,4 +7,4 @@ Zend_Registry::get('sql')->query('CREATE TABLE `album_item` ( ' . 'primary key (id),' . 'key (`album_id`)' . ') engine=MyISAM default charset=utf8'); -?> \ No newline at end of file +?> diff --git a/library/Class/Import/Typo3.php b/library/Class/Import/Typo3.php index 7bc2443ea6ebed5d3a629499bfd67211c74bad2e..3c36f32ad87001d1dd56a2576191adbc443c52c5 100644 --- a/library/Class/Import/Typo3.php +++ b/library/Class/Import/Typo3.php @@ -20,13 +20,14 @@ */ class Class_Import_Typo3 { use Trait_TimeSource; + use Trait_StaticFileWriter; const DEFAULT_CAT_ID = 30000; - const BOKEH_IMG_URL = "http://www.mediathequeouestprovence.fr/uploads/"; -// const BOKEH_IMG_URL="http://web.afi-sa.net/miop-test.net/userfiles/image/uploads/"; - const BOKEH_ATTACHMENT_URL = "http://www.mediathequeouestprovence.fr/fileadmin/fichiers/"; -// const BOKEH_ATTACHMENT_URL="http://web.afi-sa.net/miop-test.net/userfiles/file/"; + + const FOLDER_IMGS = "pics/"; //directory to get external images + const BOKEH_IMG_URL = "http://www.mediathequeouestprovence.fr/uploads/"; //url to get files + const BOKEH_ATTACHMENT_URL = "http://www.mediathequeouestprovence.fr/fileadmin/fichiers/"; // path to admin files (specific miop) const BOKEH_FILEADMIN_URL = "http://www.mediathequeouestprovence.fr/fileadmin/"; -// const BOKEH_FILEADMIN_URL= "http://web.afi-sa.net/miop_test.net/userfiles/image/"; + const UID_TYPO3_CF = 'uid_typo3'; @@ -121,6 +122,20 @@ class Class_Import_Typo3 { $logger->addLogRow("\n\n ******** Détection des dossiers documentaires"); $this->updateCategoriesForDossiersDocumentaires(); } + if ($what == 'sito_reimport') { + $logger->addLogRow("\n\n ******** Reimport des sitothèques"); + $this->importSites(); + $logger->addLogRow("\n\n ******** Récupération des images pour les sitothèques"); + $this->updateSites(); + $logger->addLogRow("\n\ Attention : Relancer une intégration cosmogramme pour que l'import soit pris en compte"); + } + + if ($what == 'sito') { + $logger->addLogRow("\n\n ******** Récupération des images pour les sitothèques"); + $this->updateSites(); + $logger->addLogRow("\n\ Attention : Relancer une intégration cosmogramme pour que l'import soit pris en compte"); + } + if ($what == 'advices') { $logger->addLogRow("\n\n ******** Attribution des avis de notices"); @@ -219,6 +234,13 @@ class Class_Import_Typo3 { public function importSites() { + Class_Sitotheque::deleteBy([]); + Class_SitothequeCategorie::deleteBy([]); + + $this->sites_categories_map = new SiteCategoriesMap('Non classé', $this->domaine_map); + $t3categories = $this->t3db->findAllNewsCat(); + $this->sites_categories_map->build($t3categories); + $t3news = $this->t3db->findAllSites(); foreach($t3news as $new) $element = $this->traceUnknownKohaUrls( @@ -229,10 +251,36 @@ class Class_Import_Typo3 { } + + public function updateSites() { + + $t3sites=$this->t3db->findAllExternalSites(); + foreach ($t3sites as $t3site) { + $link_array = explode(' ', $t3site['ext_url']); + $image=explode(',',$t3site['image']); + $this->createImageForExternalWebsite($link_array[0],$image[0]); + } + + } + + + + public function createImageForExternalWebsite($url,$image) { + if (!$image) + return; + $image_contents=$this->getFileWriter()->getContents(self::BOKEH_IMG_URL.self::FOLDER_IMGS.$image); + if (!$image_contents) + return; + $website_thumbnail= new Class_WebService_WebSiteThumbnail(); + $this->getFileWriter()->putContents($website_thumbnail->getFilePath($url), $image_contents); + } + + public function createSito($new) { $date_maj = date("Y-m-d H:i:s", $new['crdate']); $id_cat = $this->sites_categories_map->find($new['category'])->getId(); $url = $this->convertKohaToBokehUrl($this->format_url($new['ext_url'])); + $tags = str_replace(', ', ';', $new['tx_danpextendnews_tags']); $element = Class_Sitotheque::newInstance(['id_cat' => $id_cat, @@ -294,7 +342,7 @@ class Class_Import_Typo3 { protected function addImage($image) { if (!$image) return ''; - return '<img src="'.self::BOKEH_IMG_URL.'pics/'.$image.'" alt=""/>'; + return '<img src="'.self::BOKEH_IMG_URL.self::FOLDER_IMGS.$image.'" alt=""/>'; } @@ -1143,7 +1191,7 @@ class Typo3DB { 'mysqli', ['host' => 'localhost', 'username' => 'root', - 'password' => '', + 'password' => 'root', 'dbname' => 'miop_typo3'])); } @@ -1190,7 +1238,12 @@ class Typo3DB { public function findAllSites() { - return $this->t3db->fetchAll("select * from tt_news where deleted=0 and hidden=0 and ext_url>'' order by uid ASC"); + return $this->t3db->fetchAll("select * from tt_news where deleted=0 and t3ver_label not like 'DELETED!' and hidden=0 and ext_url not like '%koha.mediathequeouestprovence.fr%' and ext_url>'' order by uid ASC"); + } + + + public function findAllExternalSites() { + return $this->t3db->fetchAll("select * from tt_news where deleted=0 and t3ver_label not like 'DELETED!' and hidden=0 and image>'' and ext_url not like '%koha.mediathequeouestprovence.fr%' and ext_url>'' order by uid ASC"); } diff --git a/library/Class/Users.php b/library/Class/Users.php index 45b58221d4eaff95e00a7125a0cc31189ff065c6..6a0434c7a8da4541141eb431a4d993cb07f76b17 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -52,8 +52,8 @@ class UsersLoader extends Storm_Model_Loader { $sql_template .= 'where '; $sql_template .= - '(nom like \'%2$s\' or login like \'%2$s\') '. - 'order by nom, prenom, login limit '.$limit; + '(nom like \'%2$s\' or login like \'%2$s\') '. + 'order by nom, prenom, login limit '.$limit; $like = strtolower($search).'%'; @@ -216,16 +216,16 @@ class UsersLoader extends Storm_Model_Loader { public function findBlowfish($login) { return array_filter( - Class_Users::findAllBy(['login' => $login]), - function($user) { - return substr($user->getPassword(), 0, 4) === '$2a$'; - }); + Class_Users::findAllBy(['login' => $login]), + function($user) { + return substr($user->getPassword(), 0, 4) === '$2a$'; + }); } public function isEmailUnique($email) { $users = Class_Users::findFirstBy([ - 'where' => 'login = "'.$email.'" or mail = "'.$email.'"']); + 'where' => 'login = "'.$email.'" or mail = "'.$email.'"']); return $users ? false : true; } } @@ -247,49 +247,49 @@ class Class_Users extends Storm_Model_Abstract { protected $_table_primary = 'ID_USER'; protected $_loader_class = 'UsersLoader'; protected $_has_many = [ - 'subscriptions' => ['model' => 'Class_NewsletterSubscription', - 'role' => 'user', - 'dependents' => 'delete'], + 'subscriptions' => ['model' => 'Class_NewsletterSubscription', + 'role' => 'user', + 'dependents' => 'delete'], - 'newsletters' => ['through' => 'subscriptions'], + 'newsletters' => ['through' => 'subscriptions'], - 'avis' => ['model' => 'Class_AvisNotice', - 'role' => 'user', - 'order' => 'date_avis desc'], + 'avis' => ['model' => 'Class_AvisNotice', + 'role' => 'user', + 'order' => 'date_avis desc'], - 'avis_articles' => ['model' => 'Class_Avis', - 'role' => 'auteur', - 'order' => 'date_avis desc'], + 'avis_articles' => ['model' => 'Class_Avis', + 'role' => 'auteur', + 'order' => 'date_avis desc'], - 'paniers' => ['model' => 'Class_PanierNotice', - 'role' => 'user', - 'order' => 'date_maj desc'], + 'paniers' => ['model' => 'Class_PanierNotice', + 'role' => 'user', + 'order' => 'date_maj desc'], - 'suggestion_achat' => ['model' => 'Class_SuggestionAchat', - 'role' => 'user', - 'order' => 'date_creation desc'], + 'suggestion_achat' => ['model' => 'Class_SuggestionAchat', + 'role' => 'user', + 'order' => 'date_creation desc'], - 'session_formation_inscriptions' => ['model' => 'Class_SessionFormationInscription', - 'role' => 'stagiaire'], + 'session_formation_inscriptions' => ['model' => 'Class_SessionFormationInscription', + 'role' => 'stagiaire'], - 'session_formations' => ['through' => 'session_formation_inscriptions'], + 'session_formations' => ['through' => 'session_formation_inscriptions'], - 'formations' => ['through' => 'session_formation_inscriptions'], + 'formations' => ['through' => 'session_formation_inscriptions'], - 'session_formation_interventions' => ['model' => 'Class_SessionFormationIntervention', - 'role' => 'intervenant'], + 'session_formation_interventions' => ['model' => 'Class_SessionFormationIntervention', + 'role' => 'intervenant'], - 'session_interventions' => ['through' => 'session_formation_interventions'], + 'session_interventions' => ['through' => 'session_formation_interventions'], - 'user_group_memberships' => ['model' => 'Class_UserGroupMembership', - 'role' => 'user', - 'dependents' => 'delete'], + 'user_group_memberships' => ['model' => 'Class_UserGroupMembership', + 'role' => 'user', + 'dependents' => 'delete'], - 'user_groups' => ['through' => 'user_group_memberships'], + 'user_groups' => ['through' => 'user_group_memberships'], - 'formulaires' => ['model' => 'Class_Formulaire', - 'role' => 'user', - 'order' => 'date_creation desc'], + 'formulaires' => ['model' => 'Class_Formulaire', + 'role' => 'user', + 'order' => 'date_creation desc'], ]; @@ -383,11 +383,11 @@ class Class_Users extends Storm_Model_Abstract { */ public function isRedacteur() { return in_array( - $this->getRoleLevel(), - [ - ZendAfi_Acl_AdminControllerRoles::MODO_BIB, - ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL - ] + $this->getRoleLevel(), + [ + ZendAfi_Acl_AdminControllerRoles::MODO_BIB, + ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL + ] ); } @@ -442,9 +442,9 @@ class Class_Users extends Storm_Model_Abstract { */ public function setModeContact($mode_contact) { switch ($mode_contact) { - case self::MODE_CONTACT_MAIL: $this->setIsContactMail(true)->setIsContactSms(false); break; - case self::MODE_CONTACT_SMS: $this->setIsContactMail(false)->setIsContactSms(true); break; - default: $this->setIsContactMail(false)->setIsContactSms(false); + case self::MODE_CONTACT_MAIL: $this->setIsContactMail(true)->setIsContactSms(false); break; + case self::MODE_CONTACT_SMS: $this->setIsContactMail(false)->setIsContactSms(true); break; + default: $this->setIsContactMail(false)->setIsContactSms(false); } return $this; } @@ -594,8 +594,8 @@ class Class_Users extends Storm_Model_Abstract { public function getUserGroupsIds() { $groups = $this->getUserGroups(); return array_map( - function($group) { return $group->getId();}, - $groups); + function($group) { return $group->getId();}, + $groups); } @@ -813,25 +813,25 @@ class Class_Users extends Storm_Model_Abstract { public function getUsers($id_zone,$id_site,$role_level,$recherche,$page) { if($id_site and $id_site !="ALL") - { - if($id_site=="PORTAIL") $id_site=0; - $cond[]="id_site=$id_site"; - } + { + if($id_site=="PORTAIL") $id_site=0; + $cond[]="id_site=$id_site"; + } elseif($id_zone and $id_zone !="ALL") - { - if($id_zone=="PORTAIL") $cond[]="ID_SITE=0"; - else { - $bibs=fetchAll("select ID_SITE from bib_c_site where ID_ZONE=$id_zone"); - if(!$bibs) return false; - foreach($bibs as $bib) - { - if($inSql) $inSql.=","; - $inSql.=$bib["ID_SITE"]; - } - $cond[]="ID_SITE in($inSql)"; + if($id_zone=="PORTAIL") $cond[]="ID_SITE=0"; + else + { + $bibs=fetchAll("select ID_SITE from bib_c_site where ID_ZONE=$id_zone"); + if(!$bibs) return false; + foreach($bibs as $bib) + { + if($inSql) $inSql.=","; + $inSql.=$bib["ID_SITE"]; + } + $cond[]="ID_SITE in($inSql)"; + } } - } $recherche = array_merge(array('role' => '', 'login' => '', 'nom' => ''), $recherche); @@ -893,7 +893,7 @@ class Class_Users extends Storm_Model_Abstract { if ($this->getRoleLevel() > 1 and $this->getRoleLevel() < 5 and $this->getIdSite() == 0) { $cls_role= new ZendAfi_Acl_AdminControllerRoles(); $this->addError($this->_("La bibliothèque est obligatoire pour le rôle : %s", - $cls_role->getLibelleRole($this->getRoleLevel()))); + $cls_role->getLibelleRole($this->getRoleLevel()))); } if ($this->getRole()=="abonne_sigb" and !$this->getIdabon()) @@ -1192,7 +1192,7 @@ class Class_Users extends Storm_Model_Abstract { public function beforeSave() { $this->setDateMaj(Class_Multimedia_Utils_DateTimeFormat::getInstance() - ->getCurrentDateFormatInYmdHMS()); + ->getCurrentDateFormatInYmdHMS()); if(!$this->isNew()) return $this; @@ -1246,7 +1246,7 @@ class Class_Users extends Storm_Model_Abstract { $end = strtotime('+1 day', $start); return (int) Class_Multimedia_DeviceHold::getLoader() - ->getDurationForUserBetweenTimes($this, $start, $end); + ->getDurationForUserBetweenTimes($this, $start, $end); } @@ -1259,7 +1259,7 @@ class Class_Users extends Storm_Model_Abstract { $end = strtotime('next monday', $start); return (int) Class_Multimedia_DeviceHold::getLoader() - ->getDurationForUserBetweenTimes($this, $start, $end); + ->getDurationForUserBetweenTimes($this, $start, $end); } @@ -1272,7 +1272,7 @@ class Class_Users extends Storm_Model_Abstract { $end = strtotime('first day of next month', $start); return (int) Class_Multimedia_DeviceHold::getLoader() - ->getDurationForUserBetweenTimes($this, $start, $end); + ->getDurationForUserBetweenTimes($this, $start, $end); } diff --git a/library/Class/WebService/Vignette.php b/library/Class/WebService/Vignette.php index bf2434ac13ce49854ff613e1df667ac3e508438e..abca3011ce1c08f63177a1e1561e16e92140cde3 100644 --- a/library/Class/WebService/Vignette.php +++ b/library/Class/WebService/Vignette.php @@ -311,7 +311,6 @@ class Class_WebService_Thumbnail_Provider_Site extends Class_WebService_Thumbnai if (!$site=$notice->getSite()) return $this; $url = $site->getUrl(); - if (!$url_thumbnail = $webthumbnail->fetchFullUrl($url)) $url_thumbnail = 'NO'; diff --git a/library/Class/WebService/WebSiteThumbnail.php b/library/Class/WebService/WebSiteThumbnail.php index cdd1764c021e20a581d6bfe383d8037a05815aee..53f2166083b44254f9ebaaf6c9acea14c323570b 100644 --- a/library/Class/WebService/WebSiteThumbnail.php +++ b/library/Class/WebService/WebSiteThumbnail.php @@ -36,6 +36,14 @@ class Class_WebService_WebSiteThumbnail { } + public function getFilePath($url) { + $this->checkThumbsDir(); + + $filename = strtolower($this->fileNameFromUrl($url)); + return $this->fullPath($filename); + + } + public function getWebThumbnailURL($url) { $this->checkThumbsDir(); diff --git a/library/ZendAfi/View/Helper/Notice/Vignette.php b/library/ZendAfi/View/Helper/Notice/Vignette.php index 353226ff1ff310284b7da29837e60a1e9b8857b0..2d4fa99bd28c451b40d1647a5844652b350eac6c 100644 --- a/library/ZendAfi/View/Helper/Notice/Vignette.php +++ b/library/ZendAfi/View/Helper/Notice/Vignette.php @@ -22,6 +22,7 @@ class ZendAfi_View_Helper_Notice_Vignette extends Zend_View_Helper_HtmlElement { use Trait_Translator; public function notice_Vignette($notice, $preferences=[]) { + if (!$notice->getUrlVignette()) $notice->fetchUrlVignette(); @@ -34,6 +35,7 @@ class ZendAfi_View_Helper_Notice_Vignette extends Zend_View_Helper_HtmlElement { public function imgVignette($notice, $preferences) { $img = $notice->fetchUrlVignette(); + return $this->linkTagForNoticeUrlVignetteTitle($notice, $img, Class_WebService_Vignette::getSource($img), $preferences); } diff --git a/scripts/import_typo3.php b/scripts/import_typo3.php index 3b059a8111ba02b19075bafb5b5f33b281b0c487..a52897db47e76bfc1381ae550cfa2454e6b25720 100644 --- a/scripts/import_typo3.php +++ b/scripts/import_typo3.php @@ -2,7 +2,9 @@ /* * Launch import_typo3.php like: * php import_typo3.php <arg> - * <arg> can be users (import users only), docu(update dossiers documentaires only), articles (import articles only) or all (import all) + * <arg> can be users (import users only), docu(update dossiers documentaires only), articles (import articles only), + * sito (import image file for sitotheque) or sito_reimport (delete and reimport sito) + * or all (import all) * php import_typo3.php update <last_update_date 20-11-2015 > * Script import data in a database named miop_typo3. To change it, edit the line 109. */ diff --git a/tests/application/modules/opac/controllers/RssControllerTest.php b/tests/application/modules/opac/controllers/RssControllerTest.php index fd3712bcdee22d65a4320534bc02b638276ed67d..1f23f9c7064cb0c33a73261361ddfca058603bda 100644 --- a/tests/application/modules/opac/controllers/RssControllerTest.php +++ b/tests/application/modules/opac/controllers/RssControllerTest.php @@ -310,12 +310,12 @@ class RssControllerCritiquesTest extends AbstractControllerTestCase { /** @test */ public function rssShouldContainsTwoItems() { - $this->assertXPath('//item[2]'); + $this->assertXPath('//item[2]', $this->_response->getBody()); } /** @test */ public function rssLinkShouldContainExpectedUrl() { - $this->assertXPathContentContains('//channel/link', BASE_URL); + $this->assertXPathContentContains('//channel/link', BASE_URL, $this->_response->getBody()); } /** @test */ diff --git a/tests/fixtures/RessourcesNumeriquesFixtures.php b/tests/fixtures/RessourcesNumeriquesFixtures.php index 3babce9846ec52bcf5ba8fbd626217e0ce517eb5..4ebd1f73f00f347c3d807ae88be62e39ee6bb024 100644 --- a/tests/fixtures/RessourcesNumeriquesFixtures.php +++ b/tests/fixtures/RessourcesNumeriquesFixtures.php @@ -261,4 +261,5 @@ class RessourcesNumeriquesFixtures { Class_AdminVar::newInstanceWithId('DILICOM_PNB_GLN_CONTRACTOR', ['valeur' => '']); } } + ?> diff --git a/tests/library/Class/Import/Typo3Fixture.php b/tests/library/Class/Import/Typo3Fixture.php index b6b630390af0bd4b41fd77eef6d9a461b7f54b71..720eeab45890d25573da0e175410c3d74253fc01 100644 --- a/tests/library/Class/Import/Typo3Fixture.php +++ b/tests/library/Class/Import/Typo3Fixture.php @@ -19,6 +19,35 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +class MockFileWriter { + protected $contents="image"; + protected $path; + protected $image; + public function fileExists() { + return false; + } + public function dirExists() { + return true; + } + public function getContents($image) { + $this->image=$image; + return $this->contents; + } + + public function getPath() { + return $this->path; + } + public function getImage() { + return $this->image; + } + public function putContents($path, $contents) { + $this->contents=$contents; + $this->path= $path; + } + +} + + class MockTypo3DB { public function findAllUsers() { @@ -136,10 +165,26 @@ class MockTypo3DB { } + public function findAllExternalSites() { + + return [ ['crdate' => '1412781027', + 'category' => 1, + 'image' => 'Federation_francaise_de_Go.JPG,fede_go.jpg', + 'title' => 'MuséoParc Alésia', + 'ext_url' => 'http://www.alesia.com/:Profil _blank', + 'tx_danpextendnews_tags' => 'Alésia, Jules César, Vercingétorix, Gaule, armée, bataille', + 'short' => null, + 'uid' => 14478, + 'pid' => 49]]; + + } + + public function findAllSites() { return [ ['crdate' => '1412781027', 'category' => 1, + 'image' => 'Federation_francaise_de_Go.JPG', 'title' => 'MuséoParc Alésia', 'ext_url' => 'http://www.alesia.com/', 'tx_danpextendnews_tags' => 'Alésia, Jules César, Vercingétorix, Gaule, armée, bataille', @@ -149,6 +194,7 @@ class MockTypo3DB { ['crdate' => '1412769359', 'category' => 1, + 'image' => '', 'title' => 'L\'ouest canadien', 'ext_url' => 'http://koha.mediathequeouestprovence.fr/cgi-bin/koha/opac-detail.pl?biblionumber=268360', 'tx_danpextendnews_tags' => 'Canada', @@ -157,6 +203,7 @@ class MockTypo3DB { 'pid' => 0], ['crdate' => '1412769359', 'category' => 1, + 'image' => '', 'title' => 'Qui a dit que les pingouins ne savaient pas taper ? ', 'ext_url' => 'http://koha.mediathequeouestprovence.fr/cgi-bin/koha/opac-detail.pl?foo=bar', 'tx_danpextendnews_tags' => 'Canada', diff --git a/tests/library/Class/Import/Typo3Test.php b/tests/library/Class/Import/Typo3Test.php index 781eab29075ba3aa103ad3dd76b50a2197749b65..432770c95bc9252cad03482c7d8d1cab86da01ec 100644 --- a/tests/library/Class/Import/Typo3Test.php +++ b/tests/library/Class/Import/Typo3Test.php @@ -533,6 +533,39 @@ class Import_Typo3CalendarTest extends Import_Typo3TestCase { +class Import_Typo3SitothequeUpdateTest extends Import_Typo3TestCase { + protected $filewriter; + public function setUp() { + parent::setUp(); + + $this->filewriter=new MockFileWriter(); + Class_Import_Typo3::setFileWriter($this->filewriter); + Class_WebService_WebSiteThumbnail::setFileWriter($this->filewriter); + $this->sito = Class_Sitotheque::findFirstBy(['titre' => 'MuséoParc Alésia']); + $this->migration->updateSites(); + } + + /** @test */ + public function imageShouldBeImported() { + $this->assertEquals('image', $this->filewriter->getContents('picto.jpg')); + + } + + /** @test */ + public function imageShouldBeFederationFrancaiseGo() { + $this->assertEquals('http://www.mediathequeouestprovence.fr/uploads/pics/Federation_francaise_de_Go.JPG',$this->filewriter->getImage()); + } + + /** @test */ + public function blankShouldBeRemovedFromUrlAndShouldLowerCasesName() { + $this->assertContains('www_alesia_com__profil.jpg', $this->filewriter->getPath()); + + } + + + +} + class Import_Typo3SitothequeTest extends Import_Typo3TestCase { public function setUp() { parent::setUp(); @@ -585,7 +618,6 @@ class Import_Typo3SitothequeTest extends Import_Typo3TestCase { } - /** @test */ public function ouestCanadienShouldStoreUidTypo3() { $this->assertEquals(14479, Class_Sitotheque::findFirstBy(['titre' => 'L\'ouest canadien'])->getCustomField('uid_typo3')); diff --git a/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php b/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php index 47ece7c259ac40e4d08708f8b0dd4c3db0d6745e..f4f09643e1b084f821d3f0ea510d98e43f7a078a 100644 --- a/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php +++ b/tests/library/ZendAfi/View/Helper/WebThumbnailTest.php @@ -52,7 +52,7 @@ class ViewHelperWebThumbnailTestReturnedUrl extends ViewHelperWebThumbnailTestCa ->whenCalled('dirExists')->answers(true); $this->helper->setFileWriter($this->_file_writer); -$this->google_thumbnail_path = USERFILESPATH.'/web_thumbnails/www_google_com.jpg'; + $this->google_thumbnail_path = USERFILESPATH.'/web_thumbnails/www_google_com.jpg'; } @@ -98,17 +98,10 @@ $this->google_thumbnail_path = USERFILESPATH.'/web_thumbnails/www_google_com.jpg public function subpageUrlWithParams() { $this->_file_writer ->whenCalled('fileExists') - ->with(USERFILESPATH.'/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter.jpg') + ->with(USERFILESPATH.'/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter_test.jpg') ->answers(true); - - $this->thumbnailer - ->whenCalled('fetchUrlToFile') - ->with('http://www.google.fr/search?sourceid=chrome&ie=UTF-8&q=harry+potter', - USERFILESPATH.'/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter.jpg') - ->answers(true); - - $url = $this->helper->webThumbnail('http://www.google.fr/search?sourceid=chrome&ie=UTF-8&q=harry+potter'); - $this->assertEquals(BASE_URL . '/userfiles/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter.jpg', + $url = $this->helper->webThumbnail('http://www.google.fr/search?sourceid=chrome&ie=UTF-8&q=harry+potter%3Atest'); + $this->assertEquals(BASE_URL . '/userfiles/web_thumbnails/www_google_fr_search_sourceid_chrome_ie_UTF-8_q_harry_potter_test.jpg', $url); }