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;
|
2024-01-04 21:51:32 +00:00
|
|
|
use Illuminate\Support\Facades\File;
|
2024-10-24 10:45:45 +00:00
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
2018-08-30 05:37:03 +00:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
2024-01-11 12:41:33 +00:00
|
|
|
use function Tests\test_path;
|
|
|
|
|
2018-08-30 05:37:03 +00:00
|
|
|
class ApplicationInformationServiceTest extends TestCase
|
|
|
|
{
|
2024-10-24 10:45:45 +00:00
|
|
|
#[Test]
|
|
|
|
public function getLatestVersionNumber(): void
|
2018-08-30 05:37:03 +00:00
|
|
|
{
|
|
|
|
$latestVersion = 'v1.1.2';
|
|
|
|
|
|
|
|
$mock = new MockHandler([
|
2024-01-06 11:31:50 +00:00
|
|
|
new Response(200, [], File::get(test_path('blobs/github-tags.json'))),
|
2018-08-30 05:37:03 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
$client = new Client(['handler' => HandlerStack::create($mock)]);
|
2024-06-04 13:35:00 +00:00
|
|
|
$service = new ApplicationInformationService($client);
|
2018-08-30 05:37:03 +00:00
|
|
|
|
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'));
|
2018-08-30 05:37:03 +00:00
|
|
|
}
|
|
|
|
}
|