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 * * @covers FireflyIII\Http\Controllers\HelpController::show */ 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. * * @covers FireflyIII\Http\Controllers\HelpController::show */ public function testGetHelpTextNoRoute() { // 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(false); $this->call('GET', '/help/accounts.index'); $this->assertResponseOk(); } }