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

120 lines
3.1 KiB
PHP
Raw Normal View History

2015-08-20 17:09:04 +02:00
<?php
use Faker\Factory;
class TaskCest
{
/**
* @var \Faker\Generator
*/
private $faker;
public function _before(AcceptanceTester $I)
{
$I->checkIfLogin($I);
$this->faker = Factory::create();
}
public function createTimerTask(AcceptanceTester $I)
{
2017-03-25 20:51:08 +01:00
$clientName = $this->faker->name;
$clientEmail = $this->faker->safeEmail;
2017-03-25 20:01:35 +01:00
$project = $this->faker->text(20);
2017-03-25 20:51:08 +01:00
$description = $this->faker->text(100);
2015-08-20 17:09:04 +02:00
$I->wantTo('create a timed task');
2017-03-25 20:51:08 +01:00
// create client
$I->amOnPage('/clients/create');
$I->fillField(['name' => 'name'], $clientName);
$I->fillField(['name' => 'contacts[0][email]'], $clientEmail);
$I->click('Save');
$I->see($clientEmail);
$clientId = $I->grabFromDatabase('clients', 'id', ['name' => $clientName]);
2015-08-20 17:09:04 +02:00
$I->amOnPage('/tasks/create');
$I->seeCurrentUrlEquals('/tasks/create');
2017-03-25 20:51:08 +01:00
$I->selectDropdown($I, $clientName, '.client-select .dropdown-toggle');
2017-03-25 20:01:35 +01:00
$I->selectDropdownCreate($I, 'project', $project);
2015-08-20 17:09:04 +02:00
$I->fillField('#description', $description);
$I->click('Start');
$I->wait(rand(2, 5));
$I->click('Stop');
$I->click('Save');
2017-03-25 20:51:08 +01:00
$I->seeInDatabase('tasks', [
'description' => $description,
'client_id' => $clientId,
]);
2017-03-25 20:01:35 +01:00
$I->seeInDatabase('projects', ['name' => $project]);
2017-05-14 21:23:19 +02:00
$I->click('More Actions');
$I->click('Invoice Task');
$I->click('Mark Sent');
$I->see('Sent');
2017-08-03 09:20:38 +02:00
$I->wait(1);
2017-05-15 07:54:35 +02:00
$I->see('Successfully created invoice');
2015-08-20 17:09:04 +02:00
}
public function createManualTask(AcceptanceTester $I)
{
$description = $this->faker->text(100);
$I->wantTo('create a manual task');
$I->amOnPage('/tasks/create');
$I->seeCurrentUrlEquals('/tasks/create');
$I->selectOption('#task_type3', 'Manual');
$I->fillField('#description', $description);
$I->click('Save');
$I->seeInDatabase('tasks', ['description' => $description]);
}
public function editTask(AcceptanceTester $I)
{
$description = $this->faker->text(100);
$I->wantTo('edit a task');
$I->amOnPage('/tasks/1/edit');
$I->seeCurrentUrlEquals('/tasks/1/edit');
$I->fillField('#description', $description);
$I->click('Save');
$I->seeInDatabase('tasks', ['description' => $description]);
}
public function listTasks(AcceptanceTester $I)
{
2015-08-30 14:08:15 +02:00
$I->wantTo('list tasks');
2015-08-20 17:09:04 +02:00
$I->amOnPage('/tasks');
$I->seeNumberOfElements('tbody tr[role=row]', [1, 10]);
}
/*
public function deleteTask(AcceptanceTester $I)
{
$I->wantTo('delete a Task');
$I->amOnPage('/tasks');
$task_id = Helper::getRandom('Task', 'public_id');
//delete task
$I->executeJS(sprintf('deleteEntity(%d)', $task_id));
$I->acceptPopup();
//check if Task was delete
$I->wait(2);
$I->seeInDatabase('tasks', ['public_id' => $task_id, 'is_deleted' => true]);
}
*/
}