mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-17 07:08:19 +00:00
Refactored a lot of tests.
This commit is contained in:
@@ -46,12 +46,12 @@ class HelpControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
*/
|
||||
public function testShow(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$help = $this->mock(HelpInterface::class);
|
||||
$help->shouldReceive('hasRoute')->andReturn(true)->once();
|
||||
$help->shouldReceive('inCache')->andReturn(false)->once();
|
||||
@@ -65,19 +65,16 @@ class HelpControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
*/
|
||||
public function testShowBackupFromCache(): void
|
||||
{
|
||||
// force pref in dutch for test
|
||||
Preference::where('user_id', $this->user()->id)->where('name', 'language')->delete();
|
||||
Preference::create(['user_id' => $this->user()->id, 'name' => 'language', 'data' => 'nl_NL']);
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$help = $this->mock(HelpInterface::class);
|
||||
$help->shouldReceive('hasRoute')->withArgs(['index'])->andReturn(true)->once();
|
||||
$help->shouldReceive('inCache')->withArgs(['index', 'nl_NL'])->andReturn(false)->once();
|
||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
||||
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(false)->once();
|
||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'en_US'])->andReturn('')->once();
|
||||
|
||||
// is US in cache?
|
||||
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(true)->once();
|
||||
@@ -86,7 +83,7 @@ class HelpControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('help.show', ['index']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('US from cache.'); // Dutch translation
|
||||
$response->assertSee('US from cache.');
|
||||
|
||||
// put English back:
|
||||
Preference::where('user_id', $this->user()->id)->where('name', 'language')->delete();
|
||||
@@ -94,19 +91,16 @@ class HelpControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
*/
|
||||
public function testShowBackupFromGithub(): void
|
||||
{
|
||||
// force pref in dutch for test
|
||||
Preference::where('user_id', $this->user()->id)->where('name', 'language')->delete();
|
||||
Preference::create(['user_id' => $this->user()->id, 'name' => 'language', 'data' => 'nl_NL']);
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$help = $this->mock(HelpInterface::class);
|
||||
$help->shouldReceive('hasRoute')->withArgs(['index'])->andReturn(true)->once();
|
||||
$help->shouldReceive('inCache')->withArgs(['index', 'nl_NL'])->andReturn(false)->once();
|
||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'nl_NL'])->andReturn('')->once();
|
||||
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(false)->once();
|
||||
$help->shouldReceive('getFromGithub')->withArgs(['index', 'en_US'])->andReturn('')->once();
|
||||
|
||||
// is US in cache?
|
||||
$help->shouldReceive('inCache')->withArgs(['index', 'en_US'])->andReturn(false)->once();
|
||||
@@ -117,7 +111,7 @@ class HelpControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('help.show', ['index']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Deze helptekst is nog niet beschikbaar in het Nederlands.'); // Dutch
|
||||
$response->assertSee('This help text is not yet available in your language');
|
||||
|
||||
// put English back:
|
||||
Preference::where('user_id', $this->user()->id)->where('name', 'language')->delete();
|
||||
@@ -125,11 +119,12 @@ class HelpControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
*/
|
||||
public function testShowCached(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$help = $this->mock(HelpInterface::class);
|
||||
$help->shouldReceive('hasRoute')->andReturn(true)->once();
|
||||
$help->shouldReceive('inCache')->andReturn(true)->once();
|
||||
@@ -142,11 +137,12 @@ class HelpControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController
|
||||
*/
|
||||
public function testShowNoRoute(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$help = $this->mock(HelpInterface::class);
|
||||
$help->shouldReceive('hasRoute')->andReturn(false)->once();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user