Various code cleanup.

This commit is contained in:
James Cole
2017-12-29 09:05:35 +01:00
parent cf66ae61e1
commit 3815f9836f
135 changed files with 1021 additions and 973 deletions

View File

@@ -136,6 +136,30 @@ class UpdateControllerTest extends TestCase
$response->assertSee('the latest available release');
}
/**
* @covers \FireflyIII\Http\Controllers\Admin\UpdateController::updateCheck
*/
public function testUpdateCheckError()
{
$falseConfig = new Configuration;
$falseConfig->data = false;
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
$version = config('firefly.version') . '-alpha';
$releases = [
new Release(['id' => 'x', 'title' => $version, 'content' => '', 'updated' => new Carbon]),
];
$updater = $this->mock(UpdateRequest::class);
$updater->shouldReceive('call')->andThrow(FireflyException::class, 'Something broke.');
$updater->shouldReceive('getReleases')->andReturn($releases);
// expect a new release (because of .1)
$this->be($this->user());
$response = $this->post(route('admin.update-check.manual'));
$response->assertStatus(200);
$response->assertSee('An error occurred while checking');
}
/**
* @covers \FireflyIII\Http\Controllers\Admin\UpdateController::updateCheck
*/
@@ -161,28 +185,4 @@ class UpdateControllerTest extends TestCase
$response->assertSee($version);
$response->assertSee('which is newer than the');
}
/**
* @covers \FireflyIII\Http\Controllers\Admin\UpdateController::updateCheck
*/
public function testUpdateCheckError()
{
$falseConfig = new Configuration;
$falseConfig->data = false;
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
$version = config('firefly.version') . '-alpha';
$releases = [
new Release(['id' => 'x', 'title' => $version, 'content' => '', 'updated' => new Carbon]),
];
$updater = $this->mock(UpdateRequest::class);
$updater->shouldReceive('call')->andThrow(FireflyException::class, 'Something broke.');
$updater->shouldReceive('getReleases')->andReturn($releases);
// expect a new release (because of .1)
$this->be($this->user());
$response = $this->post(route('admin.update-check.manual'));
$response->assertStatus(200);
$response->assertSee('An error occurred while checking');
}
}