From 8fb0c2a2f56064bf638734c56128e8983dc97008 Mon Sep 17 00:00:00 2001 From: Lubos Remplik Date: Thu, 24 May 2018 13:58:07 +0200 Subject: [PATCH 1/4] Using Shell::abort instead of error as it is deprecated --- src/Shell/Task/MigrationDiffTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Shell/Task/MigrationDiffTask.php b/src/Shell/Task/MigrationDiffTask.php index 71a54f2d..5df73c56 100644 --- a/src/Shell/Task/MigrationDiffTask.php +++ b/src/Shell/Task/MigrationDiffTask.php @@ -102,7 +102,7 @@ public function bake($name) $this->setup(); if (!$this->checkSync()) { - $this->error('Your migrations history is not in sync with your migrations files. ' . + $this->abort('Your migrations history is not in sync with your migrations files. ' . 'Make sure all your migrations have been migrated before baking a diff.'); return 1; @@ -445,7 +445,7 @@ protected function bakeSnapshot($name) ]); if ($dispatch === 1) { - $this->error('Something went wrong during the snapshot baking. Please try again.'); + $this->abort('Something went wrong during the snapshot baking. Please try again.'); } return $dispatch; @@ -479,7 +479,7 @@ protected function getDumpSchema() if (!file_exists($path)) { $msg = 'Unable to retrieve the schema dump file. You can create a dump file using ' . 'the `cake migrations dump` command'; - $this->error($msg); + $this->abort($msg); } return unserialize(file_get_contents($path)); From 2e30e4cfc885e2b12b4a2977da42364dd0f58b46 Mon Sep 17 00:00:00 2001 From: Lubos Remplik Date: Thu, 24 May 2018 14:02:31 +0200 Subject: [PATCH 2/4] More Shell::abort replaces --- src/Shell/Task/MigrationTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shell/Task/MigrationTask.php b/src/Shell/Task/MigrationTask.php index 94698d19..fd746a10 100644 --- a/src/Shell/Task/MigrationTask.php +++ b/src/Shell/Task/MigrationTask.php @@ -82,7 +82,7 @@ public function templateData() $primaryKey = $columnParser->parsePrimaryKey($arguments); if (in_array($action[0], ['alter_table', 'add_field']) && !empty($primaryKey)) { - $this->error('Adding a primary key to an already existing table is not supported.'); + $this->abort('Adding a primary key to an already existing table is not supported.'); } list($action, $table) = $action; From 923beca1318caf9195101680686b84b6fbae6b7f Mon Sep 17 00:00:00 2001 From: Lubos Remplik Date: Thu, 24 May 2018 15:41:30 +0200 Subject: [PATCH 3/4] Shell::abort fixing tests --- tests/TestCase/Shell/Task/MigrationDiffTaskTest.php | 10 +++++----- tests/TestCase/Shell/Task/MigrationTaskTest.php | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/TestCase/Shell/Task/MigrationDiffTaskTest.php b/tests/TestCase/Shell/Task/MigrationDiffTaskTest.php index 0c095188..f48b45b9 100644 --- a/tests/TestCase/Shell/Task/MigrationDiffTaskTest.php +++ b/tests/TestCase/Shell/Task/MigrationDiffTaskTest.php @@ -77,14 +77,14 @@ public function getTaskMock($mockedMethods = []) */ public function testHistoryNotInSync() { - $this->Task = $this->getTaskMock(['error']); + $this->Task = $this->getTaskMock(['abort']); $this->Task->params['require-table'] = false; $this->Task->params['connection'] = 'test'; $expectedMessage = 'Your migrations history is not in sync with your migrations files. ' . 'Make sure all your migrations have been migrated before baking a diff.'; $this->Task->expects($this->any()) - ->method('error') + ->method('abort') ->with($expectedMessage); $this->Task->bake('NotInSync'); @@ -98,7 +98,7 @@ public function testHistoryNotInSync() */ public function testEmptyHistoryNoMigrations() { - $this->Task = $this->getTaskMock(['error', 'dispatchShell']); + $this->Task = $this->getTaskMock(['abort', 'dispatchShell']); $this->Task->params['require-table'] = false; $this->Task->params['connection'] = 'test'; $this->Task->params['plugin'] = 'Blog'; @@ -122,7 +122,7 @@ public function testEmptyHistoryNoMigrations() */ public function testEmptyHistoryNoMigrationsError() { - $this->Task = $this->getTaskMock(['error', 'dispatchShell']); + $this->Task = $this->getTaskMock(['abort', 'dispatchShell']); $this->Task->params['require-table'] = false; $this->Task->params['connection'] = 'test'; $this->Task->params['plugin'] = 'Blog'; @@ -136,7 +136,7 @@ public function testEmptyHistoryNoMigrationsError() ->will($this->returnValue(1)); $this->Task->expects($this->any()) - ->method('error') + ->method('abort') ->with('Something went wrong during the snapshot baking. Please try again.'); $this->Task->bake('EmptyHistoryNoMigrations'); diff --git a/tests/TestCase/Shell/Task/MigrationTaskTest.php b/tests/TestCase/Shell/Task/MigrationTaskTest.php index edf54557..97237f13 100644 --- a/tests/TestCase/Shell/Task/MigrationTaskTest.php +++ b/tests/TestCase/Shell/Task/MigrationTaskTest.php @@ -37,7 +37,7 @@ public function setUp() ->getMock(); $this->Task = $this->getMockBuilder('\Migrations\Shell\Task\MigrationTask') - ->setMethods(['in', 'err', 'createFile', '_stop', 'error']) + ->setMethods(['in', 'err', 'createFile', '_stop', 'abort']) ->setConstructorArgs([$inputOutput]) ->getMock(); @@ -124,7 +124,7 @@ public function testCreateDuplicateName() ->getMock(); $task = $this->getMockBuilder('\Migrations\Shell\Task\MigrationTask') - ->setMethods(['in', 'err', '_stop', 'error']) + ->setMethods(['in', 'err', '_stop', 'abort']) ->setConstructorArgs([$inputOutput]) ->getMock(); @@ -148,7 +148,7 @@ public function testCreateDuplicateNameWithForce() ->getMock(); $task = $this->getMockBuilder('\Migrations\Shell\Task\MigrationTask') - ->setMethods(['in', 'err', '_stop', 'error']) + ->setMethods(['in', 'err', '_stop', 'abort']) ->setConstructorArgs([$inputOutput]) ->getMock(); @@ -179,7 +179,7 @@ public function testCreateDuplicateNameWithForce() public function testAddPrimaryKeyToExistingTable() { $this->Task->expects($this->any()) - ->method('error'); + ->method('abort'); $this->Task->args = [ 'add_pk_to_users', From c23da5731b08d1fec6b218072386183ac940f095 Mon Sep 17 00:00:00 2001 From: Lubos Remplik Date: Fri, 25 May 2018 14:17:46 +0200 Subject: [PATCH 4/4] Fixing tests with Shell abort / error --- tests/TestCase/Shell/Task/MigrationTaskTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestCase/Shell/Task/MigrationTaskTest.php b/tests/TestCase/Shell/Task/MigrationTaskTest.php index 97237f13..a851b6ee 100644 --- a/tests/TestCase/Shell/Task/MigrationTaskTest.php +++ b/tests/TestCase/Shell/Task/MigrationTaskTest.php @@ -37,7 +37,7 @@ public function setUp() ->getMock(); $this->Task = $this->getMockBuilder('\Migrations\Shell\Task\MigrationTask') - ->setMethods(['in', 'err', 'createFile', '_stop', 'abort']) + ->setMethods(['in', 'err', 'createFile', '_stop', 'abort', 'error']) ->setConstructorArgs([$inputOutput]) ->getMock(); @@ -124,7 +124,7 @@ public function testCreateDuplicateName() ->getMock(); $task = $this->getMockBuilder('\Migrations\Shell\Task\MigrationTask') - ->setMethods(['in', 'err', '_stop', 'abort']) + ->setMethods(['in', 'err', '_stop', 'error']) ->setConstructorArgs([$inputOutput]) ->getMock();