diff --git a/library/Class/Testing/HttpResponse.php b/library/Class/Testing/HttpResponse.php new file mode 100644 index 0000000000000000000000000000000000000000..847aed641423fbd5121f85781bcac3e292836117 --- /dev/null +++ b/library/Class/Testing/HttpResponse.php @@ -0,0 +1,27 @@ +<?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_Testing_HttpResponse extends Class_Entity { + public function isSuccessful() { + return true; + } +} \ No newline at end of file diff --git a/library/Class/WebService/Abstract.php b/library/Class/WebService/Abstract.php index 51977f04beee2f105aa8bcb2afb15ebda6adff57..ab848cf14d10e4a849544ed561c85a71c1f1852f 100644 --- a/library/Class/WebService/Abstract.php +++ b/library/Class/WebService/Abstract.php @@ -36,9 +36,8 @@ class Class_WebService_Abstract { public static function getHttpClient() { - if (static::$_http_client==null || !isset(static::$_http_client)) { + if (static::$_http_client==null || !isset(static::$_http_client)) static::$_http_client = new Class_WebService_SimpleWebClient(); - } return static::$_http_client; } diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Album.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Album.php index 183007782cef401f1e380481436906ca5a1f9b6e..15e7732c2be398a1a453286cc4325af387e84583 100644 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Album.php +++ b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Album.php @@ -138,4 +138,10 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Album extends ZendAfi_Contro public function getStrategyLabel() { return 'album'; } + + + protected function getSearchColumns() { + return ['titre', + 'type_doc_id']; + } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php b/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php index e3f8e6aa9dde7e40d7f50c5cb742d1a92b4c5153..4f1fff36495db85c4c8a9c71b16e8dcd15089d3b 100644 --- a/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php +++ b/library/ZendAfi/View/Helper/DigitalResource/Dashboard/Harvest.php @@ -155,20 +155,26 @@ class ZendAfi_View_Helper_DigitalResource_Dashboard_Harvest extends ZendAfi_View if(!$count = $config->countAlbums()) return $this->_tagWarning($this->_('Aucun album présent pour cette ressource')); - $first_album = Class_Album::findFirstWithPosterBy(['type_doc_id' => $config->getDocType(), - 'order' => 'titre asc']); - $albums_link = $this->_tagAnchor($this->view->absoluteUrl(['module' => 'admin', 'controller' => 'album', 'action' => 'index', - 'cat_id' => $first_album->getRootCategoryId()], null, true), + 'title_search' => $config->getDocType()], null, true), $this->_('Voir les albums'), ['target' => '_blank']); return implode([$this->_tag('h4', $this->_('Nombre d\'albums présents dans Bokeh : %d', $count)), $albums_link, - $this->_tag('h4', + $this->_thumbnailing($config)]); + } + + + protected function _thumbnailing($config) { + if (!$first_album = Class_Album::findFirstWithPosterBy(['type_doc_id' => $config->getDocType(), + 'order' => 'titre asc'])) + return ''; + + return implode([$this->_tag('h4', $this->_('Tentative de vignettage de l\'album "%s" : ', $first_album->getTitre())), $this->_tagPre($this->_('Image source : %s', $first_album->getPoster())), $this->_renderThumbnailerLog($first_album)]); diff --git a/library/digital_resources/DiMusic/tests/DiMusicTest.php b/library/digital_resources/DiMusic/tests/DiMusicTest.php index d7e84caa5d2eca79319891728a5bdc9f6515aba5..20301543a77147f669fdd88b34874f4b73530b49 100644 --- a/library/digital_resources/DiMusic/tests/DiMusicTest.php +++ b/library/digital_resources/DiMusic/tests/DiMusicTest.php @@ -133,8 +133,8 @@ class DiMusicDashboardActivatedTest extends DiMusicActivatedTestCase { ->assertSave(); Class_WebService_BibNumerique_Vignette::setHttpClient($this->mock() - ->whenCalled('open_url') - ->answers(true)); + ->whenCalled('getResponse') + ->answers(new Class_Testing_HttpResponse(['Body' => true]))); ZendAfi_Auth::getInstance() ->logUser($this->fixture('Class_Users', @@ -179,7 +179,7 @@ class DiMusicDashboardActivatedTest extends DiMusicActivatedTestCase { /** @test */ public function harvestUrlShouldBeDisplay() { - $this->assertContains('<pre>https://export.divercities.eu/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc&set=music</pre>', + $this->assertContains('<pre>https://export.divercities.eu/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc&set=music</pre>', $this->_response->getBody()); } diff --git a/library/digital_resources/Skilleos/tests/SkilleosTest.php b/library/digital_resources/Skilleos/tests/SkilleosTest.php index f93255d6371fa7041692b17637994880030ffa5a..7ac2a9cbebf2881739e31a7252a9dfdd703dd91f 100644 --- a/library/digital_resources/Skilleos/tests/SkilleosTest.php +++ b/library/digital_resources/Skilleos/tests/SkilleosTest.php @@ -191,17 +191,14 @@ abstract class SkilleosServiceTestCase extends AbstractControllerTestCase { ->with('http://moncompte.skilleos.com/rest/api/trainings', ['headers' => ['Authorization' => "Bearer YTEzMDA1M2Q1ZGRmYmE0YjJkNWQ3MGY3ZGUyYTI3ZWJkMjBjOGI2NzIzMDIzMDc0MDAyYTE0NGJjMTRmMzkzMg"]]) ->answers($results_json) - ->whenCalled('open_url') - ->with('https://moncompte.skilleos.com/uploads/ressources/default/0001/11/thumb_10683_default_big.png') - ->answers(null) - ->whenCalled('open_url') + ->whenCalled('getResponse') ->with('https://moncompte.skilleos.com/uploads/ressources/default/0001/12/thumb_11659_default_big.png') - ->answers(null) + ->answers(new Class_Testing_HttpResponse(['Body' => null])) - ->whenCalled('open_url') + ->whenCalled('getResponse') ->with('https://moncompte.skilleos.com/uploads/ressources/default/0001/11/thumb_10672_default_big.png') - ->answers(null) + ->answers(new Class_Testing_HttpResponse(['Body' => null])) ->beStrict(); diff --git a/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php b/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php index d407c124c345804b55fea5e67e94100dda2bebf6..2507c83340cb1e74d124b68652562293239d4999 100644 --- a/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php +++ b/library/digital_resources/StoryPlayR/tests/StoryPlayRTest.php @@ -107,9 +107,11 @@ class StoryPlayRDashboardActivatedTest extends StoryPlayRActivatedTestCase { 'https://preprod.storyplayr.com/api/opds-with-links'); Class_WebService_BibNumerique_Vignette::setHttpClient($this->mock() - ->whenCalled('open_url') + ->whenCalled('getResponse') ->with('https://preprod.storyplayr.com/api/library/17fcdd4f-0c1c-4515-a0cf-594f41b03550/thumbnail/large') - ->answers('image')); + ->answers(new Class_Testing_HttpResponse(['Body' => 'image']))); + + $album = $this->fixture('Class_Album', ['id' => 20, diff --git a/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php index 1241af5ef9ce7e9b0c959a8be39f3e2dcc00c845..2b44f4a8bd06e3f6ebd4a9b1e3b6dbceddff1d72 100644 --- a/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php +++ b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php @@ -129,12 +129,6 @@ class ToutApprendreDashboardActivatedTest extends ToutApprendreActivatedTestCase } - /** @test */ - public function sourceImageShouldBeValid() { - $this->assertXPathContentContains('//pre','Image source : '); - } - - /** @test */ public function doctypeImageUrlShouldBePresent() { $this->assertXPath('//h4/img[contains(@src, "/digital-resource/typedoc-icon/id/ToutApprendre")]'); diff --git a/tests/library/Class/WebService/Album/VignetteTest.php b/tests/library/Class/WebService/Album/VignetteTest.php index ce93a68cda68a5d46e0e7902ecf698e662260991..2f56063f7b1d6c4ae7a20dc771bc7ff354e27173 100644 --- a/tests/library/Class/WebService/Album/VignetteTest.php +++ b/tests/library/Class/WebService/Album/VignetteTest.php @@ -75,9 +75,8 @@ abstract class Class_WebService_Album_VignetteBlancheNeigeTestCase extends Class $this->_http_client - ->whenCalled('open_url') - ->with('http://mediatheque.com/blanche_neige.jpg') - ->answers('an image'); + ->whenCalled('getResponse') + ->answers(new Class_Testing_HttpResponse(['Body' => 'an image'])); $this->_vignette->setFileWriter($this->_file_writer = Storm_Test_ObjectWrapper::mock()); $this->_file_writer @@ -178,9 +177,8 @@ class Class_WebService_Album_VignetteBlancheNeigeErrorsTest extends Class_WebSer /** @test */ public function withoutDataShouldNotSaveImage() { $this->_http_client - ->whenCalled('open_url') - ->with($this->_album->getPoster()) - ->answers(''); + ->whenCalled('getResponse') + ->answers(new Class_Testing_HttpResponse(['Body' => ''])); $this->_vignette->updateAlbum($this->_album); $this->assertFalse($this->_file_writer->methodHasBeenCalled('putContents'));