Skip to content
Snippets Groups Projects
Commit 4c34e4f2 authored by gloas's avatar gloas
Browse files

Moissonnage Vodeclic , parse catalogue XML

parent 905ce605
Branches
Tags
No related merge requests found
......@@ -2475,6 +2475,8 @@ library/Class/WebService/SIGB/VSmart/Service.php -text
library/Class/WebService/SRU.php -text
library/Class/WebService/SimpleWebClient.php -text
library/Class/WebService/Vignette.php -text
library/Class/WebService/Vodeclic.php -text
library/Class/WebService/Vodeclic/CatalogueParser.php -text
library/Class/WebService/XMLParser.php -text
library/Class/Xml.php -text
library/Class/Xml/Builder.php -text
......@@ -5046,6 +5048,7 @@ tests/fixtures/fnac_millenium_suite.html -text
tests/fixtures/lastfm_right_franz_liszt_pelerinage.html -text
tests/fixtures/lastfm_wrong_franz_liszt_pelerinage.html -text
tests/fixtures/orphee.wsdl -text
tests/fixtures/vodeclic_catalogue.xml -text
tests/fixtures/ws_maze.wsdl -text
tests/library/Class/AdminVarTest.php -text
tests/library/Class/AgendaSQYImportTest.php -text
......@@ -5159,6 +5162,7 @@ tests/library/Class/WebService/SIGB/PergameTest.php -text
tests/library/Class/WebService/SIGB/VSmartAuthenticateTest.php -text
tests/library/Class/WebService/SIGB/VSmartFixtures.php -text
tests/library/Class/WebService/SIGB/VSmartTest.php -text
tests/library/Class/WebService/VodeclicTest.php -text
tests/library/Class/Xml/BuilderTest.php -text
tests/library/ZendAfi/Auth/Adapter/AuthCommSigbTest.php -text
tests/library/ZendAfi/AuthTest.php -text
......
<?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_Webservice_Vodeclic {
protected $_albums;
public function parseXML($xml) {
$parser = new Class_WebService_Vodeclic_CatalogueParser();
$parser->parseXML($xml);
$this->_albums = $parser->getAlbums();
}
public function getAlbums() {
return $this->_albums;
}
}
?>
\ No newline at end of file
<?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_WebService_Vodeclic_CatalogueParser {
protected $_albums,
$_current_album;
public function parseXML($xml) {
$parser = new Class_WebService_XMLParser();
$parser->setElementHandler($this);
$parser->parse($xml);
}
public function getAlbums() {
return $this->_albums;
}
public function startFormation($attributes) {
$this->_current_album = new Class_Album();
$this->_albums[]= $this->_current_album;
}
public function endTitre($data) {
$this->_current_album->setTitre($data);
}
public function endVodeclic_id($data) {
$this->_current_album->setIdOrigine($data);
}
public function endLink($data) {
$this->_current_album->setUrlOrigine($data);
}
public function endDescription($data) {
$this->_current_album->setDescription($data);
}
/** Initialisation du parametre Id_Langue a fre */
public function endLanguage($data) {
$idLangue='fre';
if($data=='fr'){
$idLangue='fre';
}
$this->_current_album->setIdLangue($idLangue);
}
public function endPublishdate($data){
$this->_current_album->setDateMaj($data);
}
public function endPublishyear($data) {
$this->_current_album->setAnnee($data);
}
}
?>
\ No newline at end of file
This diff is collapsed.
<?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 VodeclicTest extends Storm_Test_ModelTestCase{
public function setUp() {
parent::setUp();
/* Class_AdminVar::newInstanceWithId('VODECLIC_ID', ['valeur' => 'zork-sa']);
Class_AdminVar::newInstanceWithId('VODECLIC_KEY', ['valeur' => '12345']);
Class_AdminVar::newInstanceWithId('VODECLIC_BIB_ID', ['valeur' => '12']); */
$catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/vodeclic_catalogue.xml');
/* $this->_http_client = Storm_Test_ObjectWrapper::mock();
$this->_http_client
->whenCalled('https://lms.vodeclic.com/api/catalogue.xml')
->answers($catalogue_xml);*/
$this->_vodeclic = new Class_WebService_Vodeclic();
$this->_vodeclic->parseXML($catalogue_xml);
$this->_first_album = $this->_vodeclic->getAlbums()[0];
}
/**
* [[file:~/www/afi-opac/tests/fixtures/vodeclic_catalogue.xml::<titre>Safari%202</titre][formation Safari2]]
* @test
*/
public function firstAlbumTitreShouldBeSafari2() {
//$first_album = $this->_vodeclic->getAlbums()[0];
$this->assertEquals('Safari 2', $this->_first_album->getTitre());
}
/** @test */
public function numberOfAlbumsShouldBe269() {
$this->assertEquals(269, count($this->_vodeclic->getAlbums()));
}
/** @test */
public function firstAlbumSafari2IdOrigineShouldBe1() {
//$first_album = $this->_vodeclic->getAlbums()[0];
$this->assertEquals('1', $this->_first_album->getIdOrigine());
}
/** @test */
public function firstAlbumSafari2LinkShouldBeSet() {
//$first_Album = $this->_vodeclic->getAlbums()[0];
$this->assertEquals('http://biblio.vodeclic.com/formation/1',$this->_first_album->getUrlOrigine());
}
/** @test */
public function firstAlbumSafari2DesciptionShouldBeSet() {
//$first_ALbum = $this->_vodeclic->getAlbums()[0];
$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() {
//$first_Album = $this->_vodeclic->getAlbums()[0];
$this->assertEquals('fre',$this->_first_album->getIdLangue());
}
/** @test */
public function firstAlbumSafari2DateMajShouldBeSet (){
//$first_Album = $this->_vodeclic->getAlbums()[0];
$this->assertEquals('2007-08-01T00:00:00+02:00',$this->_first_album->getDateMaj());
}
/** @test */
public function firstAlbumSafari2AnneeShouldBe2007 (){
//$first_Album = $this->_vodeclic->getAlbums()[0];
$this->assertEquals('2007',$this->_first_album->getAnnee());
}
}
?>
\ No newline at end of file
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