Testing a secure route laravel 5.5 NotFoundHttpException

Posted 5 months ago by longestdrive


Today's testing question is on secure routes.

Within my routes file I have:

if (App::environment() == 'deployed') {

Route::get('/contact', array(
    'as' => 'contact.secure.page',
    'uses' => '[email protected]'

This works on the live server. On my testing development machine I don't have any certificates installed so always get an error message about security etc but ignored until now as it didn't affect my development.

Now I'm trying to write a test to ensure the page is visible and here's my test:

    namespace Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ContactFormTest extends TestCase

    use DatabaseMigrations;

    public function setUp()



    public function test_visitor_can_see_contact_form()

        $response = $this->get('/contact');

            ->assertSee('CONTACT US');


But the test fails because with an httpNotFound exception

In earlier versions of Laravel I could use

$response = $this->callSecure('GET', '/contact');

But this no longer works in Laravel 5.5.

How can I specify the test creates and calls an https url for this test?


Please sign in or create an account to participate in this conversation.