Implementing paratest

This commit is contained in:
David Bomba 2020-10-09 23:13:18 +11:00
parent 5cd1acd484
commit ae2562b020
9 changed files with 3 additions and 403 deletions

View File

@ -56,7 +56,6 @@ class Gateway extends StaticModel
return $this->getMethods();
}
/**
* Test if gateway is custom.
* @return bool TRUE|FALSE

View File

@ -1,37 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="true" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./app</directory>
</include>
<exclude>
<directory suffix=".php">./vendor</directory>
<directory suffix=".php">./app/Providers</directory>
<directory suffix=".php">./app/Http</directory>
<directory suffix=".php">./app/Models</directory>
<directory suffix=".php">./app/Transformers</directory>
<directory suffix=".php">./app/Events</directory>
<directory suffix=".php">./app/Observers</directory>
<directory suffix=".php">./app/Policies</directory>
<directory suffix=".php">./app/Jobs</directory>
<directory suffix=".php">./app/Factory</directory>
<directory suffix=".php">./app/Helpers</directory>
<directory suffix=".php">./app/Libraries</directory>
<directory suffix=".php">./app/Listeners</directory>
<directory suffix=".php">./app/Mail</directory>
<directory suffix=".php">./app/Notifications</directory>
<directory suffix=".php">./app/Providers</directory>
<directory suffix=".php">./app/Repositories</directory>
<directory suffix=".php">./app/Filters</directory>
<file>./app/Console/Kernel.php</file>
<file>./app/Constants.php</file>
<file>./app/Libraries/OFX.php</file>
<file>./app/Exceptions/Handler.php</file>
</exclude>
<report>
<clover outputFile="coverage.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
@ -53,6 +22,8 @@
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="MAIL_MAILER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
<logging/>
</phpunit>

View File

@ -1,32 +0,0 @@
<?php
namespace Tests\Browser\Client;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class PaymentMethods extends DuskTestCase
{
public function testAddPaymentMethodPage(): void
{
$this->browse(function (Browser $browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$browser->visit(route('client.payment_methods.index'))
->waitFor('.dataTable')
->waitFor('.dataTables_empty')
->assertSee('No records found');
// TODO: Testing Stripe <iframe>
$browser->visit(route('client.payment_methods.create'))
->assertSee('Add Payment Method')
->assertSee('Save');
});
}
}

View File

@ -1,229 +0,0 @@
<?php
namespace Tests\Browser;
use App\Models\ClientContact;
use App\Models\Credit;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\RecurringInvoice;
use App\Utils\Traits\MakesHash;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\DuskTestCase;
class ClientPortalTest extends DuskTestCase
{
use WithFaker;
use MakesHash;
public $contact;
public function tearDown(): void
{
parent::tearDown();
$this->browse(function ($browser) {
$browser->driver->manage()->deleteAllCookies();
});
}
public function testLoginPageDisplayed()
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->assertPathIs('/client/login');
});
}
public function testLoginAValidUser()
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard')
->visit('client/logout')
->assertPathIs('/client/login');
});
}
public function testDashboardElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$browser->visit('/client/dashboard')
->assertSee(ctrans('texts.quick_overview_statistics'))
->visit('client/logout')
->assertPathIs('/client/login');
});
}
/**
* Test list of invoices.
*
* @return void
*/
public function testInvoicesElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$invoice = Invoice::first();
$browser->visit('/client/invoices')
->assertSee(ctrans('texts.pay_now'))
->assertSee($invoice->number)
->clickLink(ctrans('texts.view'))
->assertPathIs(route('client.invoice.show', $invoice->hashed_id, false))
->assertSee(ctrans('texts.pay_now'));
$browser->visit('/client/invoices')
->check('#paid')
->assertSee(ctrans('texts.paid'))
->visit('client/logout')
->assertPathIs('/client/login');
});
}
public function testRecurringInvoicesElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$invoice = RecurringInvoice::first();
$browser->visit('/client/recurring_invoices')
->assertSee(ctrans('texts.recurring_invoices'))
->clickLink(ctrans('texts.view'))
->assertPathIs(route('client.recurring_invoices.show', $invoice->hashed_id, false))
->visit('/client/logout')
->assertPathIs('/client/login');
});
}
/**
* List of payments.
*
* @return void
*/
public function testPaymentsElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$payment = Payment::first();
$browser->visit('/client/payments')
->clickLink(ctrans('texts.view'))
->assertPathIs(route('client.payments.show', $payment->hashed_id, false))
->visit('/client/logout')
->assertPathIs('/client/login');
});
}
/**
* List of payment methods.
*
* @return void
*/
public function testPaymentMethodsElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$browser->visit('/client/payment_methods')
->assertSee('No results found.')
->visit('client/logout')
->assertPathIs('/client/login');
});
}
public function testQuotesElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$credit = Credit::first();
$browser->visit('/client/quotes')
->clickLink(ctrans('texts.view'))
->assertPathIs(route('client.credits.show', $credit->hashed_id, false))
->visit('client/logout')
->assertPathIs('/client/login');
});
}
public function testCreditsElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$browser->visit('/client/credits')
->assertSee('No results found.')
->visit('client/logout')
->assertPathIs('/client/login');
});
}
public function testProfilePageContactUpdate(): void
{
$faker = \Faker\Factory::create();
$this->browse(function ($browser) use ($faker) {
$browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$client_contact = ClientContact::where('email', 'user@example.com')->first();
$browser->maximize();
$browser->visit(sprintf('/client/profile/%s/edit', $client_contact->client->user->hashed_id))
->assertSee(ctrans('texts.profile'));
$first_name = $browser->value('#first_name');
$browser->value('#first_name', $faker->firstName);
$browser->assertSee(ctrans('texts.save'))
->press(ctrans('texts.save'));
$this->assertNotEquals($first_name, $browser->value('#first_name'));
$browser->visit('client/logout')
->assertPathIs('/client/login');
});
}
}

View File

@ -1,41 +0,0 @@
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class HomePage extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
//
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Page as BasePage;
abstract class Page extends BasePage
{
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public static function siteElements()
{
return [
'@element' => '#selector',
];
}
}

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,44 +0,0 @@
<?php
namespace Tests;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
static::startChromeDriver();
}
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
]);
return RemoteWebDriver::create(
'http://localhost:9515',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY,
$options
)
);
}
}