|
31 | 31 |
|
32 | 32 | class AdapterTest extends TestCase
|
33 | 33 | {
|
34 |
| - /** @var MockObject */ |
| 34 | + /** @var MockObject&DriverInterface */ |
35 | 35 | protected $mockDriver;
|
36 | 36 |
|
37 |
| - /** @var MockObject */ |
| 37 | + /** @var MockObject&PlatformInterface */ |
38 | 38 | protected $mockPlatform;
|
39 | 39 |
|
40 |
| - /** @var MockObject */ |
| 40 | + /** @var MockObject&ConnectionInterface */ |
41 | 41 | protected $mockConnection;
|
42 | 42 |
|
43 |
| - /** @var MockObject */ |
| 43 | + /** @var MockObject&StatementInterface */ |
44 | 44 | protected $mockStatement;
|
45 | 45 |
|
46 | 46 | /** @var Adapter */
|
47 | 47 | protected $adapter;
|
48 | 48 |
|
49 | 49 | protected function setUp(): void
|
50 | 50 | {
|
51 |
| - $this->mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); |
52 |
| - $this->mockConnection = $this->getMockBuilder(ConnectionInterface::class)->getMock(); |
53 |
| - $this->mockDriver->expects($this->any())->method('checkEnvironment')->will($this->returnValue(true)); |
54 |
| - $this->mockDriver->expects($this->any())->method('getConnection') |
| 51 | + $this->mockDriver = $this->createMock(DriverInterface::class); |
| 52 | + $this->mockConnection = $this->createMock(ConnectionInterface::class); |
| 53 | + $this->mockDriver->method('checkEnvironment')->will($this->returnValue(true)); |
| 54 | + $this->mockDriver->method('getConnection') |
55 | 55 | ->will($this->returnValue($this->mockConnection));
|
56 |
| - $this->mockPlatform = $this->getMockBuilder(PlatformInterface::class)->getMock(); |
57 |
| - $this->mockStatement = $this->getMockBuilder(StatementInterface::class)->getMock(); |
58 |
| - $this->mockDriver->expects($this->any())->method('createStatement') |
| 56 | + $this->mockPlatform = $this->createMock(PlatformInterface::class); |
| 57 | + $this->mockStatement = $this->createMock(StatementInterface::class); |
| 58 | + $this->mockDriver->method('createStatement') |
59 | 59 | ->will($this->returnValue($this->mockStatement));
|
60 | 60 |
|
61 | 61 | $this->adapter = new Adapter($this->mockDriver, $this->mockPlatform);
|
@@ -222,6 +222,25 @@ public function testQueryWhenPreparedProducesStatement()
|
222 | 222 | self::assertSame($this->mockStatement, $s);
|
223 | 223 | }
|
224 | 224 |
|
| 225 | + /** @group #210 */ |
| 226 | + public function testProducedResultSetPrototypeIsDifferentForEachQuery() |
| 227 | + { |
| 228 | + $statement = $this->createMock(StatementInterface::class); |
| 229 | + $result = $this->createMock(ResultInterface::class); |
| 230 | + |
| 231 | + $this->mockDriver->method('createStatement') |
| 232 | + ->willReturn($statement); |
| 233 | + $this->mockStatement->method('execute') |
| 234 | + ->willReturn($result); |
| 235 | + $result->method('isQueryResult') |
| 236 | + ->willReturn(true); |
| 237 | + |
| 238 | + self::assertNotSame( |
| 239 | + $this->adapter->query('SELECT foo', []), |
| 240 | + $this->adapter->query('SELECT foo', []) |
| 241 | + ); |
| 242 | + } |
| 243 | + |
225 | 244 | /**
|
226 | 245 | * @testdox unit test: Test query() in prepare mode, with array of parameters, produces a result object
|
227 | 246 | * @covers \Laminas\Db\Adapter\Adapter::query
|
|
0 commit comments