Fixed tests.

This commit is contained in:
James Cole
2015-06-21 16:10:32 +02:00
parent ad8a9717d1
commit 780d137b76
3 changed files with 6 additions and 123 deletions

View File

@@ -56,13 +56,13 @@ class ProfileController extends Controller
if (!Hash::check($request->get('current_password'), Auth::user()->password)) { if (!Hash::check($request->get('current_password'), Auth::user()->password)) {
Session::flash('error', 'Invalid current password!'); Session::flash('error', 'Invalid current password!');
return Redirect::route('change-password'); return Redirect::route('profile.change-password');
} }
$result = $this->validatePassword($request->get('current_password'), $request->get('new_password')); $result = $this->validatePassword($request->get('current_password'), $request->get('new_password'));
if (!($result === true)) { if (!($result === true)) {
Session::flash('error', $result); Session::flash('error', $result);
return Redirect::route('change-password'); return Redirect::route('profile.change-password');
} }
// update the user with the new password. // update the user with the new password.
@@ -103,7 +103,7 @@ class ProfileController extends Controller
if (!Hash::check($request->get('password'), Auth::user()->password)) { if (!Hash::check($request->get('password'), Auth::user()->password)) {
Session::flash('error', 'Invalid password!'); Session::flash('error', 'Invalid password!');
return Redirect::route('delete-account'); return Redirect::route('profile.delete-account');
} }
// DELETE! // DELETE!

View File

@@ -103,8 +103,6 @@ class ProfileControllerTest extends TestCase
public function testPostChangePasswordInvalidCurrent() public function testPostChangePasswordInvalidCurrent()
{ {
$user = FactoryMuffin::create('FireflyIII\User'); $user = FactoryMuffin::create('FireflyIII\User');
$user->password = bcrypt('current');
$user->save();
$this->be($user); $this->be($user);
$post = [ $post = [
@@ -116,7 +114,7 @@ class ProfileControllerTest extends TestCase
$this->call('POST', '/profile/change-password', $post); $this->call('POST', '/profile/change-password', $post);
$this->assertRedirectedToRoute('change-password'); $this->assertRedirectedToRoute('profile.change-password');
$this->assertSessionHas('error', 'Invalid current password!'); $this->assertSessionHas('error', 'Invalid current password!');
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
@@ -144,7 +142,7 @@ class ProfileControllerTest extends TestCase
$this->assertSessionHas('error', 'The idea is to change your password.'); $this->assertSessionHas('error', 'The idea is to change your password.');
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
$this->assertRedirectedToRoute('change-password'); $this->assertRedirectedToRoute('profile.change-password');
} }
@@ -188,7 +186,7 @@ class ProfileControllerTest extends TestCase
$this->call('POST', '/profile/delete-account', $post); $this->call('POST', '/profile/delete-account', $post);
$this->assertRedirectedToRoute('delete-account'); $this->assertRedirectedToRoute('profile.delete-account');
$this->assertSessionHas('error', 'Invalid password!'); $this->assertSessionHas('error', 'Invalid password!');
$this->assertResponseStatus(302); $this->assertResponseStatus(302);

View File

@@ -1,115 +0,0 @@
<?php
use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class ReportControllerTest
*/
class ReminderControllerTest extends TestCase
{
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
parent::setUp();
}
/**
* This method is called before the first test of this test class is run.
*
* @since Method available since Release 3.4.0
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* @covers FireflyIII\Http\Controllers\ReminderController::act
*/
public function testAct()
{
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
$this->be($reminder->remindersable->account->user);
$this->call('GET', '/reminder/act/' . $reminder->id);
$this->assertResponseStatus(302);
$this->assertRedirectedToRoute('transactions.create', ['transfer']);
}
/**
* @covers FireflyIII\Http\Controllers\ReminderController::dismiss
*/
public function testDismiss()
{
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
$this->be($reminder->remindersable->account->user);
$this->call('GET', '/reminder/dismiss/' . $reminder->id);
$this->assertResponseStatus(302);
$this->assertRedirectedTo('/');
}
/**
* @covers FireflyIII\Http\Controllers\ReminderController::index
*/
public function testIndex()
{
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
$collection = new Collection([$reminder]);
$repository = $this->mock('FireflyIII\Repositories\Reminder\ReminderRepositoryInterface');
$repository->shouldReceive('getActiveReminders')->andReturn($collection);
$repository->shouldReceive('getExpiredReminders')->andReturn($collection);
$repository->shouldReceive('getInactiveReminders')->andReturn($collection);
$repository->shouldReceive('getDismissedReminders')->andReturn($collection);
$this->call('GET', '/reminders');
$this->assertResponseOk();
}
/**
* @covers FireflyIII\Http\Controllers\ReminderController::show
*/
public function testShow()
{
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
$reminder->notnow = false;
$reminder->save();
$this->be($reminder->remindersable->account->user);
$this->call('GET', '/reminder/' . $reminder->id);
$this->assertResponseOk();
}
/**
* @covers FireflyIII\Http\Controllers\ReminderController::show
*/
public function testShowDismissed()
{
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
$reminder->notnow = true;
$reminder->save();
$this->be($reminder->remindersable->account->user);
$this->call('GET', '/reminder/' . $reminder->id);
$this->assertResponseOk();
}
}