diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 85b4cede7d9a..e2fc72af1b6c 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -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');
diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php
index b9dec31654c2..895fd93b439e 100644
--- a/resources/views/master.blade.php
+++ b/resources/views/master.blade.php
@@ -1,7 +1,7 @@
- {{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }} |
+ {{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}
diff --git a/resources/views/payments/edit.blade.php b/resources/views/payments/edit.blade.php
index 97fcb277129b..b36be5428d68 100644
--- a/resources/views/payments/edit.blade.php
+++ b/resources/views/payments/edit.blade.php
@@ -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('') !!}
diff --git a/resources/views/payments/payment.blade.php b/resources/views/payments/payment.blade.php
index 359f01a3ccd7..374b5ef5a8b8 100644
--- a/resources/views/payments/payment.blade.php
+++ b/resources/views/payments/payment.blade.php
@@ -230,7 +230,7 @@ header h3 em {
{!! Former::text('postal_code')->placeholder(trans('texts.postal_code'))->label('') !!}
- {!! 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') !!}
diff --git a/tests/_bootstrap.php.default b/tests/_bootstrap.php.default
new file mode 100644
index 000000000000..193f2f90f10c
--- /dev/null
+++ b/tests/_bootstrap.php.default
@@ -0,0 +1,8 @@
+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');
diff --git a/tests/acceptance/CreditCest.php b/tests/acceptance/CreditCest.php
index 738c8e6fb03f..6d7f1ac719b5 100644
--- a/tests/acceptance/CreditCest.php
+++ b/tests/acceptance/CreditCest.php
@@ -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);
}
}
\ No newline at end of file
diff --git a/tests/acceptance/InvoiceCest.php b/tests/acceptance/InvoiceCest.php
index ad7a4048be80..ee3bd1d2cf31 100644
--- a/tests/acceptance/InvoiceCest.php
+++ b/tests/acceptance/InvoiceCest.php
@@ -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');
diff --git a/tests/acceptance/InvoiceDesignCest.php b/tests/acceptance/InvoiceDesignCest.php
index dfe9f789ecc0..f774e51f2bd1 100644
--- a/tests/acceptance/InvoiceDesignCest.php
+++ b/tests/acceptance/InvoiceDesignCest.php
@@ -1,5 +1,4 @@
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');
+ });
+ }
+}
\ No newline at end of file
diff --git a/tests/acceptance/PaymentCest.php b/tests/acceptance/PaymentCest.php
index cd8664505ccb..275d73909f53 100644
--- a/tests/acceptance/PaymentCest.php
+++ b/tests/acceptance/PaymentCest.php
@@ -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));
diff --git a/tests/functional/SettingsCest.php b/tests/functional/SettingsCest.php
index a0c71f419011..ddf3dbf2a857 100644
--- a/tests/functional/SettingsCest.php
+++ b/tests/functional/SettingsCest.php
@@ -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));
+ }
+
+
}