From 3b4ce4a8313b353ca62922e2b18bfd55555dce66 Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@afi-sa.fr>
Date: Tue, 3 Oct 2017 14:33:22 +0200
Subject: [PATCH] dev #65265 : fix css and test

---
 .../ZendAfi/View/Helper/TagEditArticle.php    |  3 +-
 public/admin/css/front_nav.css                |  8 +++-
 .../ZendAfi/View/Helper/Accueil/NewsTest.php  | 39 ++++++++++++++-----
 3 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/library/ZendAfi/View/Helper/TagEditArticle.php b/library/ZendAfi/View/Helper/TagEditArticle.php
index 6beb6f36066..70f27ad4649 100644
--- a/library/ZendAfi/View/Helper/TagEditArticle.php
+++ b/library/ZendAfi/View/Helper/TagEditArticle.php
@@ -34,7 +34,8 @@ class ZendAfi_View_Helper_TagEditArticle extends ZendAfi_View_Helper_BaseHelper
     if (!Class_Users::isCurrentUserCanEditArticle($article))
       return '';
 
-    return $this->_renderEdit() . $this->_renderVersion();
+    return $this->_tag('div', $this->_renderEdit() . $this->_renderVersion(),
+                       ['class' => 'edit_article']);
   }
 
 
diff --git a/public/admin/css/front_nav.css b/public/admin/css/front_nav.css
index c5143b5c4ac..5060492f66a 100644
--- a/public/admin/css/front_nav.css
+++ b/public/admin/css/front_nav.css
@@ -232,7 +232,11 @@ div.menu_vertical ul a.edit_menu,
     left: -1em !important;
 }
 
-article header .edit_article,
 section .edit_library {
     top: 2ex;
-}
\ No newline at end of file
+}
+
+article header .edit_article {
+    position:absolute;
+    top: 2ex;
+}
diff --git a/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php b/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php
index 09cd0607f75..de4961d7b2b 100644
--- a/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php
+++ b/tests/library/ZendAfi/View/Helper/Accueil/NewsTest.php
@@ -22,11 +22,12 @@ require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php';
 
 
 abstract class NewsHelperTestCase extends ViewHelperTestCase {
+  protected $_storm_default_to_volatile = true;
+
   public function setUp() {
     parent::setUp();
-    Storm_Model_Loader::defaultToVolatile();
 
-    $this->article_wrapper = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article');
+    $this->article_wrapper = $this->onLoaderOfModel('Class_Article');
     Class_Profil::setCurrentProfil(Class_Profil::newInstanceWithId(5));
 
     Zend_Registry::get('translate')->setLocale('fr');
@@ -329,7 +330,9 @@ class NewsHelperWithThreeArticlesWithPermissionUserModoTest extends NewsHelperWi
 
 
 
-class NewsHelperWithThreeArticlesWorkflowActivatedUserAdminTest extends NewsHelperWithThreeArticlesTestCase {
+class NewsHelperWithThreeArticlesWorkflowActivatedUserAdminTest
+  extends NewsHelperWithThreeArticlesTestCase {
+
   public function setUp() {
     parent::setUp();
 
@@ -352,27 +355,36 @@ class NewsHelperWithThreeArticlesWorkflowActivatedUserAdminTest extends NewsHelp
                                  'op_largeur_img' => 200,
                                  'op_transition' => 'zork']];
 
+    Class_Versions::setPersistence($this->mock()->whenCalled('count')->answers(2));
+
     $helper = new ZendAfi_View_Helper_Accueil_News(12, $params);
     $helper->setView(new ZendAfi_Controller_Action_Helper_View());
     $this->html = $helper->getBoite();
   }
 
+
+  public function tearDown() {
+    Class_Versions::setPersistence(null);
+    parent::tearDown();
+  }
+
+
   /** @test */
-  function getArticlesByPreferencesParamsShouldContainStatusValidated() {
+  public function getArticlesByPreferencesParamsShouldContainStatusValidated() {
     $prefs = $this->article_wrapper->getFirstAttributeForLastCallOn('getArticlesByPreferences');
     $this->assertEquals(Class_Article::STATUS_VALIDATED, $prefs['status'][1]);
   }
 
 
   /** @test */
-  function getArticlesByPreferencesParamsShouldContainStatusDraft() {
+  public function getArticlesByPreferencesParamsShouldContainStatusDraft() {
     $prefs = $this->article_wrapper->getFirstAttributeForLastCallOn('getArticlesByPreferences');
     $this->assertEquals(Class_Article::STATUS_DRAFT, $prefs['status'][0]);
   }
 
 
   /** @test */
-  function getArticlesByPreferencesParamsShouldNotContainLangue() {
+  public function getArticlesByPreferencesParamsShouldNotContainLangue() {
     $prefs = $this->article_wrapper->getFirstAttributeForLastCallOn('getArticlesByPreferences');
     $this->assertFalse(array_isset('langue',$prefs));
   }
@@ -405,20 +417,27 @@ class NewsHelperWithThreeArticlesWorkflowActivatedUserAdminTest extends NewsHelp
 
 
   /** @test */
-  function editArticleLinksShouldBePresent() {
+  public function editArticleLinksShouldBePresent() {
+    $this->assertXPath($this->html,
+                       '//div[contains(@class, "edit_article")]//a[contains(@href, "admin/cms/edit/id/34")]');
+  }
+
+
+  /** @test */
+  public function articleVersionLinkShouldBePresent() {
     $this->assertXPath($this->html,
-                       '//a[contains(@href, "admin/cms/edit/id/34")]//img[@class="article_edit"]');
+                       '//div[contains(@class, "edit_article")]//a[contains(@href, "admin/cms/version/id/34")]');
   }
 
 
   /** @test */
-  function separatorShouldNotBeVisible() {
+  public function separatorShouldNotBeVisible() {
     $this->assertNotXPath($this->html,
                           '//div[@class="article_full_separator"]');
   }
 
   /** @test */
-  function diaporamaTransitionShouldFallbackToFade() {
+  public function diaporamaTransitionShouldFallbackToFade() {
     $this->assertContains('"fx":"fade"',
                           Class_ScriptLoader::getInstance()->html());
   }
-- 
GitLab