Development

Changeset 8932

You must first sign up to be able to contribute.

Changeset 8932

Show
Ignore:
Timestamp:
05/13/08 23:29:55 (5 months ago)
Author:
dwhittle
Message:

dwhittle: merged changes to branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dwhittle/1.0/lib/filter/sfExecutionFilter.class.php

    r7797 r8932  
    7272        $validated = true; 
    7373 
     74        // the case of the first letter of the action is insignificant 
    7475        // get the current action validation configuration 
    75         $validationConfig = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.$actionName.'.yml'; 
     76        $validationConfigWithFirstLetterLower = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.strtolower(substr($actionName, 0, 1)).substr($actionName, 1).'.yml'; 
     77        $validationConfigWithFirstLetterUpper = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.ucfirst($actionName).'.yml'; 
     78 
     79        // determine $validateFile by testing both the uppercase and lowercase 
     80        // types of validation configurations. 
     81        $validateFile = null; 
     82        if (!is_null($testValidateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfigWithFirstLetterLower, true))) 
     83        { 
     84          $validateFile = $testValidateFile; 
     85        } 
     86        else if (!is_null($testValidateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfigWithFirstLetterUpper, true))) 
     87        { 
     88          $validateFile = $testValidateFile; 
     89        } 
    7690 
    7791        // load validation configuration 
    7892        // do NOT use require_once 
    79         if (null !== $validateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig, true)) 
     93        if (!is_null($validateFile)) 
    8094        { 
    8195          // create validator manager 
  • branches/dwhittle/1.0/test/functional/fixtures/project/apps/frontend/modules/validation/actions/actions.class.php

    r6598 r8932  
    1313  public function executeIndex() 
    1414  { 
     15    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     16    { 
     17      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     18    } 
    1519  } 
    1620 
    1721  public function handleErrorIndex() 
    1822  { 
     23    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     24 
     25    return sfView::SUCCESS; 
     26  } 
     27 
     28  public function executeIndex2() 
     29  { 
     30    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     31    { 
     32      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     33    } 
     34  } 
     35 
     36  public function handleErrorIndex2() 
     37  { 
     38    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     39 
    1940    return sfView::SUCCESS; 
    2041  } 
  • branches/dwhittle/1.0/test/functional/validationTest.php

    r6598 r8932  
    138138  checkResponseElement('body ul[class="errors"] li[class="input4"]', 'Required') 
    139139; 
     140 
     141// check that /validation/index and /validation/Index both uses the index.yml validation file (see #1617) 
     142// those tests are only relevant on machines where filesystems are case sensitive. 
     143$b-> 
     144  post('/validation/index')-> 
     145  isStatusCode(200)-> 
     146  isRequestParameter('module', 'validation')-> 
     147  isRequestParameter('action', 'index')-> 
     148  isResponseHeader('X-Validated', 'ko') 
     149; 
     150 
     151$b-> 
     152  post('/validation/Index')-> 
     153  isStatusCode(200)-> 
     154  isRequestParameter('module', 'validation')-> 
     155  isRequestParameter('action', 'Index')-> 
     156  isResponseHeader('X-Validated', 'ko') 
     157; 
     158 
     159$b-> 
     160  post('/validation/INdex')-> 
     161  isStatusCode(404) 
     162; 
     163 
     164$b-> 
     165  post('/validation/index2')-> 
     166  isStatusCode(200)-> 
     167  isRequestParameter('module', 'validation')-> 
     168  isRequestParameter('action', 'index2')-> 
     169  isResponseHeader('X-Validated', 'ko') 
     170; 
     171 
     172$b-> 
     173  post('/validation/Index2')-> 
     174  isStatusCode(200)-> 
     175  isRequestParameter('module', 'validation')-> 
     176  isRequestParameter('action', 'Index2')-> 
     177  isResponseHeader('X-Validated', 'ko') 
     178; 
  • branches/dwhittle/1.1/lib/i18n/sfMessageFormat.class.php

    r6812 r8932  
    186186    $this->loadCatalogue($catalogue); 
    187187 
    188     if (empty($args)) 
    189     { 
    190       $args = array(); 
    191     } 
    192  
    193188    foreach ($this->messages[$catalogue] as $variant) 
    194189    { 
    195       // foreach of the translation units 
    196       foreach ($variant as $source => $result
     190      // we found it, so return the target translation 
     191      if (isset($variant[$string])
    197192      { 
    198         // we found it, so return the target translation 
    199         if ($source == $string) 
     193        $target = $variant[$string];  
     194 
     195        // check if it contains only strings. 
     196        if (is_array($target)) 
    200197        { 
    201           // check if it contains only strings. 
    202           $target = is_string($result) ? $result : $result[0]; 
    203  
    204           // found, but untranslated 
    205           if (empty($target)) 
    206           { 
    207             return $this->postscript[0].$this->replaceArgs($string, $args).$this->postscript[1]; 
    208           } 
    209           else 
    210           { 
    211             return $this->replaceArgs($target, $args); 
    212           } 
     198          $target = array_shift($target); 
    213199        } 
     200 
     201        // found, but untranslated 
     202        if (empty($target)) 
     203        { 
     204          return $this->postscript[0].$this->replaceArgs($string, $args).$this->postscript[1]; 
     205        } 
     206        return $this->replaceArgs($target, $args); 
    214207      } 
    215208    } 
  • branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/lib/filter/sfValidationExecutionFilter.class.php

    r7797 r8932  
    108108    $validated = true; 
    109109 
    110     // lowercase first letter and enforce convention 
    111     $actionName[0] = strtolower($actionName[0]); 
    112  
     110    // the case of the first letter of the action is insignificant 
    113111    // get the current action validation configuration 
    114     $validationConfig = $moduleName.'/validate/'.$actionName.'.yml'; 
     112    $validationConfigWithFirstLetterLower = strtolower(substr($actionName, 0, 1)).substr($actionName, 1).'.yml'; 
     113    $validationConfigWithFirstLetterUpper = ucfirst($actionName).'.yml'; 
     114 
     115    // determine $validateFile by testing both the uppercase and lowercase 
     116    // types of validation configurations. 
     117    $validateFile = null; 
     118    if (!is_null($testValidateFile = $this->context->getConfigCache()->checkConfig('modules/'.$moduleName.'/validate/'.$validationConfigWithFirstLetterLower, true))) 
     119    { 
     120      $validateFile = $testValidateFile; 
     121    } 
     122    else if (!is_null($testValidateFile = $this->context->getConfigCache()->checkConfig('modules/'.$moduleName.'/validate/'.$validationConfigWithFirstLetterUpper, true))) 
     123    { 
     124      $validateFile = $testValidateFile; 
     125    } 
    115126 
    116127    // load validation configuration 
    117128    // do NOT use require_once 
    118     if (null !== $validateFile = $this->context->getConfigCache()->checkConfig('modules/'.$validationConfig, true)) 
     129    if (!is_null($validateFile)) 
    119130    { 
    120131      // create validator manager 
  • branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/fixtures/apps/frontend/modules/validation/actions/actions.class.php

    r7167 r8932  
    1313  public function executeIndex() 
    1414  { 
     15    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     16    { 
     17      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     18    } 
    1519  } 
    1620 
    1721  public function handleErrorIndex() 
    1822  { 
     23    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     24 
     25    return sfView::SUCCESS; 
     26  } 
     27 
     28  public function executeIndex2() 
     29  { 
     30    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     31    { 
     32      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     33    } 
     34  } 
     35 
     36  public function handleErrorIndex2() 
     37  { 
     38    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     39 
    1940    return sfView::SUCCESS; 
    2041  } 
  • branches/dwhittle/1.1/lib/plugins/sfCompat10Plugin/test/functional/validationTest.php

    r7167 r8932  
    157157$headers = $b->getResponse()->getHttpHeaders(); 
    158158$b->test()->ok(!isset($headers['X-Test']), 'Validation for GET is also triggered by HEAD requests'); 
     159 
     160// check that /validation/index and /validation/Index both uses the index.yml validation file (see #1617) 
     161// those tests are only relevant on machines where filesystems are case sensitive. 
     162$b-> 
     163  post('/validation/index')-> 
     164  isStatusCode(200)-> 
     165  isRequestParameter('module', 'validation')-> 
     166  isRequestParameter('action', 'index')-> 
     167  isResponseHeader('X-Validated', 'ko') 
     168; 
     169 
     170$b-> 
     171  post('/validation/Index')-> 
     172  isStatusCode(200)-> 
     173  isRequestParameter('module', 'validation')-> 
     174  isRequestParameter('action', 'Index')-> 
     175  isResponseHeader('X-Validated', 'ko') 
     176; 
     177 
     178// needed to pass tests on case and non case sensitive machines 
     179if (!file_exists(dirname(__FILE__).'/fixtures/apps/frontend/modules/validation/templates/IndexSuccess.php')) 
     180{ 
     181  $b->throwsException('sfRenderException'); 
     182} 
     183 
     184$b-> 
     185  post('/validation/INdex')-> 
     186  isStatusCode(404) 
     187; 
     188 
     189$b-> 
     190  post('/validation/index2')-> 
     191  isStatusCode(200)-> 
     192  isRequestParameter('module', 'validation')-> 
     193  isRequestParameter('action', 'index2')-> 
     194  isResponseHeader('X-Validated', 'ko') 
     195; 
     196 
     197if (!is_readable(dirname(__FILE__).'/fixtures/apps/frontend/modules/validation/templates/index2Success.php')) 
     198{ 
     199  $b->throwsException('sfRenderException'); 
     200} 
     201 
     202$b-> 
     203  post('/validation/Index2')-> 
     204  isStatusCode(200)-> 
     205  isRequestParameter('module', 'validation')-> 
     206  isRequestParameter('action', 'Index2')-> 
     207  isResponseHeader('X-Validated', 'ko') 
     208; 
     209 
  • branches/dwhittle/1.1/test/unit/yaml/sfYamlDumperTest.php

    r8490 r8932  
    7070{ '': bar, 'foo''bar': {  }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } } 
    7171EOF; 
    72 $t->is(sfYaml::dump($array, -10), $expected, '::dump() takes an inline level argument'); 
    73 $t->is(sfYaml::dump($array, 0), $expected, '::dump() takes an inline level argument'); 
     72$t->is($dumper->dump($array, -10), $expected, '->dump() takes an inline level argument'); 
     73$t->is($dumper->dump($array, 0), $expected, '->dump() takes an inline level argument'); 
    7474 
    7575$expected = <<<EOF 
     
    8080 
    8181EOF; 
    82 $t->is(sfYaml::dump($array, 1), $expected, '::dump() takes an inline level argument'); 
     82$t->is($dumper->dump($array, 1), $expected, '->dump() takes an inline level argument'); 
    8383 
    8484$expected = <<<EOF 
     
    9494 
    9595EOF; 
    96 $t->is(sfYaml::dump($array, 2), $expected, '::dump() takes an inline level argument'); 
     96$t->is($dumper->dump($array, 2), $expected, '->dump() takes an inline level argument'); 
    9797 
    9898$expected = <<<EOF 
     
    112112 
    113113EOF; 
    114 $t->is(sfYaml::dump($array, 3), $expected, '::dump() takes an inline level argument'); 
     114$t->is($dumper->dump($array, 3), $expected, '->dump() takes an inline level argument'); 
    115115 
    116116$expected = <<<EOF 
     
    132132 
    133133EOF; 
    134 $t->is(sfYaml::dump($array, 4), $expected, '::dump() takes an inline level argument'); 
    135 $t->is(sfYaml::dump($array, 10), $expected, '::dump() takes an inline level argument'); 
     134$t->is($dumper->dump($array, 4), $expected, '->dump() takes an inline level argument'); 
     135$t->is($dumper->dump($array, 10), $expected, '->dump() takes an inline level argument'); 
    136136 
    137137// objects 
     
    142142} 
    143143$a = array('foo' => new A(), 'bar' => 1); 
    144 $t->is(sfYaml::dump($a), <<<EOF 
    145 foo: !!php/object:O:1:"A":1:{s:1:"a";s:3:"foo";} 
    146 bar: 1 
    147  
    148 EOF 
    149 , '::dump() is able to dump objects'); 
     144$t->is($dumper->dump($a), '{ foo: !!php/object:O:1:"A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', '->dump() is able to dump objects'); 
  • branches/dwhittle/1.1/test/unit/yaml/sfYamlParserTest.php

    r8490 r8932  
    7474} 
    7575$a = array('foo' => new A(), 'bar' => 1); 
    76 $t->is(sfYaml::load(<<<EOF 
     76$t->is($parser->parse(<<<EOF 
    7777foo: !!php/object:O:1:"A":1:{s:1:"a";s:3:"foo";} 
    7878bar: 1 
    7979EOF 
    80 ), $a, '::dump() is able to dump objects'); 
     80), $a, '->parse() is able to dump objects');