Skip to content

Instantly share code, notes, and snippets.

@GesJeremie
Created January 21, 2016 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GesJeremie/7cd6b8a9133f6fec6340 to your computer and use it in GitHub Desktop.
Save GesJeremie/7cd6b8a9133f6fec6340 to your computer and use it in GitHub Desktop.
Put that under tests/functionnal/PurchaseMasterBoxTest.php
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Faker\Factory as Faker;
class PurchaseMasterBoxTest extends TestCase
{
// This is important, don't forget it.
// By default the tests are runned against the database you are working on.
// Every call to the database from your tests are wrapped into a transaction
// like that we don't put the mess in it.
use DatabaseTransactions;
/** @test */
public function auto_connect_user_and_visit_his_account()
{
// Create one customer (you can change 1 to X to change the number of customers created)
// You can set an array in create() if you want to override some entries (like first_name, last_name, etc ..)
// In our case we need to know what's the email and the password to use it when we will connect. So I pass
// email and password in it.
$customer = factory(App\Models\Customer::class, 1)->create([
'email' => 'awesome@domain.com',
'password' => Hash::make('jeremie')
]);
// Auto connect the user created
Auth::guard('customer')->attempt(['email' => 'awesome@domain.com', 'password' => 'jeremie']);
// Check if we can see the profile
$this->visit('/customer/profile')
->seePageIs('/customer/profile');
// That's all
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment