Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Services/GiphyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GiphyService

public function __construct()
{
$this->apiKey = config('services.giphy.api_key', '');
$this->apiKey = (string) config('services.giphy.api_key', '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Services/UnsplashService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UnsplashService

public function __construct()
{
$this->accessKey = config('services.unsplash.access_key', '');
$this->accessKey = (string) config('services.unsplash.access_key', '');
}

/**
Expand Down
22 changes: 22 additions & 0 deletions tests/Unit/Services/MediaSearchKeyFallbackTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use App\Services\GiphyService;
use App\Services\UnsplashService;

test('unsplash service tolerates a null access key without throwing', function () {
config(['services.unsplash.access_key' => null]);

$result = (new UnsplashService)->search('cats');

expect($result)->toBe(['results' => [], 'total' => 0, 'total_pages' => 0]);
});

test('giphy service tolerates a null api key without throwing', function () {
config(['services.giphy.api_key' => null]);

$result = (new GiphyService)->search('cats');

expect($result)->toBe(['results' => [], 'total' => 0, 'total_pages' => 0]);
});