mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-21 03:39:00 +00:00
Expand tests.
This commit is contained in:
63
tests/Feature/Controllers/JavascriptControllerTest.php
Normal file
63
tests/Feature/Controllers/JavascriptControllerTest.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* JavascriptControllerTest.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class JavascriptControllerTest
|
||||
*
|
||||
* @package Tests\Feature\Controllers
|
||||
*/
|
||||
class JavascriptControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::accounts
|
||||
*/
|
||||
public function testAccounts()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]))
|
||||
->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once();
|
||||
$currencyRepos->shouldReceive('findByCode')->withArgs(['EUR'])->andReturn(new TransactionCurrency);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('javascript.accounts'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
|
||||
* @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangePicker
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @dataProvider dateRangeProvider
|
||||
*/
|
||||
public function testVariables(string $range)
|
||||
{
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('javascript.variables'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user