mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 23:34:28 -04:00
Added online payment acceptance test
This commit is contained in:
parent
01089d3562
commit
0183c02ef6
@ -348,7 +348,7 @@ class UserController extends BaseController
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
public function switchAccount($newUserId)
|
||||
public function switchAccount($newUserId)
|
||||
{
|
||||
$oldUserId = Auth::user()->id;
|
||||
$referer = Request::header('referer');
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{App::getLocale()}}">
|
||||
<head>
|
||||
<title>{{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }} | </title>
|
||||
<title>{{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}</title>
|
||||
<meta name="description" content="{{ isset($description) ? $description : trans('texts.app_description') }}" />
|
||||
|
||||
<!-- Source: https://github.com/hillelcoren/invoice-ninja -->
|
||||
|
@ -26,7 +26,10 @@
|
||||
@endif
|
||||
|
||||
@if (!$payment || !$payment->account_gateway_id)
|
||||
{!! Former::select('payment_type_id')->addOption('','')->fromQuery($paymentTypes, 'name', 'id') !!}
|
||||
{!! Former::select('payment_type_id')
|
||||
->addOption('','')
|
||||
->fromQuery($paymentTypes, 'name', 'id')
|
||||
->addGroupClass('payment-type-select') !!}
|
||||
@endif
|
||||
|
||||
{!! Former::text('payment_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT))->append('<i class="glyphicon glyphicon-calendar"></i>') !!}
|
||||
|
@ -230,7 +230,7 @@ header h3 em {
|
||||
{!! Former::text('postal_code')->placeholder(trans('texts.postal_code'))->label('') !!}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{!! Former::select('country_id')->placeholder(trans('texts.country_id'))->fromQuery($countries, 'name', 'id')->label('') !!}
|
||||
{!! Former::select('country_id')->placeholder(trans('texts.country_id'))->fromQuery($countries, 'name', 'id')->label('')->addGroupClass('country-select') !!}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
8
tests/_bootstrap.php.default
Normal file
8
tests/_bootstrap.php.default
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
// This is global bootstrap for autoloading
|
||||
use Codeception\Util\Fixtures;
|
||||
|
||||
Fixtures::add('username', 'user@example.com');
|
||||
Fixtures::add('password', 'password');
|
||||
|
||||
Fixtures::add('gateway_key', '');
|
@ -1,16 +1,9 @@
|
||||
<?php
|
||||
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->checkIfLogin($I);
|
||||
|
||||
$I->wantTo('Test all pages load');
|
||||
$I->amOnPage('/login');
|
||||
//$I->see(trans('texts.forgot_password'));
|
||||
|
||||
// Login as test user
|
||||
$I->fillField(['name' => 'email'], 'hillelcoren@gmail.com');
|
||||
$I->fillField(['name' => 'password'], '4uejs%2ksl#271df');
|
||||
$I->click('Let\'s go');
|
||||
$I->see('Dashboard');
|
||||
|
||||
// Top level navigation
|
||||
$I->amOnPage('/dashboard');
|
||||
|
@ -19,12 +19,17 @@ class CreditCest
|
||||
public function create(AcceptanceTester $I)
|
||||
{
|
||||
$note = $this->faker->catchPhrase;
|
||||
$clientName = $I->grabFromDatabase('clients', 'name');
|
||||
$clientEmail = $this->faker->safeEmail;
|
||||
|
||||
$I->wantTo('Create a credit');
|
||||
$I->amOnPage('/credits/create');
|
||||
|
||||
$I->selectDropdown($I, $clientName, '.client-select .dropdown-toggle');
|
||||
$I->amOnPage('/clients/create');
|
||||
$I->fillField(['name' => 'email'], $clientEmail);
|
||||
$I->click('Save');
|
||||
$I->see($clientEmail);
|
||||
|
||||
$I->amOnPage('/credits/create');
|
||||
$I->selectDropdown($I, $clientEmail, '.client-select .dropdown-toggle');
|
||||
$I->fillField(['name' => 'amount'], rand(50, 200));
|
||||
$I->fillField(['name' => 'private_notes'], $note);
|
||||
$I->selectDataPicker($I, '#credit_date', 'now + 1 day');
|
||||
@ -35,7 +40,7 @@ class CreditCest
|
||||
|
||||
$I->amOnPage('/credits');
|
||||
$I->seeCurrentUrlEquals('/credits');
|
||||
$I->see($clientName);
|
||||
$I->see($clientEmail);
|
||||
}
|
||||
|
||||
}
|
@ -19,14 +19,20 @@ class InvoiceCest
|
||||
|
||||
public function createInvoice(AcceptanceTester $I)
|
||||
{
|
||||
$clientName = $I->grabFromDatabase('clients', 'name');
|
||||
$clientEmail = $this->faker->safeEmail;
|
||||
|
||||
$I->wantTo('create an invoice');
|
||||
|
||||
$I->amOnPage('/clients/create');
|
||||
$I->fillField(['name' => 'email'], $clientEmail);
|
||||
$I->click('Save');
|
||||
$I->see($clientEmail);
|
||||
|
||||
$I->amOnPage('/invoices/create');
|
||||
|
||||
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
|
||||
|
||||
$I->selectDropdown($I, $clientName, '.client_select .dropdown-toggle');
|
||||
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
|
||||
$I->selectDataPicker($I, '#invoice_date');
|
||||
$I->selectDataPicker($I, '#due_date', '+ 15 day');
|
||||
$I->fillField('#po_number', rand(100, 200));
|
||||
@ -41,12 +47,17 @@ class InvoiceCest
|
||||
|
||||
public function createRecurringInvoice(AcceptanceTester $I)
|
||||
{
|
||||
$clientName = $I->grabFromDatabase('clients', 'name');
|
||||
$clientEmail = $this->faker->safeEmail;
|
||||
|
||||
$I->wantTo('create a recurring invoice');
|
||||
$I->amOnPage('/recurring_invoices/create');
|
||||
|
||||
$I->amOnPage('/clients/create');
|
||||
$I->fillField(['name' => 'email'], $clientEmail);
|
||||
$I->click('Save');
|
||||
$I->see($clientEmail);
|
||||
|
||||
$I->selectDropdown($I, $clientName, '.client_select .dropdown-toggle');
|
||||
$I->amOnPage('/recurring_invoices/create');
|
||||
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
|
||||
$I->selectDataPicker($I, '#end_date', '+ 1 week');
|
||||
$I->fillField('#po_number', rand(100, 200));
|
||||
$I->fillField('#discount', rand(0, 20));
|
||||
@ -55,11 +66,11 @@ class InvoiceCest
|
||||
|
||||
$I->executeJS("submitAction('email')");
|
||||
$I->wait(1);
|
||||
$I->see($clientName);
|
||||
$I->see($clientEmail);
|
||||
|
||||
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
|
||||
$I->click('Recurring Invoice');
|
||||
$I->see($clientName);
|
||||
$I->see($clientEmail);
|
||||
|
||||
$I->click('#lastInvoiceSent');
|
||||
$I->see($invoiceNumber);
|
||||
@ -73,7 +84,7 @@ class InvoiceCest
|
||||
|
||||
//change po_number with random number
|
||||
$po_number = rand(100, 300);
|
||||
$I->fillField('po_number', $po_number);
|
||||
$I->fillField('#po_number', $po_number);
|
||||
|
||||
//save
|
||||
$I->executeJS('submitAction()');
|
||||
@ -86,7 +97,7 @@ class InvoiceCest
|
||||
public function cloneInvoice(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantTo('clone an invoice');
|
||||
$I->amOnPage('invoices/1/clone');
|
||||
$I->amOnPage('/invoices/1/clone');
|
||||
|
||||
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../helpers/Helper.php';
|
||||
|
||||
use \AcceptanceTester;
|
||||
use Faker\Factory;
|
||||
|
83
tests/acceptance/OnlinePaymentCest.php
Normal file
83
tests/acceptance/OnlinePaymentCest.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use \AcceptanceTester;
|
||||
use Faker\Factory;
|
||||
|
||||
class OnlinePaymentCest
|
||||
{
|
||||
private $faker;
|
||||
|
||||
public function _before(AcceptanceTester $I)
|
||||
{
|
||||
$I->checkIfLogin($I);
|
||||
|
||||
$this->faker = Factory::create();
|
||||
}
|
||||
|
||||
public function onlinePayment(AcceptanceTester $I)
|
||||
{
|
||||
$I->wantTo('test an online payment');
|
||||
|
||||
$clientEmail = $this->faker->safeEmail;
|
||||
$productKey = $this->faker->text(10);
|
||||
|
||||
// set gateway info
|
||||
$I->wantTo('create a gateway');
|
||||
$I->amOnPage('/company/payments');
|
||||
|
||||
if (strpos($I->grabFromCurrentUrl(), 'create') > 0) {
|
||||
$I->fillField(['name' =>'23_apiKey'], Fixtures::get('gateway_key'));
|
||||
$I->selectOption('#token_billing_type_id', 4);
|
||||
$I->click('Save');
|
||||
$I->see('Successfully created gateway');
|
||||
}
|
||||
|
||||
// create client
|
||||
$I->amOnPage('/clients/create');
|
||||
$I->fillField(['name' => 'email'], $clientEmail);
|
||||
$I->click('Save');
|
||||
$I->see($clientEmail);
|
||||
|
||||
// create product
|
||||
$I->amOnPage('/products/create');
|
||||
$I->fillField(['name' => 'product_key'], $productKey);
|
||||
$I->fillField(['name' => 'notes'], $this->faker->text(80));
|
||||
$I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20));
|
||||
$I->click('Save');
|
||||
$I->see($productKey);
|
||||
|
||||
// create invoice
|
||||
$I->amOnPage('/invoices/create');
|
||||
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
|
||||
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey);
|
||||
$I->click('Save');
|
||||
$I->see($clientEmail);
|
||||
|
||||
// enter payment
|
||||
$clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]);
|
||||
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId]);
|
||||
$invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]);
|
||||
|
||||
$clientSession = $I->haveFriend('client');
|
||||
$clientSession->does(function(AcceptanceTester $I) use ($invitationKey) {
|
||||
$I->amOnPage('/view/' . $invitationKey);
|
||||
$I->click('Pay Now');
|
||||
|
||||
$I->fillField(['name' => 'first_name'], $this->faker->firstName);
|
||||
$I->fillField(['name' => 'last_name'], $this->faker->lastName);
|
||||
$I->fillField(['name' => 'address1'], $this->faker->streetAddress);
|
||||
$I->fillField(['name' => 'address2'], $this->faker->streetAddress);
|
||||
$I->fillField(['name' => 'city'], $this->faker->city);
|
||||
$I->fillField(['name' => 'state'], $this->faker->state);
|
||||
$I->fillField(['name' => 'postal_code'], $this->faker->postcode);
|
||||
$I->selectDropdown($I, 'United States', '.country-select .dropdown-toggle');
|
||||
$I->fillField(['name' => 'card_number'], '4242424242424242');
|
||||
$I->fillField(['name' => 'cvv'], '1234');
|
||||
$I->selectOption('#expiration_month', 12);
|
||||
$I->selectOption('#expiration_year', date('Y'));
|
||||
$I->click('.btn-success');
|
||||
$I->see('Successfully applied payment');
|
||||
});
|
||||
}
|
||||
}
|
@ -17,16 +17,38 @@ class PaymentCest
|
||||
|
||||
public function create(AcceptanceTester $I)
|
||||
{
|
||||
$clientName = $I->grabFromDatabase('clients', 'name');
|
||||
$amount = rand(1, 30);
|
||||
$clientEmail = $this->faker->safeEmail;
|
||||
$productKey = $this->faker->text(10);
|
||||
$amount = rand(1, 10);
|
||||
|
||||
$I->wantTo('enter a payment');
|
||||
$I->amOnPage('/payments/create');
|
||||
|
||||
$I->selectDropdown($I, $clientName, '.client-select .dropdown-toggle');
|
||||
// create client
|
||||
$I->amOnPage('/clients/create');
|
||||
$I->fillField(['name' => 'email'], $clientEmail);
|
||||
$I->click('Save');
|
||||
$I->see($clientEmail);
|
||||
|
||||
// create product
|
||||
$I->amOnPage('/products/create');
|
||||
$I->fillField(['name' => 'product_key'], $productKey);
|
||||
$I->fillField(['name' => 'notes'], $this->faker->text(80));
|
||||
$I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20));
|
||||
$I->click('Save');
|
||||
$I->see($productKey);
|
||||
|
||||
// create invoice
|
||||
$I->amOnPage('/invoices/create');
|
||||
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
|
||||
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey);
|
||||
$I->click('Save');
|
||||
$I->see($clientEmail);
|
||||
|
||||
$I->amOnPage('/payments/create');
|
||||
$I->selectDropdown($I, $clientEmail, '.client-select .dropdown-toggle');
|
||||
$I->selectDropdownRow($I, 1, '.invoice-select .combobox-container');
|
||||
$I->fillField(['name' => 'amount'], $amount);
|
||||
$I->selectDropdownRow($I, 1, 'div.panel-body div.form-group:nth-child(4) .combobox-container');
|
||||
$I->selectDropdown($I, 'Cash', '.payment-type-select .dropdown-toggle');
|
||||
$I->selectDataPicker($I, '#payment_date', 'now + 1 day');
|
||||
$I->fillField(['name' => 'transaction_reference'], $this->faker->text(12));
|
||||
|
||||
|
@ -51,6 +51,7 @@ class SettingsCest
|
||||
$I->see('Successfully updated settings');
|
||||
}
|
||||
|
||||
/*
|
||||
public function onlinePayments(FunctionalTester $I)
|
||||
{
|
||||
$gateway = $I->grabRecord('account_gateways', array('gateway_id' => 23));
|
||||
@ -73,16 +74,15 @@ class SettingsCest
|
||||
$apiKey = $config->apiKey;
|
||||
}
|
||||
|
||||
/*
|
||||
$I->amOnPage('/gateways/1/edit');
|
||||
$I->click('Save');
|
||||
// $I->amOnPage('/gateways/1/edit');
|
||||
// $I->click('Save');
|
||||
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->see('Successfully updated gateway');
|
||||
$I->seeRecord('account_gateways', array('config' => '{"apiKey":"ASHHOWAH"}'));
|
||||
*/
|
||||
// $I->seeResponseCodeIs(200);
|
||||
// $I->see('Successfully updated gateway');
|
||||
// $I->seeRecord('account_gateways', array('config' => '{"apiKey":"ASHHOWAH"}'));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public function createProduct(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('create a product');
|
||||
@ -92,7 +92,7 @@ class SettingsCest
|
||||
|
||||
$I->fillField(['name' => 'product_key'], $productKey);
|
||||
$I->fillField(['name' => 'notes'], $this->faker->text(80));
|
||||
$I->fillField(['name' => 'cost'], $this->faker->numberBetween(1,20));
|
||||
$I->fillField(['name' => 'cost'], $this->faker->numberBetween(1, 20));
|
||||
$I->click('Save');
|
||||
|
||||
$I->seeResponseCodeIs(200);
|
||||
@ -190,4 +190,38 @@ class SettingsCest
|
||||
$I->click('Run');
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
||||
public function createUser(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('create a user');
|
||||
$I->amOnPage('/users/create');
|
||||
|
||||
$email = $this->faker->safeEmail;
|
||||
|
||||
$I->fillField(['name' => 'first_name'], $this->faker->firstName);
|
||||
$I->fillField(['name' => 'last_name'], $this->faker->lastName);
|
||||
$I->fillField(['name' => 'email'], $email);
|
||||
$I->click('Send invitation');
|
||||
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->see('Successfully sent invitation');
|
||||
$I->seeRecord('users', array('email' => $email));
|
||||
}
|
||||
|
||||
public function createToken(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('create a token');
|
||||
$I->amOnPage('/tokens/create');
|
||||
|
||||
$name = $this->faker->firstName;
|
||||
|
||||
$I->fillField(['name' => 'name'], $name);
|
||||
$I->click('Save');
|
||||
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->see('Successfully created token');
|
||||
$I->seeRecord('account_tokens', array('name' => $name));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user