mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
86 lines
2.7 KiB
PHP
86 lines
2.7 KiB
PHP
|
<?php
|
||
|
|
||
|
use Codeception\Util\Fixtures;
|
||
|
use \AcceptanceTester;
|
||
|
use Faker\Factory;
|
||
|
|
||
|
class OnlinePaymentCest
|
||
|
{
|
||
|
private $faker;
|
||
|
|
||
|
public function _before(AcceptanceTester $I)
|
||
|
{
|
||
|
$I->checkIfLogin($I);
|
||
|
|
||
|
$this->faker = Factory::create();
|
||
|
}
|
||
|
|
||
|
public function checkBalance(AcceptanceTester $I)
|
||
|
{
|
||
|
$I->wantTo('ensure the balance is correct');
|
||
|
|
||
|
$clientEmail = $this->faker->safeEmail;
|
||
|
$productKey = $this->faker->text(10);
|
||
|
$productPrice = $this->faker->numberBetween(1, 20);
|
||
|
|
||
|
// create client
|
||
|
$I->amOnPage('/clients/create');
|
||
|
$I->fillField(['name' => 'email'], $clientEmail);
|
||
|
$I->click('Save');
|
||
|
$I->wait(1);
|
||
|
$I->see($clientEmail);
|
||
|
|
||
|
$clientId = $I->grabFromCurrentUrl('~clients/(\d+)~');
|
||
|
|
||
|
// create product
|
||
|
$I->amOnPage('/products/create');
|
||
|
$I->fillField(['name' => 'product_key'], $productKey);
|
||
|
$I->fillField(['name' => 'notes'], $this->faker->text(80));
|
||
|
$I->fillField(['name' => 'cost'], $productPrice);
|
||
|
$I->click('Save');
|
||
|
$I->wait(1);
|
||
|
$I->see($productKey);
|
||
|
|
||
|
// create invoice
|
||
|
$I->amOnPage('/invoices/create');
|
||
|
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
|
||
|
$I->fillField('table.invoice-table tbody tr:nth-child(1) #product_key', $productKey);
|
||
|
$I->click('Save');
|
||
|
$I->wait(1);
|
||
|
$I->see($clientEmail);
|
||
|
$invoiceId = $I->grabFromCurrentUrl('~invoices/(\d+)~');
|
||
|
$I->amOnPage("/clients/{$clientId}");
|
||
|
$I->see('Balance $' . $productPrice);
|
||
|
|
||
|
// update the invoice
|
||
|
$I->amOnPage('/invoices/' . $invoiceId);
|
||
|
$I->fillField(['name' => 'quantity'], 2);
|
||
|
$I->click('Save');
|
||
|
$I->wait(1);
|
||
|
$I->amOnPage("/clients/{$clientId}");
|
||
|
$I->see('Balance $' . ($productPrice * 2));
|
||
|
|
||
|
// enter payment
|
||
|
$I->amOnPage("/payments/create/{$clientId}/{$invoiceId}");
|
||
|
$I->click('Save');
|
||
|
$I->wait(1);
|
||
|
$I->see('Balance $0.00');
|
||
|
$I->see('Paid to Date $' . ($productPrice * 2));
|
||
|
|
||
|
// archive the invoice
|
||
|
$I->amOnPage('/invoices/' . $invoiceId);
|
||
|
$I->executeJS('submitAction("archive")');
|
||
|
$I->wait(1);
|
||
|
$I->amOnPage("/clients/{$clientId}");
|
||
|
$I->see('Balance $0.00');
|
||
|
$I->see('Paid to Date $' . ($productPrice * 2));
|
||
|
|
||
|
// delete the invoice
|
||
|
$I->amOnPage('/invoices/' . $invoiceId);
|
||
|
$I->executeJS('submitAction("delete")');
|
||
|
$I->wait(1);
|
||
|
$I->amOnPage("/clients/{$clientId}");
|
||
|
$I->see('Balance $0.00');
|
||
|
$I->see('Paid to Date $0.00');
|
||
|
}
|
||
|
}
|