Commit 0d9769b7 authored by Laurent's avatar Laurent
Browse files

Merge branch 'hotline#64820_connecteur_cite_de_la_musique' into 'stable'

Hotline#64820 connecteur cite de la musique

See merge request !2450
parents 1e9582a3 4415b096
- ticket #64820 : Connecteur Cité de la musique : prise en charge du nouveau serveur OAI
\ No newline at end of file
<?php
(new Class_Migration_CiteDeLaMusiqueBecomesPhilharmonieDeParis())->run();
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH 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).
*
* BOKEH 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 BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Migration_CiteDeLaMusiqueBecomesPhilharmonieDeParis {
const URL = 'http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx';
public function run() {
$cite = new Class_AdminVar_CiteDeLaMusique();
if (!$cite->isEnabled())
return $this;
$this
->updateAdminVar()
->updateUrlOrigine()
->implyFullHarvest()
;
}
protected function updateAdminVar() {
Class_AdminVar::set('CITEDELAMUSIQUE', static::URL);
return $this;
}
protected function updateUrlOrigine() {
Zend_Db_Table::getDefaultAdapter()
->query('update album set url_origine="' . static::URL . '"');
return $this;
}
protected function implyFullHarvest() {
Zend_Db_Table::getDefaultAdapter()
->query('delete from harvest_log where type_doc=' . Class_TypeDoc::CITEDELAMUSIQUE);
return $this;
}
}
......@@ -1793,3 +1793,54 @@ class UpgradeDB_338_Test extends UpgradeDBTestCase {
$this->assertEquals('$2y$', substr($datas['password'], 0, 4));
}
}
class UpgradeDB_339_Test extends UpgradeDBTestCase {
protected static $album_id;
public function prepare() {
$this->query('replace into bib_admin_var (clef, valeur) values
("CITEDELAMUSIQUE", "http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx"),
("CITEDELAMUSIQUE_ID", "78-testing-test"),
("CITEDELAMUSIQUE_SETS", "videos")');
$this->query('insert into album (titre, type_doc_id, url_origine) values("pad", 119, "http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx")');
static::$album_id = $this->query('select id from album order by id desc limit 1')->fetch()['id'];
$this->query('insert into harvest_log (type_doc, end_date) values(119, "2017-12-22")');
}
public function tearDown() {
if ($album = Class_Album::find(static::$album_id))
$album->delete();
parent::tearDown();
}
/** @test */
public function adminPasswordShouldBeHashed() {
$datas = $this->query('select valeur from bib_admin_var where clef="CITEDELAMUSIQUE"')
->fetch();
$this->assertEquals('http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx',
$datas['valeur']);
}
/** @test */
public function urlOrigineShouldBeConverted() {
$datas = $this->query('select url_origine from album where id=' . static::$album_id)->fetch();
$this->assertEquals('http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx',
$datas['url_origine']);
}
/** @test */
public function harvestLogShouldBeDeleted() {
$datas = $this->query('select count(*) as numberOf from harvest_log where type_doc=119')->fetch();
$this->assertEquals(0, $datas['numberOf']);
}
}
......@@ -22,7 +22,7 @@
class CiteDeLaMusiqueFixtures {
public static function activate() {
Class_AdminVar::set('CITEDELAMUSIQUE',
'http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx');
'http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx');
Class_AdminVar::set('CITEDELAMUSIQUE_SETS',
'videos-concerts-docu-entiers;audios-concerts-entiers');
......@@ -243,15 +243,15 @@ class CiteDeLaMusiqueParserTest extends ModelTestCase {
$this->_http_client = $this->mock();
$this->_http_client
->whenCalled('open_url')
->with('http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx?verb=ListRecords&metadataPrefix=Ermes&set=videos-concerts-docu-entiers')
->with('http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx?verb=ListRecords&metadataPrefix=Ermes&set=videos-concerts-docu-entiers')
->answers(CiteDeLaMusiqueFixtures::getFixtureContent('cite_de_la_musique_oai.xml'))
->whenCalled('open_url')
->with('http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx?verb=ListRecords&resumptionToken=%21%21videos-concerts-docu-entiers%21100%211061%21Ermes')
->with('http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx?verb=ListRecords&resumptionToken=%21%21videos-concerts-docu-entiers%21100%211061%21Ermes')
->answers(CiteDeLaMusiqueFixtures::getFixtureContent('cite_de_la_musique_oai_end.xml'))
->whenCalled('open_url')
->with('http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx?verb=ListRecords&metadataPrefix=Ermes&set=audios-concerts-entiers')
->with('http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx?verb=ListRecords&metadataPrefix=Ermes&set=audios-concerts-entiers')
->answers(CiteDeLaMusiqueFixtures::getFixtureContent('cite_de_la_musique_oai_audios.xml'))
->whenCalled('open_url')
......@@ -349,7 +349,7 @@ class CiteDeLaMusiqueParserTest extends ModelTestCase {
/** @test */
public function hommageUrlOrigineShouldBeMediaDotCiteDeLaMusique() {
$this->assertEquals('http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx',
$this->assertEquals('http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx',
$this->_hommage->getUrlOrigine());
}
......@@ -451,7 +451,7 @@ class CiteDeLaMusiqueOAIHarvestTest extends ModelTestCase {
$http_client = $this->mock();
$http_client
->whenCalled('open_url')
->with('http://media.citedelamusique.fr/EXTRANET/oaiserver.ashx?verb=ListRecords&metadataPrefix=Ermes&set=videos-concerts-docu-entiers&from=2017-10-11')
->with('http://pad.philharmoniedeparis.fr/EXPLOITATION/oaiserver.ashx?verb=ListRecords&metadataPrefix=Ermes&set=videos-concerts-docu-entiers&from=2017-10-11')
->answers(CiteDeLaMusiqueFixtures::getFixtureContent('cite_de_la_musique_oai.xml'))
->whenCalled('open_url')
......
Markdown is supported
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