dimanche 28 février 2016

PHPUnit + Laravel 5.2 + Visit may not be refreshing

I am testing a view in Laravel 5.2, specifically the following blade:

<p>Balance: {{ Auth::user()->total() }}</p>

The PHPUnit test is as follows:

// In the setUp() I create a user and log them in,
// the associated tests for that case work well.
// After setUp() the PHPUnit is "seeing" the
// the user's page: /members/{username}

// Get user as variable.
$user = Auth::user();

// Have user post payment.
$user->pay(600);

// Verify user is expected user
$this->assertTrue(($user->username == 'something'));

// visit: User profile page.
// seeInDatabase: Verify new payment stored in database.
// see: Verify template updated with payment total.
$this->visit('/members/'. $user->username)
    ->seeInDatabase('payments', ['amount' => 600, 'user_id' => $user->id])
    ->see('Point balance: 600');

When I run this test via PHPUnit, the "Point balance" is displayed as 0. When I run the test manually, it is displayed properly.

So, I'm wondering what I am missing in this sequence?

ps. This is a huge part of my app, and I really don't want to avoid automating this part of testing.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1KVtCcA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire