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

63 lines
1.8 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-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 vendor
$I->amOnPage('/vendors/create');
$I->fillField(['name' => 'name'], $vendorName);
$I->click('Save');
$I->see($vendorName);
$vendorId = $I->grabFromDatabase('vendors', 'id', ['name' => $vendorName]);
// 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);
$I->selectDropdown($I, $vendorName, '.vendor-select .dropdown-toggle');
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);
2016-02-26 10:47:39 +01:00
$I->seeInDatabase('expenses', ['vendor_id' => $vendorId]);
2017-03-13 09:00:07 +01:00
$I->seeInDatabase('expenses', ['client_id' => $clientId]);
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);
2016-02-26 10:47:39 +01:00
$I->click('Save');
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);
}
}