| @@ 147-183 (lines=37) @@ | ||
| 144 | /** | |
| 145 | * @param array|null $params Connection parameters | |
| 146 | */ | |
| 147 | private function getMockContainer(string $connectionName, array $params = null) : MockObject | |
| 148 |     { | |
| 149 | // Mock the container and everything you'll need here | |
| 150 |         $mockDoctrine = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry') | |
| 151 | ->getMock(); | |
| 152 | ||
| 153 | $mockDoctrine->expects($this->any()) | |
| 154 |             ->method('getDefaultConnectionName') | |
| 155 | ->withAnyParameters() | |
| 156 | ->willReturn($connectionName); | |
| 157 | ||
| 158 |         $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection') | |
| 159 | ->disableOriginalConstructor() | |
| 160 | ->setMethods(['getParams']) | |
| 161 | ->getMockForAbstractClass(); | |
| 162 | ||
| 163 | $mockConnection->expects($this->any()) | |
| 164 |             ->method('getParams') | |
| 165 | ->withAnyParameters() | |
| 166 | ->willReturn($params); | |
| 167 | ||
| 168 | $mockDoctrine->expects($this->any()) | |
| 169 |             ->method('getConnection') | |
| 170 | ->withAnyParameters() | |
| 171 | ->willReturn($mockConnection); | |
| 172 | ||
| 173 |         $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container') | |
| 174 | ->setMethods(['get']) | |
| 175 | ->getMock(); | |
| 176 | ||
| 177 | $mockContainer->expects($this->any()) | |
| 178 |             ->method('get') | |
| 179 |             ->with('doctrine') | |
| 180 | ->willReturn($mockDoctrine); | |
| 181 | ||
| 182 | return $mockContainer; | |
| 183 | } | |
| 184 | } | |
| 185 | ||
| @@ 104-140 (lines=37) @@ | ||
| 101 | /** | |
| 102 | * @param mixed[]|null $params Connection parameters | |
| 103 | */ | |
| 104 | private function getMockContainer(string $connectionName, array $params = null) : MockObject | |
| 105 |     { | |
| 106 | // Mock the container and everything you'll need here | |
| 107 |         $mockDoctrine = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry') | |
| 108 | ->getMock(); | |
| 109 | ||
| 110 | $mockDoctrine->expects($this->any()) | |
| 111 |             ->method('getDefaultConnectionName') | |
| 112 | ->withAnyParameters() | |
| 113 | ->willReturn($connectionName); | |
| 114 | ||
| 115 |         $mockConnection = $this->getMockBuilder('Doctrine\DBAL\Connection') | |
| 116 | ->disableOriginalConstructor() | |
| 117 | ->setMethods(['getParams']) | |
| 118 | ->getMockForAbstractClass(); | |
| 119 | ||
| 120 | $mockConnection->expects($this->any()) | |
| 121 |             ->method('getParams') | |
| 122 | ->withAnyParameters() | |
| 123 | ->willReturn($params); | |
| 124 | ||
| 125 | $mockDoctrine->expects($this->any()) | |
| 126 |             ->method('getConnection') | |
| 127 | ->withAnyParameters() | |
| 128 | ->willReturn($mockConnection); | |
| 129 | ||
| 130 |         $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container') | |
| 131 | ->setMethods(['get']) | |
| 132 | ->getMock(); | |
| 133 | ||
| 134 | $mockContainer->expects($this->any()) | |
| 135 |             ->method('get') | |
| 136 |             ->with('doctrine') | |
| 137 | ->willReturn($mockDoctrine); | |
| 138 | ||
| 139 | return $mockContainer; | |
| 140 | } | |
| 141 | } | |
| 142 | ||