Expanded test coverage.

This commit is contained in:
James Cole
2014-12-16 20:25:24 +01:00
parent a4f273b48b
commit 5135be3000
4 changed files with 104 additions and 14 deletions

View File

@@ -191,12 +191,8 @@ class AccountController extends BaseController
if ($data['post_submit_action'] == 'store') {
return Redirect::route('accounts.index', $data['what']);
}
// create another.
if ($data['post_submit_action'] == 'create_another') {
return Redirect::route('accounts.create', $data['what'])->withInput();
}
return Redirect::route('accounts.index', $data['what']);
return Redirect::route('accounts.create', $data['what'])->withInput();
}
/**
@@ -235,11 +231,8 @@ class AccountController extends BaseController
if ($data['post_submit_action'] == 'update') {
return Redirect::route('accounts.index', $data['what']);
}
// go back to update screen.
if ($data['post_submit_action'] == 'return_to_edit') {
return Redirect::route('accounts.edit', $account->id)->withInput(['post_submit_action' => 'return_to_edit']);
}
return Redirect::route('accounts.index', $data['what']);
// go back to update screen.
return Redirect::route('accounts.edit', $account->id)->withInput(['post_submit_action' => 'return_to_edit']);
}
}

View File

@@ -1,7 +1,7 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what) }}
{{Form::open(['class' => 'form-horizontal','route' => 'accounts.store'])}}
{{Form::open(['class' => 'form-horizontal','id' => 'store','route' => 'accounts.store'])}}
{{Form::hidden('what',$what)}}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">

View File

@@ -1,7 +1,7 @@
@extends('layouts.default')
@section('content')
{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) }}
{{Form::model($account, ['class' => 'form-horizontal','url' => route('accounts.update',$account->id)])}}
{{Form::model($account, ['class' => 'form-horizontal','id' => 'update','url' => route('accounts.update',$account->id)])}}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="panel panel-primary">

View File

@@ -54,7 +54,6 @@ class AccountControllerCest
$I->amOnPage('/accounts/delete/3');
$I->see('Delete account "Delete me"');
$I->submitForm('#destroy', []);
// TODO I dont believe this actually works.
$I->dontSeeRecord('accounts', ['id' => 3, 'deleted_at' => null]);
resetToClean::clean();
}
@@ -64,7 +63,7 @@ class AccountControllerCest
*/
public function edit(FunctionalTester $I)
{
$I->wantTo('delete an asset account');
$I->wantTo('edit an asset account');
$I->amOnPage('/accounts/edit/3');
$I->see('Edit asset account "Delete me"');
}
@@ -96,7 +95,55 @@ class AccountControllerCest
*/
public function store(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account');
$I->see('Create a new asset account');
$I->submitForm('#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'store']);
$I->seeRecord('accounts', ['name' => 'New through tests.']);
resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
public function storeValidateOnly(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account');
$I->see('Create a new asset account');
$I->submitForm(
'#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only']
);
$I->dontSeeRecord('accounts', ['name' => 'New through tests.']);
resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
public function storeAndCreateAnother(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('store a new asset account and create another');
$I->see('Create a new asset account');
$I->submitForm(
'#store', ['name' => 'New through tests.', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'create_another']
);
$I->seeRecord('accounts', ['name' => 'New through tests.']);
resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
public function storeFail(FunctionalTester $I)
{
$I->amOnPage('/accounts/create/asset');
$I->wantTo('make storing a new asset account fail.');
$I->see('Create a new asset account');
$I->submitForm('#store', ['name' => null, 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only']);
$I->dontSeeRecord('accounts', ['name' => 'New through tests.']);
resetToClean::clean();
}
/**
@@ -105,6 +152,56 @@ class AccountControllerCest
public function update(FunctionalTester $I)
{
$I->wantTo('update an asset account');
$I->amOnPage('/accounts/edit/3');
$I->see('Edit asset account "Delete me"');
$I->submitForm('#update', ['name' => 'Update me', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']);
$I->seeRecord('accounts', ['name' => 'Update me']);
resetToClean::clean();
}
/**
* @param FunctionalTester $I
*/
public function failUpdate(FunctionalTester $I)
{
$I->wantTo('update an asset account and fail');
$I->amOnPage('/accounts/edit/3');
$I->see('Edit asset account "Delete me"');
$I->submitForm('#update', ['name' => '', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'update']);
$I->seeRecord('accounts', ['name' => 'Delete me']);
}
/**
* @param FunctionalTester $I
*/
public function validateUpdateOnly(FunctionalTester $I)
{
$I->wantTo('update an asset account and validate only');
$I->amOnPage('/accounts/edit/2');
$I->see('Edit asset account "Savings account"');
$I->submitForm(
'#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'validate_only']
);
$I->dontSeeRecord('accounts', ['name' => 'Savings accountXX']);
}
/**
* @param FunctionalTester $I
*/
public function updateAndReturn(FunctionalTester $I)
{
$I->wantTo('update an asset account and return to form');
$I->amOnPage('/accounts/edit/2');
$I->see('Edit asset account "Savings account"');
$I->submitForm(
'#update', ['name' => 'Savings accountXX', 'what' => 'asset', 'account_role' => 'defaultExpense', 'post_submit_action' => 'return_to_edit']
);
$I->seeRecord('accounts', ['name' => 'Savings accountXX']);
resetToClean::clean();
}
}