Skip to content

Commit d1859a5

Browse files
committed
fix conflicts
2 parents f7fd1b8 + 898f24e commit d1859a5

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

src/Illuminate/Cache/ArrayLock.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ protected function exists()
6767
*/
6868
public function release()
6969
{
70+
if (! $this->exists()) {
71+
return false;
72+
}
73+
7074
if (! $this->isOwnedByCurrentProcess()) {
7175
return false;
7276
}

src/Illuminate/Database/Eloquent/SoftDeletes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ protected function runSoftDelete()
9292
}
9393

9494
$query->update($columns);
95+
96+
$this->syncOriginalAttributes(array_keys($columns));
9597
}
9698

9799
/**

tests/Cache/CacheArrayStoreTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,15 @@ public function testValuesAreStoredByReferenceIfSerializationIsDisabled()
218218

219219
$this->assertObjectHasAttribute('bar', $store->get('object'));
220220
}
221+
222+
public function testReleasingLockAfterAlreadyForceReleasedByAnotherOwnerFails()
223+
{
224+
$store = new ArrayStore;
225+
$owner = $store->lock('foo', 10);
226+
$wannabeOwner = $store->lock('foo', 10);
227+
$owner->acquire();
228+
$wannabeOwner->forceRelease();
229+
230+
$this->assertFalse($wannabeOwner->release());
231+
}
221232
}

tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ public function testUpdateModelAfterSoftDeleting()
269269
/** @var SoftDeletesTestUser $userModel */
270270
$userModel = SoftDeletesTestUser::find(2);
271271
$userModel->delete();
272-
$userModel->syncOriginal();
273272
$this->assertEquals($now->toDateTimeString(), $userModel->getOriginal('deleted_at'));
274273
$this->assertNull(SoftDeletesTestUser::find(2));
275274
$this->assertEquals($userModel, SoftDeletesTestUser::withTrashed()->find(2));
@@ -285,7 +284,6 @@ public function testRestoreAfterSoftDelete()
285284
/** @var SoftDeletesTestUser $userModel */
286285
$userModel = SoftDeletesTestUser::find(2);
287286
$userModel->delete();
288-
$userModel->syncOriginal();
289287
$userModel->restore();
290288

291289
$this->assertEquals($userModel->id, SoftDeletesTestUser::find(2)->id);
@@ -304,12 +302,25 @@ public function testSoftDeleteAfterRestoring()
304302
$this->assertEquals($userModel->deleted_at, SoftDeletesTestUser::find(1)->deleted_at);
305303
$this->assertEquals($userModel->getOriginal('deleted_at'), SoftDeletesTestUser::find(1)->deleted_at);
306304
$userModel->delete();
307-
$userModel->syncOriginal();
308305
$this->assertNull(SoftDeletesTestUser::find(1));
309306
$this->assertEquals($userModel->deleted_at, SoftDeletesTestUser::withTrashed()->find(1)->deleted_at);
310307
$this->assertEquals($userModel->getOriginal('deleted_at'), SoftDeletesTestUser::withTrashed()->find(1)->deleted_at);
311308
}
312309

310+
public function testModifyingBeforeSoftDeletingAndRestoring()
311+
{
312+
$this->createUsers();
313+
314+
/** @var SoftDeletesTestUser $userModel */
315+
$userModel = SoftDeletesTestUser::find(2);
316+
$userModel->email = '[email protected]';
317+
$userModel->delete();
318+
$userModel->restore();
319+
320+
$this->assertEquals($userModel->id, SoftDeletesTestUser::find(2)->id);
321+
$this->assertSame('[email protected]', SoftDeletesTestUser::find(2)->email);
322+
}
323+
313324
public function testUpdateOrCreate()
314325
{
315326
$this->createUsers();

tests/Database/DatabaseSoftDeletingTraitTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public function testDeleteSetsSoftDeletedColumn()
2424
'deleted_at' => 'date-time',
2525
'updated_at' => 'date-time',
2626
]);
27+
$model->shouldReceive('syncOriginalAttributes')->once()->with([
28+
'deleted_at',
29+
'updated_at',
30+
]);
2731
$model->delete();
2832

2933
$this->assertInstanceOf(Carbon::class, $model->deleted_at);

0 commit comments

Comments
 (0)