Improve test coverage.

This commit is contained in:
James Cole
2019-07-24 19:02:41 +02:00
parent 226e2f7185
commit ee95606ec0
39 changed files with 378 additions and 234 deletions

View File

@@ -28,8 +28,8 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Tests\TestCase;
use Preferences;
use Tests\TestCase;
/**
* Class LinkControllerTest
@@ -85,7 +85,7 @@ class LinkControllerTest extends TestCase
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$linkType = LinkType::where('editable', 1)->first();
$another= LinkType::where('editable', 0)->first();
$another = LinkType::where('editable', 0)->first();
$repository->shouldReceive('get')->once()->andReturn(new Collection([$linkType, $another]));
$repository->shouldReceive('countJournals')->andReturn(2);
$this->be($this->user());
@@ -100,9 +100,9 @@ class LinkControllerTest extends TestCase
*/
public function testDeleteNonEditable(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mock(LinkTypeRepositoryInterface::class);
$linkType = LinkType::where('editable', 0)->first();
$linkType = LinkType::where('editable', 0)->first();
// mock default session stuff
$this->mockDefaultSession();
@@ -216,7 +216,7 @@ class LinkControllerTest extends TestCase
*/
public function testShow(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@@ -327,7 +327,7 @@ class LinkControllerTest extends TestCase
*/
public function testUpdateNonEditable(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$this->mock(LinkTypeRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();