2018-08-30 12:37:03 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration\Services;
|
|
|
|
|
|
|
|
use App\Services\ApplicationInformationService;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use GuzzleHttp\Handler\MockHandler;
|
|
|
|
use GuzzleHttp\HandlerStack;
|
|
|
|
use GuzzleHttp\Psr7\Response;
|
2018-08-30 12:37:24 +07:00
|
|
|
use Illuminate\Contracts\Cache\Repository as Cache;
|
2024-01-04 22:51:32 +01:00
|
|
|
use Illuminate\Support\Facades\File;
|
2018-08-30 12:37:03 +07:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
2024-01-11 13:41:33 +01:00
|
|
|
use function Tests\test_path;
|
|
|
|
|
2018-08-30 12:37:03 +07:00
|
|
|
class ApplicationInformationServiceTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testGetLatestVersionNumber(): void
|
|
|
|
{
|
|
|
|
$latestVersion = 'v1.1.2';
|
|
|
|
|
|
|
|
$mock = new MockHandler([
|
2024-01-06 12:31:50 +01:00
|
|
|
new Response(200, [], File::get(test_path('blobs/github-tags.json'))),
|
2018-08-30 12:37:03 +07:00
|
|
|
]);
|
|
|
|
|
|
|
|
$client = new Client(['handler' => HandlerStack::create($mock)]);
|
2022-08-08 18:00:59 +02:00
|
|
|
$service = new ApplicationInformationService($client, app(Cache::class));
|
2018-08-30 12:37:03 +07:00
|
|
|
|
2022-10-07 22:25:44 +08:00
|
|
|
self::assertSame($latestVersion, $service->getLatestVersionNumber());
|
2020-12-23 00:01:49 +01:00
|
|
|
self::assertSame($latestVersion, cache()->get('latestKoelVersion'));
|
2018-08-30 12:37:03 +07:00
|
|
|
}
|
|
|
|
}
|