Updated various classes and tests.

This commit is contained in:
James Cole
2014-07-02 23:31:59 +02:00
parent 063cf14531
commit 757e076a83
7 changed files with 190 additions and 94 deletions

2
.gitignore vendored
View File

@@ -8,3 +8,5 @@ composer.lock
Thumbs.db Thumbs.db
.idea/ .idea/
tests/_output/* tests/_output/*
_ide_helper.php
/build/logs/clover.xml

View File

@@ -0,0 +1,75 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Filename
|--------------------------------------------------------------------------
|
| The default path to the helper file
|
*/
'filename' => '_ide_helper.php',
/*
|--------------------------------------------------------------------------
| Helper files to include
|--------------------------------------------------------------------------
|
| Include helper files. By default not included, but can be toggled with the
| -- helpers (-H) option. Extra helper files can be included.
|
*/
'include_helpers' => false,
'helper_files' => array(
base_path().'/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
),
/*
|--------------------------------------------------------------------------
| Model locations to include
|--------------------------------------------------------------------------
|
| Define in which directories the ide-helper:models command should look
| for models.
|
*/
'model_locations' => array(
'app/models',
),
/*
|--------------------------------------------------------------------------
| Extra classes
|--------------------------------------------------------------------------
|
| These implementations are not really extended, but called with magic functions
|
*/
'extra' => array(
'Artisan' => array('Illuminate\Foundation\Artisan'),
'Eloquent' => array('Illuminate\Database\Eloquent\Builder', 'Illuminate\Database\Query\Builder'),
'Session' => array('Illuminate\Session\Store'),
),
'magic' => array(
'Log' => array(
'debug' => 'Monolog\Logger::addDebug',
'info' => 'Monolog\Logger::addInfo',
'notice' => 'Monolog\Logger::addNotice',
'warning' => 'Monolog\Logger::addWarning',
'error' => 'Monolog\Logger::addError',
'critical' => 'Monolog\Logger::addCritical',
'alert' => 'Monolog\Logger::addAlert',
'emergency' => 'Monolog\Logger::addEmergency',
)
)
);

View File

@@ -1,99 +1,99 @@
<?php <?php
use Firefly\Storage\Account\AccountRepositoryInterface as ARI; //use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
class AccountController extends \BaseController { class AccountController extends \BaseController {
public function __construct(ARI $accounts) { // public function __construct(ARI $accounts) {
$this->accounts = $accounts; // $this->accounts = $accounts;
} // }
//
/** // /**
* Display a listing of the resource. // * Display a listing of the resource.
* // *
* @return Response // * @return Response
*/ // */
public function index() // public function index()
{ // {
//
} // }
//
//
/** // /**
* Show the form for creating a new resource. // * Show the form for creating a new resource.
* // *
* @return Response // * @return Response
*/ // */
public function create() // public function create()
{ // {
if($this->accounts->count() == 0) { // if($this->accounts->count() == 0) {
return View::make('accounts.create-first-time'); // return View::make('accounts.create-first-time');
} // }
return View::make('accounts'); // return View::make('accounts');
} // }
//
//
/** // /**
* Store a newly created resource in storage. // * Store a newly created resource in storage.
* // *
* @return Response // * @return Response
*/ // */
public function store() // public function store()
{ // {
$account = $this->accounts->store(); // $account = $this->accounts->store();
if($account === false) { // if($account === false) {
Session::flash('error','Could not create account with provided information'); // Session::flash('error','Could not create account with provided information');
return Redirect::route('accounts.create')->withInput()->withErrors($this->accounts->validator); // return Redirect::route('accounts.create')->withInput()->withErrors($this->accounts->validator);
} // }
} // }
//
//
/** // /**
* Display the specified resource. // * Display the specified resource.
* // *
* @param int $id // * @param int $id
* @return Response // * @return Response
*/ // */
public function show($id) // public function show($id)
{ // {
// // //
} // }
//
//
/** // /**
* Show the form for editing the specified resource. // * Show the form for editing the specified resource.
* // *
* @param int $id // * @param int $id
* @return Response // * @return Response
*/ // */
public function edit($id) // public function edit($id)
{ // {
// // //
} // }
//
//
/** // /**
* Update the specified resource in storage. // * Update the specified resource in storage.
* // *
* @param int $id // * @param int $id
* @return Response // * @return Response
*/ // */
public function update($id) // public function update($id)
{ // {
// // //
} // }
//
//
/** // /**
* Remove the specified resource from storage. // * Remove the specified resource from storage.
* // *
* @param int $id // * @param int $id
* @return Response // * @return Response
*/ // */
public function destroy($id) // public function destroy($id)
{ // {
// // //
} // }
} }

View File

@@ -17,6 +17,7 @@ class ProfileController extends BaseController
{ {
// old, new1, new2 // old, new1, new2
/** @noinspection PhpUndefinedFieldInspection */
if (!Hash::check(Input::get('old'), Auth::user()->password)) { if (!Hash::check(Input::get('old'), Auth::user()->password)) {
Session::flash('error', 'Invalid current password!'); Session::flash('error', 'Invalid current password!');
return View::make('profile.change-password'); return View::make('profile.change-password');
@@ -37,7 +38,9 @@ class ProfileController extends BaseController
// update the user with the new password. // update the user with the new password.
$password = Hash::make(Input::get('new1')); $password = Hash::make(Input::get('new1'));
/** @noinspection PhpUndefinedFieldInspection */
Auth::user()->password = $password; Auth::user()->password = $password;
/** @noinspection PhpUndefinedMethodInspection */
Auth::user()->save(); Auth::user()->save();
Session::flash('success', 'Password changed!'); Session::flash('success', 'Password changed!');
return Redirect::route('profile'); return Redirect::route('profile');

View File

@@ -26,6 +26,7 @@ class UserController extends BaseController
'password' => Input::get('password') 'password' => Input::get('password')
]; ];
if (Auth::attempt($data, $rememberMe)) { if (Auth::attempt($data, $rememberMe)) {
Session::flash('success', 'Logged in!');
return Redirect::route('index'); return Redirect::route('index');
} }
Session::flash('error', 'No good!'); Session::flash('error', 'No good!');
@@ -35,7 +36,7 @@ class UserController extends BaseController
public function register() public function register()
{ {
if (Config::get('auth.allow_register') !== true) { if (Config::get('auth.allow_register') !== true) {
return App::abort(404); App::abort(404);
} }
return View::make('user.register'); return View::make('user.register');
} }
@@ -43,7 +44,7 @@ class UserController extends BaseController
public function postRegister() public function postRegister()
{ {
if (Config::get('auth.allow_register') !== true) { if (Config::get('auth.allow_register') !== true) {
return App::abort(404); App::abort(404);
} }
$user = $this->user->register(Input::all()); $user = $this->user->register(Input::all());
if ($user) { if ($user) {

View File

@@ -30,6 +30,17 @@ class UserControllerTest extends TestCase
$data = ['email' => 'bla@bla.nl', 'password' => 'xxxx','remember_me' => '1']; $data = ['email' => 'bla@bla.nl', 'password' => 'xxxx','remember_me' => '1'];
Auth::shouldReceive('attempt')->once()->andReturn(true); Auth::shouldReceive('attempt')->once()->andReturn(true);
$this->call('POST', '/login', $data); $this->call('POST', '/login', $data);
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('index');
}
public function testPostFalseLogin()
{
$data = ['email' => 'bla@bla.nl', 'password' => 'xxxx','remember_me' => '1'];
Auth::shouldReceive('attempt')->once()->andReturn(false);
View::shouldReceive('make')->with('user.login')->once();
$this->call('POST', '/login', $data);
$this->assertSessionHas('error');
} }
public function tearDown() public function tearDown()

4
ide-helper.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
php artisan clear-compiled --env=local
php artisan ide-helper:generate --env=local
php artisan optimize --env=local