mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Expand coverage.
This commit is contained in:
@@ -112,10 +112,10 @@ class UpdateController extends Controller
|
|||||||
$check = version_compare($current, $first->getTitle());
|
$check = version_compare($current, $first->getTitle());
|
||||||
FireflyConfig::set('last_update_check', time());
|
FireflyConfig::set('last_update_check', time());
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
Log::error(sprintf('Could not check for updates: %s', $e->getMessage())); // @codeCoverageIgnore
|
Log::error(sprintf('Could not check for updates: %s', $e->getMessage()));
|
||||||
}
|
}
|
||||||
if ($check === -2) {
|
if ($check === -2) {
|
||||||
$string = strval(trans('firefly.update_check_error')); // @codeCoverageIgnore
|
$string = strval(trans('firefly.update_check_error'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($check === -1) {
|
if ($check === -1) {
|
||||||
|
@@ -24,6 +24,7 @@ namespace Tests\Feature\Controllers\Admin;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyConfig;
|
use FireflyConfig;
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\Configuration;
|
use FireflyIII\Models\Configuration;
|
||||||
use FireflyIII\Services\Github\Object\Release;
|
use FireflyIII\Services\Github\Object\Release;
|
||||||
use FireflyIII\Services\Github\Request\UpdateRequest;
|
use FireflyIII\Services\Github\Request\UpdateRequest;
|
||||||
@@ -160,4 +161,28 @@ class UpdateControllerTest extends TestCase
|
|||||||
$response->assertSee($version);
|
$response->assertSee($version);
|
||||||
$response->assertSee('which is newer than the');
|
$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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user