mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-12 14:52:27 +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.',
|
'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 */
|
/** @test */
|
||||||
function user_can_view_a_published_concert_listing()
|
function user_can_view_a_published_concert_listing()
|
||||||
{
|
{
|
||||||
$concert = Concert::create([
|
$concert = factory(Concert::class)->states('published')->create([
|
||||||
'title' => 'The Red Chord',
|
'title' => 'The Red Chord',
|
||||||
'subtitle' => 'with Animosity and Lethargy',
|
'subtitle' => 'with Animosity and Lethargy',
|
||||||
'date' => Carbon::parse('December 13, 2016 8:00pm'),
|
'date' => Carbon::parse('December 13, 2016 8:00pm'),
|
||||||
@@ -24,7 +24,6 @@ class ViewConcertListingTest extends TestCase
|
|||||||
'state' => 'ON',
|
'state' => 'ON',
|
||||||
'zip' => '17916',
|
'zip' => '17916',
|
||||||
'additional_information' => 'For tickets, call (555) 555-5555.',
|
'additional_information' => 'For tickets, call (555) 555-5555.',
|
||||||
'published_at' => Carbon::parse('-1 week'),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->visit('/concerts/'.$concert->id);
|
$this->visit('/concerts/'.$concert->id);
|
||||||
@@ -43,9 +42,7 @@ class ViewConcertListingTest extends TestCase
|
|||||||
/** @test */
|
/** @test */
|
||||||
function user_cannot_view_unpublished_concert_listings()
|
function user_cannot_view_unpublished_concert_listings()
|
||||||
{
|
{
|
||||||
$concert = factory(Concert::class)->create([
|
$concert = factory(Concert::class)->states('unpublished')->create();
|
||||||
'published_at' => null,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->get('/concerts/'.$concert->id);
|
$this->get('/concerts/'.$concert->id);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user