1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 21:52:35 +01:00
invoiceninja/tests/Browser/ClientPortal/Gateways/Braintree/ACHTest.php

93 lines
2.9 KiB
PHP
Raw Normal View History

2021-08-27 17:32:28 +02:00
<?php
namespace Tests\Browser\ClientPortal\Gateways\Braintree;
2021-08-27 19:36:21 +02:00
use App\DataMapper\FeesAndLimits;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
2021-08-27 17:32:28 +02:00
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
2021-08-27 19:36:21 +02:00
use Tests\Browser\Pages\ClientPortal\Login;
2021-08-27 17:32:28 +02:00
use Tests\DuskTestCase;
class ACHTest extends DuskTestCase
{
2021-08-27 19:36:21 +02:00
protected function setUp(): void
2021-08-27 17:32:28 +02:00
{
2021-08-27 19:36:21 +02:00
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
2021-08-27 17:32:28 +02:00
$this->browse(function (Browser $browser) {
2021-08-27 19:36:21 +02:00
$browser
->visit(new Login())
->auth();
2021-08-27 17:32:28 +02:00
});
2021-08-27 19:36:21 +02:00
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->restore();
$cg = CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::BANK_TRANSFER} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$company = Company::first();
$settings = $company->settings;
$settings->client_portal_allow_under_payment = true;
$settings->client_portal_allow_over_payment = true;
$company->settings = $settings;
$company->save();
2021-08-27 17:32:28 +02:00
}
2021-08-27 19:45:45 +02:00
public function testAddingBankAccount()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Bank Account')
->type('#account-holder-name', 'John Doe')
->type('#account-number', '1000000000')
->type('#routing-number', '011000015')
->type('#billing-postal-code', '12345')
->press('Add Payment Method')
2021-08-30 12:34:45 +02:00
->waitForText('Added payment method.');
2021-08-27 19:45:45 +02:00
});
}
2021-08-27 19:45:59 +02:00
public function testPayingWithExistingACH()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bank Transfer')
->click('.toggle-payment-with-token')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
2021-08-27 19:46:20 +02:00
public function testRemoveACHAccount()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
2021-08-27 17:32:28 +02:00
}