mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-04 13:16:31 +00:00
Clean up tests, test only the important things.
This commit is contained in:
@@ -55,76 +55,6 @@ class RuleControllerTest extends TestCase
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
/** @var Rule $rule */
|
||||
$rule = $this->user()->rules()->first();
|
||||
|
||||
// mock stuff:
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('destroy')->once()->andReturn(true);
|
||||
|
||||
$response = $this->delete('/api/v1/rules/' . $rule->id);
|
||||
$response->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(RuleTransformer::class);
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('getAll')->once()->andReturn(new Collection);
|
||||
|
||||
|
||||
// call API
|
||||
$response = $this->get('/api/v1/rules');
|
||||
$response->assertStatus(200);
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
*/
|
||||
public function testShow(): void
|
||||
{
|
||||
$rule = $this->user()->rules()->first();
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$transformer = $this->mock(RuleTransformer::class);
|
||||
|
||||
// mock calls to transformer:
|
||||
$transformer->shouldReceive('setParameters')->withAnyArgs()->atLeast()->once();
|
||||
$transformer->shouldReceive('setCurrentScope')->withAnyArgs()->atLeast()->once()->andReturnSelf();
|
||||
$transformer->shouldReceive('getDefaultIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('getAvailableIncludes')->withAnyArgs()->atLeast()->once()->andReturn([]);
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
|
||||
|
||||
// call API
|
||||
$response = $this->get('/api/v1/rules/' . $rule->id);
|
||||
$response->assertStatus(200);
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
|
||||
Reference in New Issue
Block a user