@@ 100-137 (lines=38) @@ | ||
97 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
98 | } |
|
99 | ||
100 | public function testResourceRepository() |
|
101 | { |
|
102 | $documentManager = $this->createDocumentManagerMock(); |
|
103 | $documentManager |
|
104 | ->expects($this->once()) |
|
105 | ->method('getClassMetadata') |
|
106 | ->with($this->identicalTo($documentName = 'document')) |
|
107 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
108 | ||
109 | $classMetadata |
|
110 | ->expects($this->once()) |
|
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([$resource = $this->createResourceMock()]))); |
|
118 | ||
119 | $resource |
|
120 | ->expects($this->once()) |
|
121 | ->method('getModel') |
|
122 | ->will($this->returnValue($documentName)); |
|
123 | ||
124 | $documentManager |
|
125 | ->expects($this->once()) |
|
126 | ->method('getUnitOfWork') |
|
127 | ->will($this->returnValue($this->createUnitOfWorkMock())); |
|
128 | ||
129 | $classMetadata->customRepositoryClassName = $repositoryClass = Repository::class; |
|
130 | ||
131 | $this->assertInstanceOf( |
|
132 | $repositoryClass, |
|
133 | $repository = $this->repositoryFactory->getRepository($documentManager, $documentName) |
|
134 | ); |
|
135 | ||
136 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
137 | } |
|
138 | ||
139 | /** |
|
140 | * @return \PHPUnit_Framework_MockObject_MockObject|RegistryInterface |
@@ 132-169 (lines=38) @@ | ||
129 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
130 | } |
|
131 | ||
132 | public function testResourceRepository() |
|
133 | { |
|
134 | $documentManager = $this->createDocumentManagerMock(); |
|
135 | $documentManager |
|
136 | ->expects($this->once()) |
|
137 | ->method('getClassMetadata') |
|
138 | ->with($this->identicalTo($documentName = 'document')) |
|
139 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
140 | ||
141 | $classMetadata |
|
142 | ->expects($this->once()) |
|
143 | ->method('getName') |
|
144 | ->will($this->returnValue($documentName)); |
|
145 | ||
146 | $this->resourceRegistry |
|
147 | ->expects($this->once()) |
|
148 | ->method('getIterator') |
|
149 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
150 | ||
151 | $resource |
|
152 | ->expects($this->once()) |
|
153 | ->method('getModel') |
|
154 | ->will($this->returnValue($documentName)); |
|
155 | ||
156 | $documentManager |
|
157 | ->expects($this->once()) |
|
158 | ->method('getUnitOfWork') |
|
159 | ->will($this->returnValue($this->createUnitOfWorkMock())); |
|
160 | ||
161 | $classMetadata->customRepositoryClassName = $repositoryClass = Repository::class; |
|
162 | ||
163 | $this->assertInstanceOf( |
|
164 | $repositoryClass, |
|
165 | $repository = $this->repositoryFactory->getRepository($documentManager, $documentName) |
|
166 | ); |
|
167 | ||
168 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
169 | } |
|
170 | ||
171 | public function testTranslatableRepository() |
|
172 | { |
|
@@ 171-208 (lines=38) @@ | ||
168 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
169 | } |
|
170 | ||
171 | public function testTranslatableRepository() |
|
172 | { |
|
173 | $documentManager = $this->createDocumentManagerMock(); |
|
174 | $documentManager |
|
175 | ->expects($this->once()) |
|
176 | ->method('getClassMetadata') |
|
177 | ->with($this->identicalTo($documentName = 'document')) |
|
178 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
179 | ||
180 | $classMetadata |
|
181 | ->expects($this->once()) |
|
182 | ->method('getName') |
|
183 | ->will($this->returnValue($documentName)); |
|
184 | ||
185 | $this->resourceRegistry |
|
186 | ->expects($this->once()) |
|
187 | ->method('getIterator') |
|
188 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
189 | ||
190 | $resource |
|
191 | ->expects($this->once()) |
|
192 | ->method('getModel') |
|
193 | ->will($this->returnValue($documentName)); |
|
194 | ||
195 | $documentManager |
|
196 | ->expects($this->once()) |
|
197 | ->method('getUnitOfWork') |
|
198 | ->will($this->returnValue($this->createUnitOfWorkMock())); |
|
199 | ||
200 | $classMetadata->customRepositoryClassName = $repositoryClass = TranslatableRepository::class; |
|
201 | ||
202 | $this->assertInstanceOf( |
|
203 | $repositoryClass, |
|
204 | $repository = $this->repositoryFactory->getRepository($documentManager, $documentName) |
|
205 | ); |
|
206 | ||
207 | $this->assertSame($repository, $this->repositoryFactory->getRepository($documentManager, $documentName)); |
|
208 | } |
|
209 | ||
210 | /** |
|
211 | * @return \PHPUnit_Framework_MockObject_MockObject|RegistryInterface |