From 511cb4d69371c3811e73d88873c53a2822bc8d84 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Wed, 3 Feb 2016 14:45:01 +0100 Subject: [PATCH] dev #37100 test fix --- library/ZendAfi/View/Helper/Permalink.php | 4 ++- .../ZendAfi/View/Helper/ReseauxSociaux.php | 2 +- .../modules/AbstractControllerTestCase.php | 1 + .../ProfilOptionsControllerTest.php | 27 +++++-------------- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/library/ZendAfi/View/Helper/Permalink.php b/library/ZendAfi/View/Helper/Permalink.php index 7e19456f18a..fa85d052b98 100644 --- a/library/ZendAfi/View/Helper/Permalink.php +++ b/library/ZendAfi/View/Helper/Permalink.php @@ -26,6 +26,8 @@ class ZendAfi_View_Helper_Permalink extends ZendAfi_View_Helper_BaseHelper { ? $profil->getUrlImage($icon) : URL_ADMIN_IMG . 'reseaux/permalink.gif'; + $lien_permanent = $this->view->_('Lien permanent'); + $dialog = $this->view->tag('div', $this->view->tag('p', $this->view->_('Copiez le lien suivant') . ':') . $this->view->tag('input', @@ -34,7 +36,7 @@ class ZendAfi_View_Helper_Permalink extends ZendAfi_View_Helper_BaseHelper { 'readonly' => 'readonly', 'value' => $url, 'style' => 'width: 100%']), - ['title' => $this->view->_('Lien permanent')]); + ['title' => $lien_permanent]); return $this->view->tagImgHover($icon_url, ['class' => 'permalien-img', diff --git a/library/ZendAfi/View/Helper/ReseauxSociaux.php b/library/ZendAfi/View/Helper/ReseauxSociaux.php index 8cfa41ee159..a5427414470 100644 --- a/library/ZendAfi/View/Helper/ReseauxSociaux.php +++ b/library/ZendAfi/View/Helper/ReseauxSociaux.php @@ -39,7 +39,7 @@ class ZendAfi_View_Helper_ReseauxSociaux extends ZendAfi_View_Helper_BaseHelper public function renderArticle($article) { - return $this->links(['url_to_share'=>$this->view->url($article->getUrl()).'?id_profil='.$id_profil, + return $this->links(['url_to_share'=>$this->view->url($article->getUrl()).'?id_profil=' . Class_Profil::getCurrentProfil()->getId(), 'titre' => $article->getTitre(), 'message' => 'article', 'img_url' => $article->getFirstImageURL()]); diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 29948e1cf7b..e0824891d8e 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -20,6 +20,7 @@ */ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase { use Storm_Test_THelpers; + protected $_registry_sql, $_storm_default_to_volatile = false; diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index 36620c78a31..55abf04364d 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -87,7 +87,7 @@ abstract class ProfilOptionsControllerWithProfilAdulteTestCase extends AbstractC 'picto' => 'vide.gif', 'preferences' => [ 'titre' => 'Nouvelles', - 'nb_aff' => 0]], + 'nb_aff' => 2]], ['type_menu' => 'PROFIL', @@ -363,28 +363,13 @@ class ProfilOptionsControllerProfilAdulteWithCacheTest extends ProfilOptionsCont class ProfilOptionsControllerTwitterLinkWithProfilAdulteTest extends ProfilOptionsControllerWithProfilAdulteTestCase { protected $_mock_web_client; - public function setUp() { - parent::setUp(); - $this->_mock_web_client = Storm_Test_ObjectWrapper::on(new Class_WebService_SimpleWebClient()); - ZendAfi_View_Helper_ShareUrl::setDefaultWebClient($this->_mock_web_client); - - $this->_mock_web_client - ->whenCalled('open_url') - ->answers('http://is.gd/PkdNgD'); - - } - - - public function tearDown() { - ZendAfi_View_Helper_ShareUrl::resetDefaultWebClient(); - parent::tearDown(); - } - - /** @test */ public function twitterLinkShouldReturnJavascriptForTweet() { - $this->dispatch('/opac/index/share/on/twitter/titre/Profil+Adulte?url='.urlencode('http://localhost'.BASE_URL.'/index/index'), true); - $this->assertContains("window.open('http://twitter.com/share?url=http%3A%2F%2Fis.gd%2FPkdNgD&text=Profil+Adulte&counturl=http%3A%2F%2Fis.gd%2FPkdNgD','_blank','toolbar=0,status=0,width=800, height=410');", + $url = 'http://localhost'.BASE_URL.'/index/index'; + $this->dispatch('/opac/index/share/on/twitter/titre/Profil+Adulte?url=' . urlencode($url), true); + + $expected_url = urlencode('http://localhost'.BASE_URL.'/index/index?id_profil=22'); + $this->assertContains("window.open('http://twitter.com/share?url=" . $expected_url . "&text=Profil+Adulte&counturl=" . $expected_url . "','_blank','toolbar=0,status=0,width=800, height=410');", $this->_response->getBody()); } -- GitLab