mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-03-15 04:09:39 +01:00
Add a new test for the update check (#96)
This commit is contained in:
parent
54226a5eca
commit
efd6dbd720
72
tests/Unit/Helper/UpdateCheckTest.php
Normal file
72
tests/Unit/Helper/UpdateCheckTest.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Helper;
|
||||
|
||||
use App\Helper\UpdateHelper;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class UpdateCheckTest
|
||||
*
|
||||
* @package Tests\Unit\Helper
|
||||
*/
|
||||
class UpdateCheckTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test the checkForUpdates() helper function with a new update available.
|
||||
* Must return the given version string.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSuccessfulCheck(): void
|
||||
{
|
||||
Http::fake([
|
||||
'github.com/*' => Http::response(
|
||||
[['tag_name' => 'v100.0.0']],
|
||||
200
|
||||
),
|
||||
]);
|
||||
|
||||
$result = UpdateHelper::checkForUpdates();
|
||||
|
||||
$this->assertEquals('v100.0.0', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the checkForUpdates() helper function with no update available.
|
||||
* Must return true.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSuccessfulCheckWithoutVersion(): void
|
||||
{
|
||||
Http::fake([
|
||||
'github.com/*' => Http::response(
|
||||
[['tag_name' => 'v0.0.0']],
|
||||
200
|
||||
),
|
||||
]);
|
||||
|
||||
$result = UpdateHelper::checkForUpdates();
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the checkForUpdates() helper function, but trigger a network / http error.
|
||||
* Must return false.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testValidWaybackLink(): void
|
||||
{
|
||||
Http::fake([
|
||||
'github.com/*' => Http::response([], 404),
|
||||
]);
|
||||
|
||||
$result = UpdateHelper::checkForUpdates();
|
||||
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user