37 lines
828 B
PHP
37 lines
828 B
PHP
<?php
|
|
|
|
use App\Domains\Link\Services\LinkCacheService;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
beforeEach(function () {
|
|
// Clean up test keys
|
|
Redis::del('link:testslug');
|
|
});
|
|
|
|
afterEach(function () {
|
|
Redis::del('link:testslug');
|
|
});
|
|
|
|
it('stores link data in redis hash', function () {
|
|
$service = new LinkCacheService;
|
|
|
|
$service->put('testslug', [
|
|
'target' => 'https://example.com',
|
|
'status' => 'active',
|
|
'workspace_id' => '1',
|
|
]);
|
|
|
|
$data = $service->get('testslug');
|
|
|
|
expect($data['target'])->toBe('https://example.com')
|
|
->and($data['status'])->toBe('active');
|
|
});
|
|
|
|
it('returns null for unknown slug', function () {
|
|
$service = new LinkCacheService;
|
|
expect($service->get('nonexistent-'.uniqid()))->toBeNull();
|
|
});
|