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