Changeset 251

Show
Ignore:
Timestamp:
09/11/06 00:18:55 (2 years ago)
Author:
laurentj
Message:

quelques tests unitaires supplémentaires sur les daos et ajout d'un plugin autolocale, pour la detection automatique de la langue de l'internaute.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/jelix-lib.mn

    r247 r251  
    304304  magicquotes.plugin.php 
    305305  plugin.xml 
     306cd lib/jelix-plugins/autolocale 
     307  autolocale.plugin.ini.php.dist 
     308  autolocale.plugin.php 
     309  plugin.xml 
    306310 
    307311 
  • trunk/lib/jelix/dao/jDaoParser.class.php

    r250 r251  
    225225 
    226226    /** 
    227     * Is it a string ? 
    228     * @var boolean 
    229     */ 
    230     public $isString = true; 
    231  
    232     /** 
    233227    * Says if it's a primary key. 
    234228    * @var boolean 
     
    257251    public $minlength = null; 
    258252 
     253    /** 
     254    * Is it a string ? 
     255    * @var boolean 
     256    */ 
    259257    public $needQuotes = true; 
     258 
    260259    public $ofPrimaryTable = true; 
    261260 
    262261    /** 
    263262    * constructor. 
    264     <property name="nom simplifi�field="nom du champs" table="alias de la table" 
    265       datatype=""   required="true/false" 
    266       minlength="" maxlength="" regexp="" sequence="nom de la sequence" 
    267       updatemotif="" insertmotif="" selectmotif="" 
    268      /> 
    269263    */ 
    270264    function __construct ($params, $def){ 
  • trunk/testapp/modules/testapp/templates/sommaire.tpl

    r132 r251  
    11<h2>Sommaire</h2> 
    22 
     3<h3>Tests simples</h3> 
    34<ul> 
    45   <li><a href="{jurl 'main_hello'}">Hello world en html</a></li> 
    56   <li><a href="{jurl 'main_hello', array('output'=>'text')}">Hello world en texte</a></li> 
    67   <li><a href="{jurl 'main_hello2'}">Template Hello world surcharg�a></li> 
    7    <li><a href="{jurl 'unittest~default_index'}">Tests unitaires</a></li> 
    8  
    98   <li><a href="{jurl 'main_testdao'}">test dao</a></li> 
    109</ul> 
    1110 
     11<h3>Tests Unitaires</h3> 
     12<ul> 
     13<li><a href="{jurl 'unittest~default_index'}">sommaire Tests unitaires</a></li> 
     14</ul> 
    1215 
    1316<h3>Formulaires</h3> 
  • trunk/testapp/modules/unittest/classes/utdao.class.php

    r250 r251  
    138138    <array method="getMethods()">array()</array> 
    139139    <array method="getOuterJoins()">array(\'news_rubriques\')</array> 
    140     <array method="getInnerJoins()"></array> 
     140    <array method="getInnerJoins()">array()</array> 
    141141</object>' 
    142142), 
    143143 
     144 
     145 array('<?xml version="1.0"?> 
     146<dao xmlns="http://jelix.org/ns/dao/1.0"> 
     147  <datasources> 
     148     <primarytable name="news"           primarykey="news_id" /> 
     149     <optionalforeigntable name="news_rubriques" primarykey="news_rubriques_id" onforeignkey="news_rubrique" /> 
     150     <foreigntable name="news_author" realname="jx_authors_news" primarykey="author_id" onforeignkey="author_id" /> 
     151  </datasources> 
     152</dao>', 
     153 
     154'<?xml version="1.0"?> 
     155<object class="jDaoParser"> 
     156    <array method="getProperties()">array()</array> 
     157    <array method="getTables()"> 
     158        <array key="news"> 
     159            <string key="name" value="news" /> 
     160            <string key="realname" value="news" /> 
     161            <array key="pk" value="">array(\'news_id\')</array> 
     162            <!-- <array key="fk" value="">array()</array>--> 
     163            <array key="fields">array()</array> 
     164        </array> 
     165        <array key="news_rubriques"> 
     166            <string key="name" value="news_rubriques" /> 
     167            <string key="realname" value="news_rubriques" /> 
     168            <array key="pk" value="">array(\'news_rubriques_id\')</array> 
     169            <array key="fk" value="">array(\'news_rubrique\')</array> 
     170            <array key="fields">array()</array> 
     171        </array> 
     172        <array key="news_author"> 
     173            <string key="name" value="news_author" /> 
     174            <string key="realname" value="jx_authors_news" /> 
     175            <array key="pk" value="">array(\'author_id\')</array> 
     176            <array key="fk" value="">array(\'author_id\')</array> 
     177            <array key="fields">array()</array> 
     178        </array> 
     179    </array> 
     180    <string method="getPrimaryTable()" value="news"/> 
     181    <array method="getMethods()">array()</array> 
     182    <array method="getOuterJoins()">array(\'news_rubriques\')</array> 
     183    <array method="getInnerJoins()">array(array(\'news_rubriques\',0))</array> 
     184</object>' 
     185), 
    144186 
    145187      ); 
     
    218260), 
    219261 
     262        array('<?xml version="1.0"?> 
     263<dao xmlns="http://jelix.org/ns/dao/1.0"> 
     264  <datasources> 
     265    <primarytable name="news"           primarykey="news_id" /> 
     266    <foreigntable name="news_author" realname="jx_authors_news" primarykey="author_id" /> 
     267 
     268  </datasources> 
     269</dao>', 
     270'jelix~daoxml.foreignkey.missing', 
     271array('','') 
     272 
     273), 
     274 
     275        array('<?xml version="1.0"?> 
     276<dao xmlns="http://jelix.org/ns/dao/1.0"> 
     277  <datasources> 
     278    <primarytable name="news"           primarykey="news_id" /> 
     279    <foreigntable name="news_author" realname="jx_authors_news" primarykey="author_id" onforeignkey="" /> 
     280 
     281  </datasources> 
     282</dao>', 
     283'jelix~daoxml.foreignkey.missing', 
     284array('','') 
     285 
     286), 
     287 
     288        array('<?xml version="1.0"?> 
     289<dao xmlns="http://jelix.org/ns/dao/1.0"> 
     290  <datasources> 
     291    <primarytable name="news"           primarykey="news_id" /> 
     292    <foreigntable name="news_author" realname="jx_authors_news" primarykey="author_id" onforeignkey="author_id,foo_id" /> 
     293 
     294  </datasources> 
     295</dao>', 
     296'jelix~daoxml.foreignkey.missing', 
     297array('','') 
     298 
     299), 
    220300 
    221301      ); 
     
    239319    } 
    240320 
     321 
     322    protected $propDatas=array( 
     323        array( 
     324        '<?xml version="1.0"?> 
     325        <property name="label" datatype="string" />', 
     326        '<?xml version="1.0"?> 
     327        <object> 
     328            <string p="name" value="label"/> 
     329            <string p="fieldName" value="label"/> 
     330            <string p="table" value="news"/> 
     331            <string p="datatype" value="string"/> 
     332            <null p="regExp"/> 
     333            <boolean p="required" value="false"/> 
     334            <boolean p="isPK" value="false" /> 
     335            <boolean p="isFK" value="false" /> 
     336            <string p="updateMotif" value="%s" /> 
     337            <string p="insertMotif" value="%s" /> 
     338            <string p="selectMotif" value="%s" /> 
     339            <string p="sequenceName" value="" /> 
     340            <null p="maxlength"/> 
     341            <null p="minlength"/> 
     342            <boolean p="needQuotes" value="true" /> 
     343            <boolean p="ofPrimaryTable" value="true" /> 
     344        </object>' 
     345        ),/* 
     346        array( 
     347        '<?xml version="1.0"?> 
     348        <property name="" field="nom du champs" table="alias de la table" 
     349                    datatype=""   required=""  minlength="" maxlength="" 
     350                    regExp="" sequence="nom de la sequence" 
     351                    updatemotif="" insertmotif="" selectmotif=""/>', 
     352        '<?xml version="1.0"?> 
     353        <object> 
     354            <string p="name" value=""/> 
     355            <string p="fieldName" value=""/> 
     356            <string p="table" value=""/> 
     357            <string p="datatype" value=""/> 
     358            <null p="regExp"/> 
     359            <boolean p="required" value="false"/> 
     360            <boolean p="isPK" value="false" /> 
     361            <boolean p="isFK" value="false" /> 
     362            <string p="updateMotif" value="%s" /> 
     363            <string p="insertMotif" value="%s" /> 
     364            <string p="selectMotif" value="%s" /> 
     365            <string p="sequenceName" value="" /> 
     366            <int p="maxlength" value="0"/> <null p="maxlength"/> 
     367            <int p="minlength" value="0"/> <null p="minlength"/> 
     368            <boolean p="needQuotes" value="true" /> 
     369            <boolean p="ofPrimaryTable" value="true" /> 
     370        </object>' 
     371        ), 
     372        array( 
     373        '<?xml version="1.0"?> 
     374        <property name="" field="nom du champs" table="alias de la table" 
     375                    datatype=""   required=""  minlength="" maxlength="" 
     376                    regExp="" sequence="nom de la sequence" 
     377                    updatemotif="" insertmotif="" selectmotif=""/>', 
     378        '<?xml version="1.0"?> 
     379        <object> 
     380            <string p="name" value=""/> 
     381            <string p="fieldName" value=""/> 
     382            <string p="table" value=""/> 
     383            <string p="datatype" value=""/> 
     384            <null p="regExp"/> 
     385            <boolean p="required" value="false"/> 
     386            <boolean p="isPK" value="false" /> 
     387            <boolean p="isFK" value="false" /> 
     388            <string p="updateMotif" value="%s" /> 
     389            <string p="insertMotif" value="%s" /> 
     390            <string p="selectMotif" value="%s" /> 
     391            <string p="sequenceName" value="" /> 
     392            <int p="maxlength" value="0"/> <null p="maxlength"/> 
     393            <int p="minlength" value="0"/> <null p="minlength"/> 
     394            <boolean p="needQuotes" value="true" /> 
     395            <boolean p="ofPrimaryTable" value="true" /> 
     396        </object>' 
     397        ), 
     398*/ 
     399    ); 
     400 
     401    function testProperties() { 
     402        $dao ='<?xml version="1.0"?> 
     403<dao xmlns="http://jelix.org/ns/dao/1.0"> 
     404  <datasources> 
     405    <primarytable name="news" primarykey="news_id" /> 
     406    <foreigntable name="news_author" primarykey="author_id" onforeignkey="author_id" /> 
     407  </datasources> 
     408</dao>'; 
     409 
     410        $parser = new jDaoParser(); 
     411        $parser->parse(simplexml_load_string($dao),2); 
     412 
     413        foreach($this->propDatas as $k=>$t){ 
     414            $this->sendMessage("test good property ".$k); 
     415            $xml= simplexml_load_string($t[0]); 
     416            try{ 
     417                $p = new jDaoProperty($xml, $parser); 
     418                $this->assertComplexIdenticalStr($p, $t[1]); 
     419            }catch(jDaoXmlException $e){ 
     420                $this->fail("Exception sur le contenu xml inattendue : ".$e->getMessage()); 
     421            }catch(Exception $e){ 
     422                $this->fail("Exception inconnue : ".$e->getMessage()); 
     423            } 
     424        } 
     425    } 
     426 
     427 
    241428} 
    242429 
Download in other formats: Unified Diff Zip Archive