Test code cleanup.

This commit is contained in:
James Cole 2016-01-24 18:05:04 +01:00
parent 610f782054
commit 7b2fe8eb4a
11 changed files with 32 additions and 66 deletions

View File

@ -38,14 +38,8 @@ class AccountControllerTest extends TestCase
public function testDestroy() public function testDestroy()
{ {
$this->be($this->user()); $this->be($this->user());
$args = [
'_token' => Session::token(),
];
$this->session(['accounts.delete.url' => 'http://localhost']); $this->session(['accounts.delete.url' => 'http://localhost']);
$response = $this->call('POST', '/accounts/destroy/6');
$response = $this->call('POST', '/accounts/destroy/6', $args);
$this->assertSessionHas('success'); $this->assertSessionHas('success');
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
} }
@ -89,7 +83,6 @@ class AccountControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->session(['accounts.create.url' => 'http://localhost']); $this->session(['accounts.create.url' => 'http://localhost']);
$args = [ $args = [
'_token' => Session::token(),
'name' => 'Some kind of test account.', 'name' => 'Some kind of test account.',
'what' => 'asset', 'what' => 'asset',
'amount_currency_id_virtualBalance' => 1, 'amount_currency_id_virtualBalance' => 1,
@ -112,7 +105,6 @@ class AccountControllerTest extends TestCase
'id' => 1, 'id' => 1,
'name' => 'TestData new name', 'name' => 'TestData new name',
'active' => 1, 'active' => 1,
'_token' => Session ::token(),
]; ];
$this->be($this->user()); $this->be($this->user());

View File

@ -29,14 +29,8 @@ class AttachmentControllerTest extends TestCase
public function testDestroy() public function testDestroy()
{ {
$this->be($this->user()); $this->be($this->user());
$args = [
'_token' => Session::token(),
];
$this->session(['attachments.delete.url' => 'http://localhost']); $this->session(['attachments.delete.url' => 'http://localhost']);
$response = $this->call('POST', '/attachment/destroy/2');
$response = $this->call('POST', '/attachment/destroy/2', $args);
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
} }
@ -81,7 +75,6 @@ class AttachmentControllerTest extends TestCase
'title' => 'New title', 'title' => 'New title',
'description' => 'New descr', 'description' => 'New descr',
'notes' => 'New notes', 'notes' => 'New notes',
'_token' => Session::token(),
]; ];
$this->be($this->user()); $this->be($this->user());

View File

@ -74,7 +74,6 @@ class AuthControllerTest extends TestCase
'email' => 'thegrumpydictator@gmail.com', 'email' => 'thegrumpydictator@gmail.com',
'password' => 'james', 'password' => 'james',
'remember' => 1, 'remember' => 1,
'_token' => Session::token(),
]; ];
$response = $this->call('POST', '/login', $args); $response = $this->call('POST', '/login', $args);
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
@ -94,7 +93,6 @@ class AuthControllerTest extends TestCase
'email' => 'thegrumpydictator+test@gmail.com', 'email' => 'thegrumpydictator+test@gmail.com',
'password' => 'james123', 'password' => 'james123',
'password_confirmation' => 'james123', 'password_confirmation' => 'james123',
'_token' => Session::token(),
]; ];
$response = $this->call('POST', '/register', $args); $response = $this->call('POST', '/register', $args);
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());

View File

@ -19,7 +19,6 @@ class PasswordControllerTest extends TestCase
{ {
$args = [ $args = [
'email' => 'thegrumpydictator@gmail.com', 'email' => 'thegrumpydictator@gmail.com',
'_token' => Session::token(),
]; ];
$response = $this->call('POST', '/password/email', $args); $response = $this->call('POST', '/password/email', $args);
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());

View File

@ -42,10 +42,7 @@ class BillControllerTest extends TestCase
{ {
$this->session(['bills.delete.url' => 'http://localhost']); $this->session(['bills.delete.url' => 'http://localhost']);
$this->be($this->user()); $this->be($this->user());
$args = [ $response = $this->call('POST', '/bills/destroy/2');
'_token' => Session::token(),
];
$response = $this->call('POST', '/bills/destroy/2', $args);
$this->assertSessionHas('success'); $this->assertSessionHas('success');
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
} }
@ -100,7 +97,6 @@ class BillControllerTest extends TestCase
$args = [ $args = [
'name' => 'Some test', 'name' => 'Some test',
'match' => 'words', 'match' => 'words',
'_token' => Session::token(),
'amount_min' => 10, 'amount_min' => 10,
'amount_max' => 100, 'amount_max' => 100,
'amount_currency_id_amount_min' => 1, 'amount_currency_id_amount_min' => 1,
@ -127,7 +123,6 @@ class BillControllerTest extends TestCase
'id' => 1, 'id' => 1,
'name' => 'Some test', 'name' => 'Some test',
'match' => 'words', 'match' => 'words',
'_token' => Session::token(),
'amount_min' => 10, 'amount_min' => 10,
'amount_max' => 100, 'amount_max' => 100,
'amount_currency_id_amount_min' => 1, 'amount_currency_id_amount_min' => 1,

View File

@ -20,7 +20,6 @@ class BudgetControllerTest extends TestCase
{ {
$args = [ $args = [
'amount' => 1200, 'amount' => 1200,
'_token' => Session::token(),
]; ];
$this->be($this->user()); $this->be($this->user());
@ -55,13 +54,8 @@ class BudgetControllerTest extends TestCase
{ {
$this->be($this->user()); $this->be($this->user());
$args = [
'_token' => Session::token(),
];
$this->session(['budgets.delete.url' => 'http://localhost']); $this->session(['budgets.delete.url' => 'http://localhost']);
$response = $this->call('POST', '/budgets/destroy/2');
$response = $this->call('POST', '/budgets/destroy/2', $args);
$this->assertSessionHas('success'); $this->assertSessionHas('success');
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
} }
@ -103,7 +97,6 @@ class BudgetControllerTest extends TestCase
{ {
$args = [ $args = [
'amount' => 1200, 'amount' => 1200,
'_token' => Session::token(),
]; ];
$this->be($this->user()); $this->be($this->user());
@ -129,7 +122,6 @@ class BudgetControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->session(['budgets.create.url' => 'http://localhost']); $this->session(['budgets.create.url' => 'http://localhost']);
$args = [ $args = [
'_token' => Session::token(),
'name' => 'Some kind of test budget.', 'name' => 'Some kind of test budget.',
]; ];
@ -146,7 +138,6 @@ class BudgetControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->session(['budgets.edit.url' => 'http://localhost']); $this->session(['budgets.edit.url' => 'http://localhost']);
$args = [ $args = [
'_token' => Session::token(),
'name' => 'Some kind of test budget.', 'name' => 'Some kind of test budget.',
]; ];

View File

@ -41,13 +41,9 @@ class CategoryControllerTest extends TestCase
{ {
$this->be($this->user()); $this->be($this->user());
$args = [
'_token' => Session::token(),
];
$this->session(['categories.delete.url' => 'http://localhost']); $this->session(['categories.delete.url' => 'http://localhost']);
$response = $this->call('POST', '/categories/destroy/2', $args); $response = $this->call('POST', '/categories/destroy/2');
$this->assertSessionHas('success'); $this->assertSessionHas('success');
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
} }
@ -84,6 +80,7 @@ class CategoryControllerTest extends TestCase
/** /**
* @covers FireflyIII\Http\Controllers\CategoryController::show * @covers FireflyIII\Http\Controllers\CategoryController::show
* @covers FireflyIII\Http\Controllers\Controller::getSumOfRange
*/ */
public function testShow() public function testShow()
{ {
@ -111,7 +108,6 @@ class CategoryControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->session(['categories.create.url' => 'http://localhost']); $this->session(['categories.create.url' => 'http://localhost']);
$args = [ $args = [
'_token' => Session::token(),
'name' => 'Some kind of test cat.', 'name' => 'Some kind of test cat.',
]; ];
@ -128,7 +124,6 @@ class CategoryControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->session(['categories.edit.url' => 'http://localhost']); $this->session(['categories.edit.url' => 'http://localhost']);
$args = [ $args = [
'_token' => Session::token(),
'name' => 'Some kind of test category.', 'name' => 'Some kind of test category.',
]; ];

View File

@ -112,7 +112,6 @@ class CsvControllerTest extends TestCase
6 => 'budget-name', 6 => 'budget-name',
], ],
'map' => [], 'map' => [],
'_token' => Session::token(),
]; ];
// create session data: // create session data:
@ -160,7 +159,6 @@ class CsvControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->session($this->getSessionData()); $this->session($this->getSessionData());
$postData = [ $postData = [
'_token' => Session::token(),
'mapping' 'mapping'
=> [0 => ['NL11XOLA6707795988' => '1',], => [0 => ['NL11XOLA6707795988' => '1',],
1 => ['NL10TAPT8906262744' => '0', 'NL93UPSZ1261542703' => '0', 'NL86IHAL3264575116' => '0', 'NL63BKBO9993148806' => '0', 1 => ['NL10TAPT8906262744' => '0', 'NL93UPSZ1261542703' => '0', 'NL86IHAL3264575116' => '0', 'NL63BKBO9993148806' => '0',
@ -193,7 +191,6 @@ class CsvControllerTest extends TestCase
$file = new UploadedFile(storage_path('build/test-upload.csv'), 'test-file.csv', 'text/plain', 446); $file = new UploadedFile(storage_path('build/test-upload.csv'), 'test-file.csv', 'text/plain', 446);
$args = [ $args = [
'_token' => Session::token(),
'date_format' => 'Ymd', 'date_format' => 'Ymd',
'csv_import_account' => 1, 'csv_import_account' => 1,
]; ];

View File

@ -51,15 +51,9 @@ class CurrencyControllerTest extends TestCase
*/ */
public function testDestroy() public function testDestroy()
{ {
$args = [
'_token' => Session::token(),
];
$this->session(['currency.delete.url' => 'http://localhost/currency']); $this->session(['currency.delete.url' => 'http://localhost/currency']);
$this->be($this->user()); $this->be($this->user());
$response = $this->call('POST', '/currency/destroy/3', $args); $response = $this->call('POST', '/currency/destroy/3');
$this->assertSessionHas('success'); $this->assertSessionHas('success');
$this->assertRedirectedToRoute('currency.index'); $this->assertRedirectedToRoute('currency.index');
$this->assertEquals(302, $response->status()); $this->assertEquals(302, $response->status());
@ -94,7 +88,6 @@ class CurrencyControllerTest extends TestCase
$this->be($this->user()); $this->be($this->user());
$this->session(['currency.create.url' => 'http://localhost/currency']); $this->session(['currency.create.url' => 'http://localhost/currency']);
$args = [ $args = [
'_token' => Session::token(),
'name' => 'New Euro.', 'name' => 'New Euro.',
'symbol' => 'Y', 'symbol' => 'Y',
'code' => 'IUY', 'code' => 'IUY',
@ -118,7 +111,6 @@ class CurrencyControllerTest extends TestCase
'name' => 'New Euro.', 'name' => 'New Euro.',
'symbol' => 'Y', 'symbol' => 'Y',
'code' => 'IUY', 'code' => 'IUY',
'_token' => Session::token(),
]; ];
$this->be($this->user()); $this->be($this->user());

View File

@ -20,7 +20,6 @@ class HomeControllerTest extends TestCase
$args = [ $args = [
'start' => '2012-01-01', 'start' => '2012-01-01',
'end' => '2012-04-01', 'end' => '2012-04-01',
'_token' => Session::token(),
]; ];
// if date range is > 50, should have flash. // if date range is > 50, should have flash.
@ -41,6 +40,7 @@ class HomeControllerTest extends TestCase
/** /**
* @covers FireflyIII\Http\Controllers\HomeController::index * @covers FireflyIII\Http\Controllers\HomeController::index
* @covers FireflyIII\Http\Controllers\Controller::__construct
*/ */
public function testIndex() public function testIndex()
{ {

View File

@ -16,25 +16,39 @@ class NewUserControllerTest extends TestCase
/** /**
* @covers FireflyIII\Http\Controllers\NewUserController::index * @covers FireflyIII\Http\Controllers\NewUserController::index
* @todo Implement testIndex().
*/ */
public function testIndex() public function testIndex()
{ {
// Remove the following lines when you implement this test. $this->be($this->emptyUser());
$this->markTestIncomplete( $this->call('GET', '/');
'This test has not been implemented yet.' $this->assertResponseStatus(302);
); $this->assertRedirectedToRoute('new-user.index');
}
/**
* @covers FireflyIII\Http\Controllers\NewUserController::index
*/
public function testIndexGo()
{
$this->be($this->emptyUser());
$this->call('GET', '/new-user');
$this->assertResponseStatus(200);
} }
/** /**
* @covers FireflyIII\Http\Controllers\NewUserController::submit * @covers FireflyIII\Http\Controllers\NewUserController::submit
* @todo Implement testSubmit().
*/ */
public function testSubmit() public function testSubmit()
{ {
// Remove the following lines when you implement this test. $this->be($this->emptyUser());
$this->markTestIncomplete(
'This test has not been implemented yet.' $args = [
); 'bank_name' => 'New bank',
'bank_balance' => 100,
];
$this->call('POST', '/new-user/submit', $args);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
} }
} }