Changeset 2867
- Timestamp:
- 11/29/06 14:33:35 (2 years ago)
- Files:
-
- trunk/lib/helper/UrlHelper.php (modified) (1 diff)
- trunk/lib/util/sfDomCssSelector.class.php (modified) (1 diff)
- trunk/test/unit/helper/UrlHelperTest.php (modified) (1 diff)
- trunk/test/unit/i18n/sfNumberFormatInfoTest.php (modified) (2 diffs)
- trunk/test/unit/sfContextMock.class.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/helper/UrlHelper.php
r2798 r2867 114 114 if (is_object($name)) 115 115 { 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 } 117 124 } 118 125 trunk/lib/util/sfDomCssSelector.class.php
r2281 r2867 168 168 } 169 169 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'); 171 183 } 172 184 trunk/test/unit/helper/UrlHelperTest.php
r2798 r2867 64 64 { 65 65 } 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'); 66 try 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 } 72 catch (sfException $e) 73 { 74 $t->pass('link_to() can take an object as its first argument if __toString() method is defined'); 75 } 76 68 77 class testObjectWithToString 69 78 { trunk/test/unit/i18n/sfNumberFormatInfoTest.php
r2834 r2867 29 29 $t->isa_ok(sfNumberFormatInfo::getInstance(), 'sfNumberFormatInfo', '::getInstance() returns an sfNumberFormatInfo instance'); 30 30 $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'); 32 32 $t->isa_ok(sfNumberFormatInfo::getInstance('fr'), 'sfNumberFormatInfo', '::getInstance() can take a culture as its first argument'); 33 33 $n = sfNumberFormatInfo::getInstance(); … … 52 52 // ::getCurrencyInstance() 53 53 $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'); 55 55 56 56 // ::getPercentageInstance() 57 57 $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'); 59 59 60 60 // ::getScientificInstance() 61 61 $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'); 63 63 64 64 // setters/getters trunk/test/unit/sfContextMock.class.php
r2733 r2867 30 30 public function getRequest() 31 31 { 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 } 34 39 35 40 return $request; … … 38 43 public function getResponse() 39 44 { 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 } 42 52 43 53 return $response;