Working on tests

This commit is contained in:
Hillel Coren 2017-03-31 11:54:36 +03:00
parent 3f44620a1d
commit 9fe32b903d
2 changed files with 21 additions and 14 deletions

View File

@ -112,9 +112,13 @@ class AcceptanceTester extends \Codeception\Actor
function fillInvoice(\AcceptanceTester $I, $clientEmail, $productKey) function fillInvoice(\AcceptanceTester $I, $clientEmail, $productKey)
{ {
$I->amOnPage('/invoices/create'); $I->amOnPage('/invoices/create');
$invoiceNumber = $I->grabValueFrom('#invoice_number');
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle'); $I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey); $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'); $I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
return $invoiceNumber;
} }
function createOnlinePayment(\AcceptanceTester $I, $invitationKey) function createOnlinePayment(\AcceptanceTester $I, $invitationKey)

View File

@ -18,7 +18,7 @@ class GatewayFeesCest
public function checkLineItemFee(AcceptanceTester $I) public function checkLineItemFee(AcceptanceTester $I)
{ {
$clientName = $this->faker->word(); $clientName = $this->faker->text(14);
$clientEmail = $this->faker->safeEmail; $clientEmail = $this->faker->safeEmail;
$productKey = $this->faker->word(); $productKey = $this->faker->word();
$taxName = $this->faker->word(); $taxName = $this->faker->word();
@ -120,8 +120,7 @@ class GatewayFeesCest
private function createInvoice($I, $clientName, $productKey, $amount, $fee, $partial = false) private function createInvoice($I, $clientName, $productKey, $amount, $fee, $partial = false)
{ {
$I->fillInvoice($I, $clientName, $productKey); $invoiceNumber = $I->fillInvoice($I, $clientName, $productKey);
$invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value');
if ($partial) { if ($partial) {
$amount = ($partial * 2); $amount = ($partial * 2);
@ -145,25 +144,29 @@ class GatewayFeesCest
private function createPayment($I, $invitationKey, $amount, $balance, $fee) private function createPayment($I, $invitationKey, $amount, $balance, $fee)
{ {
$invoiceId = $I->grabFromDatabase('invitations', 'invoice_id', ['invitation_key' => $invitationKey]);
// check we correctly remove/add back the gateway fee // check we correctly remove/add back the gateway fee
$I->amOnPage('/view/' . $invitationKey);
$I->click('Pay Now');
$I->see(number_format($fee, 2) . ' Fee');
$I->see(number_format($fee * 2, 2) . ' Fee');
$I->amOnPage('/payment/' . $invitationKey . '/credit_card'); $I->amOnPage('/payment/' . $invitationKey . '/credit_card');
$I->seeInDatabase('invoices', [
'id' => $invoiceId,
'amount' => ($amount + $fee),
]);
$I->amOnPage('/payment/' . $invitationKey . '/bank_transfer'); $I->amOnPage('/payment/' . $invitationKey . '/bank_transfer');
$I->amOnPage('/payment/' . $invitationKey . '/credit_card'); $I->seeInDatabase('invoices', [
'id' => $invoiceId,
'amount' => ($amount + $fee * 2),
]);
$I->amOnPage('/view/' . $invitationKey); $I->amOnPage('/view/' . $invitationKey);
$I->click('Pay Now'); $I->seeInDatabase('invoices', [
$I->see(number_format($fee, 2) . ' Fee'); 'id' => $invoiceId,
$I->see(number_format($fee * 2, 2) . ' Fee'); 'amount' => ($amount),
]);
$I->createOnlinePayment($I, $invitationKey); $I->createOnlinePayment($I, $invitationKey);
$invoiceId = $I->grabFromDatabase('invitations', 'invoice_id', ['invitation_key' => $invitationKey]);
$I->seeInDatabase('invoices', [ $I->seeInDatabase('invoices', [
'id' => $invoiceId, 'id' => $invoiceId,
'amount' => ($amount + $fee), 'amount' => ($amount + $fee),