2015-08-20 17:09:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Codeception\Util\Fixtures;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherited Methods
|
|
|
|
* @method void wantToTest($text)
|
|
|
|
* @method void wantTo($text)
|
|
|
|
* @method void execute($callable)
|
|
|
|
* @method void expectTo($prediction)
|
|
|
|
* @method void expect($prediction)
|
|
|
|
* @method void amGoingTo($argumentation)
|
|
|
|
* @method void am($role)
|
|
|
|
* @method void lookForwardTo($achieveValue)
|
|
|
|
* @method void comment($description)
|
|
|
|
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
|
|
|
|
*
|
|
|
|
* @SuppressWarnings(PHPMD)
|
|
|
|
*/
|
|
|
|
class AcceptanceTester extends \Codeception\Actor
|
|
|
|
{
|
|
|
|
use _generated\AcceptanceTesterActions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define custom actions here
|
|
|
|
*/
|
|
|
|
function checkIfLogin(\AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
//if ($I->loadSessionSnapshot('login')) return;
|
|
|
|
|
2016-08-02 09:41:04 +02:00
|
|
|
$I->amOnPage('/login?lang=en');
|
2016-02-18 08:20:53 +01:00
|
|
|
$I->see('Login');
|
2015-08-20 17:09:04 +02:00
|
|
|
$I->fillField(['name' => 'email'], Fixtures::get('username'));
|
|
|
|
$I->fillField(['name' => 'password'], Fixtures::get('password'));
|
2015-10-13 09:11:44 +02:00
|
|
|
$I->click('Login');
|
2015-08-20 17:09:04 +02:00
|
|
|
|
|
|
|
//$I->saveSessionSnapshot('login');
|
2016-08-02 09:41:04 +02:00
|
|
|
}
|
2015-08-20 17:09:04 +02:00
|
|
|
|
|
|
|
function selectDataPicker(\AcceptanceTester $I, $element, $date = 'now')
|
|
|
|
{
|
2016-10-02 12:36:14 +02:00
|
|
|
$date = strtotime($date) * 1000;
|
|
|
|
$I->executeJS(sprintf('$(\'%s\').datepicker(\'update\', new Date(%s))', $element, $date));
|
2015-08-20 17:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function selectDropdown(\AcceptanceTester $I, $option, $dropdownSelector)
|
|
|
|
{
|
|
|
|
$I->click($dropdownSelector);
|
2017-04-12 16:04:09 +02:00
|
|
|
$I->click(sprintf('ul.typeahead li[data-value*="%s"]', $option));
|
2015-08-20 17:09:04 +02:00
|
|
|
}
|
|
|
|
|
2017-03-25 20:01:35 +01:00
|
|
|
function selectDropdownCreate(\AcceptanceTester $I, $entityType, $value, $entityTypeShort = false)
|
|
|
|
{
|
|
|
|
$entityTypeShort = $entityTypeShort ?: $entityType;
|
|
|
|
$I->fillField("#{$entityType}_name", $value);
|
2017-04-12 16:04:09 +02:00
|
|
|
$I->click(sprintf('ul.typeahead li[data-value*="%s"]', "Create {$entityTypeShort}: \$name"));
|
2017-03-25 20:01:35 +01:00
|
|
|
}
|
|
|
|
|
2015-08-20 17:09:04 +02:00
|
|
|
function selectDropdownRow(\AcceptanceTester $I, $option, $dropdownSelector)
|
|
|
|
{
|
|
|
|
$I->click("$dropdownSelector span.dropdown-toggle");
|
|
|
|
$I->click("$dropdownSelector ul li:nth-child($option)");
|
|
|
|
}
|
2017-03-19 14:31:25 +01:00
|
|
|
|
|
|
|
function createGateway(\AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
if ( ! $I->grabFromDatabase('account_gateways', 'id', ['id' => 1])) {
|
|
|
|
$I->wantTo('create a gateway');
|
2017-10-11 12:02:41 +02:00
|
|
|
$I->amOnPage('/gateways/create');
|
2017-03-19 14:31:25 +01:00
|
|
|
$I->fillField(['name' =>'23_apiKey'], env('stripe_secret_key') ?: Fixtures::get('stripe_secret_key'));
|
|
|
|
$I->fillField(['name' =>'publishable_key'], '');
|
|
|
|
$I->click('Save');
|
|
|
|
$I->see('Successfully created gateway');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-12 14:46:46 +02:00
|
|
|
function createClient(\AcceptanceTester $I, $email)
|
2017-03-19 14:31:25 +01:00
|
|
|
{
|
|
|
|
$I->amOnPage('/clients/create');
|
|
|
|
$I->fillField(['name' => 'contacts[0][email]'], $email);
|
|
|
|
$I->click('Save');
|
|
|
|
$I->see($email);
|
|
|
|
}
|
|
|
|
|
|
|
|
function createProduct(\AcceptanceTester $I, $productKey, $cost, $taxName = '', $taxRate = '')
|
|
|
|
{
|
|
|
|
$I->amOnPage('/products/create');
|
|
|
|
$I->fillField(['name' => 'product_key'], $productKey);
|
|
|
|
$I->fillField(['name' => 'cost'], $cost);
|
|
|
|
|
|
|
|
if ($taxName && $taxRate) {
|
|
|
|
$taxOption = $taxName . ': ' . number_format($taxRate, 3) . '%';
|
2017-05-17 12:14:32 +02:00
|
|
|
$I->selectOption('#tax_select1', $taxOption);
|
2017-03-19 14:31:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$I->click('Save');
|
|
|
|
$I->wait(1);
|
|
|
|
//$I->see($productKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
function createTaxRate(\AcceptanceTester $I, $name, $rate)
|
|
|
|
{
|
|
|
|
$I->amOnPage('/tax_rates/create');
|
|
|
|
$I->fillField(['name' => 'name'], $name);
|
|
|
|
$I->fillField(['name' => 'rate'], $rate);
|
|
|
|
$I->click('Save');
|
|
|
|
$I->see($name);
|
|
|
|
$I->see($rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
function fillInvoice(\AcceptanceTester $I, $clientEmail, $productKey)
|
|
|
|
{
|
|
|
|
$I->amOnPage('/invoices/create');
|
2017-03-31 10:54:36 +02:00
|
|
|
$invoiceNumber = $I->grabValueFrom('#invoice_number');
|
|
|
|
|
2017-03-19 14:31:25 +01:00
|
|
|
$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');
|
2017-03-31 10:54:36 +02:00
|
|
|
|
|
|
|
return $invoiceNumber;
|
2017-03-19 14:31:25 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 16:44:35 +01:00
|
|
|
function createOnlinePayment(\AcceptanceTester $I, $invitationKey)
|
2017-03-19 14:31:25 +01:00
|
|
|
{
|
|
|
|
$clientSession = $I->haveFriend('client');
|
|
|
|
$clientSession->does(function(AcceptanceTester $I) use ($invitationKey) {
|
|
|
|
$I->amOnPage('/view/' . $invitationKey);
|
|
|
|
$I->click('Pay Now');
|
2017-10-13 08:56:45 +02:00
|
|
|
$I->click('Credit Card');
|
2017-03-19 14:31:25 +01:00
|
|
|
$I->fillField('#card_number', '4242424242424242');
|
|
|
|
$I->fillField('#cvv', '100');
|
|
|
|
$I->selectOption('#expiration_month', 12);
|
|
|
|
$I->selectOption('#expiration_year', date('Y'));
|
|
|
|
$I->click('.btn-success');
|
2017-11-14 19:07:58 +01:00
|
|
|
$I->wait(5);
|
2017-03-19 14:31:25 +01:00
|
|
|
$I->see('Successfully applied payment');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkSettingOption(\AcceptanceTester $I, $url, $option)
|
|
|
|
{
|
|
|
|
$I->amOnPage('/settings/' . $url);
|
|
|
|
$I->checkOption('#' . $option);
|
|
|
|
$I->click('Save');
|
|
|
|
}
|
|
|
|
|
|
|
|
function uncheckSettingOption(\AcceptanceTester $I, $url, $option)
|
|
|
|
{
|
|
|
|
$I->amOnPage('/settings/' . $url);
|
|
|
|
$I->uncheckOption('#' . $option);
|
|
|
|
$I->click('Save');
|
|
|
|
}
|
|
|
|
|
2015-08-20 17:09:04 +02:00
|
|
|
}
|