@@ 90-122 (lines=33) @@ | ||
87 | $this->assertSame($repository, $this->repositoryFactory->getRepository($entityManager, $entityName)); |
|
88 | } |
|
89 | ||
90 | public function testResourceRepository() |
|
91 | { |
|
92 | $entityManager = $this->createEntityManagerMock(); |
|
93 | $entityManager |
|
94 | ->expects($this->exactly(3)) |
|
95 | ->method('getClassMetadata') |
|
96 | ->with($this->identicalTo($entityName = 'entity')) |
|
97 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
98 | ||
99 | $classMetadata |
|
100 | ->expects($this->exactly(3)) |
|
101 | ->method('getName') |
|
102 | ->will($this->returnValue($entityName)); |
|
103 | ||
104 | $this->resourceRegistry |
|
105 | ->expects($this->once()) |
|
106 | ->method('getIterator') |
|
107 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
108 | ||
109 | $resource |
|
110 | ->expects($this->once()) |
|
111 | ->method('getModel') |
|
112 | ->will($this->returnValue($entityName)); |
|
113 | ||
114 | $classMetadata->customRepositoryClassName = $repositoryClass = Repository::class; |
|
115 | ||
116 | $this->assertInstanceOf( |
|
117 | $repositoryClass, |
|
118 | $repository = $this->repositoryFactory->getRepository($entityManager, $entityName) |
|
119 | ); |
|
120 | ||
121 | $this->assertSame($repository, $this->repositoryFactory->getRepository($entityManager, $entityName)); |
|
122 | } |
|
123 | ||
124 | /** |
|
125 | * @return \PHPUnit_Framework_MockObject_MockObject|RegistryInterface |
@@ 122-154 (lines=33) @@ | ||
119 | $this->assertSame($repository, $this->repositoryFactory->getRepository($entityManager, $entityName)); |
|
120 | } |
|
121 | ||
122 | public function testResourceRepository() |
|
123 | { |
|
124 | $entityManager = $this->createEntityManagerMock(); |
|
125 | $entityManager |
|
126 | ->expects($this->exactly(3)) |
|
127 | ->method('getClassMetadata') |
|
128 | ->with($this->identicalTo($entityName = 'entity')) |
|
129 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
130 | ||
131 | $classMetadata |
|
132 | ->expects($this->exactly(3)) |
|
133 | ->method('getName') |
|
134 | ->will($this->returnValue($model = 'name')); |
|
135 | ||
136 | $this->resourceRegistry |
|
137 | ->expects($this->once()) |
|
138 | ->method('getIterator') |
|
139 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
140 | ||
141 | $resource |
|
142 | ->expects($this->once()) |
|
143 | ->method('getModel') |
|
144 | ->will($this->returnValue($model)); |
|
145 | ||
146 | $classMetadata->customRepositoryClassName = $repositoryClass = Repository::class; |
|
147 | ||
148 | $this->assertInstanceOf( |
|
149 | $repositoryClass, |
|
150 | $repository = $this->repositoryFactory->getRepository($entityManager, $entityName) |
|
151 | ); |
|
152 | ||
153 | $this->assertSame($repository, $this->repositoryFactory->getRepository($entityManager, $entityName)); |
|
154 | } |
|
155 | ||
156 | public function testTranslatableRepository() |
|
157 | { |
|
@@ 156-188 (lines=33) @@ | ||
153 | $this->assertSame($repository, $this->repositoryFactory->getRepository($entityManager, $entityName)); |
|
154 | } |
|
155 | ||
156 | public function testTranslatableRepository() |
|
157 | { |
|
158 | $entityManager = $this->createEntityManagerMock(); |
|
159 | $entityManager |
|
160 | ->expects($this->exactly(3)) |
|
161 | ->method('getClassMetadata') |
|
162 | ->with($this->identicalTo($entityName = 'entity')) |
|
163 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
164 | ||
165 | $classMetadata |
|
166 | ->expects($this->exactly(3)) |
|
167 | ->method('getName') |
|
168 | ->will($this->returnValue($model = 'name')); |
|
169 | ||
170 | $this->resourceRegistry |
|
171 | ->expects($this->once()) |
|
172 | ->method('getIterator') |
|
173 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
174 | ||
175 | $resource |
|
176 | ->expects($this->once()) |
|
177 | ->method('getModel') |
|
178 | ->will($this->returnValue($model)); |
|
179 | ||
180 | $classMetadata->customRepositoryClassName = $repositoryClass = TranslatableRepository::class; |
|
181 | ||
182 | $this->assertInstanceOf( |
|
183 | $repositoryClass, |
|
184 | $repository = $this->repositoryFactory->getRepository($entityManager, $entityName) |
|
185 | ); |
|
186 | ||
187 | $this->assertSame($repository, $this->repositoryFactory->getRepository($entityManager, $entityName)); |
|
188 | } |
|
189 | ||
190 | /** |
|
191 | * @return \PHPUnit_Framework_MockObject_MockObject|RegistryInterface |