2015-08-20 17:09:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use \AcceptanceTester;
|
|
|
|
use App\Models\Credit;
|
|
|
|
use Faker\Factory;
|
|
|
|
use Codeception\Util\Fixtures;
|
|
|
|
|
|
|
|
class CreditCest
|
|
|
|
{
|
|
|
|
private $faker;
|
|
|
|
|
|
|
|
public function _before(AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
$I->checkIfLogin($I);
|
|
|
|
|
|
|
|
$this->faker = Factory::create();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create(AcceptanceTester $I)
|
|
|
|
{
|
|
|
|
$note = $this->faker->catchPhrase;
|
2015-09-01 20:40:30 +02:00
|
|
|
$clientEmail = $this->faker->safeEmail;
|
2015-08-20 17:09:04 +02:00
|
|
|
|
|
|
|
$I->wantTo('Create a credit');
|
|
|
|
|
2015-09-01 20:40:30 +02:00
|
|
|
$I->amOnPage('/clients/create');
|
|
|
|
$I->fillField(['name' => 'email'], $clientEmail);
|
|
|
|
$I->click('Save');
|
|
|
|
$I->see($clientEmail);
|
|
|
|
|
|
|
|
$I->amOnPage('/credits/create');
|
|
|
|
$I->selectDropdown($I, $clientEmail, '.client-select .dropdown-toggle');
|
2015-08-20 17:09:04 +02:00
|
|
|
$I->fillField(['name' => 'amount'], rand(50, 200));
|
|
|
|
$I->fillField(['name' => 'private_notes'], $note);
|
|
|
|
$I->selectDataPicker($I, '#credit_date', 'now + 1 day');
|
|
|
|
$I->click('Save');
|
|
|
|
|
|
|
|
$I->see('Successfully created credit');
|
|
|
|
$I->seeInDatabase('credits', array('private_notes' => $note));
|
|
|
|
|
|
|
|
$I->amOnPage('/credits');
|
|
|
|
$I->seeCurrentUrlEquals('/credits');
|
2015-09-01 20:40:30 +02:00
|
|
|
$I->see($clientEmail);
|
2015-08-20 17:09:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|