Changeset 69

Show
Ignore:
Timestamp:
02/02/06 01:38:13 (3 years ago)
Author:
laurentj
Message:

ajout test unitaire sur urls simple et correction bug sur simple

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/core/url/jUrlEngine.significant.class.php

    r66 r69  
    198198 
    199199         $url->scriptName = $urlinfo[1]; 
    200  
     200         if(!$GLOBALS['gJConfig']->urlengine['multiview_on']){ 
     201            $script.=$GLOBALS['gJConfig']->urlengine['entrypoint_extension']; 
     202         } 
    201203         if($urlinfo[0]==0){ 
    202204            $cl = $urlinfo[1]; 
  • trunk/lib/jelix/core/url/jUrlEngine.simple.class.php

    r51 r69  
    2525    } 
    2626 
    27     protected function getScript($requestType, $module=null, $action=null, $nosuffix=false){ 
     27    protected function getScript($requestType, $module=null, $action=null){ 
    2828        static $urlspe = null; 
    2929        global $gJConfig; 
     
    4141               } 
    4242           } 
    43  
    4443           $found = false; 
    45  
    46            if($action && $action !='' && isset($sep[$module.'~'.$action.'@'.$requestType])){ 
    47                 $script = $sep[$module.'~'.$action.'@'.$requestType]; 
     44           if($action && $action !='' && isset($urlspe[$module.'~'.$action.'@'.$requestType])){ 
     45                $script = $urlspe[$module.'~'.$action.'@'.$requestType]; 
    4846                $found = true; 
    4947           } 
    50  
    51            if($module && $module !='' && !$found &&  isset($sep[$module.'~*@'.$requestType])){ 
    52                 $script = $sep[$module.'~*@'.$requestType]; 
     48           if($module && $module !='' && !$found &&  isset($urlspe[$module.'~*@'.$requestType])){ 
     49                $script = $urlspe[$module.'~*@'.$requestType]; 
    5350                $found = true; 
    5451           } 
    55  
    56            if(!$found && isset($sep['@'.$requestType])){ 
    57                $script = $sep['@'.$requestType]; 
     52           if(!$found && isset($urlspe['@'.$requestType])){ 
     53               $script = $urlspe['@'.$requestType]; 
    5854                $found = true; 
    5955           } 
    6056        } 
    61  
    62         if(!$nosuffix && !$gJConfig->urlengine['multiview_on']){ 
     57        if(!$gJConfig->urlengine['multiview_on']){ 
    6358            $script.=$gJConfig->urlengine['entrypoint_extension']; 
    6459        } 
  • trunk/lib/simpletest/runner.php

    r67 r69  
    183183                    $invoker->invoke($method); 
    184184                } 
     185 
    185186                $this->_scorer->paintMethodEnd($method); 
    186187            } 
  • trunk/lib/simpletest/simple_test.php

    r67 r69  
    8484        function run(&$reporter) { 
    8585            $reporter->paintCaseStart($this->getLabel()); 
    86             $this->_runner = &$this->_createRunner($reporter); 
     86            $this->_runner = & $this->_createRunner($reporter); 
    8787            $this->_runner->run(); 
    8888            $reporter->paintCaseEnd($this->getLabel()); 
  • trunk/myapp/var/config/config.classic.ini.php.dist

    r60 r69  
    8989xmlrpc = "@xmlrpc" 
    9090jsonrpc = "@jsonrpc" 
     91 
     92 
     93[logfiles] 
     94default=messages.log 
  • trunk/testapp/modules/testapp/actiongroups/main.ag.php

    r65 r69  
    2626         $rep->body->assign('value','name'); 
    2727      } 
     28 
    2829      return $rep; 
    2930   } 
  • trunk/testapp/modules/unittest/actiongroups/default.ag.php

    r67 r69  
    3434   } 
    3535 
     36   function getTestCreate(){ 
     37      $rep = $this->getResponse('default'); 
     38      $rep->title = 'test unitaires sur la creation d\'url avec jUrl'; 
    3639 
     40      $ut = jClasses::create("unittestservice"); 
     41      $ut->init($rep); 
     42      $ut->urlsTest(); 
     43 
     44      return $rep; 
     45   } 
    3746} 
    3847?> 
  • trunk/testapp/modules/unittest/actions.xml

    r67 r69  
    1111      </action> 
    1212 
    13       <action name="urlsigparse" ag="urlsig" method="getTestParsing" > 
     13      <action name="urlsigparse" ag="default" method="getTestParsing" > 
    1414         <response default="true" name="default" type="unittest" /> 
    1515      </action> 
    1616 
    17       <action name="urlsigcreate" ag="urlsig" method="getTestCreate" > 
     17      <action name="urlsigcreate" ag="default" method="getTestCreate" > 
    1818         <response default="true" name="default" type="unittest" /> 
    1919      </action> 
  • trunk/testapp/modules/unittest/classes/unittestservice.class.php

    r67 r69  
    11<?php 
     2/** 
     3* @package     testapp 
     4* @subpackage  unittest module 
     5* @version     $Id$ 
     6* @author      Jouanneau Laurent 
     7* @contributor 
     8* @copyright   2006 Jouanneau laurent 
     9* @link        http://www.jelix.org 
     10* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     11*/ 
    212 
    313require_once(LIB_PATH.'/simpletest/unit_tester.php'); 
    4 require_once(LIB_PATH.'/simpletest/reporter.php'); 
     14require_once(dirname(__FILE__).'/jhtmlrespreporter.class.php'); 
    515 
    6 class jHtmlRepReporter extends SimpleReporter { 
    7    protected $_response; 
    8    function __construct($response) { 
    9       $this->SimpleReporter(); 
    10       $this->_response = $response; 
    11    } 
    12  
    13    function paintHeader($test_name) { 
    14       $this->_response->title=$test_name; 
    15       $this->_response->body->append('MAIN','<h2>'.$test_name.'</h2>'); 
    16    } 
    17  
    18    function paintFooter($test_name) { 
    19       $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "resultfail" : "resultsuccess"); 
    20       $str = "<div class=\"$colour\">"; 
    21       $str.= $this->getTestCaseProgress() . "/" . $this->getTestCaseCount(); 
    22       $str.= " test cases complete:\n"; 
    23       $str.= "<strong>" . $this->getPassCount() . "</strong> passes, "; 
    24       $str.= "<strong>" . $this->getFailCount() . "</strong> fails and "; 
    25       $str.= "<strong>" . $this->getExceptionCount() . "</strong> exceptions."; 
    26       $str.= "</div>\n"; 
    27       $this->_response->body->append('MAIN',$str); 
    28    } 
    29  
    30    function paintFail($message) { 
    31       parent::paintFail($message); 
    32  
    33       $str = "<span class=\"fail\">Fail</span>: "; 
    34       $breadcrumb = $this->getTestList(); 
    35       array_shift($breadcrumb); 
    36       $str.= implode(" -&gt; ", $breadcrumb); 
    37       $str.= " -&gt; " . $this->_htmlEntities($message) . "<br />\n"; 
    38       $this->_response->body->append('MAIN',$str); 
    39    } 
    40  
    41    function paintException($message) { 
    42       parent::paintException($message); 
    43       $str=  "<span class=\"fail\">Exception</span>: "; 
    44       $breadcrumb = $this->getTestList(); 
    45       array_shift($breadcrumb); 
    46       $str.=  implode(" -&gt; ", $breadcrumb); 
    47       $str.=  " -&gt; <strong>" . $this->_htmlEntities($message) . "</strong><br />\n"; 
    48       $this->_response->body->append('MAIN',$str); 
    49    } 
    50  
    51    function paintMessage($message) { 
    52       $this->_response->body->append('MAIN','<p>'.$message.'</p>'); 
    53    } 
    54  
    55    function paintFormattedMessage($message) { 
    56       $this->_response->body->append('MAIN','<pre>' . $this->_htmlEntities($message) . '</pre>'); 
    57    } 
    58  
    59    function _htmlEntities($message) { 
    60       return htmlentities($message, ENT_COMPAT, $this->_character_set); 
    61    } 
    62 } 
    6316 
    6417 
     
    7225 
    7326      $test = jClasses::create("utevents"); 
    74       $test->run(new jHtmlRepReporter($this->_rep)); 
     27      $test->run(new jHtmlRespReporter($this->_rep)); 
    7528   } 
    7629      /*$test = &new GroupTest('All tests'); 
     
    7831      $test->run(new HtmlReporter()); 
    7932      */ 
     33 
     34   function urlsTest(){ 
     35      $test = jClasses::create("utcreateurls"); 
     36      $test->run(new jHtmlRespReporter($this->_rep)); 
     37   } 
    8038} 
    8139?> 
  • trunk/testapp/modules/unittest/classes/utevents.class.php

    r67 r69  
    11<?php 
     2/** 
     3* @package     testapp 
     4* @subpackage  unittest module 
     5* @version     $Id$ 
     6* @author      Jouanneau Laurent 
     7* @contributor 
     8* @copyright   2006 Jouanneau laurent 
     9* @link        http://www.jelix.org 
     10* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     11*/ 
    212 
    313class UTEvents extends UnitTestCase { 
    414 
    515    function testEvents() { 
    6       $this->sendMessage("�nement simple"); 
    716      $response = jEvent::notify('TestEvent'); 
    817      $response = $response->getResponse (); 
     
    1019      $temoin = serialize(array('module'=>'unittest','ok'=>true)); 
    1120 
    12       $this->assertTrue($temoin == $response, 'Premier ev�ment'); 
     21      $this->assertTrue($temoin == $response, '�nement simple'); 
    1322 
    14       $this->sendMessage("�nement avec param�es"); 
    1523      $temoin = array('hello'=>'world'); 
    1624      $response = jEvent::notify('TestEventWithParams',$temoin ); 
    1725      $response = $response->getResponse (); 
    1826 
    19       $this->assertTrue(($response[0]['params'] == 'world'), 'Deuxi� ev�ment'); 
     27      $this->assertTrue(($response[0]['params'] == 'world'), '�nement avec param�es'); 
    2028    } 
    2129} 
  • trunk/testapp/modules/unittest/templates/accueil.tpl

    r67 r69  
    99 
    1010</ul> 
    11 <!-- 
     11 
    1212<h3>jUrl</h3> 
    1313<ul> 
    1414    <li><a href="?module=unittest&amp;action=urlsigcreate">Tester la cr�ion d'url</a></li> 
    15     <li><a href="?module=unittest&amp;action=urlsigparse">Tester l'analyse d'url</a></li
     15<!--    <li><a href="?module=unittest&amp;action=urlsigparse">Tester l'analyse d'url</a></li>--
    1616</ul> 
    17 --> 
     17 
    1818</div> 
    1919 
  • trunk/testapp/var/config/urls.xml

    r53 r69  
    22<urls xmlns="http://jelix.org/ns/urls/1.0"> 
    33    <classicentrypoint name="index" default="true"> 
    4        <url pathinfo="/test/:annee/:mois" module="testapp" action="test1"> 
     4        <url pathinfo="/test/:annee/:mois" module="testapp" action="test1"> 
    55              <param name="annee" escape="true" regexp="\d{4}"/> 
    66              <param name="mois" escape="false" /> 
    77              <static name="bla" value="cequejeveux" /> 
    88        </url> 
    9         <!--<url handler="foo" module="testapp"  />--> 
     9 
     10        <url pathinfo="/test/news/:annee/:mois/:id" module="unittest" action="url1"> 
     11           <param name="annee" regexp="\d{4}"/> 
     12           <param name="mois"  regexp="\d{2}" /> 
     13           <param name="id"   regexp="\d{2}" /> 
     14        </url> 
     15 
     16        <url pathinfo="/test/cms/:rubrique/:id_art-:article" module="unittest" action="url3"> 
     17           <param name="rubrique" /> 
     18           <param name="id_art" regexp="\d+"/> 
     19           <param name="article" escape="true"/> 
     20        </url> 
     21 
    1022    </classicentrypoint> 
     23    <classicentrypoint name="testnews"> 
     24       <url pathinfo="/:annee/:mois" module="unittest" action="url2"> 
     25          <param name="annee" regexp="\d{4}"/> 
     26          <param name="mois"  regexp="\d{2}" /> 
     27          <static name="mystatic" value="valeur statique" /> 
     28        </url> 
     29    </classicentrypoint> 
     30    <classicentrypoint name="foo/bar"> 
     31       <url handler="urlfoo" module="unittest" action="url4" /> 
     32    </classicentrypoint> 
     33 
    1134    <classicentrypoint name="news"> 
    1235        <url module="news" /> 
  • trunk/testapp/www/unittest.css

    r67 r69  
    3232 
    3333.fail { color: red; } 
     34.pass { color: green; } 
    3435pre { background-color: lightgray; } 
    3536 
Download in other formats: Unified Diff Zip Archive