koel/tests/Integration/Services/ApplicationInformationServiceTest.php

31 lines
949 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 Illuminate\Log\Logger;
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)]);
$service = new ApplicationInformationService($client, app(Cache::class), app(Logger::class));
self::assertEquals($latestVersion, $service->getLatestVersionNumber());
2018-08-30 05:42:47 +00:00
self::assertSame($latestVersion, cache('latestKoelVersion'));
}
}