From 35787755349fcc0307f778283bad1f697967204c Mon Sep 17 00:00:00 2001 From: Alejandro Ibarra Date: Fri, 7 Jun 2024 08:57:02 +0200 Subject: [PATCH 1/2] 2288 - Add migration version and name to pending actions error --- src/Phinx/Migration/AbstractMigration.php | 2 +- tests/Phinx/Migration/AbstractMigrationTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Phinx/Migration/AbstractMigration.php b/src/Phinx/Migration/AbstractMigration.php index 9cecf0c7e..050480f59 100644 --- a/src/Phinx/Migration/AbstractMigration.php +++ b/src/Phinx/Migration/AbstractMigration.php @@ -358,7 +358,7 @@ public function postFlightCheck(): void { foreach ($this->tables as $table) { if ($table->hasPendingActions()) { - throw new RuntimeException('Migration has pending actions after execution!'); + throw new RuntimeException(sprintf('Migration %s_%s has pending actions after execution!', $this->getVersion(), $this->getName())); } } } diff --git a/tests/Phinx/Migration/AbstractMigrationTest.php b/tests/Phinx/Migration/AbstractMigrationTest.php index 6304fb68b..dd095f2d9 100644 --- a/tests/Phinx/Migration/AbstractMigrationTest.php +++ b/tests/Phinx/Migration/AbstractMigrationTest.php @@ -280,7 +280,7 @@ public function testPostFlightCheckFail() $table->addColumn('column1', 'integer', ['null' => true]); $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Migration has pending actions after execution!'); + $this->expectExceptionMessage(sprintf('Migration %s_%s has pending actions after execution!', $migrationStub->getVersion(), $migrationStub->getName())); $migrationStub->postFlightCheck(); } From aef52b4ee19b4fb4465ecc3606b79193fd95cecf Mon Sep 17 00:00:00 2001 From: Alejandro Ibarra Date: Mon, 10 Jun 2024 09:53:46 +0200 Subject: [PATCH 2/2] 2288 - Update postFlightCheckFail test to remove dynamic message --- tests/Phinx/Migration/AbstractMigrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Phinx/Migration/AbstractMigrationTest.php b/tests/Phinx/Migration/AbstractMigrationTest.php index dd095f2d9..1af5e2121 100644 --- a/tests/Phinx/Migration/AbstractMigrationTest.php +++ b/tests/Phinx/Migration/AbstractMigrationTest.php @@ -265,7 +265,7 @@ public function testTableMethod() public function testPostFlightCheckFail() { // stub migration - $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', ['mockenv', 20230102030405]); + $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', ['mockenv', 20230102030405], 'PostFlightCheck'); $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') ->setConstructorArgs([[]]) @@ -280,7 +280,7 @@ public function testPostFlightCheckFail() $table->addColumn('column1', 'integer', ['null' => true]); $this->expectException(RuntimeException::class); - $this->expectExceptionMessage(sprintf('Migration %s_%s has pending actions after execution!', $migrationStub->getVersion(), $migrationStub->getName())); + $this->expectExceptionMessage('Migration 20230102030405_PostFlightCheck has pending actions after execution!'); $migrationStub->postFlightCheck(); }