Skip to content
Snippets Groups Projects
Commit 66d3accb authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #55145 lekiosk : add batch + test fix

parent a7b43625
Branches
Tags
5 merge requests!2102#57574 : correction orthographe des jours de la semaine,!2080Sandbox detach zf from storm,!2061Master,!2034Dev#55145 contractuel 2455 le kiosk recherche federee,!2025Dev#55145 contractuel 2455 le kiosk recherche federee
Pipeline #467 failed with stage
in 8 minutes and 12 seconds
......@@ -50,10 +50,10 @@ class Class_Migration_DigitalResource_LeKiosk {
if(!$old_var = Class_AdminVAr::find($old))
return $this;
if(!Class_AdminVAr::set($new, $old_var->getValeur()))
return $this;
$old_var->delete();
return $old_var->delete();
Class_AdminVAr::set($new, $old_var->getValeur());
return $this;
}
......
<?php
/**
* Copyright (c) 2012-2014, 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 Lekiosk_Batch extends Class_DigitalResource_Batch {}
......@@ -46,6 +46,8 @@ class Lekiosk_Config extends Class_DigitalResource_Config {
],
'SsoAction' => 'lekiosk',
'Batch' => 'Lekiosk_Batch',
'Service' => 'Lekiosk_Service',
'ModuleMenu' => 'Lekiosk_ModuleMenu',
];
}
......
......@@ -20,6 +20,8 @@
*/
class Lekiosk_Service extends Class_DigitalResource_Service {
use Trait_StaticFileSystem;
protected $_albums;
......@@ -30,7 +32,7 @@ class Lekiosk_Service extends Class_DigitalResource_Service {
protected function loadPage($page_number = 1) {
$xml = $this->httpGet($this->_getCatalogueUrl());
$xml = $this->getFileSystem()->file_get_contents($this->_getCatalogueUrl());
$this->_parser = new Lekiosk_Service_Parser();
$this->_parser->parseXML($xml);
......
......@@ -26,5 +26,10 @@ class Lekiosk_Service_Album extends Class_WebService_BibNumerique_RessourceNumer
->setTypeDocId(Lekiosk_Config::getInstance()->getDocType())
->addEditor($this->getEditeur());
}
public function getRessourceCategorieLibelle() {
return Lekiosk_Config::getInstance()->getName();
}
}
?>
\ No newline at end of file
......@@ -25,7 +25,6 @@ class Lekiosk_Service_Parser {
$this->_albums = new Storm_Collection();
$this->_parser = new Class_WebService_XMLParser();
$this->_parser->setElementHandler($this);
xdebug_break();
$this->_parser->parse($xml);
return $this;
}
......@@ -41,6 +40,7 @@ class Lekiosk_Service_Parser {
->addPoster($attribs['COVERURL'])
->setEditeur($attribs['EDITEUR'])
->addMatiere($attribs['CATEGORIES'])
->setYear(explode('-', $attribs['RELEASEDATE'])[0])
;
$this->_albums->append($album);
}
......
......@@ -18,27 +18,39 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class LekioskAdminVars {
public static function activate() {
Class_AdminVar::set('Lekiosk_ID', '29');
Class_AdminVar::set('Lekiosk_FTP_LOGIN', 'FOIX');
Class_AdminVar::set('Lekiosk_FTP_PASSWORD', 'PWD');
}
public static function deactivate() {
Class_AdminVar::set('Lekiosk_ID', '');
Class_AdminVar::set('Lekiosk_FTP_LOGIN', '');
Class_AdminVar::set('Lekiosk_FTP_PASSWORD', '');
}
}
abstract class LeKioskLinkModeLinkTestCase extends ModelTestCase {
protected
$_storm_default_to_volatile = true,
$_lekiosk_config;
public function setUp() {
parent::setUp();
$this->fixture('Class_Profil', [
'id' => 1,
'libelle' => 'portail',
'mail_site' => '']);
'id' => 1,
'libelle' => 'portail',
'mail_site' => '']);
LekioskAdminVars::activate();
......@@ -56,7 +68,7 @@ class LeKioskLinkModeLinkTest extends LeKioskLinkModeLinkTestCase {
public function urlForMyemailAtLekioskDotComShouldContainsEncryptedEmail() {
$expected = 'http://pro.lekiosk.com/lekiosque.authenticate.aspx?email=1671f18f515f49271985280397c1c2bc48e1bfa31a3b638cb22e510e4953d65e&id=29&AccessHash=e6715cdcc53d6d2b130f4025ea44b67872eb5455';
$this->assertEquals(
$expected,
$expected,
(new Lekiosk_Link('myemail@lekiosk.com'))->url()
);
}
......@@ -96,7 +108,7 @@ class LeKioskLinkModeSSOTest extends LeKioskLinkModeLinkTestCase {
public function linkShouldBeCasUrlWithLeKioskId() {
$url = 'https://pro.lekiosk.com/AutentificationCas.aspx?'
.'cas_fournisseur=' . urlencode(ROOT_URL . BASE_URL . '/cas-server-v10')
.'&id=29'
.'&id=29'
.'&ReturnUrl=';
$this->assertEquals($url,
......@@ -113,148 +125,107 @@ class ModulesControllerLeKioskUserWithGroupWithRightCasTest extends AbstractCont
public function setUp() {
parent::setUp();
LekioskAdminVars::activate();
$group = $this->fixture('Class_UserGroup', ['id' => 1])
->addRight(Class_UserGroup::RIGHT_ACCES_LEKIOSK);
Class_Users::getIdentity()->setUserGroups([$group]);
Class_AdminVar::set('Lekiosk_SSO_MODE', 'CAS');
$_SERVER['HTTP_REFERER'] = '_http://localhost/view/notice';
$this->dispatch('/opac/modules/lekiosk', true);
}
/** @test */
public function shouldHaveAccessToLekiosk() {
$this->assertContains('https://pro.lekiosk.com/AutentificationCas.aspx',
$this->_response->getBody());
}
}
$user = Class_Users::getIdentity()->beAbonneSIGB();
$group = $this->fixture('Class_UserGroup',
['id' => 1]);
Lekiosk_Config::getInstance()->getPermissions();
$lekiosk_permission_id = Class_Permission::findFirstBy(['code' => 'Lekiosk'])->getId();
$this->fixture('Class_UserGroup_Permission',
['id' => 1,
'id_group' => 1,
'id_permission' => $lekiosk_permission_id,
'id_model' => null,
'model_class' => null
]);
class LeKioskModulesControllerLoginRequiredTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function datas() {
return [
['LeKiosk', 'lekiosk']
];
$user->setUserGroups([$group]);
}
/**
* @test
* @dataProvider datas
*/
public function withoutLoginShouldRedirectToLogin($type, $action) {
call_user_func(['RessourcesNumeriquesFixtures', 'activate' . $type]);
$_SERVER['HTTP_REFERER'] = '/opac/cms/articleview/id/23';
ZendAfi_Auth::getInstance()->clearIdentity();
$this->dispatch('/opac/modules/' . $action);
$this->assertContains('/auth/login?redirect='.urlencode(ROOT_URL . BASE_URL . '/modules/' . $action),
/** @test */
public function shouldHaveAccessToLekioskCas() {
Class_AdminVar::set('Lekiosk_SSO_MODE', 'CAS');
$this->dispatch('/opac/modules/lekiosk', true);
$this->assertContains('https://pro.lekiosk.com/AutentificationCas.aspx',
$this->_response->getBody());
}
}
class ModulesControllerLoginRequiredLeKioskCasTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
/** @test */
public function shouldRedirectToLogin() {
LekioskAdminVars::activate();
Class_AdminVar::set('Lekiosk_SSO_MODE', 'CAS');
$_SERVER['HTTP_REFERER'] = '/opac/cms/articleview/id/23';
ZendAfi_Auth::getInstance()->clearIdentity();
public function shouldHaveAccessToLekiosk() {
$this->dispatch('/opac/modules/lekiosk', true);
$this->assertContains('/auth/login?redirect='.urlencode(ROOT_URL . BASE_URL . '/modules/lekiosk'),
$this->_response->getBody());
$this->assertContains('http://pro.lekiosk.com', $this->_response->getBody());
}
}
class ModulesControllerLeKioskUserWithoutGroupTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
class LeKioskModulesControllerTest extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_expected_login_redirect;
public function setUp() {
parent::setUp();
$this->_expected_login_redirect = '/auth/login?redirect='.urlencode(ROOT_URL . BASE_URL . '/modules/lekiosk');
LekioskAdminVars::activate();
$no_lekiosk = $this->fixture('Class_Users',
['id' => 56,
'login' => 'no lekiosk',
'password' => 'no']);
ZendAfi_Auth::getInstance()->logUser($no_lekiosk);
$this->dispatch('/opac/modules/lekiosk', true);
}
/** @test */
public function shouldHaveAccessForbiddenMessage() {
$this->assertFlashMessengerContentContains('Votre abonnement ne permet pas');
}
}
class ModulesControllerLeKioskUserWithGroupWithoutRightTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
LekioskAdminVars::activate();
$group = $this->fixture('Class_UserGroup', ['id' => 1]);
Class_Users::getIdentity()->setUserGroups([$group]);
public function withoutLoginShouldRedirectToLogin() {
ZendAfi_Auth::getInstance()->clearIdentity();
$this->dispatch('/opac/modules/lekiosk', true);
$this->assertContains($this->_expected_login_redirect, $this->_response->getBody());
}
/** @test */
public function shouldHaveAccessForbiddenMessage() {
$this->assertFlashMessengerContentContains('Votre abonnement ne permet pas');
}
}
public function withCasEnabledAndNotUserConnectedshouldRedirectToLogin() {
Class_AdminVar::set('Lekiosk_SSO_MODE', 'CAS');
ZendAfi_Auth::getInstance()->clearIdentity();
$this->dispatch('/opac/modules/lekiosk', true);
$this->assertContains($this->_expected_login_redirect, $this->_response->getBody());
}
class ModulesControllerLeKioskUserWithGroupWithRightTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
/** @test */
public function withNoGroupShouldDisplayNoAccessMessage() {
$no_lekiosk = $this->fixture('Class_Users',
['id' => 56,
'login' => 'no lekiosk',
'password' => 'no']);
LekioskAdminVars::activate();
$group = $this->fixture('Class_UserGroup', ['id' => 1])
->addRight(Class_UserGroup::RIGHT_ACCES_LEKIOSK);
Class_Users::getIdentity()->setUserGroups([$group]);
ZendAfi_Auth::getInstance()->logUser($no_lekiosk);
$this->dispatch('/opac/modules/lekiosk', true);
$this->assertFlashMessengerContentContains('Votre abonnement ne permet pas');
}
/** @test */
public function shouldHaveAccessToLekiosk() {
$this->assertContains('http://pro.lekiosk.com', $this->_response->getBody());
public function groupWithNoRightsShouldDisplayNoAccessMessage() {
$group = $this->fixture('Class_UserGroup', ['id' => 1]);
Class_Users::getIdentity()
->beAbonneSIGB()
->setUserGroups([$group]);
$this->dispatch('/opac/modules/lekiosk', true);
$this->assertFlashMessengerContentContains('Votre abonnement ne permet pas');
}
}
abstract class LeKioskServiceTestCase extends ModelTestCase {
protected
......@@ -266,18 +237,20 @@ abstract class LeKioskServiceTestCase extends ModelTestCase {
$catalogue_xml = file_get_contents(__DIR__. '/catalogue.xml');
$this->_http_client = $this->mock();
$this->_http_client
->whenCalled('open_url')
->with('ftp://FOIX:PWD@ftp.lekiosk.com/lekiosque_06022017.xml')
->answers($catalogue_xml)
$file_system = $this->mock()
->whenCalled('file_get_contents')
->with('ftp://FOIX:PWD@ftp.lekiosk.com/lekiosque_06022017.xml')
->answers($catalogue_xml);
->whenCalled('open_url')
->answers('une-image')
;
$this->_http_client = $this->mock()
->whenCalled('open_url')
->answers(null);
$this->_service = new Lekiosk_Service(new Lekiosk_Config(new Class_DigitalResource_Wrapper(Class_DigitalResource::getInstance(), 'Lekiosk')));
Lekiosk_Service::setDefaultHttpClient($this->_http_client);
$this->_service->setFileSystem($file_system);
$this->_service->setTimeSource(new TimeSourceForTest('2017-02-06 10:00:00'));
$this->_service->harvest();
Class_Album::clearCache();
......@@ -287,6 +260,7 @@ abstract class LeKioskServiceTestCase extends ModelTestCase {
class LeKioskServiceHarvestTest extends LekioskServiceTestCase {
/** @test */
......@@ -307,6 +281,12 @@ class LeKioskServiceHarvestTest extends LekioskServiceTestCase {
}
/** @test */
public function categoryLeKioskShouldBeCreated() {
$this->assertEquals('Lekiosk', $this->_10_national_sport->getCategoryLabel());
}
/** @test */
public function nationalSportShoulBeFound() {
$this->assertNotNull($this->_10_national_sport);
......@@ -325,6 +305,12 @@ class LeKioskServiceHarvestTest extends LekioskServiceTestCase {
}
/** @test */
public function nationalSportEditionYearShouldBe2017() {
$this->assertEquals('2017', $this->_10_national_sport->getAnnee());
}
/** @test */
public function nationalSportSSOUrlShouldBeLeKioskDotCom() {
$this->assertEquals('https://pro.lekiosk.com/lekiosque.sso.aspx?ReturnUrl=Le-10-Sport-National-z1962566.aspx', $this->_10_national_sport->getExternalUri());
......@@ -360,4 +346,67 @@ class LeKioskServiceHarvestTest extends LekioskServiceTestCase {
$sport = Class_CodifMatiere::find($this->_10_national_sport->getMatiere());
$this->assertEquals('Sport', $sport->getLibelle());
}
}
class LekioskAdminUserGroupControllerRessourcesNumeriquesTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->fixture('Class_Bib',
['id' => 9,
'libelle' => 'Annecy']);
$this->fixture('Class_UserGroup',
['id' => 6,
'libelle'=> 'Modérateurs bib',
'group_type' => Class_UserGroup::TYPE_DYNAMIC,
'users' => [],
'rights' => [],
'role_level' => ZendAfi_Acl_AdminControllerRoles::MODO_BIB,
'id_bib' => 9]);
}
/** @test */
public function ressourceActivatedShouldBeVisible() {
LekioskAdminVars::activate();
$this->dispatch('admin/usergroup/edit/id/6', true);
$this->assertXPathContentContains('//label', 'Bibliothèque numérique: accéder à LeKiosk');
}
/** @test */
public function ressourceDeactivatedShouldNotBeVisible() {
LekioskAdminVars::deactivate();
$this->dispatch('admin/usergroup/edit/id/6', true);
$this->assertNotXPathContentContains('//label', 'LeKiosk');
}
}
class LekioskBatchIndexTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
LekioskAdminVars::activate();
$this->dispatch('/admin/batch/add', true);
}
/** @test */
public function lekioskBatchShouldBePresent() {
$this->assertXPathContentContains('//form//select//option[@value="Lekiosk_Batch"]',
'Moissonner catalogue Lekiosk');
}
}
\ No newline at end of file
......@@ -1066,8 +1066,7 @@ class Admin_UserGroupControllerRessourcesNumeriquesTest extends Admin_UserGroupC
['CVS', 'CVS'],
['ToutApprendre', 'Tout Apprendre'],
['MusicMe', 'Music Me'],
['NumeriquePremium', 'Numérique Premium'],
['Lekiosk', 'Lekiosk.com']];
['NumeriquePremium', 'Numérique Premium']];
}
......
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