Files
firefly-iii/tests/functional/BillControllerCest.php

277 lines
8.5 KiB
PHP
Raw Normal View History

2014-12-25 00:42:31 +01:00
<?php
/**
2014-12-29 20:28:17 +01:00
* Class BillControllerCest
2014-12-30 17:55:46 +01:00
*
* @SuppressWarnings("CamelCase")
* @SuppressWarnings("short")
2014-12-25 00:42:31 +01:00
*/
2014-12-29 20:28:17 +01:00
class BillControllerCest
2014-12-25 00:42:31 +01:00
{
/**
* @param FunctionalTester $I
*/
public function _after(FunctionalTester $I)
{
}
/**
* @param FunctionalTester $I
*/
public function _before(FunctionalTester $I)
{
$I->amLoggedAs(['email' => 'thegrumpydictator@gmail.com', 'password' => 'james']);
}
/**
* @param FunctionalTester $I
*/
public function create(FunctionalTester $I)
{
2014-12-29 20:28:17 +01:00
$I->wantTo('create a bill');
$I->amOnPage('/bills/create');
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function delete(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('delete a bill');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/delete/' . $bill->id);
$I->see('Delete "' . $bill->name . '"');
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function destroy(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('destroy a bill');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/delete/' . $bill->id);
$I->see('Delete "' . $bill->name . '"');
2014-12-25 00:42:31 +01:00
$I->submitForm('#destroy', []);
2014-12-29 20:28:17 +01:00
$I->see('The bill was deleted.');
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function edit(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('edit a bill');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/edit/' . $bill->id);
$I->see($bill->name);
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function index(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('see all bills');
$I->amOnPage('/bills');
2015-01-01 21:06:24 +01:00
$I->see('Bills');
$I->see($bill->name);
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function rescan(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('rescan a bill');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/rescan/' . $bill->id);
2014-12-25 00:42:31 +01:00
$I->see('Rescanned everything.');
}
/**
* @param FunctionalTester $I
*/
public function rescanInactive(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->where('active', 0)->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('rescan an inactive bill');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/rescan/' . $bill->id);
2014-12-29 20:28:17 +01:00
$I->see('Inactive bills cannot be scanned.');
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function show(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('show a bill');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/show/' . $bill->id);
$I->see($bill->name);
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function store(FunctionalTester $I)
{
2014-12-29 20:28:17 +01:00
$I->wantTo('store a bill');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
2014-12-29 20:28:17 +01:00
'name' => 'Some bill',
'match' => 'one,two',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'store',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
2014-12-29 20:28:17 +01:00
$I->see('Bill &quot;Some bill&quot; stored.');
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
2014-12-29 20:28:17 +01:00
$I->wantTo('store a bill and fail');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
2014-12-29 20:28:17 +01:00
'name' => 'Some bill',
'match' => '',
'amount_min' => 10,
'amount_max' => 20,
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
2014-12-29 20:28:17 +01:00
$I->dontSeeInDatabase('bills', ['name' => 'Some bill']);
$I->see('Could not store bill');
}
2014-12-30 17:55:46 +01:00
/**
* @param FunctionalTester $I
*/
public function storeRecreate(FunctionalTester $I)
{
2014-12-29 20:28:17 +01:00
$I->wantTo('validate a bill and create another one');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
2014-12-29 20:28:17 +01:00
'name' => 'Some bill',
'match' => 'one,two',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'create_another',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0,
]
);
2014-12-29 20:28:17 +01:00
$I->see('Bill &quot;Some bill&quot; stored.');
}
/**
* @param FunctionalTester $I
*/
public function storeValidate(FunctionalTester $I)
{
2014-12-29 20:28:17 +01:00
$I->wantTo('validate a bill');
$I->amOnPage('/bills/create');
$I->submitForm(
'#store', [
2014-12-29 20:28:17 +01:00
'name' => 'Some bill',
'match' => 'one,two',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'validate_only',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0,
]
);
$I->see('form-group has-success has-feedback');
2014-12-25 00:42:31 +01:00
}
/**
* @param FunctionalTester $I
*/
public function update(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-29 20:28:17 +01:00
$I->wantTo('update a bill');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/edit/' . $bill->id);
$I->submitForm(
'#update', [
2014-12-29 20:28:17 +01:00
'name' => 'Some bill',
'match' => 'bla,bla',
'amount_min' => 10,
'amount_max' => 20,
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
2014-12-29 20:28:17 +01:00
$I->see('Bill &quot;Some bill&quot; updated.');
}
/**
* @param FunctionalTester $I
*/
2014-12-30 18:44:58 +01:00
public function updateFail(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-30 18:44:58 +01:00
$I->wantTo('update a bill and fail');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/edit/' . $bill->id);
$I->submitForm(
'#update', [
2014-12-29 20:28:17 +01:00
'name' => 'Some bill',
2014-12-30 18:44:58 +01:00
'match' => '',
'amount_min' => 10,
'amount_max' => 20,
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
2014-12-30 18:44:58 +01:00
$I->see('Could not update bill');
}
/**
* @param FunctionalTester $I
*/
2014-12-30 18:44:58 +01:00
public function updateReturn(FunctionalTester $I)
{
2015-01-01 21:06:24 +01:00
$bill = User::whereEmail('thegrumpydictator@gmail.com')->first()->bills()->first();
2014-12-30 18:44:58 +01:00
$I->wantTo('update a bill and return to edit it');
2015-01-01 21:06:24 +01:00
$I->amOnPage('/bills/edit/' . $bill->id);
$I->submitForm(
'#update', [
2014-12-30 18:44:58 +01:00
'name' => 'Some bill',
'match' => 'bla,bla',
'amount_min' => 10,
'amount_max' => 20,
'post_submit_action' => 'return_to_edit',
'date' => date('Y-m-d'),
'repeat_freq' => 'monthly',
'skip' => 0
]
);
2014-12-30 18:44:58 +01:00
$I->see('Bill &quot;Some bill&quot; updated.');
2014-12-25 00:42:31 +01:00
}
2015-01-02 06:16:49 +01:00
}