Commit 6d62296e authored by vinot's avatar vinot
Browse files

factorisation et nettoyage du code pour eviter d'avoir la variable qui se balade

parent ba48ecf7
......@@ -861,7 +861,7 @@ class AbonneController extends ZendAfi_Controller_Action {
public function suggestionAchatAction() {
if (Class_AdminVar::get("DISABLE_SUGGESTIONS")) {
if (Class_AdminVar::areSuggestionsDisabled()) {
$this->_forward('suggestion-achat-inactive');
return;
}
......@@ -869,7 +869,7 @@ class AbonneController extends ZendAfi_Controller_Action {
public function suggestionAchatAddAction() {
if (Class_AdminVar::get("DISABLE_SUGGESTIONS")) {
if (Class_AdminVar::areSuggestionsDisabled()) {
$this->_forward('suggestion-achat-inactive');
return;
}
......@@ -904,7 +904,7 @@ class AbonneController extends ZendAfi_Controller_Action {
public function suggestionAchatOkAction() {
if (Class_AdminVar::get("DISABLE_SUGGESTIONS")) {
if (Class_AdminVar::areSuggestionsDisabled()) {
$this->_forward('suggestion-achat-inactive');
return;
}
......
......@@ -45,7 +45,7 @@ if ($this->is_pertinence) {
<?php
if ((int)$preferences['suggestion_achat'] == 1 && !Class_AdminVar::get("DISABLE_SUGGESTIONS"))
if ((int)$preferences['suggestion_achat'] == 1 && !Class_AdminVar::areSuggestionsDisabled())
echo $this->tag('span',
$this->tagAnchor(['controller' => 'abonne',
'action' => 'suggestion-achat'],
......
......@@ -339,6 +339,14 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
}
/**
* @return bool
*/
public function areSuggestionsDisabled() {
return Class_AdminVar::isModuleEnabled("DISABLE_SUGGESTIONS");
}
/**
* @return bool
*/
......
......@@ -20,7 +20,7 @@
*/
class ZendAfi_View_Helper_Abonne_SuggestionAchat extends ZendAfi_View_Helper_Abonne_Abstract {
public function abonne_SuggestionAchat($user) {
if (Class_AdminVar::get("DISABLE_SUGGESTIONS")) {
if (Class_AdminVar::areSuggestionsDisabled()) {
return '';
}
$action_url = $this->view->url(['controller' => 'abonne',
......
......@@ -141,7 +141,7 @@ class AbonneControllerFicheAsAdminDisableSuggestTest extends AbstractAbonneContr
/** @test */
public function linkShouldToSuggestionAchatShouldNotBePresent() {
public function linkToSuggestionAchatShouldNotBePresent() {
$this->assertNotXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]',
'Suggérer un achat');
}
......
......@@ -1067,16 +1067,17 @@ class AbonneControllerSuggestionAchatBibSelectOrderTest extends AbstractControll
}
}
class AbonneControllerSuggestionAchatInactiveControllerIndexTest extends AbstractControllerTestCase {
abstract class AbonneControllerSuggestionAchatInactiveTest extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('DISABLE_SUGGESTIONS', true);
$this->dispatch('/abonne/suggestion-achat', true);
}
/** @test */
public function divModulesShouldContainsServiceInactif() {
$this->assertXPathContentContains('//div',
......@@ -1084,39 +1085,38 @@ class AbonneControllerSuggestionAchatInactiveControllerIndexTest extends Abstrac
$this->_response->getBody());
}
}
class AbonneControllerSuggestionAchatAddInactiveControllerIndexTest extends AbstractControllerTestCase {
class AbonneControllerSuggestionAchatInactiveControllerIndexTest extends AbonneControllerSuggestionAchatInactiveTest {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('DISABLE_SUGGESTIONS', true);
$this->dispatch('/abonne/suggestion-achat-add', true);
$this->dispatch('/abonne/suggestion-achat', true);
}
}
/** @test */
public function divModulesShouldContainsServiceInactif() {
$this->assertXPathContentContains('//div',
'les suggestions d\'achats ne sont pas possibles pour le moment.',
$this->_response->getBody());
class AbonneControllerSuggestionAchatAddInactiveControllerIndexTest extends AbonneControllerSuggestionAchatInactiveTest {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->dispatch('/abonne/suggestion-achat-add', true);
}
}
class AbonneControllerSuggestionAchatOkInactiveControllerIndexTest extends AbstractControllerTestCase {
class AbonneControllerSuggestionAchatOkInactiveControllerIndexTest extends AbonneControllerSuggestionAchatInactiveTest {
protected
$_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('DISABLE_SUGGESTIONS', true);
$this->dispatch('/abonne/suggestion-achat-ok', true);
}
/** @test */
public function divModulesShouldContainsServiceInactif() {
$this->assertXPathContentContains('//div',
'les suggestions d\'achats ne sont pas possibles pour le moment.',
$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