throw new Horde_Provider_Exception(sprintf("No such element: %s", $k));
}
}
+
+ /**
+ * Test if the element is available.
+ *
+ * @param string $k The key of the element to test for.
+ *
+ * @return boolean True if the element is sset, false otherwise.
+ */
+ public function __isset($k)
+ {
+ return isset($this->elements[$k]);
+ }
+
+ /**
+ * Delete the element.
+ *
+ * @param string $k The key of the element to delete.
+ *
+ * @return NULL
+ */
+ public function __unset($k)
+ {
+ if (isset($this->elements[$k])) {
+ unset($this->elements[$k]);
+ }
+ }
}
\ No newline at end of file
$world['result'] = $e;
}
break;
+ case 'deleting the element':
+ try {
+ unset($world['provider']->{$arguments[0]});
+ } catch (Exception $e) {
+ $world['result'] = $e;
+ }
+ break;
default:
return $this->notImplemented($action);
}
$this->assertTrue($world['result'] instanceOf Exception);
$this->assertEquals($arguments[0], $world['result']->getMessage());
break;
+ case 'the element exists':
+ $this->assertTrue(isset($world['provider']->{$arguments[0]}));
+ break;
default:
return $this->notImplemented($action);
}
$this->given('a provider')
->given('a registered element', 'key', 'value')
->when('retrieving the element', 'key')
+ ->then('the element exists', 'key')
->then('the result is', 'value');
}
/**
+ * Test deleting a simple element.
+ *
+ * @scenario
+ *
+ * @return NULL
+ */
+ public function deletingASimpleElement()
+ {
+ $this->given('a provider')
+ ->given('a registered element', 'key', 'value')
+ ->when('deleting the element', 'key')
+ ->when('retrieving the element', 'key')
+ ->then('the result is an error with the message',
+ 'No such element: key');
+ }
+
+ /**
* Test retrieving a new element with invalid recursion.
*
* @scenario