| @@ 58-98 (lines=41) @@ | ||
| 55 | $this->assertInstanceOf(RepositoryFactoryInterface::class, $this->repositoryFactory); |
|
| 56 | } |
|
| 57 | ||
| 58 | public function testRepository() |
|
| 59 | { |
|
| 60 | $documentManager = $this->createDocumentManagerMock(); |
|
| 61 | $documentManager |
|
| 62 | ->expects($this->exactly(2)) |
|
| 63 | ->method('getClassMetadata') |
|
| 64 | ->with($this->identicalTo($documentName = 'document')) |
|
| 65 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 66 | ||
| 67 | $documentManager |
|
| 68 | ->expects($this->exactly(2)) |
|
| 69 | ->method('getConfiguration') |
|
| 70 | ->will($this->returnValue($configuration = $this->createConfigurationMock())); |
|
| 71 | ||
| 72 | $configuration |
|
| 73 | ->expects($this->exactly(2)) |
|
| 74 | ->method('getDefaultRepositoryClassName') |
|
| 75 | ->will($this->returnValue($repositoryClass = DocumentRepository::class)); |
|
| 76 | ||
| 77 | $classMetadata |
|
| 78 | ->expects($this->exactly(2)) |
|
| 79 | ->method('getName') |
|
| 80 | ->will($this->returnValue($documentName)); |
|
| 81 | ||
| 82 | $this->resourceRegistry |
|
| 83 | ->expects($this->once()) |
|
| 84 | ->method('getIterator') |
|
| 85 | ->will($this->returnValue(new \ArrayIterator([]))); |
|
| 86 | ||
| 87 | $documentManager |
|
| 88 | ->expects($this->once()) |
|
| 89 | ->method('getUnitOfWork') |
|
| 90 | ->will($this->returnValue($this->createUnitOfWorkMock())); |
|
| 91 | ||
| 92 | $this->assertInstanceOf( |
|
| 93 | $repositoryClass, |
|
| 94 | $repository = $this->repositoryFactory->getRepository($documentManager, $documentName) |
|
| 95 | ); |
|
| 96 | ||
| 97 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
| 98 | } |
|
| 99 | ||
| 100 | public function testResourceRepository() |
|
| 101 | { |
|
| @@ 90-130 (lines=41) @@ | ||
| 87 | $this->assertInstanceOf(RepositoryFactory::class, $this->repositoryFactory); |
|
| 88 | } |
|
| 89 | ||
| 90 | public function testRepository() |
|
| 91 | { |
|
| 92 | $documentManager = $this->createDocumentManagerMock(); |
|
| 93 | $documentManager |
|
| 94 | ->expects($this->exactly(2)) |
|
| 95 | ->method('getClassMetadata') |
|
| 96 | ->with($this->identicalTo($documentName = 'document')) |
|
| 97 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 98 | ||
| 99 | $documentManager |
|
| 100 | ->expects($this->exactly(2)) |
|
| 101 | ->method('getConfiguration') |
|
| 102 | ->will($this->returnValue($configuration = $this->createConfigurationMock())); |
|
| 103 | ||
| 104 | $configuration |
|
| 105 | ->expects($this->exactly(2)) |
|
| 106 | ->method('getDefaultRepositoryClassName') |
|
| 107 | ->will($this->returnValue($repositoryClass = DocumentRepository::class)); |
|
| 108 | ||
| 109 | $classMetadata |
|
| 110 | ->expects($this->exactly(2)) |
|
| 111 | ->method('getName') |
|
| 112 | ->will($this->returnValue($documentName)); |
|
| 113 | ||
| 114 | $this->resourceRegistry |
|
| 115 | ->expects($this->once()) |
|
| 116 | ->method('getIterator') |
|
| 117 | ->will($this->returnValue(new \ArrayIterator([]))); |
|
| 118 | ||
| 119 | $documentManager |
|
| 120 | ->expects($this->once()) |
|
| 121 | ->method('getUnitOfWork') |
|
| 122 | ->will($this->returnValue($this->createUnitOfWorkMock())); |
|
| 123 | ||
| 124 | $this->assertInstanceOf( |
|
| 125 | $repositoryClass, |
|
| 126 | $repository = $this->repositoryFactory->getRepository($documentManager, $documentName) |
|
| 127 | ); |
|
| 128 | ||
| 129 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
| 130 | } |
|
| 131 | ||
| 132 | public function testResourceRepository() |
|
| 133 | { |
|