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

hotline #64820 : migrate to new OAI url

parent 0a79c14d
Branches
Tags
2 merge requests!2464Master,!2450Hotline#64820 connecteur cite de la musique
Pipeline #3215 passed with stage
in 26 minutes and 24 seconds
- 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']);
}
}
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