Rename the tests to pass phpcs checks
This commit is contained in:
parent
3946e9aac4
commit
d5bbed1eac
52 changed files with 1329 additions and 1062 deletions
|
@ -1,32 +1,38 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Codebird\Codebird;
|
||||
use Tests\TestCase;
|
||||
use App\Models\WebMention;
|
||||
use Thujohn\Twitter\Facades\Twitter;
|
||||
use Codebird\Codebird;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WebMentionTest extends TestCase
|
||||
{
|
||||
public function test_commentable_method()
|
||||
/** @test */
|
||||
public function commentableMethodLinksToNotes(): void
|
||||
{
|
||||
$webmention = WebMention::find(1);
|
||||
$this->assertInstanceOf('App\Models\Note', $webmention->commentable);
|
||||
}
|
||||
public function test_published_attribute_when_no_relavent_mf2()
|
||||
|
||||
/** @test */
|
||||
public function publishedAttributeUsesUpdatedAtWhenNoRelevantMf2Data(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$updated_at = carbon()->now();
|
||||
$updated_at = Carbon::now();
|
||||
$webmention->updated_at = $updated_at;
|
||||
$this->assertEquals($updated_at->toDayDateTimeString(), $webmention->published);
|
||||
}
|
||||
|
||||
public function test_published_attribute_when_error_parsing_mf2()
|
||||
/** @test */
|
||||
public function publishedAttributeUsesUpdatedAtWhenErrorParsingMf2Data(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$updated_at = carbon()->now();
|
||||
$updated_at = Carbon::now();
|
||||
$webmention->updated_at = $updated_at;
|
||||
$webmention->mf2 = json_encode([
|
||||
'items' => [[
|
||||
|
@ -40,12 +46,8 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($updated_at->toDayDateTimeString(), $webmention->published);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a correct profile link is formed from a generic URL.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_create_photo_link_with_non_cached_image()
|
||||
/** @test */
|
||||
public function createPhotoLinkDoesNothingWithGenericUrlAndNoLocallySavedImage(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$homepage = 'https://example.org/profile.png';
|
||||
|
@ -53,12 +55,8 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($homepage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a correct profile link is formed from a generic URL (cached).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_create_photo_link_with_cached_image()
|
||||
/** @test */
|
||||
public function createPhotoLinkReturnsLocallySavedImageUrlIfItExists(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$homepage = 'https://aaronparecki.com/profile.png';
|
||||
|
@ -66,12 +64,8 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($homepage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a correct profile link is formed from a twitter URL.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_create_photo_link_with_twimg_profile_image_url()
|
||||
/** @test */
|
||||
public function createPhotoLinkDealsWithSpecialCaseOfDirectTwitterPhotoLinks(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$twitterProfileImage = 'http://pbs.twimg.com/1234';
|
||||
|
@ -79,12 +73,8 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($twitterProfileImage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test `null` is returned for a twitter profile.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_create_photo_link_with_cached_twitter_url()
|
||||
/** @test */
|
||||
public function createPhotoLinkReturnsCachedTwitterPhotoLinks(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$twitterURL = 'https://twitter.com/example';
|
||||
|
@ -93,10 +83,12 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($twitterURL));
|
||||
}
|
||||
|
||||
public function test_create_photo_link_with_noncached_twitter_url()
|
||||
/** @test */
|
||||
public function createPhotoLinkResolvesTwitterPhotoLinks(): void
|
||||
{
|
||||
$info = new \stdClass();
|
||||
$info->profile_image_url_https = 'https://pbs.twimg.com/static_profile_link.jpg';
|
||||
$info = (object) [
|
||||
'profile_image_url_https' => 'https://pbs.twimg.com/static_profile_link.jpg',
|
||||
];
|
||||
$codebirdMock = $this->getMockBuilder(Codebird::class)
|
||||
->addMethods(['users_show'])
|
||||
->getMock();
|
||||
|
@ -117,13 +109,15 @@ class WebMentionTest extends TestCase
|
|||
$this->assertEquals($expected, $webmention->createPhotoLink($twitterURL));
|
||||
}
|
||||
|
||||
public function test_get_reply_attribute_returns_null()
|
||||
/** @test */
|
||||
public function getReplyAttributeDefaultsToNull(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$this->assertNull($webmention->reply);
|
||||
}
|
||||
|
||||
public function test_get_reply_attribute_with_mf2_without_html_returns_null()
|
||||
/** @test */
|
||||
public function getReplyAttributeWithMf2WithoutHtmlReturnsNull(): void
|
||||
{
|
||||
$webmention = new WebMention();
|
||||
$webmention->mf2 = json_encode(['no_html' => 'found_here']);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue