mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-08 23:50:47 +00:00
1.2 - Sketching out the First Test
This commit is contained in:
25
tests/TestCase.php
Normal file
25
tests/TestCase.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
{
|
||||
/**
|
||||
* The base URL to use while testing the application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUrl = 'http://localhost';
|
||||
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
||||
43
tests/features/ViewConcertListingTest.php
Normal file
43
tests/features/ViewConcertListingTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ViewConcertListingTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
function user_can_view_a_concert_listing()
|
||||
{
|
||||
// Arrange
|
||||
// Create a concert
|
||||
$concert = Concert::create([
|
||||
'title' => 'The Red Chord',
|
||||
'subtitle' => 'with Animosity and Lethargy',
|
||||
'date' => Carbon::parse('December 13, 2016 8:00pm'),
|
||||
'ticket_price' => 3250,
|
||||
'venue' => 'The Mosh Pit',
|
||||
'venue_address' => '123 Example Lane',
|
||||
'city' => 'Laraville',
|
||||
'state' => 'ON',
|
||||
'zip' => '17916',
|
||||
'additional_information' => 'For tickets, call (555) 555-5555.',
|
||||
]);
|
||||
|
||||
// Act
|
||||
// View the concert listing
|
||||
$this->visit('/concerts/'.$concert->id);
|
||||
|
||||
// Assert
|
||||
// See the concert details
|
||||
$this->see('The Red Chord');
|
||||
$this->see('with Animosity and Lethargy');
|
||||
$this->see('December 13, 2016');
|
||||
$this->see('8:00pm');
|
||||
$this->see('32.50');
|
||||
$this->see('The Mosh Pit');
|
||||
$this->see('123 Example Lane');
|
||||
$this->see('Laraville, ON 17916');
|
||||
$this->see('For tickets, call (555) 555-5555.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user