Created
March 31, 2020 08:27
-
-
Save RomainMazB/9051e9bedd3e35241f8d1b62997ceb2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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