Changeset 79 for trunk/lib

Show
Ignore:
Timestamp:
10/09/08 14:39:31 (2 years ago)
Author:
nperriault
Message:

[1.1] Updated functional tests, migrated Job form

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/form/JobForm.class.php

    r75 r79  
    99{ 
    1010  /** 
     11   * @var array of Company 
     12   */ 
     13  protected $userCompanies = array(); 
     14 
     15  /** 
     16   * Constructor 
     17   * 
     18   * @param Job $job 
     19   * @param array $userCompanies 
     20   */ 
     21  public function __construct(Job $job, $options = array(), $CSRFSecret = null) 
     22  { 
     23    if (isset($options['userCompanies'])) 
     24    { 
     25      $this->userCompanies = $options['userCompanies']; 
     26      unset($options['userCompanies']); 
     27    } 
     28 
     29    parent::__construct($job, $options, $CSRFSecret); 
     30  } 
     31 
     32  /** 
    1133   * Form configuration 
    1234   * 
     
    1436  public function configure() 
    1537  { 
     38    // Unset unused widgets 
     39    unset($this['created_at'], 
     40          $this['updated_at'], 
     41          $this['contact_id'], 
     42          $this['slug']); 
     43 
     44    $this->initWidgets(); 
     45    $this->initValidators(); 
     46  } 
     47 
     48  /** 
     49   * Intitialize widgets 
     50   * 
     51   */ 
     52  public function initWidgets() 
     53  { 
     54    $this->widgetSchema['country']    = new ExtendedWidgetFormI18nSelectCountry(array('culture' => $this->culture, 'add_label_option' => __('Select a country'))); 
     55    $this->widgetSchema['expires_at'] = new sfWidgetFormI18nDate(array('culture' => $this->culture)); 
     56  } 
     57 
     58  /** 
     59   * Initialize validators 
     60   * 
     61   */ 
     62  public function initValidators() 
     63  { 
     64    $this->validatorSchema['country']    = new sfValidatorI18nChoiceCountry(array('culture' => $this->culture, 'required' => false)); 
     65    $this->validatorSchema['expires_at'] = new sfValidatorDate(array('required' => false)); 
    1666  } 
    1767} 
  • trunk/lib/model/Job.php

    r49 r79  
    44 * 
    55 * @package lib.model 
    6  */  
     6 */ 
    77class Job extends BaseJob 
    88{ 
    99 
    1010  protected $place = null; 
    11    
     11 
    1212  public function getCountryName() 
    1313  { 
     
    1818    } 
    1919  } 
    20    
     20 
    2121  public function getIsActive() 
    2222  { 
    2323    return !$this->getExpiresAt() or $this->getExpiresAt(null) > time(); 
    2424  } 
    25    
     25 
    2626  public function getPlace() 
    2727  { 
     
    5656    return $this->place; 
    5757  } 
    58    
     58 
    5959  public function getOwnerName() 
    6060  { 
     
    7272    } 
    7373  } 
    74    
     74 
    7575  public function save($con = null) 
    7676  { 
     
    7878    $modified = $this->isModified(); 
    7979    $affectedRows = parent::save($con); 
    80      
     80 
    8181    if ($this->getCompanyId() && !$this->getCompany()->getAllowContact()) 
    8282    { 
    8383      $this->getCompany()->setAllowContact(true); 
    8484      $this->getCompany()->save(); 
    85       //sfContext::getInstance()->getLogger()->info(sprintf('Company "%s" has now email contact enabled',  
    86         //                                    $this->getCompany()->getName())); 
    8785    } 
    88      
     86 
    8987    // Create "company created" event object 
    9088    if ($modified) 
     
    116114      $event->save(); 
    117115    } 
    118      
     116 
    119117    return $affectedRows; 
    120118  } 
     
    125123                     'to'   => JobPeer::SLUG); 
    126124 
    127 sfPropelBehavior::add('Job',  
    128                       array('sfPropelActAsSluggableBehavior' =>  
    129                               array('columns'   => $columns_map,  
    130                                     'separator' => '-',  
     125sfPropelBehavior::add('Job', 
     126                      array('sfPropelActAsSluggableBehavior' => 
     127                              array('columns'   => $columns_map, 
     128                                    'separator' => '-', 
    131129                                    'permanent' => true), 
    132                             'sfPropelActAsLocalizableBehavior' =>  
     130                            'sfPropelActAsLocalizableBehavior' => 
    133131                              array('location_getter' => 'getPlace'))); 
    134132 
  • trunk/lib/utils/SymfoniansTestBrowser.class.php

    r75 r79  
    157157  { 
    158158    self::$test->comment('Loading fixtures...'); 
    159  
    160     $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 
    161     $t->run(array('application' => self::$configuration->getApplication())); 
    162  
    163     self::$test->comment('Fixtures loaded.'); 
     159     
     160    try 
     161    { 
     162      $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 
     163      $t->run(array('application' => self::$configuration->getApplication())); 
     164 
     165      self::$test->comment('Fixtures loaded.'); 
     166    } 
     167    catch (PropelException $e) 
     168    { 
     169      self::$test->fail('Unable to load fixtures: '.$e->getMessage()); 
     170    } 
    164171  } 
    165172 
  • trunk/lib/validator/sfValidatorSchemaLicence.class.php

    r75 r79  
    1313  protected function doClean($values) 
    1414  { 
    15     //parent::doClean($values); 
    16  
    17     $errorSchema = new sfValidatorErrorSchema($this); 
    18  
    1915    if ($values['is_opensource'] && 0 === strlen(trim($values['licence']))) 
    2016    {