Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Quentin CHEVILLON
opacce
Commits
c08deb45
Commit
c08deb45
authored
Aug 23, 2021
by
Laurent
Browse files
Merge branch 'dev#129492_connecteur_mobidys'
parents
6395ab7d
b165d2c9
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
667 additions
and
11 deletions
+667
-11
FEATURES/129492
FEATURES/129492
+10
-0
VERSIONS_WIP/129492
VERSIONS_WIP/129492
+1
-0
library/Class/WebService/OPDS/CatalogEntry.php
library/Class/WebService/OPDS/CatalogEntry.php
+2
-0
library/Class/WebService/OPDS/CatalogReader.php
library/Class/WebService/OPDS/CatalogReader.php
+9
-9
library/digital_resources/Mobidys/Batch.php
library/digital_resources/Mobidys/Batch.php
+23
-0
library/digital_resources/Mobidys/Config.php
library/digital_resources/Mobidys/Config.php
+94
-0
library/digital_resources/Mobidys/ModuleMenu.php
library/digital_resources/Mobidys/ModuleMenu.php
+23
-0
library/digital_resources/Mobidys/Service.php
library/digital_resources/Mobidys/Service.php
+40
-0
library/digital_resources/Mobidys/Service/Album.php
library/digital_resources/Mobidys/Service/Album.php
+66
-0
library/digital_resources/Mobidys/Service/Parser.php
library/digital_resources/Mobidys/Service/Parser.php
+65
-0
library/digital_resources/Mobidys/View/Helper/Album.php
library/digital_resources/Mobidys/View/Helper/Album.php
+23
-0
library/digital_resources/Mobidys/controllers/IndexController.php
...digital_resources/Mobidys/controllers/IndexController.php
+23
-0
library/digital_resources/Mobidys/images/icon.png
library/digital_resources/Mobidys/images/icon.png
+0
-0
library/digital_resources/Mobidys/tests/MobidysTest.php
library/digital_resources/Mobidys/tests/MobidysTest.php
+165
-0
library/digital_resources/Mobidys/tests/mobidys.oai
library/digital_resources/Mobidys/tests/mobidys.oai
+66
-0
library/digital_resources/Mobidys/tests/mobidys.opds
library/digital_resources/Mobidys/tests/mobidys.opds
+55
-0
tests/library/Class/MoteurRechercheTest.php
tests/library/Class/MoteurRechercheTest.php
+2
-2
No files found.
FEATURES/129492
0 → 100644
View file @
c08deb45
'129492' =>
['Label' => $this->_('Connecteur Mobidys'),
'Desc' => $this->_('%s propose un catalogue de livres numérique à destination des dys. Le connecteur fournis l\'accès SSO et l\'aspiration du catalogue.', '<a href="https://www.mobidys.com/bibliodyssee">Mobidys</a>'),
'Image' => '',
'Video' => '',
'Category' => $this->_('Bibliothèque numérique'),
'Right' => function($feature_description, $user) {return true;},
'Wiki' => 'https://wiki.bokeh-library-portal.org/index.php?title=Mobidys',
'Test' => '',
'Date' => '2021-07-08'],
\ No newline at end of file
VERSIONS_WIP/129492
0 → 100644
View file @
c08deb45
- ticket #129492 : Bibliothèque numérique : développement du connecteur Mobidys
\ No newline at end of file
library/Class/WebService/OPDS/CatalogEntry.php
View file @
c08deb45
...
@@ -51,6 +51,7 @@ class Class_WebService_OPDS_CatalogEntry extends Class_WebService_BibNumerique_R
...
@@ -51,6 +51,7 @@ class Class_WebService_OPDS_CatalogEntry extends Class_WebService_BibNumerique_R
public
function
addFile
(
$url
,
$mimeType
)
{
public
function
addFile
(
$url
,
$mimeType
)
{
$this
->
_files
[]
=
Class_WebService_OPDS_EntryFile
::
newWith
(
$url
,
$mimeType
);
$this
->
_files
[]
=
Class_WebService_OPDS_EntryFile
::
newWith
(
$url
,
$mimeType
);
return
$this
;
}
}
...
@@ -92,6 +93,7 @@ class Class_WebService_OPDS_CatalogEntry extends Class_WebService_BibNumerique_R
...
@@ -92,6 +93,7 @@ class Class_WebService_OPDS_CatalogEntry extends Class_WebService_BibNumerique_R
foreach
(
$this
->
_files
as
$file
)
foreach
(
$this
->
_files
as
$file
)
$file
->
newRessourceInAlbum
(
$album
);
$file
->
newRessourceInAlbum
(
$album
);
return
$this
;
}
}
...
...
library/Class/WebService/OPDS/CatalogReader.php
View file @
c08deb45
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
*
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
class
Class_WebService_OPDS_CatalogReader
{
class
Class_WebService_OPDS_CatalogReader
{
...
@@ -57,7 +57,7 @@ class Class_WebService_OPDS_CatalogReader {
...
@@ -57,7 +57,7 @@ class Class_WebService_OPDS_CatalogReader {
public
function
getSearch
()
{
public
function
getSearch
()
{
if
(
null
!=
$this
->
_search
)
if
(
null
!=
$this
->
_search
)
return
$this
->
_search
;
return
$this
->
_search
;
if
(
null
!=
$this
->
_searchUrl
)
if
(
null
!=
$this
->
_searchUrl
)
...
@@ -85,7 +85,7 @@ class Class_WebService_OPDS_CatalogReader {
...
@@ -85,7 +85,7 @@ class Class_WebService_OPDS_CatalogReader {
public
function
startLink
(
$attributes
)
{
public
function
startLink
(
$attributes
)
{
if
(
!
array_key_exists
(
'TYPE'
,
$attributes
))
if
(
!
array_key_exists
(
'TYPE'
,
$attributes
))
return
;
return
;
if
(
!
$this
->
_xml_parser
->
inParents
(
'entry'
))
{
if
(
!
$this
->
_xml_parser
->
inParents
(
'entry'
))
{
...
@@ -114,8 +114,8 @@ class Class_WebService_OPDS_CatalogReader {
...
@@ -114,8 +114,8 @@ class Class_WebService_OPDS_CatalogReader {
||
false
!=
strpos
(
$attributes
[
'REL'
],
'acquisition'
)))
{
||
false
!=
strpos
(
$attributes
[
'REL'
],
'acquisition'
)))
{
$this
->
_current_entry
->
beNotice
();
$this
->
_current_entry
->
beNotice
();
if
(
in_array
(
$attributes
[
'TYPE'
],
array
(
'application/epub+zip'
,
'application/pdf'
)))
if
(
in_array
(
$attributes
[
'TYPE'
],
array
(
'application/epub+zip'
,
'application/pdf'
)))
$this
->
_current_entry
->
addFile
(
$attributes
[
'HREF'
],
$attributes
[
'TYPE'
]);
return
$this
->
_current_entry
->
addFile
(
$attributes
[
'HREF'
],
$attributes
[
'TYPE'
]);
return
;
return
$this
->
_current_entry
->
setLink
(
$attributes
[
'HREF'
])
;
}
}
if
(
array_key_exists
(
'REL'
,
$attributes
)
&&
$attributes
[
'REL'
]
==
'start'
)
{
if
(
array_key_exists
(
'REL'
,
$attributes
)
&&
$attributes
[
'REL'
]
==
'start'
)
{
...
@@ -185,22 +185,22 @@ class Class_WebService_OPDS_CatalogReader {
...
@@ -185,22 +185,22 @@ class Class_WebService_OPDS_CatalogReader {
protected
function
_concatMetadata
(
$name
,
$value
,
$separator
=
' - '
)
{
protected
function
_concatMetadata
(
$name
,
$value
,
$separator
=
' - '
)
{
$this
->
_metadatas
[
$name
]
=
(
isset
(
$this
->
_metadatas
[
$name
]))
$this
->
_metadatas
[
$name
]
=
(
isset
(
$this
->
_metadatas
[
$name
]))
?
$this
->
_metadatas
[
$name
]
.
$separator
.
$value
?
$this
->
_metadatas
[
$name
]
.
$separator
.
$value
:
$value
;
:
$value
;
}
}
protected
function
_normalizeUrl
(
$url
)
{
protected
function
_normalizeUrl
(
$url
)
{
if
(
!
$this
->
_selfUrl
)
if
(
!
$this
->
_selfUrl
)
return
$url
;
return
$url
;
if
(
'http'
==
substr
(
$url
,
0
,
4
))
if
(
'http'
==
substr
(
$url
,
0
,
4
))
return
$url
;
return
$url
;
$urlInfos
=
parse_url
(
$this
->
_selfUrl
);
$urlInfos
=
parse_url
(
$this
->
_selfUrl
);
$normalized
=
$urlInfos
[
'scheme'
]
.
'://'
.
$urlInfos
[
'host'
];
$normalized
=
$urlInfos
[
'scheme'
]
.
'://'
.
$urlInfos
[
'host'
];
if
(
'/'
==
substr
(
$url
,
0
,
1
))
if
(
'/'
==
substr
(
$url
,
0
,
1
))
return
$normalized
.
$url
;
return
$normalized
.
$url
;
return
$normalized
.
dirname
(
$urlInfos
[
'path'
])
.
$url
;
return
$normalized
.
dirname
(
$urlInfos
[
'path'
])
.
$url
;
}
}
...
...
library/digital_resources/Mobidys/Batch.php
0 → 100644
View file @
c08deb45
<?php
/**
* Copyright (c) 2012-2021, 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
Mobidys_Batch
extends
Class_DigitalResource_Batch
{}
library/digital_resources/Mobidys/Config.php
0 → 100644
View file @
c08deb45
<?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
Mobidys_Config
extends
Class_DigitalResource_Config
{
protected
function
_getConfig
()
{
return
[
'Introduction'
=>
$this
->
_
(
'Mobidys'
),
'HelpLink'
=>
'http://wiki.bokeh-library-portal.org/index.php/Mobidys'
,
'Url'
=>
'http://mobidys.com'
,
'Icon'
=>
'https://www.mobidys.com/wp-content/uploads/2020/09/logo-Mobidys-orange-simple.png'
,
'PermissionLabel'
=>
$this
->
_
(
'Bibliothèque numérique: accéder à la ressource Mobidys'
),
'NotAllowedMessage'
=>
$this
->
_
(
'Votre compte n\'est pas autorisé à accéder à cette ressource.'
),
'SsoAction'
=>
true
,
'Harvesting'
=>
true
,
'MenuLabel'
=>
$this
->
_
(
'Lien vers Mobidys'
),
'ModuleMenu'
=>
$this
->
withNameSpace
(
'ModuleMenu'
),
'Service'
=>
$this
->
withNameSpace
(
'Service'
),
'Batch'
=>
$this
->
withNameSpace
(
'Batch'
),
'DocTypeLabel'
=>
$this
->
_
(
'Mobidys'
),
'AdminVars'
=>
[
'Harvest_Url'
=>
Class_AdminVar_Meta
::
newDefault
(
$this
->
_
(
'URL du flux OPDS pour le moissonage de Mobidys'
),
[
'value'
=>
''
]),
'SSO_URL'
=>
Class_AdminVar_Meta
::
newDefault
(
$this
->
_
(
'URL SSO de la plateforme Mobidys'
),
[
'value'
=>
''
])
->
bePrivate
()]
];
}
public
function
isEnabled
()
{
return
''
!=
$this
->
getAdminVar
(
'SSO_URL'
)
&&
$this
->
getOPDSUrl
()
&&
((
new
ZendAfi_Validate_Url
())
->
isValid
(
$this
->
getOPDSUrl
()));
}
public
function
getSsoUrl
(
$user
)
{
if
(
!
$user
)
return
''
;
return
$this
->
getAdminVar
(
'SSO_URL'
)
.
'?ticket='
.
(
new
Class_CasTicket
())
->
getTicketForUser
(
$user
);
}
public
function
getAlbumSsoUrl
(
$user
,
$album
)
{
if
(
!
$album
)
return
''
;
return
$album
->
getExternalUri
()
.
'?ticket='
.
(
new
Class_CasTicket
())
->
getTicketForUser
(
$user
);
}
public
function
getOPDSUrl
()
{
return
$this
->
getAdminVar
(
'Harvest_Url'
);
}
public
function
getHarvestUrl
(
$page
=
1
)
{
$query
=
[
'lang'
=>
'fr'
];
// not working in real life with parameters :
// 'format' => 'OPDS'
$url
=
$this
->
getAdminVar
(
'Harvest_Url'
);
return
$url
.
'?'
.
http_build_query
(
array_filter
(
$query
));
}
}
library/digital_resources/Mobidys/ModuleMenu.php
0 → 100644
View file @
c08deb45
<?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
Mobidys_ModuleMenu
extends
Class_DigitalResource_ModuleMenu
{}
\ No newline at end of file
library/digital_resources/Mobidys/Service.php
0 → 100644
View file @
c08deb45
<?php
/**
* Copyright (c) 2012-2021, 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
Mobidys_Service
extends
Class_DigitalResource_Service
{
public
function
getPageCount
()
{
return
1
;
}
public
function
getRessourcesNumeriques
()
{
return
$this
->
_parser
->
getEntries
();
}
public
function
loadPage
(
$page_number
=
1
)
{
$opds
=
$this
->
httpGet
(
$this
->
_config
->
getHarvestUrl
(
$page_number
));
$this
->
_parser
=
(
new
Mobidys_Service_Parser
)
->
parse
(
$opds
);
return
$this
;
}
}
library/digital_resources/Mobidys/Service/Album.php
0 → 100644
View file @
c08deb45
<?php
/**
* Copyright (c) 2012-2021, 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
Mobidys_Service_Album
extends
Class_WebService_OPDS_CatalogEntry
{
public
function
setId
(
$id
)
{
$this
->
_id
=
$id
;
return
$this
;
}
public
function
matchId
(
$other_id
)
{
return
$this
->
getId
()
===
$other_id
;
}
public
function
getBaseUrl
()
{
return
Mobidys_Config
::
getInstance
()
->
getAdminVar
(
'SSO_URL'
);
}
protected
function
getTypeDoc
()
{
return
Mobidys_Config
::
getInstance
()
->
getDocType
();
}
public
function
fillAlbum
(
$album
)
{
parent
::
fillAlbum
(
$album
);
$album
->
setTypeDocId
(
$this
->
getTypeDoc
());
return
$this
;
}
public
function
setAuthor
(
$author
)
{
return
$this
->
addAuthor
(
$author
);
}
public
function
getRessourceCategorieLibelle
()
{
return
Mobidys_Config
::
getInstance
()
->
getDocTypeLabel
();
}
public
function
setLink
(
$link
)
{
return
$this
->
setExternalUri
(
$link
);
}
}
library/digital_resources/Mobidys/Service/Parser.php
0 → 100644
View file @
c08deb45
<?php
/**
* Copyright (c) 2012-2021, 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
Mobidys_Service_Parser
extends
Class_WebService_OPDS_CatalogReader
{
protected
$_albums
=
[];
public
function
startEntry
(
$attributes
)
{
$this
->
_current_entry
=
new
Mobidys_Service_Album
();
return
$this
;
}
public
function
endEntry
()
{
$this
->
_albums
[]
=
$this
->
_current_entry
;
return
$this
;
}
public
function
getEntries
()
{
return
$this
->
_albums
;
}
public
function
endSource
(
$data
)
{
return
$this
->
_current_entry
->
setExternalUri
(
$data
);
}
public
function
endId
(
$data
)
{
if
(
!
$this
->
_xml_parser
->
inParents
(
'entry'
))
return
$this
;
$this
->
_current_entry
->
setId
(
$data
);
return
$this
;
}
public
function
endUpdated
(
$data
)
{
if
(
!
$this
->
_xml_parser
->
inParents
(
'entry'
))
return
;
return
$this
->
_current_entry
->
setYear
(
date
(
'Y'
,
strtotime
(
$data
)));
}
}
library/digital_resources/Mobidys/View/Helper/Album.php
0 → 100644
View file @
c08deb45
<?php
/**
* Copyright (c) 2012-2021, 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
Mobidys_View_Helper_Album
extends
Class_DigitalResource_AlbumViewHelper
{}
library/digital_resources/Mobidys/controllers/IndexController.php
0 → 100644
View file @
c08deb45
<?php
/**
* Copyright (c) 2012-2021, 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
Mobidys_Plugin_IndexController
extends
Class_DigitalResource_Controller
{}
library/digital_resources/Mobidys/images/icon.png
0 → 100644
View file @
c08deb45
1.1 KB
library/digital_resources/Mobidys/tests/MobidysTest.php
0 → 100644
View file @
c08deb45
<?php
/**
* Copyright (c) 2012-2021, 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
*/
abstract
class
MobidysActivatedTestCase
extends
AbstractControllerTestCase
{
protected
$_storm_default_to_volatile
=
true
,
$_user
;
public
function
setUp
()
{
parent
::
setUp
();
Class_AdminVar
::
set
(
'Mobidys_SSO_URL'
,
'https://app.mobidys.org/mybib'
);
Class_AdminVar
::
set
(
'Mobidys_Harvest_Url'
,
'http://backend.mobidys.com/opds'
);
$http_client
=
$this
->
mock
()
->
whenCalled
(
'open_url'
)
->
with
(
'http://backend.mobidys.com/opds?lang=fr'
)
->
answers
(
file_get_contents
(
__DIR__
.
'/mobidys.opds'
))
->
beStrict
();
Mobidys_Service
::
setDefaultHttpClient
(
$http_client
);
$group
=
$this
->
fixture
(
'Class_UserGroup'
,
[
'id'
=>
1
,
'libelle'
=>
'Digital resources'
]);
$this
->
_user
=
$this
->
fixture
(
'Class_Users'
,
[
'id'
=>
1
,
'login'
=>
'Tom'
,
'password'
=>
'pwd'
])
->
setUserGroups
([
$group
]);
$this
->
fixture
(
'Class_Permission'
,
[
'id'
=>
1
,
'code'
=>
'Mobidys'
])
->
permitTo
(
$group
,
new
Class_Entity
());
}
}
class
MobidysHarvestTest
extends
MobidysActivatedTestCase
{
protected
$_album
;
public
function
setUp
()
{
parent
::
setUp
();
$ressource
=
Mobidys_Service
::
getInstance
();
$ressource
->
harvest
();
$this
->
_album
=
Class_Album
::
find
(
2
);
$this
->
_album
->
index
();
}
public
function
getAlbumAttribs
()
{
return
[
[
'getTitre'
,
'A l\'intérieur de moi'
],
[
'getIdOrigine'
,
'Interieur_de_moi'
],
[
'getExternalUri'
,
'https://app.bibliodyssee.com/land/BM_29_Landerneau/product/1016'
],
[
'getAnnee'
,
'2021'
],
[
'getDescription'
,
'Pour les tout-petits, un livre d\'éveil sensible et artistique, ouvert sur le monde qui les entoure.
Mots-clés : Emotion'
],
[
'getTypeDocId'
,
'Mobidys'
],
[
'getCategoryLabel'
,
'Mobidys'
],
[
'getPoster'
,
'https://d1ye1pkjd8d7nc.cloudfront.net/public_item/0001/05/4f2ee613e70ba86a9f75315766ae55db7dc669df.jpeg'
],
[
'getMainAuthorName'
,
'Aurélia Gaud'
],
];
}
/**
* @test
* @dataProvider getAlbumAttribs
*/
public
function
albumAttribsShouldMatch
(
$key
,
$value
)
{
$this
->
assertEquals
(
$value
,
call_user_func
([
$this
->
_album
,
$key
]));
}
}
class
MobidysSsoTest
extends
MobidysActivatedTestCase
{
public
function
setUp
()
{