firefly-iii/tests/functional/RepeatedExpenseControllerCest.php

186 lines
5.7 KiB
PHP
Raw Normal View History

2014-12-30 10:27:31 -06:00
<?php
2014-12-30 11:25:38 -06:00
use Carbon\Carbon;
2014-12-30 10:27:31 -06:00
/**
* Class RepeatedExpenseControllerCest
2014-12-30 10:55:46 -06:00
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
2014-12-30 10:27:31 -06:00
*/
class RepeatedExpenseControllerCest
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function create(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('create a repeated expense');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/create');
$I->see('Create new repeated expense');
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function delete(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('delete a repeated expense');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/delete/4');
$I->see('Delete "Nieuwe kleding"');
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function destroy(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('destroy a repeated expense');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/delete/4');
$I->submitForm('#destroy', []);
$I->dontSeeInDatabase('piggy_banks', ['id' => 5]);
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function edit(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('edit a repeated expense');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/edit/4');
$I->see('Edit repeated expense "Nieuwe kleding"');
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function index(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('see all repeated expenses');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses');
$I->see('Overview');
$I->see('Nieuwe kleding');
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function show(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('view a repeated expense');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/show/4');
$I->see('Nieuwe kleding');
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function store(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('store a repeated expense');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/create');
$I->submitForm(
'#store', [
'name' => 'TestRepeatedExpense',
'account_id' => 1,
'targetamount' => 1000,
2014-12-30 11:25:38 -06:00
'targetdate' => Carbon::now()->format('Y-m-d'),
2014-12-30 10:27:31 -06:00
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'store',
]
);
2014-12-30 11:25:38 -06:00
$I->see('Piggy bank &quot;TestRepeatedExpense&quot; stored.');
2014-12-30 10:27:31 -06:00
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function update(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('update a repeated expense');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/edit/4');
$I->submitForm(
'#update', [
'name' => 'Nieuwe kleding!',
'account_id' => 2,
'targetamount' => 1000.00,
'targetdate' => '2014-12-30',
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'update',
]
);
$I->see('Repeated expense &quot;Nieuwe kleding!&quot; updated.');
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function updateAndReturnToEdit(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('update a repeated expense and return to edit screen');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/edit/4');
$I->submitForm(
'#update', [
'name' => 'Nieuwe kleding!',
'account_id' => 2,
'targetamount' => 1000.00,
'targetdate' => '2014-12-30',
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'return_to_edit',
]
);
$I->see('Repeated expense &quot;Nieuwe kleding!&quot; updated.');
}
2014-12-30 10:55:46 -06:00
/**
* @param FunctionalTester $I
*/
2014-12-30 10:27:31 -06:00
public function updateFail(FunctionalTester $I)
{
2014-12-30 11:25:38 -06:00
$I->wantTo('try to update a repeated expense and fail');
2014-12-30 10:27:31 -06:00
$I->amOnPage('/repeatedexpenses/edit/4');
$I->submitForm(
'#update', [
'name' => '',
'account_id' => 2,
'targetamount' => 1000.00,
'targetdate' => '2014-12-30',
'rep_length' => 'month',
'rep_every' => 0,
'rep_times' => 0,
'remind_me' => 1,
'reminder' => 'month',
'post_submit_action' => 'update',
]
);
$I->see('The name field is required.');
}
}