Ejemplo n.º 1
0
 public function testAccessRemovedValue()
 {
     $di = new \Elgg\Di\DiContainer();
     $di->setValue('foo', 'Foo');
     $di->remove('foo');
     $this->setExpectedException('\\Elgg\\Di\\MissingValueException');
     $di->foo;
 }
Ejemplo n.º 2
0
 public function testNamesCannotEndWithUnderscore()
 {
     $di = new \Elgg\Di\DiContainer();
     try {
         $di->setValue('foo_', 'foo');
         $this->fail('setValue did not throw');
     } catch (\InvalidArgumentException $e) {
     }
     $this->assertFalse($di->has('foo_'));
     try {
         $di->setFactory('foo_', function () {
         });
         $this->fail('setFactory did not throw');
     } catch (\InvalidArgumentException $e) {
     }
     try {
         $di->remove('foo_');
         $this->fail('remove did not throw');
     } catch (\InvalidArgumentException $e) {
     }
     try {
         $di->_foo;
         $this->fail('->_foo did not throw');
     } catch (MissingValueException $e) {
     }
 }