mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
More tests.
This commit is contained in:
@@ -193,6 +193,7 @@ class GoogleChartControllerTest extends TestCase
|
||||
$repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition');
|
||||
$repetition->startdate = Carbon::now()->startOfMonth();
|
||||
$repetition->enddate = Carbon::now()->endOfMonth();
|
||||
$repetition->save();
|
||||
$budget = $repetition->budgetlimit->budget;
|
||||
$this->be($budget->user);
|
||||
///chart/budget/{budget}/{limitrepetition}
|
||||
|
96
tests/controllers/HelpControllerTest.php
Normal file
96
tests/controllers/HelpControllerTest.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
class HelpControllerTest 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();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything present and accounted for, and in cache:
|
||||
*/
|
||||
public function testGetHelpText()
|
||||
{
|
||||
// login
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$this->be($user);
|
||||
// mock some stuff.
|
||||
$interface = $this->mock('FireflyIII\Helpers\Help\HelpInterface');
|
||||
$interface->shouldReceive('hasRoute')->once()->with('accounts.index')->andReturn(true);
|
||||
$interface->shouldReceive('getFromCache')->once()->with('help.accounts.index.title')->andReturn('Title.');
|
||||
$interface->shouldReceive('getFromCache')->once()->with('help.accounts.index.text')->andReturn('Text');
|
||||
$interface->shouldReceive('inCache')->andReturn(true);
|
||||
|
||||
|
||||
$this->call('GET', '/help/accounts.index');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything present and accounted for, but not cached
|
||||
*/
|
||||
public function testGetHelpTextNoCache()
|
||||
{
|
||||
// login
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$content = ['title' => 'Bla', 'text' => 'Bla'];
|
||||
|
||||
$this->be($user);
|
||||
// mock some stuff.
|
||||
$interface = $this->mock('FireflyIII\Helpers\Help\HelpInterface');
|
||||
$interface->shouldReceive('hasRoute')->once()->with('accounts.index')->andReturn(true);
|
||||
$interface->shouldReceive('getFromGithub')->once()->with('accounts.index')->andReturn($content);
|
||||
$interface->shouldReceive('putInCache')->once()->withArgs(['accounts.index', $content]);
|
||||
$interface->shouldReceive('inCache')->once()->andReturn(false);
|
||||
|
||||
|
||||
$this->call('GET', '/help/accounts.index');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* No such route.
|
||||
*/
|
||||
public function testGetHelpTextNoRoute()
|
||||
{
|
||||
// login
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
$content = ['title' => 'Bla', 'text' => 'Bla'];
|
||||
|
||||
$this->be($user);
|
||||
// mock some stuff.
|
||||
$interface = $this->mock('FireflyIII\Helpers\Help\HelpInterface');
|
||||
$interface->shouldReceive('hasRoute')->once()->with('accounts.index')->andReturn(false);
|
||||
|
||||
|
||||
$this->call('GET', '/help/accounts.index');
|
||||
$this->assertResponseOk();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user