| @@ 89-130 (lines=42) @@ | ||
| 86 | * @param mixed[]|null $params Connection parameters |
|
| 87 | * @return \PHPUnit_Framework_MockObject_MockObject |
|
| 88 | */ |
|
| 89 | private function getMockContainer($connectionName, $params = null) |
|
| 90 | { |
|
| 91 | // Mock the container and everything you'll need here |
|
| 92 | $mockDoctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ConnectionRegistry') |
|
| 93 | ->getMock(); |
|
| 94 | ||
| 95 | $mockDoctrine->expects($this->any()) |
|
| 96 | ->method('getDefaultConnectionName') |
|
| 97 | ->withAnyParameters() |
|
| 98 | ->willReturn($connectionName); |
|
| 99 | ||
| 100 | $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection') |
|
| 101 | ->disableOriginalConstructor() |
|
| 102 | ->setMethods(['getParams']) |
|
| 103 | ->getMockForAbstractClass(); |
|
| 104 | ||
| 105 | $mockConnection->expects($this->any()) |
|
| 106 | ->method('getParams') |
|
| 107 | ->withAnyParameters() |
|
| 108 | ->willReturn($params); |
|
| 109 | ||
| 110 | $mockDoctrine->expects($this->any()) |
|
| 111 | ->method('getConnection') |
|
| 112 | ->withAnyParameters() |
|
| 113 | ->willReturn($mockConnection); |
|
| 114 | ||
| 115 | $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container') |
|
| 116 | ->setMethods(['get']) |
|
| 117 | ->getMock(); |
|
| 118 | ||
| 119 | $mockContainer->expects($this->any()) |
|
| 120 | ->method('get') |
|
| 121 | ->with('doctrine') |
|
| 122 | ->willReturn($mockDoctrine); |
|
| 123 | ||
| 124 | return $mockContainer; |
|
| 125 | } |
|
| 126 | } |
|
| 127 | ||
| @@ 93-134 (lines=42) @@ | ||
| 90 | * @param array|null $params Connection parameters |
|
| 91 | * @return \PHPUnit_Framework_MockObject_MockObject |
|
| 92 | */ |
|
| 93 | private function getMockContainer($connectionName, $params = null) |
|
| 94 | { |
|
| 95 | // Mock the container and everything you'll need here |
|
| 96 | $mockDoctrine = $this->getMockBuilder('Doctrine\Common\Persistence\ConnectionRegistry') |
|
| 97 | ->getMock(); |
|
| 98 | ||
| 99 | $mockDoctrine->expects($this->any()) |
|
| 100 | ->method('getDefaultConnectionName') |
|
| 101 | ->withAnyParameters() |
|
| 102 | ->willReturn($connectionName); |
|
| 103 | ||
| 104 | $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection') |
|
| 105 | ->disableOriginalConstructor() |
|
| 106 | ->setMethods(array('getParams')) |
|
| 107 | ->getMockForAbstractClass(); |
|
| 108 | ||
| 109 | $mockConnection->expects($this->any()) |
|
| 110 | ->method('getParams') |
|
| 111 | ->withAnyParameters() |
|
| 112 | ->willReturn($params); |
|
| 113 | ||
| 114 | $mockDoctrine->expects($this->any()) |
|
| 115 | ->method('getConnection') |
|
| 116 | ->withAnyParameters() |
|
| 117 | ->willReturn($mockConnection); |
|
| 118 | ||
| 119 | $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container') |
|
| 120 | ->setMethods(array('get')) |
|
| 121 | ->getMock(); |
|
| 122 | ||
| 123 | $mockContainer->expects($this->any()) |
|
| 124 | ->method('get') |
|
| 125 | ->with('doctrine') |
|
| 126 | ->willReturn($mockDoctrine); |
|
| 127 | ||
| 128 | return $mockContainer; |
|
| 129 | } |
|
| 130 | } |
|