mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 03:04:05 +00:00
1.8 - Factory States
This commit is contained in:
@@ -39,3 +39,15 @@ $factory->define(App\Concert::class, function (Faker\Generator $faker) {
|
||||
'additional_information' => 'Some sample additional information.',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Concert::class, 'published', function ($faker) {
|
||||
return [
|
||||
'published_at' => Carbon::parse('-1 week'),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Concert::class, 'unpublished', function ($faker) {
|
||||
return [
|
||||
'published_at' => null,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ class ViewConcertListingTest extends TestCase
|
||||
/** @test */
|
||||
function user_can_view_a_published_concert_listing()
|
||||
{
|
||||
$concert = Concert::create([
|
||||
$concert = factory(Concert::class)->states('published')->create([
|
||||
'title' => 'The Red Chord',
|
||||
'subtitle' => 'with Animosity and Lethargy',
|
||||
'date' => Carbon::parse('December 13, 2016 8:00pm'),
|
||||
@@ -24,7 +24,6 @@ class ViewConcertListingTest extends TestCase
|
||||
'state' => 'ON',
|
||||
'zip' => '17916',
|
||||
'additional_information' => 'For tickets, call (555) 555-5555.',
|
||||
'published_at' => Carbon::parse('-1 week'),
|
||||
]);
|
||||
|
||||
$this->visit('/concerts/'.$concert->id);
|
||||
@@ -43,9 +42,7 @@ class ViewConcertListingTest extends TestCase
|
||||
/** @test */
|
||||
function user_cannot_view_unpublished_concert_listings()
|
||||
{
|
||||
$concert = factory(Concert::class)->create([
|
||||
'published_at' => null,
|
||||
]);
|
||||
$concert = factory(Concert::class)->states('unpublished')->create();
|
||||
|
||||
$this->get('/concerts/'.$concert->id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user