diff --git a/app/Note.php b/app/Note.php index 32a15cad..b64fc765 100644 --- a/app/Note.php +++ b/app/Note.php @@ -261,29 +261,6 @@ class Note extends Model return; } - /* - * Get the relavent client name assocaited with the client id. - * - * @return string|null - * - public function getClientNameAttribute() - { - if ($this->client_id == null) { - return; - } - $name = MicropubClient::where('client_url', $this->client_id)->value('client_name'); - if ($name == null) { - $url = parse_url($this->client_id); - if (isset($url['path'])) { - return $url['host'] . $url['path']; - } - - return $url['host']; - } - - return $name; - }*/ - public function getTwitterAttribute() { if ($this->in_reply_to == null || mb_substr($this->in_reply_to, 0, 20, 'UTF-8') !== 'https://twitter.com/') { diff --git a/app/WebMention.php b/app/WebMention.php index ca2fa12d..19f827d4 100644 --- a/app/WebMention.php +++ b/app/WebMention.php @@ -2,6 +2,7 @@ namespace App; +use Cache; use Twitter; use HTMLPurifier; use Carbon\Carbon; diff --git a/tests/Unit/NotesControllerTest.php b/tests/Unit/WebMentionTest.php similarity index 62% rename from tests/Unit/NotesControllerTest.php rename to tests/Unit/WebMentionTest.php index 2e654f5e..83f3602f 100644 --- a/tests/Unit/NotesControllerTest.php +++ b/tests/Unit/WebMentionTest.php @@ -2,21 +2,14 @@ namespace Tests\Unit; +use Cache; +use App\WebMention; use Tests\TestCase; -use Illuminate\Support\Facades\Cache; -use App\Http\Controllers\NotesController; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; -class NotesControllerTest extends TestCase +class WebMentionTest extends TestCase { - protected $notesController; - - public function __construct() - { - $this->notesController = new NotesController(); - } - /** * Test a correct profile link is formed from a generic URL. * @@ -24,10 +17,10 @@ class NotesControllerTest extends TestCase */ public function test_create_photo_link_with_non_cached_image() { - $notesController = new \App\Http\Controllers\NotesController(); + $webmention = new WebMention(); $homepage = 'https://example.org/profile.png'; $expected = 'https://example.org/profile.png'; - $this->assertEquals($expected, $this->notesController->createPhotoLink($homepage)); + $this->assertEquals($expected, $webmention->createPhotoLink($homepage)); } /** @@ -37,10 +30,10 @@ class NotesControllerTest extends TestCase */ public function test_create_photo_link_with_cached_image() { - $notesController = new \App\Http\Controllers\NotesController(); + $webmention = new WebMention(); $homepage = 'https://aaronparecki.com/profile.png'; $expected = '/assets/profile-images/aaronparecki.com/image'; - $this->assertEquals($expected, $this->notesController->createPhotoLink($homepage)); + $this->assertEquals($expected, $webmention->createPhotoLink($homepage)); } /** @@ -50,10 +43,10 @@ class NotesControllerTest extends TestCase */ public function test_create_photo_link_with_twimg_profile_image_url() { - $notesController = new \App\Http\Controllers\NotesController(); + $webmention = new WebMention(); $twitterProfileImage = 'http://pbs.twimg.com/1234'; $expected = 'https://pbs.twimg.com/1234'; - $this->assertEquals($expected, $this->notesController->createPhotoLink($twitterProfileImage)); + $this->assertEquals($expected, $webmention->createPhotoLink($twitterProfileImage)); } /** @@ -63,9 +56,10 @@ class NotesControllerTest extends TestCase */ public function test_create_photo_link_with_cached_twitter_url() { + $webmention = new WebMention(); $twitterURL = 'https://twitter.com/example'; $expected = 'https://pbs.twimg.com/static_profile_link.jpg'; Cache::put($twitterURL, $expected, 1); - $this->assertEquals($expected, $this->notesController->createPhotoLink($twitterURL)); + $this->assertEquals($expected, $webmention->createPhotoLink($twitterURL)); } }