Changeset 2915

Show
Ignore:
Timestamp:
07/22/08 12:47:30 (1 month ago)
Author:
gcroes
Message:

Premiers tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/project/modules/devel/cms3/heading/classes/headingelementinformationservices.class.php

    r2911 r2915  
    2222    /** 
    2323     * Création d'un nouvel élément 
     24     * @param object $pHeadingElementInformation 
    2425     * @return int public_id de l'élément nouvellement généré 
    2526     */ 
    2627    public function insert ($pHeadingElementInformation){ 
     28        $this->fillMissing ($pHeadingElementInformation); 
     29        _dao ('headingelementinformation')->insert ($pHeadingElementInformation); 
     30        $this->_updatePublicIdIfMissing ($pHeadingElementInformation); 
     31        return $pHeadingElementInformation->public_id_hei; 
    2732    } 
    2833     
     
    4550    public function deleteByPublicId ($pPublicId){ 
    4651    } 
     52     
     53    /** 
     54     * Remplis les informations manquantes sur l'élément 
     55     */ 
     56    public function fillMissing ($pHEI){ 
     57        //Dates de mises à jour 
     58        $date = date (CopixI18N::getDateTimeFormat ()); 
     59        if (!isset ($pHEI->date_create_hei)){ 
     60            $pHEI->date_create_hei = $date; 
     61        } 
     62        if (!isset ($pHEI->date_update_hei)){ 
     63            $pHEI->date_update_hei = $date; 
     64        } 
     65         
     66        //Auteurs 
     67        $id      = _currentUser ()->getId (); 
     68        $handler = _currentUser ()->getHandler (); 
     69        $caption = _currentUser ()->getCaption (); 
     70 
     71        //ID 
     72        if (!isset ($pHEI->author_id_update_hei)){ 
     73            $pHEI->author_id_update_hei = $id; 
     74        } 
     75        if (!isset ($pHEI->author_id_create_hei)){ 
     76            $pHEI->author_id_create_hei = $id; 
     77        } 
     78        //handler 
     79        if (!isset ($pHEI->author_handler_update_hei)){ 
     80            $pHEI->author_handler_update_hei = $handler; 
     81        } 
     82        if (!isset ($pHEI->author_handler_create_hei)){ 
     83            $pHEI->author_handler_create_hei = $handler; 
     84        } 
     85        //libellé 
     86        if (!isset ($pHEI->author_caption_update_hei)){ 
     87            $pHEI->author_caption_update_hei = $caption; 
     88        } 
     89        if (!isset ($pHEI->author_caption_create_hei)){ 
     90            $pHEI->author_caption_create_hei = $caption; 
     91        } 
     92         
     93        //SiteId 
     94        if (!isset ($pHEI->site_id_hei)){ 
     95            $pHEI->site_id_hei = CopixConfig::get ('heading|site_id'); 
     96        } 
     97         
     98        //Status - Si aucun donné, on considère "PUBLISHED" 
     99        if (!isset ($pHEI->status_hei)){ 
     100            _classInclude ('heading|HeadingElementStatus'); 
     101            $pHEI->status_hei = HeadingElementStatus::PUBLISHED; 
     102        } 
     103         
     104        //Version / From Version 
     105        if (!isset ($pHEI->version_hei)){ 
     106            $pHEI->version_hei = 0; 
     107        } 
     108        if (!isset ($pHEI->fromversion_hei)){ 
     109            $pHEI->fromversion_hei = 0; 
     110        } 
     111         
     112        //affichage dans le menu 
     113        if (!isset ($pHEI->show_in_menu_hei)){ 
     114            $pHEI->show_in_menu_hei = 0;             
     115        } 
     116         
     117    } 
     118     
     119    /** 
     120     * Cette fonction met à jour le publicid dans l'enregistrement si ce dernier n'est pas présent 
     121     * @return boolean  s'il a fallu mettre l'enregistrement a jour ou non 
     122     */ 
     123    protected function _updatePublicIdIfMissing ($pHEI){ 
     124        if (!isset ($pHEI->public_id_hei)){ 
     125            $pHEI->public_id_hei = $pHEI->id_hei; 
     126            _dao ('heading|headingelementinformation')->update ($pHEI); 
     127            return true; 
     128        } 
     129        return false; 
     130    } 
     131     
     132    /** 
     133     * Donne le numéro de version "suivant" pour un contenu d'identifiant donné  
     134     * 
     135     * @param int $pPublicId    l'identifiant publique de l'élément dont on souhaite connaitre le numéro de version 
     136     * @return int  le numéro de version a venir  
     137     */ 
     138    public function getNextVersion ($pPublicId){ 
     139    } 
    47140} 
  • trunk/project/modules/devel/cms3/heading/classes/headingelementstatus.class.php

    r2912 r2915  
    88 * @license    http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
    99 */ 
     10 
     11/** 
     12 * Représentation des status possibles dans le workflow des contenus 
     13 */ 
    1014class HeadingElementStatus { 
    1115    /** 
    1216     * Constantes correspondants aux status possibles pour les éléments du CMS 
    13      *  
    1417     */ 
    1518    const DRAFT = 0;  
     
    5861    } 
    5962} 
    60 ?> 
  • trunk/project/modules/devel/cms3/heading/classes/headingservices.class.php

    r2911 r2915  
    1313 */ 
    1414class HeadingServices { 
    15     public function create ($pHeadingDescription){ 
     15    /** 
     16     * Création d'une nouvelle rubrique 
     17     * @param array / object $pHeadingDescription 
     18     */ 
     19    public function insert ($pHeadingDescription){ 
    1620        CopixDB::begin (); 
    17          
    18          
    19         _dao ('heading|heading'); 
     21        try { 
     22            _dao ('heading')->insert ($record = $this->createRecordFromObject ($pHeadingDescription)); 
     23            $record->id_helt = $record->id_head; 
     24            $record->type_hei = 'heading'; 
     25 
     26            //dans $record->id_hei on a le nouvel identifiant 
     27            _class ('heading|headingelementinformationservices')->insert ($record); 
     28             
     29            //on met maintenant a jour l'élément $record avec les informations publiques mises à jour 
     30            _dao ('heading')->update ($record); 
     31 
     32        }catch (CopixException $e){ 
     33            CopixDB::rollback (); 
     34            throw $e;  
     35        } 
    2036        CopixDB::commit (); 
    2137    } 
    22      
    23     public function createRecord  
     38 
     39    public function createRecordFromObject ($pInformations){ 
     40        return _record ('heading')->initFromDbObject (_rPPO ($pInformations)); 
     41    }  
    2442} 
  • trunk/project/modules/devel/cms3/heading/module.xml

    r2911 r2915  
    55            description="[CMS] Gestion des rubriques" /> 
    66    </general> 
     7    <parameters> 
     8        <parameter name="site_id" caption="Identifiant unique du site" default="principal" />    
     9    </parameters> 
    710</moduledefinition> 
  • trunk/project/modules/devel/cms3/heading/tests/heading_headingtest.class.php

    r2911 r2915  
    1414class Heading_HeadingTest extends CopixTest { 
    1515    public function testCreationRubrique (){ 
     16        //création d'une rubrique test 
     17        $ppo = _rPPO (); 
     18        $ppo->parent_id_head = 0;//rubrique parente = rubrique racine 
     19        $ppo->description_head = 'Rubrique testée unitairement'; 
     20        _class ('heading|headingservices')->insert ($ppo); 
     21        $this->assertFalse ($ppo->public_id_hei === null); 
     22        $this->assertFalse ($ppo->id_head === null); 
     23         
     24         
     25        $this->assertTrue (is_object ($heading = _dao ('heading')->get ($ppo->id_head))); 
    1626    } 
    1727