1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/tests/acceptance/ExpenseCest.php

64 lines
1.9 KiB
PHP
Raw Normal View History

2016-02-26 10:47:39 +01:00
<?php
use Faker\Factory;
use Codeception\Util\Fixtures;
class ExpenseCest
{
/**
* @var \Faker\Generator
*/
private $faker;
2017-03-12 20:56:56 +01:00
2016-02-26 10:47:39 +01:00
public function _before(AcceptanceTester $I)
{
$I->checkIfLogin($I);
$this->faker = Factory::create();
}
public function createExpense(AcceptanceTester $I)
{
$I->wantTo('Create an expense');
$vendorName = $this->faker->name;
2017-03-25 20:01:35 +01:00
$categoryName = $this->faker->text(20);
2017-03-13 09:00:07 +01:00
$clientName = $this->faker->name;
2016-02-26 10:47:39 +01:00
$clientEmail = $this->faker->safeEmail;
$amount = $this->faker->numberBetween(10, 20);
// create client
$I->amOnPage('/clients/create');
2017-03-13 09:00:07 +01:00
$I->fillField(['name' => 'name'], $clientName);
2016-02-26 10:47:39 +01:00
$I->fillField(['name' => 'contacts[0][email]'], $clientEmail);
$I->click('Save');
$I->see($clientEmail);
2017-03-13 09:00:07 +01:00
$clientId = $I->grabFromDatabase('clients', 'id', ['name' => $clientName]);
2016-02-26 10:47:39 +01:00
// create expense
$I->amOnPage('/expenses/create');
$I->fillField(['name' => 'amount'], $amount);
2017-03-25 20:01:35 +01:00
$I->selectDropdownCreate($I, 'vendor', $vendorName);
$I->selectDropdownCreate($I, 'expense_category', $categoryName, 'category');
2017-03-13 09:00:07 +01:00
$I->selectDropdown($I, $clientName, '.client-select .dropdown-toggle');
2016-02-26 10:47:39 +01:00
$I->click('Save');
2016-05-03 22:15:41 +02:00
$I->wait(2);
2017-03-25 20:01:35 +01:00
$vendorId = $I->grabFromDatabase('vendors', 'id', ['name' => $vendorName]);
$categoryId = $I->grabFromDatabase('expense_categories', 'id', ['name' => $categoryName]);
$I->seeInDatabase('expenses', [
'client_id' => $clientId,
'vendor_id' => $vendorId,
'expense_category_id' => $categoryId
]);
2016-02-26 10:47:39 +01:00
// invoice expense
$I->executeJS('submitAction(\'invoice\')');
2016-05-03 22:15:41 +02:00
$I->wait(2);
2017-03-25 20:01:35 +01:00
$I->click('Save Draft');
2017-03-13 09:00:07 +01:00
$I->wait(2);
2016-02-26 10:47:39 +01:00
$I->see($clientEmail);
$I->see($amount);
}
}