1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Working on tests

This commit is contained in:
Hillel Coren 2017-03-19 17:44:35 +02:00
parent 091ac684e5
commit c773eb2975
4 changed files with 29 additions and 19 deletions

View File

@ -19,7 +19,7 @@ Heres an example of reading the list of clients using cURL from the command l
curl -X GET ninja.dev/api/v1/clients -H "X-Ninja-Token: TOKEN"
For invoices, quotes, tasks and payments simply change the object type. ie,
For invoices, quotes, tasks and payments simply change the object type.
.. code-block:: shell
@ -31,6 +31,12 @@ To load a single record specify the Id in the URL. Note: you can add ?invoice_nu
curl -X GET ninja.dev/api/v1/invoices/1 -H "X-Ninja-Token: TOKEN"
You can specify additional relationships to load using the ``include`` parameter.
.. code-block:: shell
curl -X GET ninja.dev/api/v1/clients/1?include=invoices.invitations -H "X-Ninja-Token: TOKEN"
You can download a PDF using the following URL
.. code-block:: shell

View File

@ -110,11 +110,8 @@ class AcceptanceTester extends \Codeception\Actor
$I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
}
function createOnlinePayment(\AcceptanceTester $I, $invoiceNumber)
function createOnlinePayment(\AcceptanceTester $I, $invitationKey)
{
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['invoice_number' => $invoiceNumber]);
$invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]);
$clientSession = $I->haveFriend('client');
$clientSession->does(function(AcceptanceTester $I) use ($invitationKey) {
$I->amOnPage('/view/' . $invitationKey);

View File

@ -70,8 +70,8 @@ class GatewayFeesCest
// partial invoice
$invoiceNumber = $this->createInvoice($I, $clientName, $productKey, $total, $partialFeeWithTax, $total / 2);
$this->createPayment($I, $invoiceNumber, $total + $partialFeeWithTax, 0, $partialFeeWithTax);
$invitationKey = $this->createInvoice($I, $clientName, $productKey, $total, $partialFeeWithTax, $total / 2);
$this->createPayment($I, $invitationKey, $total + $partialFeeWithTax, 0, $partialFeeWithTax);
}
private function configureGatewayFeeTax($I, $taxName = '', $taxRate = '')
@ -155,17 +155,18 @@ class GatewayFeesCest
$I->click('Mark Sent');
$I->see($clientEmail);
$balance = $partial ? ($amount - $partial) : 0;
$this->createPayment($I, $invoiceNumber, $amount, $balance, $fee);
return $invoiceNumber;
}
private function createPayment($I, $invoiceNumber, $amount, $balance, $fee)
{
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['invoice_number' => $invoiceNumber]);
$clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]);
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId, 'invoice_number' => $invoiceNumber]);
$invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]);
$balance = $partial ? ($amount - $partial) : 0;
$this->createPayment($I, $invitationKey, $amount, $balance, $fee);
return $invitationKey;
}
private function createPayment($I, $invitationKey, $amount, $balance, $fee)
{
// check we correctly remove/add back the gateway fee
$I->amOnPage('/view/' . $invitationKey);
$I->click('Pay Now');
@ -181,9 +182,12 @@ class GatewayFeesCest
$I->see('$' . number_format($fee, 2) . ' Fee');
$I->see('$' . number_format($fee * 2, 2) . ' Fee');
$I->createOnlinePayment($I, $invoiceNumber);
$I->createOnlinePayment($I, $invitationKey);
$invoiceId = $I->grabFromDatabase('invitations', 'invoice_id', ['invitation_key' => $invitationKey]);
$I->seeInDatabase('invoices', [
'invoice_number' => $invoiceNumber,
'invoice_id' => $invoiceId,
'amount' => ($amount + $fee),
'balance' => $balance
]);

View File

@ -35,6 +35,7 @@ class OnlinePaymentCest
// create invoice
$I->amOnPage('/invoices/create');
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey);
$I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
@ -43,7 +44,9 @@ class OnlinePaymentCest
// enter payment
$clientId = $I->grabFromDatabase('contacts', 'client_id', ['email' => $clientEmail]);
$invoiceNumber = $I->grabFromDatabase('invoices', 'invoice_number', ['client_id' => $clientId]);
$invoiceId = $I->grabFromDatabase('invoices', 'id', ['client_id' => $clientId, 'invoice_number' => $invoiceNumber]);
$invitationKey = $I->grabFromDatabase('invitations', 'invitation_key', ['invoice_id' => $invoiceId]);
$I->createOnlinePayment($I, $invoiceNumber);
/*