more testcases for customer authentication

This commit is contained in:
Prashant Singh 2019-02-23 17:23:46 +05:30
parent 53094cadca
commit 5e704a4979
4 changed files with 83 additions and 23 deletions

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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() {
}
}