BasicAR.php
Current file: /home/magister/git/yii-example/example/protected/models/BasicAR.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
80.00% 4 / 5 CRAP
98.28% 57 / 58
BasicAR
0.00% 0 / 1
80.00% 4 / 5 5
98.28% 57 / 58
 model($className=__CLASS__)
0.00% 0 / 1 2
0.00% 0 / 1
 tableName()
100.00% 1 / 1 1
100.00% 1 / 1
 rules()
100.00% 1 / 1 1
100.00% 37 / 37
 attributeLabels()
100.00% 1 / 1 1
100.00% 8 / 8
 search()
100.00% 1 / 1 1
100.00% 11 / 11


       1                 : <?php                                                                                                                 
       2                 :                                                                                                                       
       3                 : /**                                                                                                                   
       4                 :  * This is the model class for table "tbl_basic_ar".                                                                  
       5                 :  *                                                                                                                    
       6                 :  * The followings are the available columns in table 'tbl_basic_ar':                                                  
       7                 :  * @property integer $id                                                                                              
       8                 :  * @property integer $column_boolean                                                                                  
       9                 :  * @property integer $column_number                                                                                   
      10                 :  * @property integer $column_range                                                                                    
      11                 :  * @property string $column_regex                                                                                     
      12                 :  * @property string $column_string                                                                                    
      13                 :  * @property string $column_safe                                                                                      
      14                 :  */                                                                                                                   
      15                 : class BasicAR extends CActiveRecord {                                                                                 
      16                 :     /**                                                                                                               
      17                 :      * Returns the static model of the specified AR class.                                                            
      18                 :      * @return BasicAR the static model class                                                                         
      19                 :      */                                                                                                               
      20                 :     public static function model($className=__CLASS__) {                                                              
      21               0 :         return parent::model($className);                                                                             
      22                 :     }                                                                                                                 
      23                 :                                                                                                                       
      24                 :     /**                                                                                                               
      25                 :      * @return string the associated database table name                                                              
      26                 :      */                                                                                                               
      27                 :     public function tableName() {                                                                                     
      28               6 :         return 'tbl_basic_ar';                                                                                        
      29                 :     }                                                                                                                 
      30                 :                                                                                                                       
      31                 :     /**                                                                                                               
      32                 :      * @return array validation rules for model attributes.                                                           
      33                 :      */                                                                                                               
      34                 :     public function rules() {                                                                                         
      35                 :         return array(                                                                                                 
      36                 :             // CRequiredValidator                                                                                     
      37                 :             array (                                                                                                   
      38               6 :                 'column_number, column_range, column_regex, column_string',                                           
      39               6 :                 'required',                                                                                           
      40               6 :             ),                                                                                                        
      41                 :             // The following columns in the DB are created as a INTEGER type,                                         
      42                 :             // meaning that they cannot be floats.                                                                    
      43                 :             array (                                                                                                   
      44               6 :                 'column_boolean, column_number, column_range',                                                        
      45               6 :                 'numerical',                                                                                          
      46               6 :                 'integerOnly' => true,                                                                                
      47               6 :             ),                                                                                                        
      48                 :             // CBooleanValidator                                                                                      
      49                 :             array (                                                                                                   
      50               6 :                 'column_boolean',                                                                                     
      51               6 :                 'boolean',                                                                                            
      52               6 :             ),                                                                                                        
      53                 :             // CNumberValidator                                                                                       
      54                 :             array (                                                                                                   
      55               6 :                 'column_number',                                                                                      
      56               6 :                 'numerical',                                                                                          
      57               6 :                 'min' => 1,                                                                                           
      58               6 :                 'max' => 10,                                                                                          
      59               6 :             ),                                                                                                        
      60                 :             // CRangeValidator                                                                                        
      61                 :             array (                                                                                                   
      62               6 :                 'column_range',                                                                                       
      63               6 :                 'in',                                                                                                 
      64               6 :                 'range' => array (1,3,5,7,9),                                                                         
      65               6 :             ),                                                                                                        
      66                 :             // The following colums are strings, but the migration defaults to a                                      
      67                 :             // maximum length of 255 characters.                                                                      
      68                 :             array (                                                                                                   
      69               6 :                 'column_regex, column_safe',                                                                          
      70               6 :                 'length',                                                                                             
      71               6 :                 'max' => 255,                                                                                         
      72               6 :             ),                                                                                                        
      73                 :             // CStringValidator, column_string in the db is defined as 255, but                                       
      74                 :             // were constraining it to 15 characters.                                                                 
      75                 :             array (                                                                                                   
      76               6 :                 'column_string',                                                                                      
      77               6 :                 'length',                                                                                             
      78               6 :                 'max' => 15,                                                                                          
      79               6 :             ),                                                                                                        
      80                 :             // CRegularExpressionValidator                                                                            
      81                 :             array (                                                                                                   
      82               6 :                 'column_regex',                                                                                       
      83               6 :                 'match',                                                                                              
      84               6 :                 'pattern' => '/\w+ \d+/',                                                                             
      85               6 :                 'message' => '{attribute} must contain a word, a space then a number.',                               
      86               6 :             ),                                                                                                        
      87                 :             // When the scenario is 'search' any data set in these attributes is                                      
      88                 :             // valid.                                                                                                 
      89                 :             // NOTE: The column 'id' should only be allowed in the 'search'                                           
      90                 :             // scenario, never in the 'insert' or 'update' scenario.                                                  
      91                 :             array (                                                                                                   
      92               6 :                 'id, column_boolean, column_number, column_range, column_regex, column_string, column_safe',          
      93               6 :                 'safe',                                                                                               
      94               6 :                 'on' => 'search',                                                                                     
      95               6 :             ),                                                                                                        
      96               6 :         );                                                                                                            
      97                 :     }                                                                                                                 
      98                 :                                                                                                                       
      99                 :     /**                                                                                                               
     100                 :      * @return array customized attribute labels (name=>label)                                                        
     101                 :      */                                                                                                               
     102                 :     public function attributeLabels() {                                                                               
     103                 :         return array(                                                                                                 
     104               2 :             'id' => 'ID',                                                                                             
     105               2 :             'column_boolean' => 'Boolean',                                                                            
     106               2 :             'column_number' => 'Number',                                                                              
     107               2 :             'column_range' => 'Range',                                                                                
     108               2 :             'column_regex' => 'Regexp',                                                                               
     109               2 :             'column_string' => 'String',                                                                              
     110               2 :             'column_safe' => 'Safe',                                                                                  
     111               2 :         );                                                                                                            
     112                 :     }                                                                                                                 
     113                 :                                                                                                                       
     114                 :     /**                                                                                                               
     115                 :      * Retrieves a list of models based on the current search/filter conditions.                                      
     116                 :      * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     117                 :      */                                                                                                               
     118                 :     public function search() {                                                                                        
     119               3 :         $criteria=new CDbCriteria;                                                                                    
     120               3 :         $criteria->compare ('id', $this->id);                                                                         
     121               3 :         $criteria->compare ('column_boolean', $this->column_boolean);                                                 
     122               3 :         $criteria->compare ('column_number', $this->column_number);                                                   
     123               3 :         $criteria->compare ('column_range', $this->column_range);                                                     
     124               3 :         $criteria->compare ('column_regex', $this->column_regex, true);                                               
     125               3 :         $criteria->compare ('column_string', $this->column_string, true);                                             
     126               3 :         $criteria->compare ('column_safe', $this->column_safe, true);                                                 
     127                 :                                                                                                                       
     128               3 :         return new CActiveDataProvider('BasicAR', array(                                                              
     129               3 :             'criteria' => $criteria,                                                                                  
     130               3 :         ));                                                                                                           
     131                 :     }                                                                                                                 
     132                 : }                                                                                                                     

Generated by PHP_CodeCoverage 1.1.2 using PHP 5.4.4-14+deb7u2 and PHPUnit 3.6.10 at Wed Aug 14 8:46:00 CDT 2013.