Commit 86b6d482 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #78169 add inspector_gadget to provide suggest

parent 1a768b5d
Pipeline #4757 failed with stage
in 45 minutes and 43 seconds
- ticket #78169 : Compte lecteur : ajout de l'inspecteur gadget dans l'écran d'ajout de suggestions d'achat
\ No newline at end of file
......@@ -946,6 +946,7 @@ class AbonneController extends ZendAfi_Controller_Action {
}
$form = ZendAfi_Form_SuggestionAchat::forUser($this->_user);
$form->setAction($this->view->url());
if ($this->_request->isPost()) {
$post = $this->_request->getPost();
......@@ -961,11 +962,12 @@ class AbonneController extends ZendAfi_Controller_Action {
try {
$suggestion->sendMail('noreply@'.$this->_request->getHttpHost());
} catch (Zend_Mail_Exception $e) {
$this->_helper->notify($this->_('Aucun courriel envoyé, erreur: ').$this->_($e->getMessage()));
$this->_helper->notify($this->_('Aucun courriel envoyé, erreur: %s',
$this->_($e->getMessage())));
}
$this->_helper->notify($this->_('Suggestion d\'achat enregistrée'));
$this->_redirect('/opac/abonne/suggestion-achat');
return $this->_redirect(Class_Url::absolute($this->view->url(['action' => 'suggestion-achat'])));
}
}
......
......@@ -24,7 +24,9 @@ class ZendAfi_Controller_Plugin_InspectorGadget extends Zend_Controller_Plugin_A
const PARAM_NAME = 'inspector_gadget';
protected $_enabled = false,
protected
$_enabled = false,
$_keep = false,
$_calls = [],
$_buttons = [],
$_session,
......@@ -32,7 +34,9 @@ class ZendAfi_Controller_Plugin_InspectorGadget extends Zend_Controller_Plugin_A
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$this->_session = Zend_Registry::get('session');
$this->_keep = ('keep' == $request->getParam(self::PARAM_NAME));
$this->_calls = $this->_session->inspectorCalls;
if ((!$request->getParam(self::PARAM_NAME, false)) && (!$this->_calls))
return;
......@@ -154,7 +158,10 @@ class ZendAfi_Controller_Plugin_InspectorGadget extends Zend_Controller_Plugin_A
foreach(array_filter($this->_calls, 'is_object') as $call)
$items[] = $this->_view->tag('li', $call->renderOn($this->_view));
if (!$this->_keep)
$this->_session->inspectorCalls = [];
$content = $this->_view->tag('ol', implode('', $items));
return $this
......
......@@ -674,6 +674,44 @@ class IndexControllerInspectorGadgetTest extends AbstractControllerTestCase {
class IndexControllerInspectorGadgetKeepTest extends AbstractControllerTestCase {
/** @test */
public function sessionShouldBeEmpty() {
$this->dispatch('/index/index/inspector_gadget/keep', true);
$session = Zend_Registry::get('session');
$calls = isset($session->inspectorCalls)
? $session->inspectorCalls
: [];
$this->assertEquals([], $calls);
}
/** @test */
public function sessionShouldContainsStringTest() {
$session = Zend_Registry::get('session');
$session->inspectorCalls = [serialize('test')];
$this->dispatch('/index/index/inspector_gadget/keep', true);
$calls = isset($session->inspectorCalls)
? $session->inspectorCalls
: [];
$this->assertEquals(['s:4:"test";'], $calls);
}
/** @test */
public function sessionShouldNotContainsStringTest() {
$session = Zend_Registry::get('session');
$session->inspectorCalls = [serialize('test')];
$this->dispatch('/index/index/inspector_gadget/1', true);
$calls = isset($session->inspectorCalls)
? $session->inspectorCalls
: [];
$this->assertEquals([], $calls);
}
}
class IndexControllerHeartBeatTest extends Admin_AbstractControllerTestCase {
/** @test */
......
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