|
2 | 2 |
|
3 | 3 | namespace Doctrine\DBAL\Tests;
|
4 | 4 |
|
| 5 | +use BadMethodCallException; |
5 | 6 | use Doctrine\Common\EventManager;
|
6 | 7 | use Doctrine\DBAL\Cache\QueryCacheProfile;
|
7 | 8 | use Doctrine\DBAL\Configuration;
|
8 | 9 | use Doctrine\DBAL\Connection;
|
9 | 10 | use Doctrine\DBAL\ConnectionException;
|
10 | 11 | use Doctrine\DBAL\Driver;
|
| 12 | +use Doctrine\DBAL\Driver\API\ExceptionConverter; |
11 | 13 | use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
12 | 14 | use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
13 | 15 | use Doctrine\DBAL\DriverManager;
|
@@ -81,6 +83,46 @@ public function testNoTransactionActiveByDefault(): void
|
81 | 83 | self::assertFalse($this->connection->isTransactionActive());
|
82 | 84 | }
|
83 | 85 |
|
| 86 | + public function testSetNestTransactionsWithSavepointsDoesNotConnect(): void |
| 87 | + { |
| 88 | + $this->expectNotToPerformAssertions(); |
| 89 | + |
| 90 | + $connection = new Connection( |
| 91 | + [], |
| 92 | + new class implements VersionAwarePlatformDriver { |
| 93 | + /** {@inheritDoc} */ |
| 94 | + public function connect(array $params): DriverConnection |
| 95 | + { |
| 96 | + throw new BadMethodCallException('The connection must not be opened'); |
| 97 | + } |
| 98 | + |
| 99 | + public function getDatabasePlatform(): AbstractPlatform |
| 100 | + { |
| 101 | + throw new BadMethodCallException('The connection must not be opened'); |
| 102 | + } |
| 103 | + |
| 104 | + public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager |
| 105 | + { |
| 106 | + throw new BadMethodCallException('The connection must not be opened'); |
| 107 | + } |
| 108 | + |
| 109 | + public function getExceptionConverter(): ExceptionConverter |
| 110 | + { |
| 111 | + throw new BadMethodCallException('The connection must not be opened'); |
| 112 | + } |
| 113 | + |
| 114 | + /** {@inheritDoc} */ |
| 115 | + public function createDatabasePlatformForVersion($version): AbstractPlatform |
| 116 | + { |
| 117 | + throw new BadMethodCallException('The connection must not be opened'); |
| 118 | + } |
| 119 | + }, |
| 120 | + new Configuration(), |
| 121 | + ); |
| 122 | + |
| 123 | + $connection->setNestTransactionsWithSavepoints(true); |
| 124 | + } |
| 125 | + |
84 | 126 | public function testCommitWithNoActiveTransactionThrowsException(): void
|
85 | 127 | {
|
86 | 128 | $this->expectException(ConnectionException::class);
|
|
0 commit comments