Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Put that under tests/functionnal/PurchaseMasterBoxTest.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' => '',
'password' => Hash::make('jeremie')
// Auto connect the user created
Auth::guard('customer')->attempt(['email' => '', 'password' => 'jeremie']);
// Check if we can see the profile
// That's all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment