Mikeritteronline's avatar

Laravel 5.3 style test fails to see user email constructed from factory

Here's my test

public function test_i_can_see_my_name_and_email()
{
    $user = factory(User::class)->create();

    $this->actingAs($user)->get('/admin/user')->see($user->email);
}

The route is protected, and authentication passes. When I run this in my browser all is well. But my test fails every time.

I've even run dd($user->email) and it looks good.

Here's the class declaration from the top of my php file.

<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\User;
use Laravel\Dusk\Dusk;

class AdminTest extends TestCase
{
    use DatabaseMigrations;
0 likes
1 reply
Mikeritteronline's avatar

FYI, my TestCase looks like

<?php

namespace Tests;

//use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
    use CreatesApplication;

    public $baseUrl = 'http://localhost';
}

Please or to participate in this conversation.