Skip to content

Commit 1eb94f9

Browse files
committed
NativeDriverConnectionInterface
1 parent 52a92af commit 1eb94f9

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture;
6+
7+
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;
8+
9+
interface NativeDriverConnectionInterface extends TracingDriverConnectionInterface
10+
{
11+
/**
12+
* @return object|resource
13+
*/
14+
public function getNativeConnection();
15+
}

tests/Tracing/Doctrine/DBAL/TracingDriverConnectionTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
use Doctrine\DBAL\Driver\Result as DriverResultInterface;
99
use Doctrine\DBAL\Driver\Statement as DriverStatementInterface;
1010
use Doctrine\DBAL\ParameterType;
11-
use PDO;
1211
use PHPUnit\Framework\MockObject\MockObject;
1312
use Sentry\SentryBundle\Tests\DoctrineTestCase;
13+
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\NativeDriverConnectionInterface;
1414
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnection;
1515
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement;
1616
use Sentry\State\HubInterface;
@@ -399,13 +399,16 @@ public function testGetWrappedConnection(): void
399399

400400
public function testGetNativeConnection(): void
401401
{
402-
$connection = new TracingDriverConnection($this->hub, $this->decoratedConnection, 'foo_platform', []);
402+
$nativeConnection = new class() {
403+
};
403404

404-
$this->decoratedConnection->expects($this->once())
405-
->method('getNativeConnection')
406-
->willReturn($this->createMock(PDO::class));
405+
$decoratedConnection = $this->createMock(NativeDriverConnectionInterface::class);
406+
$decoratedConnection->method('getNativeConnection')
407+
->willReturn($nativeConnection);
408+
409+
$connection = new TracingDriverConnection($this->hub, $decoratedConnection, 'foo_platform', []);
407410

408-
$this->assertSame($this->decoratedConnection, $connection->getNativeConnection());
411+
$this->assertSame($nativeConnection, $connection->getNativeConnection());
409412

410413
}
411414

tests/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnectionTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
use Doctrine\DBAL\Driver\Result;
99
use Doctrine\DBAL\Driver\Statement;
1010
use Doctrine\DBAL\ParameterType;
11-
use PDO;
1211
use PHPUnit\Framework\MockObject\MockObject;
1312
use Sentry\SentryBundle\Tests\DoctrineTestCase;
13+
use Sentry\SentryBundle\Tests\Tracing\Doctrine\DBAL\Fixture\NativeDriverConnectionInterface;
1414
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverConnectionInterface;
1515
use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection;
1616

@@ -260,12 +260,15 @@ public function testGetWrappedConnection(): void
260260

261261
public function testGetNativeConnection(): void
262262
{
263-
$nativeConnection = $this->createMock(PDO::class);
263+
$nativeConnection = new class() {
264+
};
264265

265-
$this->decoratedConnection->expects($this->once())
266-
->method('getNativeConnection')
266+
$decoratedConnection = $this->createMock(NativeDriverConnectionInterface::class);
267+
$decoratedConnection->method('getNativeConnection')
267268
->willReturn($nativeConnection);
268269

269-
$this->assertSame($nativeConnection, $this->connection->getWrappedConnection());
270+
$connection = new TracingServerInfoAwareDriverConnection($decoratedConnection);
271+
272+
$this->assertSame($nativeConnection, $connection->getNativeConnection());
270273
}
271274
}

0 commit comments

Comments
 (0)