Fix tests for the relocated createPhotoLink method
This commit is contained in:
parent
4b0a6cad1d
commit
005685ed42
3 changed files with 12 additions and 40 deletions
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue