Skip to content

Instantly share code, notes, and snippets.

@RomainMazB
Created March 31, 2020 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomainMazB/9051e9bedd3e35241f8d1b62997ceb2e to your computer and use it in GitHub Desktop.
Save RomainMazB/9051e9bedd3e35241f8d1b62997ceb2e to your computer and use it in GitHub Desktop.
public function testOldReadMessagesAreDeletedFromDatabase(): void
{
// Register messages from current and another user's city
$this->city2->history->register('11111 Message');
$this->city->history->register('22222 Message');
// Back from the future
DB::update(
"UPDATE histories SET deleted_at = NOW() - CONCAT(?::VARCHAR, ' 1 second')::INTERVAL",
[config('game.delete_read_message_after')]
);
// Register a message from current user's city
$message2_uuid = $this->city->history->register('33333 Message');
// Make it read
$this->city->history->markAsRead($message2_uuid);
// Does the read message old from 24 hours are deleted?
$this->assertDatabaseMissing('histories', ['message' => '11111 Message']);
$this->assertDatabaseMissing('histories', ['message' => '22222 Message']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment