New tests.

This commit is contained in:
James Cole
2016-12-18 17:54:11 +01:00
parent 8666197e05
commit 5a57398f81
15 changed files with 223 additions and 152 deletions

View File

@@ -94,6 +94,15 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
}
/**
* @return User
*/
public function emptyUser()
{
$user = User::find(2);
return $user;
}
/**
* @return User

View File

@@ -31,10 +31,10 @@ class NewUserControllerTest extends TestCase
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->emptyUser());
$this->call('get', route('new-user.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
@@ -42,10 +42,14 @@ class NewUserControllerTest extends TestCase
*/
public function testSubmit()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = [
'bank_name' => 'New bank',
'bank_balance' => 100,
];
$this->be($this->emptyUser());
$this->call('post', route('new-user.submit'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}

View File

@@ -8,6 +8,7 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
/**
@@ -28,182 +29,191 @@ class PiggyBankControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::add
* Implement testAdd().
*/
public function testAdd()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.add', [1]));
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::addMobile
* Implement testAddMobile().
*/
public function testAddMobile()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.add-money-mobile', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::create
* Implement testCreate().
*/
public function testCreate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.create'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::delete
* Implement testDelete().
*/
public function testDelete()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.delete', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::destroy
* Implement testDestroy().
*/
public function testDestroy()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$repository = $this->mock(PiggyBankRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$this->session(['piggy-banks.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('post', route('piggy-banks.destroy', [2]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('index');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::edit
* Implement testEdit().
*/
public function testEdit()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.edit', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::index
* Implement testIndex().
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::order
* Implement testOrder().
*/
public function testOrder()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('post', route('piggy-banks.order', [1, 2]));
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postAdd
* Implement testPostAdd().
*/
public function testPostAdd()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = ['amount' => 1];
$this->be($this->user());
$this->call('post', route('piggy-banks.add', [1]), $data);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('piggy-banks.index');
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postRemove
* Implement testPostRemove().
*/
public function testPostRemove()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = ['amount' => 1];
$this->be($this->user());
$this->call('post', route('piggy-banks.remove', [1]), $data);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('piggy-banks.index');
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::remove
* Implement testRemove().
*/
public function testRemove()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.remove', [1]));
$this->assertResponseStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::removeMobile
* Implement testRemoveMobile().
*/
public function testRemoveMobile()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.remove-money-mobile', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::show
* Implement testShow().
*/
public function testShow()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('piggy-banks.show', [1]));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::store
* Implement testStore().
*/
public function testStore()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->session(['piggy-banks.create.url' => 'http://localhost']);
$data = [
'name' => 'Piggy ' . rand(999, 10000),
'targetamount' => 100,
'account_id' => 2,
'amount_currency_id_targetamount' => 1,
];
$this->be($this->user());
$this->call('post', route('piggy-banks.store'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('index');
}
/**
* @covers \FireflyIII\Http\Controllers\PiggyBankController::update
* Implement testUpdate().
*/
public function testUpdate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->session(['piggy-banks.edit.url' => 'http://localhost']);
$data = [
'name' => 'Updated Piggy ' . rand(999, 10000),
'targetamount' => 100,
'account_id' => 2,
'amount_currency_id_targetamount' => 1,
];
$this->be($this->user());
$this->call('post', route('piggy-banks.update', [3]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('index');
}
}

View File

@@ -28,61 +28,51 @@ class PreferencesControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::code
* Implement testCode().
*/
public function testCode()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('preferences.code'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::deleteCode
* Implement testDeleteCode().
*/
public function testDeleteCode()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('preferences.delete-code'));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertSessionHas('info');
$this->assertRedirectedToRoute('preferences.index');
}
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::index
* Implement testIndex().
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::postCode
* Implement testPostCode().
*/
public function testPostCode()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('preferences.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\PreferencesController::postIndex
* Implement testPostIndex().
*/
public function testPostIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$data = [
'fiscalYearStart' => '2016-01-01'
];
$this->be($this->user());
$this->call('post', route('preferences.update'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('preferences.index');
}
}

View File

@@ -8,6 +8,7 @@
*
* See the LICENSE file for details.
*/
use FireflyIII\Repositories\User\UserRepositoryInterface;
/**
@@ -28,61 +29,69 @@ class ProfileControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\ProfileController::changePassword
* Implement testChangePassword().
*/
public function testChangePassword()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('profile.change-password'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\ProfileController::deleteAccount
* Implement testDeleteAccount().
*/
public function testDeleteAccount()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('profile.delete-account'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\ProfileController::index
* Implement testIndex().
*/
public function testIndex()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$this->be($this->user());
$this->call('get', route('profile.index'));
$this->assertResponseStatus(200);
$this->see('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\ProfileController::postChangePassword
* Implement testPostChangePassword().
*/
public function testPostChangePassword()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('changePassword');
$data = [
'current_password' => 'james',
'new_password' => 'james2',
'new_password_confirmation' => 'james2',
];
$this->be($this->user());
$this->call('post', route('profile.change-password.post'), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\ProfileController::postDeleteAccount
* Implement testPostDeleteAccount().
*/
public function testPostDeleteAccount()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('destroy');
$data = [
'password' => 'james',
];
$this->be($this->user());
$this->call('post', route('profile.delete-account.post'), $data);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('index');
}
}