From 9fe32b903d01130a2e0ccd00b2f248d41e1439b7 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 31 Mar 2017 11:54:36 +0300 Subject: [PATCH] Working on tests --- tests/_support/AcceptanceTester.php | 4 ++++ tests/acceptance/GatewayFeesCest.php | 31 +++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index 5f821119b8f5..d044963e98b4 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -112,9 +112,13 @@ class AcceptanceTester extends \Codeception\Actor function fillInvoice(\AcceptanceTester $I, $clientEmail, $productKey) { $I->amOnPage('/invoices/create'); + $invoiceNumber = $I->grabValueFrom('#invoice_number'); + $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'); + + return $invoiceNumber; } function createOnlinePayment(\AcceptanceTester $I, $invitationKey) diff --git a/tests/acceptance/GatewayFeesCest.php b/tests/acceptance/GatewayFeesCest.php index 4f5b344c8dbc..289b39715403 100644 --- a/tests/acceptance/GatewayFeesCest.php +++ b/tests/acceptance/GatewayFeesCest.php @@ -18,7 +18,7 @@ class GatewayFeesCest public function checkLineItemFee(AcceptanceTester $I) { - $clientName = $this->faker->word(); + $clientName = $this->faker->text(14); $clientEmail = $this->faker->safeEmail; $productKey = $this->faker->word(); $taxName = $this->faker->word(); @@ -120,8 +120,7 @@ class GatewayFeesCest private function createInvoice($I, $clientName, $productKey, $amount, $fee, $partial = false) { - $I->fillInvoice($I, $clientName, $productKey); - $invoiceNumber = $I->grabAttributeFrom('#invoice_number', 'value'); + $invoiceNumber = $I->fillInvoice($I, $clientName, $productKey); if ($partial) { $amount = ($partial * 2); @@ -145,25 +144,29 @@ class GatewayFeesCest 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 - $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->seeInDatabase('invoices', [ + 'id' => $invoiceId, + 'amount' => ($amount + $fee), + ]); + $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->click('Pay Now'); - $I->see(number_format($fee, 2) . ' Fee'); - $I->see(number_format($fee * 2, 2) . ' Fee'); + $I->seeInDatabase('invoices', [ + 'id' => $invoiceId, + 'amount' => ($amount), + ]); $I->createOnlinePayment($I, $invitationKey); - $invoiceId = $I->grabFromDatabase('invitations', 'invoice_id', ['invitation_key' => $invitationKey]); - $I->seeInDatabase('invoices', [ 'id' => $invoiceId, 'amount' => ($amount + $fee),