Development

Changeset 2867

You must first sign up to be able to contribute.

Changeset 2867

Show
Ignore:
Timestamp:
11/29/06 14:33:35 (2 years ago)
Author:
fabien
Message:

fixed php 5.2 problems

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/helper/UrlHelper.php

    r2798 r2867  
    114114  if (is_object($name)) 
    115115  { 
    116     $name = method_exists($name, '__toString') ? $name->__toString() : (string) $name; 
     116    if (method_exists($name, '__toString')) 
     117    { 
     118      $name = $name->__toString(); 
     119    } 
     120    else 
     121    { 
     122      throw new sfException(sprintf('Object of class "%s" cannot be converted to string (Please create a __toString() method)', get_class($name))); 
     123    } 
    117124  } 
    118125 
  • trunk/lib/util/sfDomCssSelector.class.php

    r2281 r2867  
    168168      } 
    169169 
    170       $all_nodes = array_unique(array_merge($all_nodes, $nodes)); 
     170      foreach ($nodes as $node) 
     171      { 
     172        if (!$node->getAttribute('sf_matched')) 
     173        { 
     174          $node->setAttribute('sf_matched', true); 
     175          $all_nodes[] = $node; 
     176        } 
     177      } 
     178    } 
     179 
     180    foreach ($all_nodes as $node) 
     181    { 
     182      $node->removeAttribute('sf_matched'); 
    171183    } 
    172184 
  • trunk/test/unit/helper/UrlHelperTest.php

    r2798 r2867  
    6464{ 
    6565} 
    66 $o1 = new testObject(); 
    67 $t->like(link_to($o1), '#<a href="module/action">Object id \#\d+</a>#', 'link_to() can take an object as its first argument'); 
     66try 
     67
     68  $o1 = new testObject(); 
     69  link_to($o1); 
     70  $t->fail('link_to() can take an object as its first argument if __toString() method is defined'); 
     71
     72catch (sfException $e) 
     73
     74  $t->pass('link_to() can take an object as its first argument if __toString() method is defined'); 
     75
     76 
    6877class testObjectWithToString 
    6978{ 
  • trunk/test/unit/i18n/sfNumberFormatInfoTest.php

    r2834 r2867  
    2929$t->isa_ok(sfNumberFormatInfo::getInstance(), 'sfNumberFormatInfo', '::getInstance() returns an sfNumberFormatInfo instance'); 
    3030$c = new sfCultureInfo(); 
    31 $t->is(sfNumberFormatInfo::getInstance(), $c->getNumberFormat(), '::getInstance() can take a sfCultureInfo instance as its first argument'); 
     31$t->is(sfNumberFormatInfo::getInstance($c), $c->getNumberFormat(), '::getInstance() can take a sfCultureInfo instance as its first argument'); 
    3232$t->isa_ok(sfNumberFormatInfo::getInstance('fr'), 'sfNumberFormatInfo', '::getInstance() can take a culture as its first argument'); 
    3333$n = sfNumberFormatInfo::getInstance(); 
     
    5252// ::getCurrencyInstance() 
    5353$t->diag('::getCurrencyInstance()'); 
    54 $t->is(sfNumberFormatInfo::getCurrencyInstance(), sfNumberFormatInfo::getInstance(null, sfNumberFormatInfo::CURRENCY), '::getCurrencyInstance() is a shortcut for ::getInstance() and type sfNumberFormatInfo::CURRENCY'); 
     54$t->is(sfNumberFormatInfo::getCurrencyInstance()->getPattern(), sfNumberFormatInfo::getInstance(null, sfNumberFormatInfo::CURRENCY)->getPattern(), '::getCurrencyInstance() is a shortcut for ::getInstance() and type sfNumberFormatInfo::CURRENCY'); 
    5555 
    5656// ::getPercentageInstance() 
    5757$t->diag('::getPercentageInstance()'); 
    58 $t->is(sfNumberFormatInfo::getPercentageInstance(), sfNumberFormatInfo::getInstance(null, sfNumberFormatInfo::PERCENTAGE), '::getPercentageInstance() is a shortcut for ::getInstance() and type sfNumberFormatInfo::PERCENTAGE'); 
     58$t->is(sfNumberFormatInfo::getPercentageInstance()->getPattern(), sfNumberFormatInfo::getInstance(null, sfNumberFormatInfo::PERCENTAGE)->getPattern(), '::getPercentageInstance() is a shortcut for ::getInstance() and type sfNumberFormatInfo::PERCENTAGE'); 
    5959 
    6060// ::getScientificInstance() 
    6161$t->diag('::getScientificInstance()'); 
    62 $t->is(sfNumberFormatInfo::getScientificInstance(), sfNumberFormatInfo::getInstance(null, sfNumberFormatInfo::SCIENTIFIC), '::getScientificInstance() is a shortcut for ::getInstance() and type sfNumberFormatInfo::SCIENTIFIC'); 
     62$t->is(sfNumberFormatInfo::getScientificInstance()->getPattern(), sfNumberFormatInfo::getInstance(null, sfNumberFormatInfo::SCIENTIFIC)->getPattern(), '::getScientificInstance() is a shortcut for ::getInstance() and type sfNumberFormatInfo::SCIENTIFIC'); 
    6363 
    6464// setters/getters 
  • trunk/test/unit/sfContextMock.class.php

    r2733 r2867  
    3030  public function getRequest() 
    3131  { 
    32     $request = new sfWebRequest(); 
    33     $request->initialize($this); 
     32    static $request; 
     33 
     34    if (!$request) 
     35    { 
     36      $request = new sfWebRequest(); 
     37      $request->initialize($this); 
     38    } 
    3439 
    3540    return $request; 
     
    3843  public function getResponse() 
    3944  { 
    40     $response = new sfWebResponse(); 
    41     $response->initialize($this); 
     45    static $response; 
     46 
     47    if (!$response) 
     48    { 
     49      $response = new sfWebResponse(); 
     50      $response->initialize($this); 
     51    } 
    4252 
    4353    return $response;