/**
  * @testdox  Tests that message and message type set in setMessage() are overriden by setRedirect()
  *
  * @covers   JControllerLegacy::setRedirect
  */
 public function testSetRedirectWithUrlNoMessageAndMessageTypeWithPreviouslySetMessage()
 {
     $this->class->setMessage('Folks?', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', null, 'question');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class);
     $this->assertAttributeEquals('Folks?', 'message', $this->class);
     $this->assertAttributeEquals('question', 'messageType', $this->class);
 }
示例#2
0
文件: auto.php 项目: irovast/eyedock
 /**
  * 
  * @return type
  */
 protected function orderPlugins()
 {
     $aOrder = array('jscsscontrol', 'eorisis_jquery', 'jqueryeasy', 'jch_optimize', 'plugin_googlemap3', 'cdnforjoomla', 'bigshotgoogleanalytics', 'GoogleAnalytics', 'jat3', 'cache', 'jSGCache', 'jotcache', 'vmcache_last');
     $aPlugins = $this->getPlugins();
     $aLowerPlugins = array_values(array_filter($aOrder, function ($aVal) use($aPlugins) {
         return array_key_exists($aVal, $aPlugins);
     }));
     $iNoPlugins = count($aPlugins);
     $iNoLowerPlugins = count($aLowerPlugins);
     $iBaseOrder = $iNoPlugins - $iNoLowerPlugins;
     $cid = array();
     $order = array();
     foreach ($aPlugins as $key => $value) {
         if (in_array($key, $aLowerPlugins)) {
             $value['ordering'] = $iBaseOrder + 1 + array_search($key, $aLowerPlugins);
         } elseif ($value['ordering'] >= $iBaseOrder) {
             $value['ordering'] = $iBaseOrder - 1;
         }
         $cid[] = $value['extension_id'];
         $order[] = $value['ordering'];
     }
     JArrayHelper::toInteger($cid);
     JArrayHelper::toInteger($order);
     $aOrder = array();
     $aOrder['cid'] = $cid;
     $aOrder['order'] = $order;
     $oController = new JControllerLegacy();
     $oController->addModelPath(JPATH_ADMINISTRATOR . '/components/com_plugins/models', 'PluginsModel');
     $oPluginModel = $oController->getModel('Plugin', 'PluginsModel');
     if ($oPluginModel->saveorder($aOrder['cid'], $aOrder['order']) === FALSE) {
         $oController->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $oPluginModel->getError()), 'error');
     } else {
         $oController->setMessage(JText::_('JLIB_APPLICATION_SUCCESS_ORDERING_SAVED'));
     }
     $this->display($oController);
 }
 /**
  * Test JControllerLegacy::setRedirect
  *
  * @since   11.3
  *
  * @return  void
  */
 public function testSetRedirect()
 {
     // Set the URL only
     $this->class->setRedirect('index.php?option=com_foobar');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect.');
     $this->assertAttributeEquals(null, 'message', $this->class, 'Checks the message.');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type.');
     // Set the URL and message
     $this->class->setRedirect('index.php?option=com_foobar', 'Hello World');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (2).');
     $this->assertAttributeEquals('Hello World', 'message', $this->class, 'Checks the message (2).');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (2).');
     // URL, message and message type
     $this->class->setRedirect('index.php?option=com_foobar', 'Morning Universe', 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (3).');
     $this->assertAttributeEquals('Morning Universe', 'message', $this->class, 'Checks the message (3).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (3).');
     // With previously set message
     // URL
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (4).');
     $this->assertAttributeEquals('Hi all', 'message', $this->class, 'Checks the message (4).');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (4).');
     // URL and message
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye all');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (5).');
     $this->assertAttributeEquals('Bye all', 'message', $this->class, 'Checks the message (5).');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (5).');
     // URL, message and message type
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye all', 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (6).');
     $this->assertAttributeEquals('Bye all', 'message', $this->class, 'Checks the message (6).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (6).');
     // URL and message type
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar', null, 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (7).');
     $this->assertAttributeEquals('Hi all', 'message', $this->class, 'Checks the message (7).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (7).');
     // With previously set message and message type
     // URL
     $this->class->setMessage('Hello folks', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (8).');
     $this->assertAttributeEquals('Hello folks', 'message', $this->class, 'Checks the message (8).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (8).');
     // URL and message
     $this->class->setMessage('Hello folks', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye, Folks');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (9).');
     $this->assertAttributeEquals('Bye, Folks', 'message', $this->class, 'Checks the message (9).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (9).');
     // URL, message and message type
     $this->class->setMessage('Hello folks', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye, folks', 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (10).');
     $this->assertAttributeEquals('Bye, folks', 'message', $this->class, 'Checks the message (10).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (10).');
     // URL and message type
     $this->class->setMessage('Folks?', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', null, 'question');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (10).');
     $this->assertAttributeEquals('Folks?', 'message', $this->class, 'Checks the message (10).');
     $this->assertAttributeEquals('question', 'messageType', $this->class, 'Checks the message type (10).');
 }