Exemplo n.º 1
0
 public function testGetFactoryUncallableArrayObject()
 {
     $di = new \Elgg\Di\DiContainer();
     $di->setFactory('foo', array($this, 'not-a-real-callable'));
     $this->setExpectedException('\\Elgg\\Di\\FactoryUncallableException', "Factory for 'foo' was uncallable: Elgg\\Di\\DiContainerTest->not-a-real-callable");
     $di->foo;
 }
Exemplo n.º 2
0
 public function testGetFactoryUncallable()
 {
     $di = new \Elgg\Di\DiContainer();
     $di->setFactory('foo', 'not-a-real-callable');
     $this->setExpectedException('\\Elgg\\Di\\FactoryUncallableException', "Factory for 'foo' was uncallable: 'not-a-real-callable'");
     $di->foo;
 }
Exemplo n.º 3
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) {
     }
 }