mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	Various code cleanup.
This commit is contained in:
		| @@ -709,7 +709,7 @@ class JournalCollector implements JournalCollectorInterface | ||||
|      */ | ||||
|     private function startQuery(): EloquentBuilder | ||||
|     { | ||||
|  | ||||
|         /** @var EloquentBuilder $query */ | ||||
|         $query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') | ||||
|                             ->leftJoin('transaction_currencies', 'transaction_currencies.id', 'transaction_journals.transaction_currency_id') | ||||
|                             ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id') | ||||
|   | ||||
| @@ -235,6 +235,7 @@ class AccountController extends Controller | ||||
|         $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); | ||||
|         $subTitle     = $account->name; | ||||
|         $range        = Preferences::get('viewRange', '1M')->data; | ||||
|  | ||||
|         $start        = session('start', Navigation::startOfPeriod(new Carbon, $range)); | ||||
|         $end          = session('end', Navigation::endOfPeriod(new Carbon, $range)); | ||||
|         $page         = intval(Input::get('page')) === 0 ? 1 : intval(Input::get('page')); | ||||
|   | ||||
| @@ -96,7 +96,6 @@ class RegisterController extends Controller | ||||
|             $validator->getMessageBag()->add('email', (string)trans('validation.invalid_domain')); | ||||
|  | ||||
|             event(new BlockedUseOfDomain($data['email'], $request->ip())); | ||||
|             // $this->reportBlockedDomainRegistrationAttempt($data['email'], $request->ip()); | ||||
|             $this->throwValidationException($request, $validator); | ||||
|         } | ||||
|  | ||||
| @@ -109,7 +108,6 @@ class RegisterController extends Controller | ||||
|         if (in_array($hash, $set)) { | ||||
|             $validator->getMessageBag()->add('email', (string)trans('validation.deleted_user')); | ||||
|             event(new BlockedUseOfEmail($data['email'], $request->ip())); | ||||
|             //$this->reportBlockedDomainRegistrationAttempt($data['email'], $request->ip()); | ||||
|             $this->throwValidationException($request, $validator); | ||||
|         } | ||||
|  | ||||
| @@ -217,31 +215,4 @@ class RegisterController extends Controller | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Send a message home about a blocked domain and the address attempted to register. | ||||
|      * | ||||
|      * @param string $registrationMail | ||||
|      * @param string $ipAddress | ||||
|      */ | ||||
|     private function reportBlockedDomainRegistrationAttempt(string $registrationMail, string $ipAddress) | ||||
|     { | ||||
|         try { | ||||
|             $email  = env('SITE_OWNER', false); | ||||
|             $parts  = explode('@', $registrationMail); | ||||
|             $domain = $parts[1]; | ||||
|             $fields = [ | ||||
|                 'email_address'  => $registrationMail, | ||||
|                 'blocked_domain' => $domain, | ||||
|                 'ip'             => $ipAddress, | ||||
|             ]; | ||||
|  | ||||
|             Mail::send( | ||||
|                 ['emails.blocked-registration-html', 'emails.blocked-registration-text'], $fields, function (Message $message) use ($email, $domain) { | ||||
|                 $message->to($email, $email)->subject('Blocked a registration attempt with domain ' . $domain . '.'); | ||||
|             } | ||||
|             ); | ||||
|         } catch (Swift_TransportException $e) { | ||||
|             Log::error($e->getMessage()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -129,7 +129,7 @@ class AccountController extends Controller | ||||
|             } | ||||
|         } | ||||
|         arsort($chartData); | ||||
|         $data = $this->generator->singleSet(trans('firefly.spent'), $chartData); | ||||
|         $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData); | ||||
|         $cache->store($data); | ||||
|  | ||||
|         return Response::json($data); | ||||
| @@ -393,7 +393,7 @@ class AccountController extends Controller | ||||
|         } | ||||
|  | ||||
|         arsort($chartData); | ||||
|         $data = $this->generator->singleSet(trans('firefly.spent'), $chartData); | ||||
|         $data = $this->generator->singleSet(strval(trans('firefly.spent')), $chartData); | ||||
|         $cache->store($data); | ||||
|  | ||||
|         return Response::json($data); | ||||
|   | ||||
| @@ -154,7 +154,7 @@ class BudgetController extends Controller | ||||
|         $cache->addProperty($end); | ||||
|         $cache->addProperty('chart.budget.frontpage'); | ||||
|         if ($cache->has()) { | ||||
|             //return Response::json($cache->get()); | ||||
|             return Response::json($cache->get()); | ||||
|         } | ||||
|         $budgets     = $repository->getActiveBudgets(); | ||||
|         $repetitions = $repository->getAllBudgetLimitRepetitions($start, $end); | ||||
| @@ -394,7 +394,6 @@ class BudgetController extends Controller | ||||
|                 'repetition_overspent' => $overspent, | ||||
|                 'spent'                => $spent, | ||||
|             ]; | ||||
|             //$array     = [$name, $left, $spent, $overspent, $amount, $spent]; | ||||
|         } | ||||
|  | ||||
|         return $return; | ||||
|   | ||||
| @@ -99,12 +99,12 @@ class CategoryController extends Controller | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param ReportHelperInterface $helper | ||||
|      * @param Collection            $accounts | ||||
|      * @param Carbon                $start | ||||
|      * @param Carbon                $end | ||||
|      * @param Collection $accounts | ||||
|      * @param Carbon     $start | ||||
|      * @param Carbon     $end | ||||
|      * | ||||
|      * @return mixed|string | ||||
|      * @internal param ReportHelperInterface $helper | ||||
|      */ | ||||
|     public function operations(Collection $accounts, Carbon $start, Carbon $end) | ||||
|     { | ||||
|   | ||||
| @@ -72,7 +72,7 @@ class OperationsController extends Controller | ||||
|         $cache->addProperty('income-report'); | ||||
|         $cache->addProperty($accounts->pluck('id')->toArray()); | ||||
|         if ($cache->has()) { | ||||
|             //return $cache->get(); | ||||
|             return $cache->get(); | ||||
|         } | ||||
|         $income = $this->getIncomeReport($start, $end, $accounts); | ||||
|  | ||||
|   | ||||
| @@ -112,8 +112,9 @@ interface BudgetRepositoryInterface | ||||
|     public function getInactiveBudgets(): Collection; | ||||
|  | ||||
|     /** | ||||
|      * @param Carbon $start | ||||
|      * @param Carbon $end | ||||
|      * @param Collection $accounts | ||||
|      * @param Carbon     $start | ||||
|      * @param Carbon     $end | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
|   | ||||
| @@ -13,7 +13,6 @@ namespace Auth; | ||||
|  | ||||
| use FireflyIII\Models\Preference; | ||||
| use FireflyIII\Support\Facades\Preferences; | ||||
| use Google2FA; | ||||
| use TestCase; | ||||
|  | ||||
| /** | ||||
| @@ -46,7 +45,6 @@ class TwoFactorControllerTest extends TestCase | ||||
|         Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference); | ||||
|         Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference); | ||||
|         Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference); | ||||
|         //$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); | ||||
|         $this->call('get', route('two-factor.index')); | ||||
|         $this->assertResponseStatus(200); | ||||
|     } | ||||
| @@ -65,7 +63,6 @@ class TwoFactorControllerTest extends TestCase | ||||
|         Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($truePreference); | ||||
|         Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn($secretPreference); | ||||
|         Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->andReturn($secretPreference); | ||||
|         //$has2faSecret = !is_null(Preferences::get('twoFactorAuthSecret')); | ||||
|         $this->call('get', route('two-factor.lost')); | ||||
|         $this->assertResponseStatus(200); | ||||
|     } | ||||
|   | ||||
| @@ -36,7 +36,7 @@ class BudgetControllerTest extends TestCase | ||||
|             'amount' => 200, | ||||
|         ]; | ||||
|         $this->be($this->user()); | ||||
|         $this->call('post', route('budgets.amount', [1], $data)); | ||||
|         $this->call('post', route('budgets.amount', [1]), $data); | ||||
|         $this->assertResponseStatus(200); | ||||
|     } | ||||
|  | ||||
| @@ -94,6 +94,8 @@ class BudgetControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\BudgetController::index | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testIndex(string $range) | ||||
|     { | ||||
| @@ -108,6 +110,8 @@ class BudgetControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\BudgetController::noBudget | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testNoBudget(string $range) | ||||
|     { | ||||
| @@ -135,6 +139,8 @@ class BudgetControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\BudgetController::show | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testShow(string $range) | ||||
|     { | ||||
| @@ -148,6 +154,8 @@ class BudgetControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\BudgetController::showByRepetition | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testShowByRepetition(string $range) | ||||
|     { | ||||
|   | ||||
| @@ -93,6 +93,8 @@ class CategoryControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\CategoryController::noCategory | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testNoCategory(string $range) | ||||
|     { | ||||
| @@ -107,6 +109,8 @@ class CategoryControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\CategoryController::show | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testShow(string $range) | ||||
|     { | ||||
| @@ -120,6 +124,8 @@ class CategoryControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\CategoryController::showByDate | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testShowByDate(string $range) | ||||
|     { | ||||
|   | ||||
| @@ -32,6 +32,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testExpenseAccounts(string $range) | ||||
|     { | ||||
| @@ -44,6 +46,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::expenseBudget | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testExpenseBudget(string $range) | ||||
|     { | ||||
| @@ -56,6 +60,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::expenseCategory | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testExpenseCategory(string $range) | ||||
|     { | ||||
| @@ -68,6 +74,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::frontpage | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testFrontpage(string $range) | ||||
|     { | ||||
| @@ -80,6 +88,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::incomeCategory | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testIncomeCategory(string $range) | ||||
|     { | ||||
| @@ -92,6 +102,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::period | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testPeriod(string $range) | ||||
|     { | ||||
| @@ -114,6 +126,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::revenueAccounts | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testRevenueAccounts(string $range) | ||||
|     { | ||||
| @@ -126,6 +140,8 @@ class AccountControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\AccountController::single | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testSingle(string $range) | ||||
|     { | ||||
|   | ||||
| @@ -30,8 +30,10 @@ class BillControllerTest extends TestCase | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @covers \FireflyIII\Http\Controllers\Chart\BillController::frontpage | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\BillController::frontpage | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testFrontpage(string $range) | ||||
|     { | ||||
|   | ||||
| @@ -30,8 +30,10 @@ class BudgetControllerTest extends TestCase | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::budget | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\BudgetController::budget | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testBudget(string $range) | ||||
|     { | ||||
| @@ -42,8 +44,10 @@ class BudgetControllerTest extends TestCase | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\BudgetController::budgetLimit | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testBudgetLimit(string $range) | ||||
|     { | ||||
| @@ -54,8 +58,10 @@ class BudgetControllerTest extends TestCase | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @covers \FireflyIII\Http\Controllers\Chart\BudgetController::frontpage | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\BudgetController::frontpage | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testFrontpage(string $range) | ||||
|     { | ||||
|   | ||||
| @@ -32,6 +32,8 @@ class CategoryControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\CategoryController::all | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testAll(string $range) | ||||
|     { | ||||
| @@ -44,6 +46,8 @@ class CategoryControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\CategoryController::currentPeriod | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testCurrentPeriod(string $range) | ||||
|     { | ||||
| @@ -56,6 +60,8 @@ class CategoryControllerTest extends TestCase | ||||
|     /** | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\CategoryController::frontpage | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testFrontpage(string $range) | ||||
|     { | ||||
| @@ -86,8 +92,10 @@ class CategoryControllerTest extends TestCase | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @covers \FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod | ||||
|      * @covers       \FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod | ||||
|      * @dataProvider dateRangeProvider | ||||
|      * | ||||
|      * @param string $range | ||||
|      */ | ||||
|     public function testSpecificPeriod(string $range) | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user