/**
  * Verify that getManager() returns a new instance after a call to resetManager().
  */
 public function test_get_manager_after_reset_should_return_new_manager()
 {
     $this->container->shouldReceive('singleton');
     $this->registry->addManager('default');
     $this->container->shouldReceive('make')->with('doctrine.managers.default')->andReturn(new stdClass(), new stdClass());
     $first = $this->registry->getManager();
     $this->container->shouldReceive('forgetInstance');
     $this->registry->resetManager();
     $second = $this->registry->getManager();
     $this->assertNotSame($first, $second);
 }
Esempio n. 2
0
 /**
  * Resets a named object manager.
  * 
  * This method is useful when an object manager has been closed
  * because of a rollbacked transaction AND when you think that
  * it makes sense to get a new one to replace the closed one.
  * Be warned that you will get a brand new object manager as
  * the existing one is not useable anymore. This means that any
  * other object with a dependency on this object manager will
  * hold an obsolete reference. You can inject the registry instead
  * to avoid this problem.
  *
  * @param string|null $name The object manager name (null for the default one).
  * @return \Doctrine\Common\Persistence\ObjectManager 
  * @static 
  */
 public static function resetManager($name = null)
 {
     return \LaravelDoctrine\ORM\IlluminateRegistry::resetManager($name);
 }
Esempio n. 3
0
 public function test_cannot_reset_non_existing_managers()
 {
     $this->setExpectedException(InvalidArgumentException::class, 'Doctrine Manager named "non-existing" does not exist.');
     $this->registry->resetManager('non-existing');
 }