2020-02-28 10:41:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Tests\Functional\Checkout\Cart;
|
|
|
|
|
|
|
|
|
|
use FunctionalTester;
|
|
|
|
|
use Cart;
|
2020-03-02 08:08:51 +00:00
|
|
|
use Webkul\Sales\Models\OrderAddress;
|
|
|
|
|
use Webkul\Checkout\Models\CartAddress;
|
2020-02-28 10:41:48 +00:00
|
|
|
|
|
|
|
|
class OrderCest
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param \FunctionalTester $I
|
|
|
|
|
*/
|
2020-03-02 08:08:51 +00:00
|
|
|
public function testCheckoutAsCustomer(FunctionalTester $I)
|
2020-02-28 10:41:48 +00:00
|
|
|
{
|
2020-03-02 08:08:51 +00:00
|
|
|
$customer = $I->loginAsCustomer();
|
2020-02-28 10:41:48 +00:00
|
|
|
|
2020-03-02 08:08:51 +00:00
|
|
|
$mocks = $I->prepareCart([
|
|
|
|
|
'customer' => $customer,
|
|
|
|
|
]);
|
2020-02-28 10:41:48 +00:00
|
|
|
|
2020-03-02 08:08:51 +00:00
|
|
|
// assert that checkout can be reached and generate csrf token.
|
|
|
|
|
$I->amOnRoute('shop.checkout.onepage.index');
|
2020-02-28 10:41:48 +00:00
|
|
|
|
2020-03-02 08:08:51 +00:00
|
|
|
// simulate the entering of the address(es):
|
|
|
|
|
$I->sendAjaxPostRequest(route('shop.checkout.save-address'), [
|
|
|
|
|
'_token' => csrf_token(),
|
|
|
|
|
'billing' => [
|
|
|
|
|
'address1' => ['900 Nobel Parkway'],
|
|
|
|
|
'city' => 'Quia et cillum rerum',
|
|
|
|
|
'company_name' => 'Davis and Best Plc',
|
|
|
|
|
'country' => 'TN',
|
|
|
|
|
'email' => 'kularynefo@mailinator.com',
|
|
|
|
|
'first_name' => 'Maggie',
|
|
|
|
|
'last_name' => 'Paul',
|
|
|
|
|
'phone' => '+1 (995) 347-2667',
|
|
|
|
|
'postcode' => '16239',
|
|
|
|
|
'save_as_address' => true,
|
|
|
|
|
'state' => 'Aperiam a eligendi a',
|
|
|
|
|
'use_for_shipping' => true,
|
|
|
|
|
],
|
|
|
|
|
'shipping' => [
|
|
|
|
|
'address1' => ['900 Nobel Parkway'],
|
|
|
|
|
'city' => 'Quia et cillum rerum',
|
|
|
|
|
'company_name' => 'Davis and Best Plc',
|
|
|
|
|
'country' => 'TN',
|
|
|
|
|
'email' => 'kularynefo@mailinator.com',
|
|
|
|
|
'first_name' => 'Maggie',
|
|
|
|
|
'last_name' => 'Paul',
|
|
|
|
|
'phone' => '+1 (995) 347-2667',
|
|
|
|
|
'postcode' => '16239',
|
|
|
|
|
'save_as_address' => true,
|
|
|
|
|
'state' => 'Aperiam a eligendi a',
|
|
|
|
|
'use_for_shipping' => true,
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$I->seeResponseCodeIsSuccessful();
|
|
|
|
|
|
|
|
|
|
$I->seeRecord(CartAddress::class, [
|
|
|
|
|
'city' => 'Quia et cillum rerum',
|
|
|
|
|
'company_name' => 'Davis and Best Plc',
|
|
|
|
|
'country' => 'TN',
|
|
|
|
|
'email' => 'kularynefo@mailinator.com',
|
|
|
|
|
'first_name' => 'Maggie',
|
|
|
|
|
'last_name' => 'Paul',
|
|
|
|
|
'phone' => '+1 (995) 347-2667',
|
|
|
|
|
'postcode' => '16239',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$I->sendAjaxPostRequest(route('shop.checkout.save-shipping'), [
|
|
|
|
|
'_token' => csrf_token(),
|
|
|
|
|
'shipping_method' => 'free_free',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$I->seeResponseCodeIsSuccessful();
|
2020-02-28 10:41:48 +00:00
|
|
|
|
2020-03-02 08:08:51 +00:00
|
|
|
$I->sendAjaxPostRequest(route('shop.checkout.save-payment'), [
|
|
|
|
|
'_token' => csrf_token(),
|
|
|
|
|
'payment' => [
|
|
|
|
|
'method' => 'cashondelivery',
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$I->seeResponseCodeIsSuccessful();
|
|
|
|
|
|
|
|
|
|
// simulate click on the 'place order' button at the last step:
|
|
|
|
|
$I->sendAjaxPostRequest(route('shop.checkout.save-order'),
|
|
|
|
|
['_token' => csrf_token()]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$I->seeResponseCodeIsSuccessful();
|
|
|
|
|
|
|
|
|
|
$I->seeRecord(OrderAddress::class, [
|
|
|
|
|
'city' => 'Quia et cillum rerum',
|
|
|
|
|
'company_name' => 'Davis and Best Plc',
|
|
|
|
|
'country' => 'TN',
|
|
|
|
|
'email' => 'kularynefo@mailinator.com',
|
|
|
|
|
'first_name' => 'Maggie',
|
|
|
|
|
'last_name' => 'Paul',
|
|
|
|
|
'phone' => '+1 (995) 347-2667',
|
|
|
|
|
'postcode' => '16239',
|
|
|
|
|
]);
|
|
|
|
|
}
|
2020-02-28 10:41:48 +00:00
|
|
|
}
|