Hi,
When I run sail test, I see error:
PASS Tests\Unit\ExampleTest
✓ that true is true
FAIL Tests\Feature\ViewConcertListingTest
⨯ user can view a concert listing
---
• Tests\Feature\ViewConcertListingTest > user can view a concert listing
Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException
Invalid Host "ticketbeast.testdb_connection=mysql".
at vendor/symfony/http-foundation/Request.php:1139
1135▕ return '';
1136▕ }
1137▕ $this->isHostValid = false;
1138▕
➜ 1139▕ throw new SuspiciousOperationException(sprintf('Invalid Host "%s".', $host));
1140▕ }
1141▕
1142▕ if (\count(self::$trustedHostPatterns) > 0) {
1143▕ // to avoid host header injection attacks, you should provide a list of trusted host patterns
+6 vendor frames
7 tests/Feature/ViewConcertListingTest.php:36
Illuminate\Foundation\Testing\TestCase::get()
What I have:
ViewConcertListingTest.php:
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\Concert;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
class ViewConcertListingTest extends TestCase
{
use DatabaseMigrations;
/** @test */
function user_can_view_a_concert_listing()
{
// Arrange
// Create a concert
$concert = Concert::create([
'title' => 'Sample Title',
'subtitle' => 'Sample Subtitle',
'date' => Carbon::parse('December 13, 2016 8:00pm'),
'ticket_price' => 3250,
'venue' => 'Sample Venue',
'venue_address' => '123 Sample Address',
'city' => 'Some City',
'state' => 'ON',
'zip' => '12345',
'additional_information' => 'For tickets, call (555) 555-5555.'
]);
// Act
// View the concert listing
$this->get('/concerts/'.$concert->id);
// Assert
// see the concert details
$this->see('Sample Title');
$this->see('Sample Subtitle');
$this->see('December 13, 2016');
$this->see('8:00pm');
$this->see('32.50');
$this->see('Sample Venue',);
$this->see('123 Sample Address');
$this->see('Some City, ON 12345');
$this->see('For tickets, call (555) 555-5555.');
}
}
.env:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:yGaeW5/pNK2mPsPtIkN/Mz6W52ljKKUVXVNrfye2wio=
APP_DEBUG=true
APP_URL=http://ticketbeast.testDB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=ticketbeast
DB_USERNAME=sail
DB_PASSWORD=password
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
web.php:
<?php
use Illuminate\Support\Facades\Route;
Route::get('/concerts/{id}', 'ConcertController@show');