Mock more repositories in tests.

This commit is contained in:
James Cole
2018-09-03 18:52:46 +02:00
parent 480b636c7e
commit 46ba0a5a5a
137 changed files with 496 additions and 222 deletions

View File

@@ -24,7 +24,9 @@ namespace Tests\Feature\Controllers\Admin;
use FireflyConfig;
use FireflyIII\Models\Configuration;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
use Tests\TestCase;
/**
@@ -38,7 +40,7 @@ class ConfigurationControllerTest extends TestCase
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
Log::info(sprintf('Now in %s.', \get_class($this)));
}
/**
@@ -47,8 +49,11 @@ class ConfigurationControllerTest extends TestCase
*/
public function testIndex(): void
{
$this->be($this->user());
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->be($this->user());
$falseConfig = new Configuration;
$falseConfig->data = false;
@@ -70,6 +75,11 @@ class ConfigurationControllerTest extends TestCase
*/
public function testPostIndex(): void
{
$userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
$falseConfig = new Configuration;
$falseConfig->data = false;