koel/tests/Integration/Services/ApplicationInformationServiceTest.php

30 lines
907 B
PHP
Raw Normal View History

<?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 05:37:24 +00:00
use Illuminate\Contracts\Cache\Repository as Cache;
use Tests\TestCase;
class ApplicationInformationServiceTest extends TestCase
{
public function testGetLatestVersionNumber(): void
{
$latestVersion = 'v1.1.2';
$mock = new MockHandler([
2020-12-22 20:11:22 +00:00
new Response(200, [], file_get_contents(__DIR__ . '../../../blobs/github-tags.json')),
]);
$client = new Client(['handler' => HandlerStack::create($mock)]);
2022-08-08 16:00:59 +00:00
$service = new ApplicationInformationService($client, app(Cache::class));
2022-10-07 14:25:44 +00:00
self::assertSame($latestVersion, $service->getLatestVersionNumber());
2020-12-22 23:01:49 +00:00
self::assertSame($latestVersion, cache()->get('latestKoelVersion'));
}
}