Set getLogo() as protected

This commit is contained in:
Bubka 2022-07-30 11:25:45 +02:00
parent 601d50e8a4
commit fdc944be0e
2 changed files with 10 additions and 5 deletions

View File

@ -10,14 +10,18 @@ use Illuminate\Support\Str;
class LogoService class LogoService
{ {
/** /**
* \Illuminate\Support\Collection * @var \Illuminate\Support\Collection
*/ */
protected $tfas; protected $tfas;
/** /**
* * @var
*/ */
const TFA_JSON = 'tfa.json'; const TFA_JSON = 'tfa.json';
/**
* @var
*/
const TFA_URL = 'https://2fa.directory/api/v3/tfa.json'; const TFA_URL = 'https://2fa.directory/api/v3/tfa.json';
@ -28,7 +32,7 @@ class LogoService
/** /**
* Fetch a logo for the given service and set it as an icon * Fetch a logo for the given service and save it as an icon
* *
* @param string $serviceName Name of the service to fetch a logo for * @param string $serviceName Name of the service to fetch a logo for
* @return string|null The icon filename or null if no logo has been found * @return string|null The icon filename or null if no logo has been found
@ -51,7 +55,7 @@ class LogoService
* @param string $serviceName Name of the service to fetch a logo for * @param string $serviceName Name of the service to fetch a logo for
* @return string|null The logo filename or null if no logo has been found * @return string|null The logo filename or null if no logo has been found
*/ */
public function getLogo($serviceName) protected function getLogo($serviceName)
{ {
$domain = $this->tfas->get($this->cleanDomain(strval($serviceName))); $domain = $this->tfas->get($this->cleanDomain(strval($serviceName)));
$logoFilename = $domain.'.svg'; $logoFilename = $domain.'.svg';

View File

@ -48,7 +48,8 @@ class LogoServiceTest extends TestCase
public function test_getIcon_returns_null_when_no_logo_exists() public function test_getIcon_returns_null_when_no_logo_exists()
{ {
$logoServiceMock = $this->partialMock(LogoService::class, function (MockInterface $mock) { $logoServiceMock = $this->partialMock(LogoService::class, function (MockInterface $mock) {
$mock->shouldReceive('getLogo') $mock->shouldAllowMockingProtectedMethods()
->shouldReceive('getLogo')
->once() ->once()
->andReturn(null); ->andReturn(null);
}); });