2018-08-30 05:37:03 +00: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 05:37:24 +00:00
|
|
|
use Illuminate\Contracts\Cache\Repository as Cache;
|
2018-08-30 05:37:03 +00:00
|
|
|
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')),
|
2018-08-30 05:37:03 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
$client = new Client(['handler' => HandlerStack::create($mock)]);
|
2022-08-08 16:00:59 +00:00
|
|
|
$service = new ApplicationInformationService($client, app(Cache::class));
|
2018-08-30 05:37:03 +00:00
|
|
|
|
|
|
|
self::assertEquals($latestVersion, $service->getLatestVersionNumber());
|
2020-12-22 23:01:49 +00:00
|
|
|
self::assertSame($latestVersion, cache()->get('latestKoelVersion'));
|
2018-08-30 05:37:03 +00:00
|
|
|
}
|
|
|
|
}
|