Skip to content

Commit

Permalink
add test for delete quietly
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Aug 3, 2022
1 parent 183d38f commit a27a134
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Integration/Database/EloquentDeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@ public function testForceDeletedEventIsFired()

$this->assertEquals($role->id, RoleObserver::$model->id);
}

public function testDeleteQuietly()
{
$_SERVER['(-_-)'] = '\(^_^)/';
Post::deleting(fn () => $_SERVER['(-_-)'] = null);
Post::deleted(fn () => $_SERVER['(-_-)'] = null);
$post = Post::query()->create([]);
$result = $post->deleteQuietly();

$this->assertEquals('\(^_^)/', $_SERVER['(-_-)']);
$this->assertTrue($result);
$this->assertFalse($post->exists);

// For a soft-deleted model:
Role::deleting(fn () => $_SERVER['(-_-)'] = null);
Role::deleted(fn () => $_SERVER['(-_-)'] = null);
Role::softDeleted(fn () => $_SERVER['(-_-)'] = null);
$role = Role::create([]);
$result = $role->deleteQuietly();
$this->assertTrue($result);
$this->assertEquals('\(^_^)/', $_SERVER['(-_-)']);

unset($_SERVER['(-_-)']);
}
}

class Comment extends Model
Expand Down

0 comments on commit a27a134

Please sign in to comment.