@@ -485,6 +485,37 @@ public function testGetManagerForClassWithNamespace(): void
485485 $ this ->assertEquals ($ entityManager , $ this ->registry ->getManagerForClass ('Alias:Scientist ' ));
486486 }
487487
488+ public function testGetManagerForClassReturnsNullWhenNotFound (): void
489+ {
490+ $ this ->container ->shouldReceive ('singleton ' );
491+ $ this ->registry ->addManager ('default ' );
492+
493+ $ entityManager = m::mock (EntityManagerInterface::class);
494+ $ this ->container ->shouldReceive ('make ' )
495+ ->with ('doctrine.managers.default ' )
496+ ->andReturn ($ entityManager );
497+
498+ $ metadataFactory = m::mock (ClassMetadataFactory::class);
499+ $ metadataFactory ->shouldReceive ('isTransient ' )
500+ ->with ('LaravelDoctrineTest\ORM\Assets\Entity\Scientist ' )
501+ ->once ()
502+ ->andReturnFalse ();
503+
504+ $ metadata = m::mock (ClassMetadata::class);
505+ $ metadata ->shouldReceive ('getName ' )
506+ ->once ()
507+ ->andReturn ('LaravelDoctrineTest\ORM\Assets\Entity\Theory ' );
508+
509+ $ metadataFactory ->shouldReceive ('getAllMetadata ' )
510+ ->once ()
511+ ->andReturn ([$ metadata ]);
512+
513+ $ entityManager ->shouldReceive ('getMetadataFactory ' )
514+ ->andReturn ($ metadataFactory );
515+
516+ $ this ->assertNull ($ this ->registry ->getManagerForClass ('LaravelDoctrineTest\ORM\Assets\Entity\Scientist ' ));
517+ }
518+
488519 public function testGetManagerForClassThrowsExceptionWhenNotFound (): void
489520 {
490521 $ this ->expectException (RuntimeException::class);
@@ -515,7 +546,7 @@ public function testGetManagerForClassThrowsExceptionWhenNotFound(): void
515546 $ entityManager ->shouldReceive ('getMetadataFactory ' )
516547 ->andReturn ($ metadataFactory );
517548
518- $ this ->assertEquals ($ entityManager , $ this ->registry ->getManagerForClass ('LaravelDoctrineTest\ORM\Assets\Entity\Scientist ' ));
549+ $ this ->assertEquals ($ entityManager , $ this ->registry ->getManagerForClass ('LaravelDoctrineTest\ORM\Assets\Entity\Scientist ' , true ));
519550 }
520551
521552 public function testGetManagerForClassInvalidClass (): void
0 commit comments