| @@ 103-156 (lines=54) @@ | ||
| 100 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 101 | } |
|
| 102 | ||
| 103 | public function testLoadClassMetadataWithResourceAndParentClassesWithoutInheritance() |
|
| 104 | { |
|
| 105 | $event = $this->createLoadClassMetadataEventArgsMock(); |
|
| 106 | $event |
|
| 107 | ->expects($this->once()) |
|
| 108 | ->method('getClassMetadata') |
|
| 109 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 110 | ||
| 111 | $classMetadata |
|
| 112 | ->expects($this->once()) |
|
| 113 | ->method('getName') |
|
| 114 | ->will($this->returnValue($model = 'model')); |
|
| 115 | ||
| 116 | $this->serviceRegistry |
|
| 117 | ->expects($this->once()) |
|
| 118 | ->method('getIterator') |
|
| 119 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
| 120 | ||
| 121 | $resource |
|
| 122 | ->expects($this->once()) |
|
| 123 | ->method('getModel') |
|
| 124 | ->will($this->returnValue($model)); |
|
| 125 | ||
| 126 | $classMetadata->parentClasses = [$parentClass = 'ParentClass']; |
|
| 127 | ||
| 128 | $event |
|
| 129 | ->expects($this->once()) |
|
| 130 | ->method('getObjectManager') |
|
| 131 | ->will($this->returnValue($objectManager = $this->createObjectManagerMock())); |
|
| 132 | ||
| 133 | $objectManager |
|
| 134 | ->expects($this->once()) |
|
| 135 | ->method('getClassMetadata') |
|
| 136 | ->with($this->identicalTo($parentClass)) |
|
| 137 | ->will($this->returnValue($parentMetadata = $this->createClassMetadataMock())); |
|
| 138 | ||
| 139 | $parentMetadata->isMappedSuperclass = false; |
|
| 140 | $parentMetadata->inheritanceType = ClassMetadata::INHERITANCE_TYPE_NONE; |
|
| 141 | ||
| 142 | $resource |
|
| 143 | ->expects($this->once()) |
|
| 144 | ->method('getRepository') |
|
| 145 | ->will($this->returnValue($repository = 'repository')); |
|
| 146 | ||
| 147 | $classMetadata |
|
| 148 | ->expects($this->once()) |
|
| 149 | ->method('setCustomRepositoryClass') |
|
| 150 | ->with($this->identicalTo($repository)); |
|
| 151 | ||
| 152 | $this->resourceSubscriber->loadClassMetadata($event); |
|
| 153 | ||
| 154 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 155 | $this->assertTrue($parentMetadata->isMappedSuperclass); |
|
| 156 | } |
|
| 157 | ||
| 158 | public function testLoadClassMetadataWithResourceAndParentClassesWithInheritance() |
|
| 159 | { |
|
| @@ 158-211 (lines=54) @@ | ||
| 155 | $this->assertTrue($parentMetadata->isMappedSuperclass); |
|
| 156 | } |
|
| 157 | ||
| 158 | public function testLoadClassMetadataWithResourceAndParentClassesWithInheritance() |
|
| 159 | { |
|
| 160 | $event = $this->createLoadClassMetadataEventArgsMock(); |
|
| 161 | $event |
|
| 162 | ->expects($this->once()) |
|
| 163 | ->method('getClassMetadata') |
|
| 164 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 165 | ||
| 166 | $classMetadata |
|
| 167 | ->expects($this->once()) |
|
| 168 | ->method('getName') |
|
| 169 | ->will($this->returnValue($model = 'model')); |
|
| 170 | ||
| 171 | $this->serviceRegistry |
|
| 172 | ->expects($this->once()) |
|
| 173 | ->method('getIterator') |
|
| 174 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
| 175 | ||
| 176 | $resource |
|
| 177 | ->expects($this->once()) |
|
| 178 | ->method('getModel') |
|
| 179 | ->will($this->returnValue($model)); |
|
| 180 | ||
| 181 | $classMetadata->parentClasses = [$parentClass = 'ParentClass']; |
|
| 182 | ||
| 183 | $event |
|
| 184 | ->expects($this->once()) |
|
| 185 | ->method('getObjectManager') |
|
| 186 | ->will($this->returnValue($objectManager = $this->createObjectManagerMock())); |
|
| 187 | ||
| 188 | $objectManager |
|
| 189 | ->expects($this->once()) |
|
| 190 | ->method('getClassMetadata') |
|
| 191 | ->with($this->identicalTo($parentClass)) |
|
| 192 | ->will($this->returnValue($parentMetadata = $this->createClassMetadataMock())); |
|
| 193 | ||
| 194 | $parentMetadata->isMappedSuperclass = false; |
|
| 195 | $parentMetadata->inheritanceType = ClassMetadata::INHERITANCE_TYPE_SINGLE_COLLECTION; |
|
| 196 | ||
| 197 | $resource |
|
| 198 | ->expects($this->once()) |
|
| 199 | ->method('getRepository') |
|
| 200 | ->will($this->returnValue($repository = 'repository')); |
|
| 201 | ||
| 202 | $classMetadata |
|
| 203 | ->expects($this->once()) |
|
| 204 | ->method('setCustomRepositoryClass') |
|
| 205 | ->with($this->identicalTo($repository)); |
|
| 206 | ||
| 207 | $this->resourceSubscriber->loadClassMetadata($event); |
|
| 208 | ||
| 209 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 210 | $this->assertFalse($parentMetadata->isMappedSuperclass); |
|
| 211 | } |
|
| 212 | ||
| 213 | public function testLoadClassMetadataWithResourceAndParentClassesWithoutClassMetadata() |
|
| 214 | { |
|
| @@ 99-152 (lines=54) @@ | ||
| 96 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 97 | } |
|
| 98 | ||
| 99 | public function testLoadClassMetadataWithResourceAndParentClassesWithoutInheritance() |
|
| 100 | { |
|
| 101 | $event = $this->createLoadClassMetadataEventArgsMock(); |
|
| 102 | $event |
|
| 103 | ->expects($this->once()) |
|
| 104 | ->method('getClassMetadata') |
|
| 105 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 106 | ||
| 107 | $classMetadata |
|
| 108 | ->expects($this->once()) |
|
| 109 | ->method('getName') |
|
| 110 | ->will($this->returnValue($model = 'model')); |
|
| 111 | ||
| 112 | $this->serviceRegistry |
|
| 113 | ->expects($this->once()) |
|
| 114 | ->method('getIterator') |
|
| 115 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
| 116 | ||
| 117 | $resource |
|
| 118 | ->expects($this->once()) |
|
| 119 | ->method('getModel') |
|
| 120 | ->will($this->returnValue($model)); |
|
| 121 | ||
| 122 | $classMetadata->parentClasses = [$parentClass = 'ParentClass']; |
|
| 123 | ||
| 124 | $event |
|
| 125 | ->expects($this->once()) |
|
| 126 | ->method('getObjectManager') |
|
| 127 | ->will($this->returnValue($objectManager = $this->createObjectManagerMock())); |
|
| 128 | ||
| 129 | $objectManager |
|
| 130 | ->expects($this->once()) |
|
| 131 | ->method('getClassMetadata') |
|
| 132 | ->with($this->identicalTo($parentClass)) |
|
| 133 | ->will($this->returnValue($parentMetadata = $this->createClassMetadataMock())); |
|
| 134 | ||
| 135 | $parentMetadata->isMappedSuperclass = false; |
|
| 136 | $parentMetadata->inheritanceType = ClassMetadata::INHERITANCE_TYPE_NONE; |
|
| 137 | ||
| 138 | $resource |
|
| 139 | ->expects($this->once()) |
|
| 140 | ->method('getRepository') |
|
| 141 | ->will($this->returnValue($repository = 'repository')); |
|
| 142 | ||
| 143 | $classMetadata |
|
| 144 | ->expects($this->once()) |
|
| 145 | ->method('setCustomRepositoryClass') |
|
| 146 | ->with($this->identicalTo($repository)); |
|
| 147 | ||
| 148 | $this->resourceSubscriber->loadClassMetadata($event); |
|
| 149 | ||
| 150 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 151 | $this->assertTrue($parentMetadata->isMappedSuperclass); |
|
| 152 | } |
|
| 153 | ||
| 154 | public function testLoadClassMetadataWithResourceAndParentClassesWithInheritance() |
|
| 155 | { |
|
| @@ 154-207 (lines=54) @@ | ||
| 151 | $this->assertTrue($parentMetadata->isMappedSuperclass); |
|
| 152 | } |
|
| 153 | ||
| 154 | public function testLoadClassMetadataWithResourceAndParentClassesWithInheritance() |
|
| 155 | { |
|
| 156 | $event = $this->createLoadClassMetadataEventArgsMock(); |
|
| 157 | $event |
|
| 158 | ->expects($this->once()) |
|
| 159 | ->method('getClassMetadata') |
|
| 160 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 161 | ||
| 162 | $classMetadata |
|
| 163 | ->expects($this->once()) |
|
| 164 | ->method('getName') |
|
| 165 | ->will($this->returnValue($model = 'model')); |
|
| 166 | ||
| 167 | $this->serviceRegistry |
|
| 168 | ->expects($this->once()) |
|
| 169 | ->method('getIterator') |
|
| 170 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
| 171 | ||
| 172 | $resource |
|
| 173 | ->expects($this->once()) |
|
| 174 | ->method('getModel') |
|
| 175 | ->will($this->returnValue($model)); |
|
| 176 | ||
| 177 | $classMetadata->parentClasses = [$parentClass = 'ParentClass']; |
|
| 178 | ||
| 179 | $event |
|
| 180 | ->expects($this->once()) |
|
| 181 | ->method('getObjectManager') |
|
| 182 | ->will($this->returnValue($objectManager = $this->createObjectManagerMock())); |
|
| 183 | ||
| 184 | $objectManager |
|
| 185 | ->expects($this->once()) |
|
| 186 | ->method('getClassMetadata') |
|
| 187 | ->with($this->identicalTo($parentClass)) |
|
| 188 | ->will($this->returnValue($parentMetadata = $this->createClassMetadataMock())); |
|
| 189 | ||
| 190 | $parentMetadata->isMappedSuperclass = false; |
|
| 191 | $parentMetadata->inheritanceType = ClassMetadata::INHERITANCE_TYPE_SINGLE_TABLE; |
|
| 192 | ||
| 193 | $resource |
|
| 194 | ->expects($this->once()) |
|
| 195 | ->method('getRepository') |
|
| 196 | ->will($this->returnValue($repository = 'repository')); |
|
| 197 | ||
| 198 | $classMetadata |
|
| 199 | ->expects($this->once()) |
|
| 200 | ->method('setCustomRepositoryClass') |
|
| 201 | ->with($this->identicalTo($repository)); |
|
| 202 | ||
| 203 | $this->resourceSubscriber->loadClassMetadata($event); |
|
| 204 | ||
| 205 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 206 | $this->assertFalse($parentMetadata->isMappedSuperclass); |
|
| 207 | } |
|
| 208 | ||
| 209 | public function testLoadClassMetadataWithResourceAndParentClassesWithoutClassMetadata() |
|
| 210 | { |
|