more testcases for customer authentication
This commit is contained in:
parent
53094cadca
commit
5e704a4979
|
|
@ -93,6 +93,8 @@ class CartController extends Controller
|
|||
try {
|
||||
Event::fire('checkout.cart.add.before', $id);
|
||||
|
||||
dd(request()->except('_token'));
|
||||
|
||||
$result = Cart::add($id, request()->except('_token'));
|
||||
|
||||
Event::fire('checkout.cart.add.after', $result);
|
||||
|
|
|
|||
|
|
@ -77,8 +77,49 @@ class AuthTest extends TestCase
|
|||
]);
|
||||
|
||||
$response->assertRedirect('/customer/account/profile');
|
||||
|
||||
$this->assertEquals(count([auth()->guard('customer')->user()]), 1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that customer cannot login with the wrong credentials.
|
||||
*/
|
||||
public function willNotLoginWithWrongCredentials()
|
||||
{
|
||||
$customers = app(Customer::class);
|
||||
$customer = $customers->findOneByField('email', 'prashant@webkul.com');
|
||||
|
||||
$response = $this->from(route('login'))->post(route('customer.session.create'),
|
||||
[
|
||||
'email' => $customer->email,
|
||||
'password' => 'wrongpassword3428903mlndvsnljkvsd',
|
||||
]);
|
||||
|
||||
$this->assertGuest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to confirm that customer cannot login if user does not exist.
|
||||
*/
|
||||
public function willNotLoginWithNonexistingCustomer()
|
||||
{
|
||||
$response = $this->post(route('customer.session.create'), [
|
||||
'email' => 'fiaiia9q2943jklq34h203qtb3o2@something.com',
|
||||
'password' => 'wrong-password',
|
||||
]);
|
||||
|
||||
$this->assertGuest();
|
||||
}
|
||||
|
||||
/**
|
||||
* To test that customer can logout
|
||||
*/
|
||||
public function allowsCustomerToLogout()
|
||||
{
|
||||
$customer = auth()->guard('customer')->user();
|
||||
|
||||
dd('logout test', $customer);
|
||||
|
||||
$this->get(route('customer.session.destroy'));
|
||||
|
||||
$this->assertGuest();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class CheckRegistrationPage extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExample()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
use App;
|
||||
|
||||
use Cart;
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository as Customer;
|
||||
|
||||
class AuthTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Add a simple Item in cart for guest
|
||||
*/
|
||||
public function addSimpleItemGuest() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a configurable Item in cart for guest
|
||||
*/
|
||||
public function addConfigurableItemGuest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an Item in cart for guest
|
||||
*/
|
||||
public function removeItemGuest() {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue