1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/tests/acceptance/PaymentCest.php

110 lines
3.3 KiB
PHP
Raw Normal View History

2015-08-20 17:09:04 +02:00
<?php
use App\Models\Payment;
use Faker\Factory;
class PaymentCest
{
private $faker;
public function _before(AcceptanceTester $I)
{
$I->checkIfLogin($I);
$this->faker = Factory::create();
}
public function create(AcceptanceTester $I)
{
2015-09-01 20:40:30 +02:00
$clientEmail = $this->faker->safeEmail;
$productKey = $this->faker->text(10);
$amount = rand(1, 10);
2015-08-20 17:09:04 +02:00
2015-08-30 14:08:15 +02:00
$I->wantTo('enter a payment');
2015-08-20 17:09:04 +02:00
2015-09-01 20:40:30 +02:00
// create client
$I->amOnPage('/clients/create');
2015-10-28 20:22:07 +01:00
$I->fillField(['name' => 'contacts[0][email]'], $clientEmail);
2015-09-01 20:40:30 +02:00
$I->click('Save');
$I->see($clientEmail);
// create product
$I->amOnPage('/products/create');
$I->fillField(['name' => 'product_key'], $productKey);
$I->fillField(['name' => 'notes'], $this->faker->text(80));
2015-10-28 20:22:07 +01:00
$I->fillField(['name' => 'cost'], $this->faker->numberBetween(11, 20));
2015-09-01 20:40:30 +02:00
$I->click('Save');
2016-09-14 17:54:49 +02:00
$I->wait(1);
2016-10-02 11:23:14 +02:00
//$I->see($productKey);
2015-09-01 20:40:30 +02:00
// create invoice
$I->amOnPage('/invoices/create');
$I->selectDropdown($I, $clientEmail, '.client_select .dropdown-toggle');
2017-12-25 14:23:30 +01:00
$I->fillField('table.invoice-table tbody tr:nth-child(1) td:nth-child(2) input.tt-input', $productKey);
2016-02-29 19:08:09 +01:00
$I->click('table.invoice-table tbody tr:nth-child(1) .tt-selectable');
2016-12-05 19:22:11 +01:00
$I->click('Mark Sent');
2017-02-07 16:31:06 +01:00
$I->wait(2);
2015-09-01 20:40:30 +02:00
$I->see($clientEmail);
$I->amOnPage('/payments/create');
$I->selectDropdown($I, $clientEmail, '.client-select .dropdown-toggle');
2015-08-20 17:09:04 +02:00
$I->selectDropdownRow($I, 1, '.invoice-select .combobox-container');
$I->fillField(['name' => 'amount'], $amount);
2015-09-01 20:40:30 +02:00
$I->selectDropdown($I, 'Cash', '.payment-type-select .dropdown-toggle');
2015-08-20 17:09:04 +02:00
$I->selectDataPicker($I, '#payment_date', 'now + 1 day');
$I->fillField(['name' => 'transaction_reference'], $this->faker->text(12));
$I->click('Save');
2016-09-14 17:54:49 +02:00
$I->wait(1);
2016-10-02 11:23:14 +02:00
2015-08-20 17:09:04 +02:00
$I->see('Successfully created payment');
$I->seeInDatabase('payments', ['amount' => number_format($amount, 2)]);
}
public function editPayment(AcceptanceTester $I)
{
$ref = $this->faker->text(12);
2016-09-14 17:54:49 +02:00
2015-08-30 14:08:15 +02:00
$I->wantTo('edit a payment');
2015-08-20 17:09:04 +02:00
$I->amOnPage('/payments/1/edit');
$I->selectDataPicker($I, '#payment_date', 'now + 2 day');
$I->fillField(['name' => 'transaction_reference'], $ref);
$I->click('Save');
$I->seeInDatabase('payments', ['transaction_reference' => $ref]);
}
public function listPayments(AcceptanceTester $I)
{
2015-08-30 14:08:15 +02:00
$I->wantTo('list payments');
2015-08-20 17:09:04 +02:00
$I->amOnPage('/payments');
$I->seeNumberOfElements('tbody tr[role=row]', [1, 10]);
}
/*
public function delete(AcceptanceTester $I)
{
$I->wantTo('delete a payment');
$I->amOnPage('/payments');
$I->seeCurrentUrlEquals('/payments');
$I->wait(3);
if ($num_payments = Payment::all()->count()) {
$row_rand = sprintf('tbody tr:nth-child(%d)', rand(1, $num_payments));
//show button
$I->executeJS(sprintf('$("%s div").css("visibility", "visible")', $row_rand));
//dropdown
$I->click($row_rand . ' button');
//click to delete button
$I->click($row_rand . ' ul li:nth-last-child(1) a');
$I->acceptPopup();
}
}
*/
}