this is my full code that I write it to test function from controller
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\Concerns\MakesHttpRequests;
class RouteForecastTest extends TestCase
{
protected $password = 'rightpassword';
public function setUp()
{
parent::setUp();
$this->createApplication();
$this->user = factory(App\User::class)->create([
'email' => 'testuser@email.com',
'password' => bcrypt($this->password),
'type' => 'admin'
]);
}
/** @test */
public function createTest()
{
$this->actingAs($user);
$this->visit('/client/ocp/profile/247')
->click('New ')
->seePageIs('/client/ocp/profile/247/create')
->see('name');
}
public function tearDown(){
parent::tearDown();
$this->user->delete();
}
}
i try this code with setup and teardown methods and run test using phpunit i got this error
ErrorException: Undefined variable: user
how can I fix this error?