I am testing a view in Laravel 5.2, specifically the following blade:
<p>Point 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 user's main page: /users/{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('/users/'. $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 as 600.
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.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire