Development

Changeset 8698

You must first sign up to be able to contribute.

Changeset 8698

Show
Ignore:
Timestamp:
04/30/08 18:35:28 (1 year ago)
Author:
fabien
Message:

added an exception when trying to retrieve a non existant sfEvent parameter (to ease debugging) lib/event/sfEvent.class.php test/unit/event/sfEventTest.php

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/autoload/sfCoreAutoload.class.php

    r8563 r8698  
    292292  'sfDatabaseSessionStorage' => 'storage', 
    293293  'sfMySQLSessionStorage' => 'storage', 
     294  'sfMySQLiSessionStorage' => 'storage', 
    294295  'sfNoStorage' => 'storage', 
    295296  'sfPDOSessionStorage' => 'storage', 
  • branches/1.1/lib/event/sfEvent.class.php

    r8146 r8698  
    120120  public function offsetExists($name) 
    121121  { 
    122     return isset($this->parameters[$name]); 
     122    return array_key_exists($name, $this->parameters); 
    123123  } 
    124124 
     
    132132  public function offsetGet($name) 
    133133  { 
    134     return isset($this->parameters[$name]) ? $this->parameters[$name] : null; 
     134    if (!array_key_exists($name, $this->parameters)) 
     135    { 
     136      throw new InvalidArgumentException(sprintf('The event "%s" has no "%s" parameter.', $this->name, $name)); 
     137    } 
     138 
     139    return $this->parameters[$name]; 
    135140  } 
    136141 
  • branches/1.1/test/unit/event/sfEventTest.php

    r6503 r8698  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(10, new lime_output_color()); 
     13$t = new lime_test(11, new lime_output_color()); 
    1414 
    1515$subject = new stdClass(); 
     
    4747$t->is($event['foo'], 'foo', 'sfEvent implements the ArrayAccess interface'); 
    4848 
     49try 
     50{ 
     51  $event['foobar']; 
     52  $t->fail('::offsetGet() throws an InvalidArgumentException exception when the parameter does not exist'); 
     53} 
     54catch (InvalidArgumentException $e) 
     55{ 
     56  $t->pass('::offsetGet() throws an InvalidArgumentException exception when the parameter does not exist'); 
     57} 
     58 
    4959$t->ok(isset($event['foo']), 'sfEvent implements the ArrayAccess interface'); 
    5060unset($event['foo']); 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.