Skip to content

Commit

Permalink
Merge pull request #732 from cakephp/add-decorated-connection
Browse files Browse the repository at this point in the history
Add getDecoratedConnection to 4.x
  • Loading branch information
markstory authored Jul 30, 2024
2 parents 812e285 + b8f367b commit ff26043
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/Db/Adapter/PdoAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ public function getConnection(): Connection
return $this->connection;
}

/**
* Backwards compatibility shim for migrations 3.x
*
* @return \Cake\Database\Connection
*/
public function getDecoratedConnection(): Connection
{
return $this->getConnection();
}

/**
* @inheritDoc
*/
Expand Down
6 changes: 4 additions & 2 deletions tests/TestCase/Db/Adapter/SqliteAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ protected function tearDown(): void
unset($this->adapter, $this->out, $this->io);
}

public function testConnection()
public function testGetConnection()
{
$this->assertInstanceOf(Connection::class, $this->adapter->getConnection());
$connection = $this->adapter->getConnection();
$this->assertInstanceOf(Connection::class, $connection);
$this->assertSame($connection, $this->adapter->getDecoratedConnection());
}

public function testBeginTransaction()
Expand Down

0 comments on commit ff26043

Please sign in to comment.