| @@ 62-101 (lines=40) @@ | ||
| 59 | $this->assertSame([Events::loadClassMetadata], $this->resourceSubscriber->getSubscribedEvents()); |
|
| 60 | } |
|
| 61 | ||
| 62 | public function testLoadClassMetadataWithResourceAndNoParentClasses() |
|
| 63 | { |
|
| 64 | $event = $this->createLoadClassMetadataEventArgsMock(); |
|
| 65 | $event |
|
| 66 | ->expects($this->once()) |
|
| 67 | ->method('getClassMetadata') |
|
| 68 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 69 | ||
| 70 | $classMetadata |
|
| 71 | ->expects($this->once()) |
|
| 72 | ->method('getName') |
|
| 73 | ->will($this->returnValue($model = 'model')); |
|
| 74 | ||
| 75 | $this->serviceRegistry |
|
| 76 | ->expects($this->once()) |
|
| 77 | ->method('getIterator') |
|
| 78 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
| 79 | ||
| 80 | $resource |
|
| 81 | ->expects($this->once()) |
|
| 82 | ->method('getModel') |
|
| 83 | ->will($this->returnValue($model)); |
|
| 84 | ||
| 85 | $resource |
|
| 86 | ->expects($this->once()) |
|
| 87 | ->method('getRepository') |
|
| 88 | ->will($this->returnValue($repository = 'repository')); |
|
| 89 | ||
| 90 | $classMetadata |
|
| 91 | ->expects($this->once()) |
|
| 92 | ->method('setCustomRepositoryClass') |
|
| 93 | ->with($this->identicalTo($repository)); |
|
| 94 | ||
| 95 | $classMetadata->parentClasses = []; |
|
| 96 | $classMetadata->isMappedSuperclass = false; |
|
| 97 | ||
| 98 | $this->resourceSubscriber->loadClassMetadata($event); |
|
| 99 | ||
| 100 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 101 | } |
|
| 102 | ||
| 103 | public function testLoadClassMetadataWithResourceAndParentClassesWithoutInheritance() |
|
| 104 | { |
|
| @@ 58-97 (lines=40) @@ | ||
| 55 | $this->assertSame([Events::loadClassMetadata], $this->resourceSubscriber->getSubscribedEvents()); |
|
| 56 | } |
|
| 57 | ||
| 58 | public function testLoadClassMetadataWithResourceAndNoParentClasses() |
|
| 59 | { |
|
| 60 | $event = $this->createLoadClassMetadataEventArgsMock(); |
|
| 61 | $event |
|
| 62 | ->expects($this->once()) |
|
| 63 | ->method('getClassMetadata') |
|
| 64 | ->will($this->returnValue($classMetadata = $this->createClassMetadataMock())); |
|
| 65 | ||
| 66 | $classMetadata |
|
| 67 | ->expects($this->once()) |
|
| 68 | ->method('getName') |
|
| 69 | ->will($this->returnValue($model = 'model')); |
|
| 70 | ||
| 71 | $this->serviceRegistry |
|
| 72 | ->expects($this->once()) |
|
| 73 | ->method('getIterator') |
|
| 74 | ->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()]))); |
|
| 75 | ||
| 76 | $resource |
|
| 77 | ->expects($this->once()) |
|
| 78 | ->method('getModel') |
|
| 79 | ->will($this->returnValue($model)); |
|
| 80 | ||
| 81 | $resource |
|
| 82 | ->expects($this->once()) |
|
| 83 | ->method('getRepository') |
|
| 84 | ->will($this->returnValue($repository = 'repository')); |
|
| 85 | ||
| 86 | $classMetadata |
|
| 87 | ->expects($this->once()) |
|
| 88 | ->method('setCustomRepositoryClass') |
|
| 89 | ->with($this->identicalTo($repository)); |
|
| 90 | ||
| 91 | $classMetadata->parentClasses = []; |
|
| 92 | $classMetadata->isMappedSuperclass = false; |
|
| 93 | ||
| 94 | $this->resourceSubscriber->loadClassMetadata($event); |
|
| 95 | ||
| 96 | $this->assertFalse($classMetadata->isMappedSuperclass); |
|
| 97 | } |
|
| 98 | ||
| 99 | public function testLoadClassMetadataWithResourceAndParentClassesWithoutInheritance() |
|
| 100 | { |
|