ソースを参照

Set getLogo() as protected

Bubka 3 年 前
コミット
fdc944be0e
2 ファイル変更10 行追加5 行削除
  1. 8 4
      app/Services/LogoService.php
  2. 2 1
      tests/Feature/Services/LogoServiceTest.php

+ 8 - 4
app/Services/LogoService.php

@@ -10,14 +10,18 @@ use Illuminate\Support\Str;
 class LogoService
 {
     /**
-     * \Illuminate\Support\Collection
+     * @var \Illuminate\Support\Collection
      */
     protected $tfas;
 
     /**
-     * 
+     * @var
      */
     const TFA_JSON = 'tfa.json';
+
+    /**
+     * @var
+     */
     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
      * @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
      * @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)));
         $logoFilename = $domain.'.svg';

+ 2 - 1
tests/Feature/Services/LogoServiceTest.php

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