Some attempts at code coverage and coveralls support.

This commit is contained in:
James Cole 2014-07-02 23:12:31 +02:00
parent e03e6e7290
commit 4540e93a63
8 changed files with 362 additions and 20 deletions

1
.coveralls.yml Normal file
View File

@ -0,0 +1 @@
src_dir: .

View File

@ -4,4 +4,7 @@ php:
- 5.5
install:
- composer install
- composer install
after_script:
- php vendor/bin/coveralls

View File

@ -20,15 +20,13 @@ class UserController extends BaseController
public function postLogin()
{
if (!$this->user->auth()) {
$rememberMe = Input::get('remember_me') == '1';
$data = [
'email' => Input::get('email'),
'password' => Input::get('password')
];
if (Auth::attempt($data, $rememberMe)) {
return Redirect::route('index');
}
$rememberMe = Input::get('remember_me') == '1';
$data = [
'email' => Input::get('email'),
'password' => Input::get('password')
];
if (Auth::attempt($data, $rememberMe)) {
return Redirect::route('index');
}
Session::flash('error', 'No good!');
return View::make('user.login');
@ -47,7 +45,7 @@ class UserController extends BaseController
if (Config::get('auth.allow_register') !== true) {
return App::abort(404);
}
$user = $this->user->register();
$user = $this->user->register(Input::all());
if ($user) {
if (Config::get('auth.verify_mail') === true) {
$this->email->sendVerificationMail($user);
@ -95,6 +93,7 @@ class UserController extends BaseController
}
return View::make('error')->with('message', 'Yo no hablo verification code!');
}
public function reset($reset)
{
$user = $this->user->findByReset($reset);
@ -105,4 +104,4 @@ class UserController extends BaseController
return View::make('error')->with('message', 'Yo no hablo reset code!');
}
}
}

View File

@ -9,10 +9,10 @@ class EloquentUserRepository implements UserRepositoryInterface
{
}
public function register()
public function register($array)
{
$user = new \User;
$user->email = \Input::get('email');
$user->email = $array['emai'];
$user->migrated = 0;
$user->verification = \Str::random(32);
$user->password = \Hash::make(\Str::random(12));
@ -26,11 +26,11 @@ class EloquentUserRepository implements UserRepositoryInterface
return $user;
}
public function auth()
public function auth($array)
{
$user = \User::where('email', \Input::get('email'))->first();
$user = \User::where('email', $array['email'])->first();
if (!is_null($user)) {
if (\Hash::check(\Input::get('password'), $user->password)) {
if (\Hash::check($array['password'], $user->password)) {
}
}
return false;
@ -45,6 +45,7 @@ class EloquentUserRepository implements UserRepositoryInterface
{
return \User::where('reset', $reset)->first();
}
public function findByEmail($email)
{
return \User::where('email', $email)->first();

View File

@ -6,9 +6,9 @@ namespace Firefly\Storage\User;
interface UserRepositoryInterface
{
public function register();
public function register($array);
public function auth();
public function auth($array);
public function findByVerification($verification);
public function findByReset($reset);

View File

@ -0,0 +1,40 @@
<?php
class UserControllerTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->mock = $this->mock('Firefly\Storage\User\UserRepositoryInterface');
}
public function mock($class)
{
$mock = Mockery::mock($class);
$this->app->instance($class, $mock);
return $mock;
}
public function testLogin()
{
View::shouldReceive('make')->with('user.login');
$this->call('GET', '/login');
}
public function testPostLogin()
{
$data = ['email' => 'bla@bla.nl', 'password' => 'xxxx','remember_me' => '1'];
Auth::shouldReceive('attempt')->once()->andReturn(true);
$this->call('POST', '/login', $data);
}
public function tearDown()
{
Mockery::close();
}
}

297
build/logs/clover.xml Normal file
View File

@ -0,0 +1,297 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1404335294">
<project timestamp="1404335294">
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/controllers/AccountController.php">
<class name="AccountController" namespace="global">
<metrics methods="8" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="25" coveredstatements="0" elements="33" coveredelements="0"/>
</class>
<line num="7" type="method" name="__construct" crap="2" count="0"/>
<line num="8" type="stmt" count="0"/>
<line num="9" type="stmt" count="0"/>
<line num="16" type="method" name="index" crap="2" count="0"/>
<line num="17" type="stmt" count="0"/>
<line num="19" type="stmt" count="0"/>
<line num="27" type="method" name="create" crap="6" count="0"/>
<line num="28" type="stmt" count="0"/>
<line num="29" type="stmt" count="0"/>
<line num="30" type="stmt" count="0"/>
<line num="31" type="stmt" count="0"/>
<line num="32" type="stmt" count="0"/>
<line num="33" type="stmt" count="0"/>
<line num="41" type="method" name="store" crap="6" count="0"/>
<line num="42" type="stmt" count="0"/>
<line num="43" type="stmt" count="0"/>
<line num="44" type="stmt" count="0"/>
<line num="45" type="stmt" count="0"/>
<line num="46" type="stmt" count="0"/>
<line num="47" type="stmt" count="0"/>
<line num="48" type="stmt" count="0"/>
<line num="57" type="method" name="show" crap="2" count="0"/>
<line num="58" type="stmt" count="0"/>
<line num="60" type="stmt" count="0"/>
<line num="69" type="method" name="edit" crap="2" count="0"/>
<line num="70" type="stmt" count="0"/>
<line num="72" type="stmt" count="0"/>
<line num="81" type="method" name="update" crap="2" count="0"/>
<line num="82" type="stmt" count="0"/>
<line num="84" type="stmt" count="0"/>
<line num="93" type="method" name="destroy" crap="2" count="0"/>
<line num="94" type="stmt" count="0"/>
<line num="96" type="stmt" count="0"/>
<metrics loc="99" ncloc="52" classes="1" methods="8" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="25" coveredstatements="0" elements="33" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/controllers/HomeController.php">
<class name="HomeController" namespace="global">
<metrics methods="2" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="0" elements="7" coveredelements="0"/>
</class>
<line num="7" type="method" name="__construct" crap="2" count="0"/>
<line num="8" type="stmt" count="0"/>
<line num="9" type="stmt" count="0"/>
<line num="11" type="method" name="index" crap="2" count="0"/>
<line num="12" type="stmt" count="0"/>
<line num="13" type="stmt" count="0"/>
<line num="14" type="stmt" count="0"/>
<metrics loc="15" ncloc="15" classes="1" methods="2" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="5" coveredstatements="0" elements="7" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/controllers/ProfileController.php">
<class name="ProfileController" namespace="global">
<metrics methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="29" coveredstatements="0" elements="32" coveredelements="0"/>
</class>
<line num="6" type="method" name="index" crap="2" count="0"/>
<line num="7" type="stmt" count="0"/>
<line num="8" type="stmt" count="0"/>
<line num="9" type="stmt" count="0"/>
<line num="11" type="method" name="changePassword" crap="2" count="0"/>
<line num="12" type="stmt" count="0"/>
<line num="13" type="stmt" count="0"/>
<line num="14" type="stmt" count="0"/>
<line num="16" type="method" name="postChangePassword" crap="42" count="0"/>
<line num="17" type="stmt" count="0"/>
<line num="20" type="stmt" count="0"/>
<line num="21" type="stmt" count="0"/>
<line num="22" type="stmt" count="0"/>
<line num="23" type="stmt" count="0"/>
<line num="24" type="stmt" count="0"/>
<line num="25" type="stmt" count="0"/>
<line num="26" type="stmt" count="0"/>
<line num="27" type="stmt" count="0"/>
<line num="28" type="stmt" count="0"/>
<line num="29" type="stmt" count="0"/>
<line num="30" type="stmt" count="0"/>
<line num="31" type="stmt" count="0"/>
<line num="33" type="stmt" count="0"/>
<line num="34" type="stmt" count="0"/>
<line num="35" type="stmt" count="0"/>
<line num="36" type="stmt" count="0"/>
<line num="39" type="stmt" count="0"/>
<line num="40" type="stmt" count="0"/>
<line num="41" type="stmt" count="0"/>
<line num="42" type="stmt" count="0"/>
<line num="43" type="stmt" count="0"/>
<line num="44" type="stmt" count="0"/>
<metrics loc="45" ncloc="41" classes="1" methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="29" coveredstatements="0" elements="32" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/controllers/UserController.php">
<class name="UserController" namespace="global">
<metrics methods="10" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="50" coveredstatements="11" elements="60" coveredelements="13"/>
</class>
<line num="9" type="method" name="__construct" crap="1" count="3"/>
<line num="11" type="stmt" count="3"/>
<line num="12" type="stmt" count="3"/>
<line num="14" type="stmt" count="3"/>
<line num="16" type="method" name="login" crap="1" count="2"/>
<line num="18" type="stmt" count="2"/>
<line num="19" type="stmt" count="1"/>
<line num="21" type="method" name="postLogin" crap="2.06" count="1"/>
<line num="23" type="stmt" count="1"/>
<line num="25" type="stmt" count="1"/>
<line num="26" type="stmt" count="1"/>
<line num="27" type="stmt" count="1"/>
<line num="28" type="stmt" count="1"/>
<line num="29" type="stmt" count="1"/>
<line num="31" type="stmt" count="0"/>
<line num="32" type="stmt" count="0"/>
<line num="35" type="method" name="register" crap="6" count="0"/>
<line num="37" type="stmt" count="0"/>
<line num="38" type="stmt" count="0"/>
<line num="40" type="stmt" count="0"/>
<line num="43" type="method" name="postRegister" crap="20" count="0"/>
<line num="45" type="stmt" count="0"/>
<line num="46" type="stmt" count="0"/>
<line num="48" type="stmt" count="0"/>
<line num="49" type="stmt" count="0"/>
<line num="50" type="stmt" count="0"/>
<line num="51" type="stmt" count="0"/>
<line num="52" type="stmt" count="0"/>
<line num="54" type="stmt" count="0"/>
<line num="55" type="stmt" count="0"/>
<line num="57" type="stmt" count="0"/>
<line num="60" type="method" name="logout" crap="2" count="0"/>
<line num="62" type="stmt" count="0"/>
<line num="63" type="stmt" count="0"/>
<line num="66" type="method" name="remindme" crap="2" count="0"/>
<line num="68" type="stmt" count="0"/>
<line num="71" type="method" name="postRemindme" crap="20" count="0"/>
<line num="73" type="stmt" count="0"/>
<line num="74" type="stmt" count="0"/>
<line num="75" type="stmt" count="0"/>
<line num="76" type="stmt" count="0"/>
<line num="77" type="stmt" count="0"/>
<line num="78" type="stmt" count="0"/>
<line num="79" type="stmt" count="0"/>
<line num="80" type="stmt" count="0"/>
<line num="81" type="stmt" count="0"/>
<line num="82" type="stmt" count="0"/>
<line num="83" type="stmt" count="0"/>
<line num="87" type="method" name="verify" crap="6" count="0"/>
<line num="89" type="stmt" count="0"/>
<line num="90" type="stmt" count="0"/>
<line num="91" type="stmt" count="0"/>
<line num="92" type="stmt" count="0"/>
<line num="94" type="stmt" count="0"/>
<line num="97" type="method" name="reset" crap="6" count="0"/>
<line num="99" type="stmt" count="0"/>
<line num="100" type="stmt" count="0"/>
<line num="101" type="stmt" count="0"/>
<line num="102" type="stmt" count="0"/>
<line num="104" type="stmt" count="0"/>
<metrics loc="106" ncloc="106" classes="1" methods="10" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="50" coveredstatements="11" elements="60" coveredelements="13"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/Account.php">
<class name="Account" namespace="global">
<metrics methods="4" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="13" coveredstatements="0" elements="17" coveredelements="0"/>
</class>
<line num="13" type="method" name="accountType" crap="2" count="0"/>
<line num="14" type="stmt" count="0"/>
<line num="15" type="stmt" count="0"/>
<line num="16" type="stmt" count="0"/>
<line num="18" type="method" name="transactions" crap="2" count="0"/>
<line num="19" type="stmt" count="0"/>
<line num="20" type="stmt" count="0"/>
<line num="21" type="stmt" count="0"/>
<line num="23" type="method" name="user" crap="2" count="0"/>
<line num="24" type="stmt" count="0"/>
<line num="25" type="stmt" count="0"/>
<line num="26" type="stmt" count="0"/>
<line num="36" type="method" name="balance" crap="6" count="0"/>
<line num="37" type="stmt" count="0"/>
<line num="38" type="stmt" count="0"/>
<line num="39" type="stmt" count="0"/>
<line num="40" type="stmt" count="0"/>
<metrics loc="41" ncloc="34" classes="1" methods="4" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="13" coveredstatements="0" elements="17" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/AccountType.php">
<class name="AccountType" namespace="global">
<metrics methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</class>
<line num="6" type="method" name="accounts" crap="2" count="0"/>
<line num="7" type="stmt" count="0"/>
<line num="8" type="stmt" count="0"/>
<metrics loc="9" ncloc="9" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/Component.php">
<class name="Component" namespace="global">
<metrics methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="9" coveredstatements="0" elements="12" coveredelements="0"/>
</class>
<line num="6" type="method" name="componentType" crap="2" count="0"/>
<line num="7" type="stmt" count="0"/>
<line num="8" type="stmt" count="0"/>
<line num="9" type="stmt" count="0"/>
<line num="11" type="method" name="transactions" crap="2" count="0"/>
<line num="12" type="stmt" count="0"/>
<line num="13" type="stmt" count="0"/>
<line num="14" type="stmt" count="0"/>
<line num="16" type="method" name="user" crap="2" count="0"/>
<line num="17" type="stmt" count="0"/>
<line num="18" type="stmt" count="0"/>
<line num="19" type="stmt" count="0"/>
<metrics loc="20" ncloc="20" classes="1" methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="9" coveredstatements="0" elements="12" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/ComponentType.php">
<class name="ComponentType" namespace="global">
<metrics methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="3" coveredstatements="0" elements="4" coveredelements="0"/>
</class>
<line num="6" type="method" name="components" crap="2" count="0"/>
<line num="7" type="stmt" count="0"/>
<line num="8" type="stmt" count="0"/>
<line num="9" type="stmt" count="0"/>
<metrics loc="10" ncloc="10" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="3" coveredstatements="0" elements="4" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/Elegant.php">
<class name="Elegant" namespace="global">
<metrics methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="0" elements="9" coveredelements="0"/>
</class>
<line num="9" type="method" name="isValid" crap="2" count="0"/>
<line num="10" type="stmt" count="0"/>
<line num="11" type="stmt" count="0"/>
<line num="12" type="stmt" count="0"/>
<line num="13" type="stmt" count="0"/>
<line num="14" type="stmt" count="0"/>
<line num="15" type="stmt" count="0"/>
<line num="16" type="stmt" count="0"/>
<line num="17" type="stmt" count="0"/>
<metrics loc="17" ncloc="17" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="8" coveredstatements="0" elements="9" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/Transaction.php">
<class name="Transaction" namespace="global">
<metrics methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="9" coveredstatements="0" elements="12" coveredelements="0"/>
</class>
<line num="7" type="method" name="account" crap="2" count="0"/>
<line num="8" type="stmt" count="0"/>
<line num="9" type="stmt" count="0"/>
<line num="10" type="stmt" count="0"/>
<line num="12" type="method" name="transactionJournal" crap="2" count="0"/>
<line num="13" type="stmt" count="0"/>
<line num="14" type="stmt" count="0"/>
<line num="15" type="stmt" count="0"/>
<line num="17" type="method" name="components" crap="2" count="0"/>
<line num="18" type="stmt" count="0"/>
<line num="19" type="stmt" count="0"/>
<line num="20" type="stmt" count="0"/>
<metrics loc="20" ncloc="20" classes="1" methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="9" coveredstatements="0" elements="12" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/TransactionCurrency.php">
<class name="TransactionCurrency" namespace="global">
<metrics methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</class>
<line num="6" type="method" name="transactionJournals" crap="2" count="0"/>
<line num="7" type="stmt" count="0"/>
<line num="8" type="stmt" count="0"/>
<metrics loc="9" ncloc="9" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/TransactionJournal.php">
<class name="TransactionJournal" namespace="global">
<metrics methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="6" coveredstatements="0" elements="9" coveredelements="0"/>
</class>
<line num="6" type="method" name="transactionType" crap="2" count="0"/>
<line num="7" type="stmt" count="0"/>
<line num="8" type="stmt" count="0"/>
<line num="9" type="method" name="transactionCurrency" crap="2" count="0"/>
<line num="10" type="stmt" count="0"/>
<line num="11" type="stmt" count="0"/>
<line num="13" type="method" name="transactions" crap="2" count="0"/>
<line num="14" type="stmt" count="0"/>
<line num="15" type="stmt" count="0"/>
<metrics loc="16" ncloc="16" classes="1" methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="6" coveredstatements="0" elements="9" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/TransactionType.php">
<class name="TransactionType" namespace="global">
<metrics methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</class>
<line num="5" type="method" name="transactionJournals" crap="2" count="0"/>
<line num="6" type="stmt" count="0"/>
<line num="7" type="stmt" count="0"/>
<metrics loc="8" ncloc="8" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</file>
<file name="/Library/WebServer/Documents/projects/firefly-iii/app/models/User.php">
<class name="User" namespace="global">
<metrics methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</class>
<line num="36" type="method" name="accounts" crap="2" count="0"/>
<line num="37" type="stmt" count="0"/>
<line num="38" type="stmt" count="0"/>
<metrics loc="40" ncloc="30" classes="1" methods="1" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="0" elements="3" coveredelements="0"/>
</file>
<metrics files="14" loc="455" ncloc="387" classes="14" methods="42" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="165" coveredstatements="11" elements="207" coveredelements="13"/>
</project>
</coverage>

View File

@ -26,7 +26,8 @@
},
"require-dev": {
"barryvdh/laravel-debugbar": "1.*",
"barryvdh/laravel-ide-helper": "1.*"
"barryvdh/laravel-ide-helper": "1.*",
"mockery/mockery": "dev-master"
},
"autoload": {
"classmap": [