Skip to content

[5.4] Remove superfluous ForceDelete extension from SoftDeletingScope #17552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/Illuminate/Database/Eloquent/SoftDeletingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SoftDeletingScope implements Scope
*
* @var array
*/
protected $extensions = ['ForceDelete', 'Restore', 'WithTrashed', 'WithoutTrashed', 'OnlyTrashed'];
protected $extensions = ['Restore', 'WithTrashed', 'WithoutTrashed', 'OnlyTrashed'];

/**
* Apply the scope to a given Eloquent query builder.
Expand Down Expand Up @@ -59,19 +59,6 @@ protected function getDeletedAtColumn(Builder $builder)
return $builder->getModel()->getDeletedAtColumn();
}

/**
* Add the force delete extension to the builder.
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void
*/
protected function addForceDelete(Builder $builder)
{
$builder->macro('forceDelete', function (Builder $builder) {
return $builder->getQuery()->delete();
});
}

/**
* Add the restore extension to the builder.
*
Expand Down
14 changes: 0 additions & 14 deletions tests/Database/DatabaseSoftDeletingScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ public function testApplyingScopeToABuilder()
$scope->apply($builder, $model);
}

public function testForceDeleteExtension()
{
$builder = m::mock('Illuminate\Database\Eloquent\Builder');
$builder->shouldDeferMissing();
$scope = new \Illuminate\Database\Eloquent\SoftDeletingScope;
$scope->extend($builder);
$callback = $builder->getMacro('forceDelete');
$givenBuilder = m::mock('Illuminate\Database\Eloquent\Builder');
$givenBuilder->shouldReceive('getQuery')->andReturn($query = m::mock('StdClass'));
$query->shouldReceive('delete')->once();

$callback($givenBuilder);
}

public function testRestoreExtension()
{
$builder = m::mock('Illuminate\Database\Eloquent\Builder');
Expand Down