Пример #1
0
 public function testResourceRepository()
 {
     $documentManager = $this->createDocumentManagerMock();
     $documentManager->expects($this->once())->method('getClassMetadata')->with($this->identicalTo($documentName = 'document'))->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
     $classMetadata->expects($this->once())->method('getName')->will($this->returnValue($documentName));
     $this->resourceRegistry->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()])));
     $resource->expects($this->once())->method('getModel')->will($this->returnValue($documentName));
     $documentManager->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->createUnitOfWorkMock()));
     $classMetadata->customRepositoryClassName = $repositoryClass = Repository::class;
     $this->assertInstanceOf($repositoryClass, $repository = $this->repositoryFactory->getRepository($documentManager, $documentName));
     $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName));
 }