/**
  *
  */
 public function processLaunch()
 {
     //Si aucun test n'est donné, on redirige vers la page de choix
     if (($test = _request('tests')) === null) {
         return _arRedirect(_url('unittest|'));
     }
     //Si on a demandé à lancer les tests avec Ajax, on génère le template d'appel pour chaque élément
     if (_request('ajax')) {
         $ppo = new CopixPpo();
         $ppo->TITLE_PAGE = 'Lancements des tests unitaires';
         $ppo->arTests = $this->_getTest();
         return _arPpo($ppo, 'tests.launch.php');
     } else {
         //on a pas demandé d'appel type ajax, donc on lance directement les tests demandés.
         if (CopixAjax::isAJAXRequest()) {
         } else {
             //C'est une demande normale, la réponse sera de type HTML
             $more = '';
         }
     }
     //On lance enfin la demande de test
     $httpClientRequest = new CopixHTTPClientRequest(CopixUrl::appendToUrl(_url() . 'test.php', array('tests' => $test, 'xml' => CopixAjax::isAJAXRequest())));
     $httpClient = new CopixHttpClient();
     $response = $httpClient->launch($httpClientRequest);
     return _arContent($response[0]->getBody(), array('content-type' => 'text/html'));
 }
/**
* Plugin smarty type fonction
* Purpose:  generation of a copixed url
*
* Input:    dest=module|desc|action
*           complete syntax will be:
*           desc|action for current module, desc and action
*           [action or |action] default desc, action
*           [|desc|action] project, desc and action
*           [||action] action in the project
*           [module||action] action in the default desc for the module
*           [|||] the only syntax for the current page
*
*           * = any extra params will be used to generate the url
*
*/
function smarty_function_copixurl($params, &$me)
{
    if (isset($params['notxml'])) {
        $isxml = $params['notxml'] == 'true' ? false : true;
        unset($params['notxml']);
    } else {
        $isxml = true;
    }
    $assign = '';
    if (isset($params['assign'])) {
        $assign = $params['assign'];
        unset($params['assign']);
    }
    if (!isset($params['dest']) && !isset($params['appendFrom'])) {
        $toReturn = _url(null, array(), $isxml);
    }
    if (isset($params['appendFrom'])) {
        $appendFrom = $params['appendFrom'];
        unset($params['appendFrom']);
        $toReturn = CopixUrl::appendToUrl($appendFrom, $params, $isxml);
    }
    if (isset($params['dest'])) {
        $dest = $params['dest'];
        unset($params['dest']);
        $toReturn = _url($dest, $params, $isxml);
    }
    if (strlen($assign) > 0) {
        $me->assign($assign, $toReturn);
        return '';
    } else {
        return $toReturn;
    }
}
/**
* Plugin smarty type fonction
* Purpose:  generation of a copixed url
*
* Input:    dest=module|desc|action
*           complete syntax will be:
*           desc|action for current module, desc and action
*           [action or |action] default desc, action
*           [|desc|action] project, desc and action
*           [||action] action in the project
*           [module||action] action in the default desc for the module
*           [|||] the only syntax for the current page
*
*           * = any extra params will be used to generate the url
*
*/
function smarty_function_copixurl($params, &$this)
{
    if (isset($params['notxml'])) {
        $isxml = $params['notxml'] == 'true' ? false : true;
        unset($params['notxml']);
    } else {
        $isxml = true;
    }
    $assign = '';
    if (isset($params['assign'])) {
        $assign = $params['assign'];
        unset($params['assign']);
    }
    if (!isset($params['dest']) && !isset($params['appendFrom'])) {
        $toReturn = CopixUrl::get(null, array(), $isxml);
    }
    /*
        $tabUrl = explode ('|', $params['dest']);
        $urlParams = array ();
        switch (count ($tabUrl)){
            case 1:
            $urlParams = array ('module'=>CopixContext::get (), 'desc'=>'default', 'action'=>$tabUrl[0]);
            break;
    
            case 2:
            $urlParams = array ('module'=>CopixContext::get (), 'desc'=>$tabUrl[0], 'action'=>$tabUrl[1]);
            break;
    
            case 3:
            $urlParams = array ('module'=>$tabUrl[0], 'desc'=>$tabUrl[1], 'action'=>$tabUrl[2]);
            break;
    
            default :
            $urlParams = array ();
        }
    */
    //checking parameters
    /*
    $urlParams = array ();
    if ($module != ''){
    $urlParams['module'] = $module;
    }
    if ($desc != ''){
    $urlParams['desc'] = $desc;
    }
    if ($action != ''){
    $urlParams['action'] = $action;
    }
    */
    if (isset($params['appendFrom'])) {
        $appendFrom = $params['appendFrom'];
        unset($params['appendFrom']);
        $toReturn = CopixUrl::appendToUrl($appendFrom, $params, $isxml);
    }
    if (isset($params['dest'])) {
        $dest = $params['dest'];
        unset($params['dest']);
        $toReturn = CopixUrl::get($dest, $params, $isxml);
    }
    if (strlen($assign) > 0) {
        $this->assign($assign, $toReturn);
        return '';
    } else {
        return $toReturn;
    }
}
 public function testParams()
 {
     $pUrl = 'test.php';
     $pUrlParam = 'test.php?param=value';
     $pUrlParams = 'test.php?param1=1&param2=2&param3=3';
     $pUrlParamsXml = 'test.php?param1=1&param2=2&param3=3';
     // Test des extrctions de paramètres
     $this->assertEquals(CopixUrl::extractParams($pUrl, false), array());
     $this->assertEquals(CopixUrl::extractParams($pUrlParam, false), array('param' => 'value'));
     $this->assertEquals(CopixUrl::extractParams($pUrlParam, true), array('param' => 'value'));
     $this->assertEquals(CopixUrl::extractParams($pUrlParams, false), array('param1' => 1, 'param2' => 2, 'param3' => 3));
     $this->assertEquals(CopixUrl::extractParams($pUrlParamsXml, true), array('param1' => 1, 'param2' => 2, 'param3' => 3));
     // Test des suppressions de paramètres
     $this->assertEquals(CopixUrl::removeParams($pUrl, array('param1')), $pUrl);
     $this->assertEquals(CopixUrl::removeParams($pUrlParam, array('param')), $pUrl);
     $this->assertEquals(CopixUrl::removeParams($pUrlParams, array('param1')), 'test.php?param2=2&param3=3');
     $this->assertEquals(CopixUrl::removeParams($pUrlParams, array('param2')), 'test.php?param1=1&param3=3');
     $this->assertEquals(CopixUrl::removeParams($pUrlParams, array('param3')), 'test.php?param1=1&param2=2');
     $this->assertEquals(CopixUrl::removeParams($pUrlParamsXml, array('param1'), true), 'test.php?param2=2&param3=3');
     $this->assertEquals(CopixUrl::removeParams($pUrlParamsXml, array('param2'), true), 'test.php?param1=1&param3=3');
     $this->assertEquals(CopixUrl::removeParams($pUrlParamsXml, array('param3'), true), 'test.php?param1=1&param2=2');
     // Test des ajout de paramètres
     $this->assertEquals(CopixUrl::appendToUrl($pUrl), $pUrl);
     $this->assertEquals(CopixUrl::appendToUrl($pUrl, array('param' => 'value')), $pUrlParam);
     $this->assertEquals(CopixUrl::appendToUrl($pUrl, array('param1' => '1', 'param2' => '2', 'param3' => '3')), $pUrlParams);
     $this->assertEquals(CopixUrl::appendToUrl($pUrl, array('param1' => '1', 'param2' => '2', 'param3' => '3'), true), $pUrlParamsXml);
 }