Last active
October 11, 2018 16:20
-
-
Save wilburpowery/2d7a99689b834100538c4b6a152ee2ed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
public function test_jobs_older_than_90_days_are_deleted_automatically() | |
{ | |
$listings = factory(Listing::class, 5)->create(); | |
$listings[0]->update(['created_at' => now()->subDays(91)]); | |
$listings[1]->update(['created_at' => now()->subDays(91)]); | |
// We have 5 listings now | |
$this->assertCount(5, Listing::all()); | |
// run the command to delete listings posted 90 or more days ago. | |
$this->artisan(DeleteOldListings::class); | |
// we have 3 listings now because the 2 old ones were deleted. | |
$this->assertCount(3, Listing::all()); | |
// 2 listings should have been deleted. | |
$this->assertCount(2, Listing::onlyTrashed()->get()); | |
// since were using soft deleted, we should still | |
// have 5 records if we include the trashed ones. | |
$this->assertCount(5, Listing::withTrashed()->get()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment