Few more test cases related to customer authentication
This commit is contained in:
parent
99bc1505e0
commit
571e266c15
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
use Auth;
|
||||
|
||||
use App;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository as Customer;
|
||||
|
||||
class AuthTest extends TestCase
|
||||
{
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* To check if the customer can view the login page or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerLoginPage()
|
||||
{
|
||||
config(['app.url' => 'http://127.0.0.1:8000']);
|
||||
|
||||
$response = $this->get('/customer/login');
|
||||
|
||||
$response->assertSuccessful();
|
||||
|
||||
$response->assertViewIs('shop::customers.session.index');
|
||||
}
|
||||
|
||||
public function testCustomerResgistrationPage() {
|
||||
config(['app.url' => 'http://127.0.0.1:8000']);
|
||||
|
||||
$response = $this->get('/customer/register');
|
||||
|
||||
$response->assertSuccessful();
|
||||
|
||||
$response->assertViewIs('shop::customers.signup.index');
|
||||
}
|
||||
|
||||
public function testCustomerRegistration() {
|
||||
$faker = \Faker\Factory::create();
|
||||
|
||||
$allCustomers = array();
|
||||
|
||||
$customers = app(Customer::class);
|
||||
|
||||
$created = $customers->create([
|
||||
'first_name' => explode(' ',$faker->name)[0],
|
||||
'last_name' => explode(' ',$faker->name)[0],
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'gender' => $faker->randomElement($array = array ('Male','Female', 'Other')),
|
||||
'date_of_birth' => $faker->date($format = 'Y-m-d', $max = 'now'),
|
||||
'email' => $faker->email,
|
||||
'password' => bcrypt('12345678'),
|
||||
'is_verified' => 1
|
||||
]);
|
||||
|
||||
$this->assertEquals($created->id, $created->id);
|
||||
}
|
||||
|
||||
public function testCustomerLogin() {
|
||||
$customers = app(Customer::class);
|
||||
|
||||
$customer = $customers->find(1);
|
||||
|
||||
$user = ['email' => $customer->email, 'password' => $customer->password];
|
||||
|
||||
$this->assertAuthenticatedAs($user);
|
||||
}
|
||||
}
|
||||
|
|
@ -11,10 +11,10 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class LoginTest extends TestCase
|
||||
class GeneralTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
* Test for home page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -27,6 +27,11 @@ class LoginTest extends TestCase
|
|||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for customer login
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerLoginPage()
|
||||
{
|
||||
config(['app.url' => 'http://127.0.0.1:8000']);
|
||||
|
|
@ -36,6 +41,11 @@ class LoginTest extends TestCase
|
|||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for categories page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCategoriesPage()
|
||||
{
|
||||
$categoryUrlSlug = 'marvel-figurines';
|
||||
|
|
@ -47,6 +57,11 @@ class LoginTest extends TestCase
|
|||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for customer registration page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCustomerRegistrationPage()
|
||||
{
|
||||
config(['app.url' => 'http://127.0.0.1:8000']);
|
||||
|
|
@ -56,6 +71,11 @@ class LoginTest extends TestCase
|
|||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for checkout's cart page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCartPage()
|
||||
{
|
||||
config(['app.url' => 'http://127.0.0.1:8000']);
|
||||
|
|
@ -64,4 +84,4 @@ class LoginTest extends TestCase
|
|||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue