Skip to content

Commit

Permalink
Merge pull request #363 from LubosRemplik/master
Browse files Browse the repository at this point in the history
Using Shell::abort instead of error as it is deprecated
  • Loading branch information
markstory authored May 25, 2018
2 parents 3df86d7 + c23da57 commit 742d483
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Shell/Task/MigrationDiffTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Shell/Task/MigrationTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Shell/Task/MigrationDiffTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Shell/Task/MigrationTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', 'error'])
->setConstructorArgs([$inputOutput])
->getMock();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 742d483

Please sign in to comment.