Example #1
0
 /**
  * @expectedException CM_Exception_Invalid
  * @expectedExceptionMessage Service `DummyService` already registered
  */
 public function testRegisterTwice()
 {
     $serviceManager = new CM_Service_Manager();
     $serviceManager->register('DummyService', 'DummyService', array('foo' => 'bar'));
     $serviceManager->register('DummyService', 'DummyService', array('foo' => 'bar'));
 }
Example #2
0
 public function testRegisterTwice()
 {
     $serviceManager = new CM_Service_Manager();
     $serviceManager->register('DummyService', 'DummyService', array('foo' => 'bar'));
     $exception = $this->catchException(function () use($serviceManager) {
         $serviceManager->register('DummyService', 'DummyService', array('foo' => 'bar'));
     });
     $this->assertInstanceOf('CM_Exception_Invalid', $exception);
     /** @var CM_Exception_Invalid $exception */
     $this->assertSame('Service is already registered.', $exception->getMessage());
     $this->assertSame(['service' => 'DummyService'], $exception->getMetaInfo());
 }