From b8f367bb534006398fede3fd1b519c446fe34b71 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 28 Jul 2024 19:16:37 -0400 Subject: [PATCH] Add getDecoratedConnection to 4.x Having this method will improve compatibility with historical migrations. Refs #651 --- src/Db/Adapter/PdoAdapter.php | 10 ++++++++++ tests/TestCase/Db/Adapter/SqliteAdapterTest.php | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Db/Adapter/PdoAdapter.php b/src/Db/Adapter/PdoAdapter.php index eab82677..55570ef8 100644 --- a/src/Db/Adapter/PdoAdapter.php +++ b/src/Db/Adapter/PdoAdapter.php @@ -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 */ diff --git a/tests/TestCase/Db/Adapter/SqliteAdapterTest.php b/tests/TestCase/Db/Adapter/SqliteAdapterTest.php index 593c1d49..36e78af1 100644 --- a/tests/TestCase/Db/Adapter/SqliteAdapterTest.php +++ b/tests/TestCase/Db/Adapter/SqliteAdapterTest.php @@ -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()