Commit 8b313a59 authored by Ghislain Loas's avatar Ghislain Loas

dev #75244 remove with_pagination

parent 28d7455b
......@@ -51,8 +51,6 @@ class LesYeuxDoc_Config extends Class_DigitalResource_Config {
'CATALOG_URL' => Class_AdminVar_Meta::newDefault($this->_('Url du catalogue de la plateforme LesYeuxDoc'),
['value' => 'https://www.lesyeuxdoc.fr/api/v1/films'])->bePrivate(),
'WITH_PAGINATION' => Class_AdminVar_Meta::newOnOff($this->_('Activer le moissonnage avec paginnation'), ['value' => 0])->bePrivate(),
'RETURN_URL' => Class_AdminVar_Meta::newDefault($this->_('URL utilisée dans la génération du lien le SSO. Paramètre return_url.'),
['value' => 'https://www.lesyeuxdoc.fr'])->bePrivate(),
......@@ -101,10 +99,8 @@ class LesYeuxDoc_Config extends Class_DigitalResource_Config {
public function getHarvestUrl($page = 1) {
if (!$this->getAdminVar('WITH_PAGINATION') && $page>1)
return null;
return $this->getAdminVar('CATALOG_URL')
. '?'
. http_build_query(['page_nb' => $page]);
return 1 < $page
? ''
: $this->getAdminVar('CATALOG_URL') . '?' . http_build_query(['page_nb' => 1]);
}
}
\ No newline at end of file
......@@ -111,48 +111,29 @@ class LesYeuxDocFixtures {
public function activate() {
Class_AdminVar::set('LesYeuxDoc_SSO_URL', 'http://lesyeuxdoc.com');
Class_AdminVar::newInstanceWithId('LesYeuxDoc_SSO_KEY', ['valeur' => 'pass']);
Class_AdminVar::newInstanceWithId('LesYeuxDoc_CATALOG_URL', ['valeur' => 'https://www.lesyeuxdoc.fr/api/v1/films']);
Class_AdminVar::newInstanceWithId('LesYeuxDoc_WITH_PAGINATION', ['valeur' => 'true']);
Class_AdminVar::set('LesYeuxDoc_SSO_KEY', 'pass');
Class_AdminVar::set('LesYeuxDoc_CATALOG_URL', 'https://www.lesyeuxdoc.fr/api/v1/films');
return $this;
}
public function deactivate() {
Class_AdminVar::newInstanceWithId('LesYeuxDoc_SSO_URL', ['valeur' => '']);
Class_AdminVar::newInstanceWithId('LesYeuxDoc_SSO_KEY', ['valeur' => '']);
Class_AdminVar::newInstanceWithId('LesYeuxDoc_CATALOG_URL', ['valeur' => '']);
Class_AdminVar::newInstanceWithId('LesYeuxDoc_WITH_PAGINATION', ['valeur' => 'false']);
Class_AdminVar::set('LesYeuxDoc_SSO_URL', '');
Class_AdminVar::set('LesYeuxDoc_SSO_KEY', '');
Class_AdminVar::set('LesYeuxDoc_CATALOG_URL', '');
return $this;
}
public function prepare() {
$page1 = file_get_contents(__DIR__ . '/page1.json');
$page2 = file_get_contents(__DIR__ . '/page2.json');
$http_client = $this->mock()
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/api/v1/films?page_nb=1')
->answers($page1)
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/api/v1/films?page_nb=2')
->answers($page2)
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/api/v1/films?page_nb=3')
->answers('')
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/img/thumbnail/16fe7355-0c95-4d2e-ace6-13d8ec07d9f6/front_result.jpg')
->answers(true)
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/img/thumbnail/852f6359-87cd-4a0b-9db9-343685114005/front_result.jpg')
->answers(true)
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/img/thumbnail/3d506ac1-743f-40d9-9d7a-cc51435e34e6/front_result.jpg')
->answers(true)
->whenCalled('open_url')
->with('https://www.lesyeuxdoc.fr/img/thumbnail/a514b069-43cc-4d71-9e3c-55ac267e667a/front_result.jpg')
->answers(true);
->answers('');
LesYeuxDoc_Service::setDefaultHttpClient($http_client);
......@@ -346,13 +327,18 @@ class LesYeuxDocViewRecordTest extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$service,
$fixtures;
public function setUp() {
parent::setUp();
$this->service = (new LesYeuxDocFixtures())->activate()->prepare();
$this->service = (new LesYeuxDocFixtures())
->activate()
->prepare();
$this->service->harvest();
Class_Album::find(1)->index();
}
......@@ -400,31 +386,4 @@ class LesYeuxDocViewRecordTest extends AbstractControllerTestCase {
$this->dispatch('/modules/les-yeux-doc/album_id/1', true);
$this->assertXPathContentContains('//script', 'return_url=https%3A%2F%2Fwww.lesyeuxdoc.fr%2Ffilm%2F682%2Fjean-philippe-toussaint"');
}
public function logValidUserNotAllowed() {
$user = $this->fixture('Class_Users',
['id' => 10,
'login' => 'NotAllowed',
'password' => 'pwd']);
$user
->beAbonneSIGB()
->setDateFin('9999-01-01')
->setIdabon('2345')
->setBib($this->fixture('Class_Bib',
['id' => 2,
'libelle' => 'Annecy']))
->setUserGroups([])
->save();
ZendAfi_Auth::getInstance()->logUser($user);
}
/** @test */
public function albumShouldReturnUrlWithoutYeuxDocId() {
(new LesYeuxDocFixtures())->logValidUser();
$this->dispatch('/modules/les-yeux-doc/album_id/3', true);
$this->assertXPathContentContains('//script', 'https%3A%2F%2Fwww.lesyeuxdoc.fr%2Ffilm%2F685%2Fjean-rouaud', $this->_response->getBody());
}
}
\ No newline at end of file
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