2015-04-07 12:58:49 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
|
|
|
|
2015-04-07 13:54:43 -05:00
|
|
|
/**
|
|
|
|
* Class HelpControllerTest
|
|
|
|
*/
|
2015-04-07 12:58:49 -05:00
|
|
|
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:
|
2015-05-25 12:58:13 -05:00
|
|
|
*
|
2015-05-23 12:41:54 -05:00
|
|
|
* @covers FireflyIII\Http\Controllers\HelpController::show
|
2015-04-07 12:58:49 -05:00
|
|
|
*/
|
|
|
|
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
|
2015-05-25 12:58:13 -05:00
|
|
|
*
|
2015-05-23 12:41:54 -05:00
|
|
|
* @covers FireflyIII\Http\Controllers\HelpController::show
|
2015-04-07 12:58:49 -05:00
|
|
|
*/
|
|
|
|
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.
|
2015-05-25 12:58:13 -05:00
|
|
|
*
|
2015-05-23 12:41:54 -05:00
|
|
|
* @covers FireflyIII\Http\Controllers\HelpController::show
|
2015-04-07 12:58:49 -05:00
|
|
|
*/
|
|
|
|
public function testGetHelpTextNoRoute()
|
|
|
|
{
|
|
|
|
// login
|
2015-05-05 00:51:02 -05:00
|
|
|
$user = FactoryMuffin::create('FireflyIII\User');
|
2015-04-07 12:58:49 -05:00
|
|
|
|
|
|
|
$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();
|
|
|
|
}
|
2015-05-05 05:51:57 -05:00
|
|
|
}
|