Update Laravel to v12
Some checks failed
PHP Unit / PHPUnit test suite (pull_request) Has been cancelled
Laravel Pint / Laravel Pint (pull_request) Has been cancelled

This commit is contained in:
Jonny Barnes 2025-03-01 15:00:41 +00:00
parent f2025b801b
commit 1dfa17abca
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
83 changed files with 1324 additions and 2323 deletions

View file

@ -7,13 +7,14 @@ namespace Tests\Unit;
use App\Models\Article;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ArticlesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function titleSlugIsGeneratedAutomatically(): void
{
$article = new Article;
@ -24,7 +25,7 @@ class ArticlesTest extends TestCase
$this->assertEquals('my-title', $article->titleurl);
}
/** @test */
#[Test]
public function markdownContentIsConverted(): void
{
$article = new Article;
@ -33,7 +34,7 @@ class ArticlesTest extends TestCase
$this->assertEquals('<p>Some <em>markdown</em></p>' . PHP_EOL, $article->html);
}
/** @test */
#[Test]
public function weGenerateTheDifferentTimeAttributes(): void
{
$article = Article::create([
@ -47,7 +48,7 @@ class ArticlesTest extends TestCase
$this->assertEquals($article->pubdate, $article->updated_at->toRSSString());
}
/** @test */
#[Test]
public function weGenerateTheArticleLinkFromTheSlug(): void
{
$article = Article::create([
@ -62,7 +63,7 @@ class ArticlesTest extends TestCase
);
}
/** @test */
#[Test]
public function dateScopeReturnsExpectedArticles(): void
{
Article::factory()->create([
@ -81,7 +82,7 @@ class ArticlesTest extends TestCase
$this->assertCount(2, $emptyScope);
}
/** @test */
#[Test]
public function dateScopeReturnsExpectedArticlesForDecember(): void
{
Article::factory()->create([

View file

@ -10,14 +10,15 @@ use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class BookmarksTest extends TestCase
{
/**
* @test
/*
* @\test
*
* @group puppeteer
* @\group puppeteer
*
public function takeScreenshotOfDuckDuckGo()
{
@ -25,7 +26,7 @@ class BookmarksTest extends TestCase
$this->assertTrue(file_exists(public_path() . '/assets/img/bookmarks/' . $uuid . '.png'));
}*/
/** @test */
#[Test]
public function archiveLinkMethodCallsArchiveService(): void
{
$mock = new MockHandler([
@ -38,7 +39,7 @@ class BookmarksTest extends TestCase
$this->assertEquals('/web/1234/example.org', $url);
}
/** @test */
#[Test]
public function archiveLinkMethodThrowsAnExceptionOnError(): void
{
$this->expectException(InternetArchiveException::class);
@ -52,7 +53,7 @@ class BookmarksTest extends TestCase
(new BookmarkService)->getArchiveLink('https://example.org');
}
/** @test */
#[Test]
public function archiveLinkMethodThrowsAnExceptionIfNoLocationReturned(): void
{
$this->expectException(InternetArchiveException::class);

View file

@ -4,28 +4,27 @@ declare(strict_types=1);
namespace Tests\Unit;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class HelpersTest extends TestCase
{
/** @test */
#[Test]
public function normalizeUrlIsIdempotent(): void
{
$input = 'http://example.org:80/index.php?foo=bar&baz=1';
$this->assertEquals(normalize_url(normalize_url($input)), normalize_url($input));
}
/**
* @test
*
* @dataProvider urlProvider
*/
#[Test]
#[DataProvider('urlProvider')]
public function normalizeUrlOnDataProvider(string $input, string $output): void
{
$this->assertEquals($output, normalize_url($input));
}
/** @test */
#[Test]
public function prettyPrintJson(): void
{
// phpcs:disable Generic.Files.LineLength.TooLong

View file

@ -6,13 +6,14 @@ namespace Tests\Unit\Jobs;
use App\Jobs\AddClientToDatabase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class AddClientToDatabaseJobTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function clientIsAddedToDatabaseByJob(): void
{
$job = new AddClientToDatabase('https://example.org/client');

View file

@ -10,6 +10,7 @@ use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Illuminate\FileSystem\FileSystem;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class DownloadWebMentionJobTest extends TestCase
@ -23,7 +24,7 @@ class DownloadWebMentionJobTest extends TestCase
parent::tearDown();
}
/** @test */
#[Test]
public function htmlIsSavedByJob(): void
{
$this->assertFileDoesNotExist(storage_path('HTML/https'));
@ -51,7 +52,7 @@ class DownloadWebMentionJobTest extends TestCase
$this->assertFileDoesNotExist(storage_path('HTML/https/example.org/reply') . '/1.' . date('Y-m-d') . '.backup');
}
/** @test */
#[Test]
public function htmlAndBackupSavedByJob(): void
{
$this->assertFileDoesNotExist(storage_path('HTML/https'));
@ -86,7 +87,7 @@ class DownloadWebMentionJobTest extends TestCase
$this->assertFileExists(storage_path('HTML/https/example.org/reply') . '/1.' . date('Y-m-d') . '.backup');
}
/** @test */
#[Test]
public function indexHtmlFileIsSavedByJobForUrlsEndingWithSlash(): void
{
$this->assertFileDoesNotExist(storage_path('HTML/https'));

View file

@ -11,13 +11,14 @@ use App\Models\Bookmark;
use App\Services\BookmarkService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ProcessBookmarkJobTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function archiveLinkIsSavedByJobAndScreenshotJobIsQueued(): void
{
Queue::fake();
@ -38,7 +39,7 @@ class ProcessBookmarkJobTest extends TestCase
Queue::assertPushed(SaveScreenshot::class);
}
/** @test */
#[Test]
public function archiveLinkSavedAsNullWhenExceptionThrown(): void
{
Queue::fake();

View file

@ -7,11 +7,12 @@ namespace Tests\Unit\Jobs;
use App\Jobs\ProcessMedia;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\ImageManager;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ProcessMediaJobTest extends TestCase
{
/** @test */
#[Test]
public function nonMediaFilesAreNotSaved(): void
{
$manager = app()->make(ImageManager::class);
@ -22,7 +23,7 @@ class ProcessMediaJobTest extends TestCase
$this->assertFileDoesNotExist(storage_path('app/media/') . 'file.txt');
}
/** @test */
#[Test]
public function smallImagesAreNotResized(): void
{
$manager = app()->make(ImageManager::class);
@ -37,7 +38,7 @@ class ProcessMediaJobTest extends TestCase
Storage::disk('local')->delete('public/media');
}
/** @test */
#[Test]
public function largeImagesHaveSmallerImagesCreated(): void
{
$manager = app()->make(ImageManager::class);
@ -45,16 +46,17 @@ class ProcessMediaJobTest extends TestCase
$job = new ProcessMedia('test-image.jpg');
$job->handle($manager);
Storage::disk('local')->assertExists('public/media/test-image.jpg');
Storage::disk('local')->assertExists('public/media/test-image-small.jpg');
Storage::disk('local')->assertExists('public/media/test-image-medium.jpg');
// These need to look in public disk
Storage::disk('public')->assertExists('media/test-image.jpg');
Storage::disk('public')->assertExists('media/test-image-small.jpg');
Storage::disk('public')->assertExists('media/test-image-medium.jpg');
$this->assertFileDoesNotExist(storage_path('app/media/') . 'test-image.jpg');
// Tidy up files created by the job
Storage::disk('local')->delete('public/media/test-image.jpg');
Storage::disk('local')->delete('public/media/test-image-small.jpg');
Storage::disk('local')->delete('public/media/test-image-medium.jpg');
Storage::disk('public')->delete('media/test-image.jpg');
Storage::disk('public')->delete('media/test-image-small.jpg');
Storage::disk('public')->delete('media/test-image-medium.jpg');
$this->removeDirIfEmpty(storage_path('app/public/media'));
$this->removeDirIfEmpty(storage_path('app/media'));
}

View file

@ -17,6 +17,7 @@ use Illuminate\FileSystem\FileSystem;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Jonnybarnes\WebmentionsParser\Parser;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ProcessWebMentionJobTest extends TestCase
@ -32,7 +33,7 @@ class ProcessWebMentionJobTest extends TestCase
parent::tearDown();
}
/** @test */
#[Test]
public function failureGettingWebmentionThrowsAnException(): void
{
$this->expectException(RemoteContentNotFoundException::class);
@ -51,7 +52,7 @@ class ProcessWebMentionJobTest extends TestCase
$job->handle($parser, $client);
}
/** @test */
#[Test]
public function newWebmentionGetsSavedByJob(): void
{
Queue::fake();
@ -83,7 +84,7 @@ class ProcessWebMentionJobTest extends TestCase
]);
}
/** @test */
#[Test]
public function existingWebmentionGetsUpdatedByJob(): void
{
Queue::fake();
@ -120,7 +121,7 @@ class ProcessWebMentionJobTest extends TestCase
]);
}
/** @test */
#[Test]
public function webmentionReplyGetsDeletedWhenReplyToValueChanges(): void
{
$parser = new Parser;
@ -157,7 +158,7 @@ class ProcessWebMentionJobTest extends TestCase
]);
}
/** @test */
#[Test]
public function webmentionLikeGetsDeletedWhenLikeOfValueChanges(): void
{
$parser = new Parser;
@ -194,7 +195,7 @@ class ProcessWebMentionJobTest extends TestCase
]);
}
/** @test */
#[Test]
public function webmentionRepostGetsDeletedWhenRepostOfValueChanges(): void
{
$parser = new Parser;

View file

@ -11,6 +11,7 @@ use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Jonnybarnes\WebmentionsParser\Authorship;
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class SaveProfileImageJobTest extends TestCase
@ -24,7 +25,7 @@ class SaveProfileImageJobTest extends TestCase
parent::tearDown();
}
/** @test */
#[Test]
public function authorshipAlgorithmReturnsNullOnException(): void
{
$mf = ['items' => []];
@ -36,7 +37,7 @@ class SaveProfileImageJobTest extends TestCase
$this->assertNull($job->handle($authorship));
}
/** @test */
#[Test]
public function weDoNotProcessTwitterImages(): void
{
$mf = ['items' => []];
@ -54,7 +55,7 @@ class SaveProfileImageJobTest extends TestCase
$this->assertNull($job->handle($authorship));
}
/** @test */
#[Test]
public function remoteAuthorImagesAreSavedLocally(): void
{
$mock = new MockHandler([
@ -79,7 +80,7 @@ class SaveProfileImageJobTest extends TestCase
$this->assertFileExists(public_path() . '/assets/profile-images/example.org/image');
}
/** @test */
#[Test]
public function localDefaultAuthorImageIsUsedAsFallback(): void
{
$mock = new MockHandler([
@ -107,7 +108,7 @@ class SaveProfileImageJobTest extends TestCase
);
}
/** @test */
#[Test]
public function weGetUrlFromPhotoObjectIfAltTextIsProvided(): void
{
$mock = new MockHandler([
@ -135,7 +136,7 @@ class SaveProfileImageJobTest extends TestCase
$this->assertFileExists(public_path() . '/assets/profile-images/example.org/image');
}
/** @test */
#[Test]
public function useFirstUrlIfMultipleHomepagesAreProvided(): void
{
$mock = new MockHandler([

View file

@ -13,13 +13,14 @@ use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Response;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class SaveScreenshotJobTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function screenshotIsSavedByJob(): void
{
Storage::fake('public');
@ -84,7 +85,7 @@ class SaveScreenshotJobTest extends TestCase
Storage::disk('public')->assertExists('/assets/img/bookmarks/' . $bookmark->screenshot . '.png');
}
/** @test */
#[Test]
public function screenshotJobHandlesUnfinishedTasks(): void
{
Storage::fake('public');

View file

@ -10,11 +10,12 @@ use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class SendWebMentionJobTest extends TestCase
{
/** @test */
#[Test]
public function discoverWebmentionEndpointOnOwnDomain(): void
{
$note = new Note;
@ -23,7 +24,7 @@ class SendWebMentionJobTest extends TestCase
$this->assertNull($job->discoverWebmentionEndpoint('/notes/tagged/test'));
}
/** @test */
#[Test]
public function discoverWebmentionEndpointFromHeaderLinks(): void
{
$url = 'https://example.org/webmention';
@ -38,7 +39,7 @@ class SendWebMentionJobTest extends TestCase
$this->assertEquals($url, $job->discoverWebmentionEndpoint('https://example.org'));
}
/** @test */
#[Test]
public function discoverWebmentionEndpointFromHtmlLinkTags(): void
{
$html = '<link rel="webmention" href="https://example.org/webmention">';
@ -56,7 +57,7 @@ class SendWebMentionJobTest extends TestCase
);
}
/** @test */
#[Test]
public function discoverWebmentionEndpointFromLegacyHtmlMarkup(): void
{
$html = '<link rel="http://webmention.org/" href="https://example.org/webmention">';
@ -74,14 +75,14 @@ class SendWebMentionJobTest extends TestCase
);
}
/** @test */
#[Test]
public function ensureEmptyNoteDoesNotTriggerAnyActions(): void
{
$job = new SendWebMentions(new Note);
$this->assertNull($job->handle());
}
/** @test */
#[Test]
public function weResolveRelativeUris(): void
{
$uri = '/blog/post';
@ -90,7 +91,7 @@ class SendWebMentionJobTest extends TestCase
$this->assertEquals('https://example.org/blog/post', $job->resolveUri($uri, $base));
}
/** @test */
#[Test]
public function weSendAWebmentionForANote(): void
{
$html = '<link rel="http://webmention.org/" href="https://example.org/webmention">';
@ -110,7 +111,7 @@ class SendWebMentionJobTest extends TestCase
$this->assertTrue(true);
}
/** @test */
#[Test]
public function linksInNotesCanNotSupportWebmentions(): void
{
$mock = new MockHandler([

View file

@ -11,13 +11,14 @@ use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Response;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class SyndicateNoteToBlueskyJobTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function weSyndicateNotesToBluesky(): void
{
config(['bridgy.bluesky_token' => 'test']);
@ -38,7 +39,7 @@ class SyndicateNoteToBlueskyJobTest extends TestCase
]);
}
/** @test */
#[Test]
public function weSyndicateTheOriginalMarkdownToBluesky(): void
{
config(['bridgy.bluesky_token' => 'test']);

View file

@ -11,13 +11,14 @@ use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Response;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class SyndicateNoteToMastodonJobTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function weSyndicateNotesToMastodon(): void
{
config(['bridgy.mastodon_token' => 'test']);
@ -38,7 +39,7 @@ class SyndicateNoteToMastodonJobTest extends TestCase
]);
}
/** @test */
#[Test]
public function weSyndicateTheOriginalMarkdown(): void
{
config(['bridgy.mastodon_token' => 'test']);

View file

@ -6,13 +6,14 @@ namespace Tests\Unit;
use App\Models\Like;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class LikesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function weCanSetTheAuthorUrl(): void
{
$like = new Like;
@ -20,7 +21,7 @@ class LikesTest extends TestCase
$this->assertEquals('https://joe.bloggs', $like->author_url);
}
/** @test */
#[Test]
public function weDoNotModifyPlainTextContent(): void
{
$like = new Like;
@ -31,7 +32,7 @@ class LikesTest extends TestCase
$this->assertEquals('some plaintext content', $like->content);
}
/** @test */
#[Test]
public function weCanHandleBlankContent(): void
{
$like = new Like;
@ -42,7 +43,7 @@ class LikesTest extends TestCase
$this->assertNull($like->content);
}
/** @test */
#[Test]
public function htmlLikeContentIsFiltered(): void
{
$htmlEvil = <<<'HTML'

View file

@ -7,13 +7,14 @@ namespace Tests\Unit;
use App\Models\Media;
use App\Models\Note;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class MediaTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function getTheNoteThatMediaInstanceBelongsTo(): void
{
$media = Media::factory()->for(Note::factory())->create();
@ -21,7 +22,7 @@ class MediaTest extends TestCase
$this->assertInstanceOf(Note::class, $media->note);
}
/** @test */
#[Test]
public function absoluteUrlsAreReturnedUnmodified(): void
{
$absoluteUrl = 'https://instagram-cdn.com/image/uuid';

View file

@ -7,13 +7,14 @@ namespace Tests\Unit;
use App\Models\MicropubClient;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class MicropubClientsTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function weCanGetNotesRelatingToClient(): void
{
$client = MicropubClient::factory()->make();

View file

@ -16,6 +16,7 @@ use GuzzleHttp\Psr7\Response;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class NotesTest extends TestCase
@ -25,9 +26,8 @@ class NotesTest extends TestCase
/**
* Test the getNoteAttribute method. This will then also call the
* relevant sub-methods.
*
* @test
*/
#[Test]
public function getNoteAttributeMethodCallsSubMethods(): void
{
// phpcs:ignore
@ -40,9 +40,8 @@ class NotesTest extends TestCase
/**
* Look for a default image in the contacts h-card for the makeHCards method.
*
* @test
*/
#[Test]
public function defaultImageUsedAsFallbackInMakehcardsMethod(): void
{
// phpcs:ignore
@ -70,9 +69,8 @@ class NotesTest extends TestCase
/**
* Look for a specific profile image in the contacts h-card.
*
* @test
*/
#[Test]
public function specificProfileImageUsedInMakehcardsMethod(): void
{
Contact::factory()->create([
@ -106,9 +104,8 @@ class NotesTest extends TestCase
/**
* Look for twitter URL when theres no associated contact.
*
* @test
*/
#[Test]
public function twitterLinkIsCreatedWhenNoContactFound(): void
{
$expected = '<p>Hi <a href="https://twitter.com/bob">@bob</a></p>' . PHP_EOL;
@ -118,7 +115,7 @@ class NotesTest extends TestCase
$this->assertEquals($expected, $note->note);
}
/** @test */
#[Test]
public function shorturlMethodReturnsExpectedValue(): void
{
$note = Note::factory()->make();
@ -126,7 +123,7 @@ class NotesTest extends TestCase
$this->assertEquals(config('url.shorturl') . '/notes/E', $note->shorturl);
}
/** @test */
#[Test]
public function weGetLatitudeLongitudeValuesOfAssociatedPlaceOfNote(): void
{
$place = Place::factory()->create([
@ -140,7 +137,7 @@ class NotesTest extends TestCase
$this->assertEquals('-2.3805', $note->longitude);
}
/** @test */
#[Test]
public function whenNoAssociatedPlaceWeGetNullForLatitudeLongitudeValues(): void
{
$note = Note::factory()->create();
@ -148,7 +145,7 @@ class NotesTest extends TestCase
$this->assertNull($note->longitude);
}
/** @test */
#[Test]
public function weCanGetAddressAttributeForAssociatedPlace(): void
{
$place = Place::factory()->create([
@ -162,7 +159,7 @@ class NotesTest extends TestCase
$this->assertEquals('The Bridgewater Pub', $note->address);
}
/** @test */
#[Test]
public function deletingNotesAlsoDeletesTagsViaTheEventObserver(): void
{
// first well create a temporary note to delete
@ -177,7 +174,7 @@ class NotesTest extends TestCase
]);
}
/** @test */
#[Test]
public function saveBlankNotesAsNull(): void
{
$note = new Note(['note' => '']);
@ -185,7 +182,7 @@ class NotesTest extends TestCase
$this->assertNull($note->note);
}
/** @test */
#[Test]
public function reverseGeocodeAnAttraction(): void
{
// phpcs:disable Generic.Files.LineLength.TooLong
@ -210,7 +207,7 @@ class NotesTest extends TestCase
);
}
/** @test */
#[Test]
public function reverseGeocodeASuburb(): void
{
// phpcs:disable Generic.Files.LineLength.TooLong
@ -235,7 +232,7 @@ class NotesTest extends TestCase
);
}
/** @test */
#[Test]
public function reverseGeocodeACity(): void
{
// Note Ive modified this JSON response so it only contains the
@ -262,7 +259,7 @@ class NotesTest extends TestCase
);
}
/** @test */
#[Test]
public function reverseGeocodeACounty(): void
{
// Note Ive removed everything below county to test for queries where
@ -286,7 +283,7 @@ class NotesTest extends TestCase
$this->assertEquals('<span class="p-region">Kent</span>, <span class="p-country-name">UK</span>', $address);
}
/** @test */
#[Test]
public function reverseGeocodeACountry(): void
{
// Note Ive removed everything below country to test for querires where
@ -310,7 +307,7 @@ class NotesTest extends TestCase
$this->assertEquals('<span class="p-country-name">Ireland</span>', $address);
}
/** @test */
#[Test]
public function addImageElementToNoteContentWhenMediaAssociated(): void
{
$media = Media::factory()->create([
@ -327,7 +324,7 @@ class NotesTest extends TestCase
$this->assertEquals($expected, $note->content);
}
/** @test */
#[Test]
public function addVideoElementToNoteContentWhenMediaAssociated(): void
{
$media = Media::factory()->create([
@ -344,7 +341,7 @@ class NotesTest extends TestCase
$this->assertEquals($expected, $note->content);
}
/** @test */
#[Test]
public function addAudioElementToNoteContentWhenMediaAssociated(): void
{
$media = Media::factory()->create([
@ -362,10 +359,9 @@ class NotesTest extends TestCase
}
/**
* @test
*
* @todo Why do we need to provide text?
*/
#[Test]
public function provideTextForBlankContent(): void
{
$note = new Note;
@ -382,9 +378,8 @@ class NotesTest extends TestCase
$this->assertNull($note->twitter);
}*/
/** @test */
public function markdownContentGetsConverted(): void
#[Test]
public function markdown_content_gets_converted(): void
{
$note = Note::factory()->create([
'note' => 'The best search engine? https://duckduckgo.com',
@ -398,9 +393,8 @@ class NotesTest extends TestCase
/**
* For now, just reply on a cached object instead of actually querying Twitter.
*
* @test
*/
#[Test]
public function checkInReplyToIsTwitterLink(): void
{
$tempContent = (object) [
@ -415,7 +409,7 @@ class NotesTest extends TestCase
$this->assertEquals($tempContent, $note->twitter);
}
/** @test */
#[Test]
public function latitudeAndLongitudeCanBeParsedFromPlainLocation(): void
{
$note = Note::factory()->create([
@ -426,7 +420,7 @@ class NotesTest extends TestCase
$this->assertSame(4.56, $note->longitude);
}
/** @test */
#[Test]
public function addressAttributeCanBeRetrievedFromPlainLocation(): void
{
Cache::put('1.23,4.56', '<span class="p-country-name">Antarctica</span>');
@ -438,7 +432,7 @@ class NotesTest extends TestCase
$this->assertSame('<span class="p-country-name">Antarctica</span>', $note->address);
}
/** @test */
#[Test]
public function mastodonUsernamesAreParsedCorrectly(): void
{
$expected = '<p>Hi <a href="https://phpc.social/@freekmurze">@freekmurze@phpc.social</a> how are you?</p>' . PHP_EOL;

View file

@ -10,13 +10,14 @@ use App\Services\PlaceService;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Testing\RefreshDatabase;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class PlacesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function canRetrieveAssociatedNotes(): void
{
$place = Place::factory()->create();
@ -27,7 +28,7 @@ class PlacesTest extends TestCase
$this->assertCount(5, $place->notes);
}
/** @test */
#[Test]
public function nearMethodReturnsCollection(): void
{
Place::factory()->create([
@ -39,7 +40,7 @@ class PlacesTest extends TestCase
$this->assertEquals('the-bridgewater-pub', $nearby[0]->slug);
}
/** @test */
#[Test]
public function getLongurl(): void
{
$place = Place::factory()->create([
@ -48,7 +49,7 @@ class PlacesTest extends TestCase
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->longurl);
}
/** @test */
#[Test]
public function getShorturl()
{
$place = Place::factory()->create([
@ -57,7 +58,7 @@ class PlacesTest extends TestCase
$this->assertEquals(config('url.shorturl') . '/places/the-bridgewater-pub', $place->shorturl);
}
/** @test */
#[Test]
public function getUri(): void
{
$place = Place::factory()->create([
@ -66,7 +67,7 @@ class PlacesTest extends TestCase
$this->assertEquals(config('app.url') . '/places/the-bridgewater-pub', $place->uri);
}
/** @test */
#[Test]
public function placeServiceReturnsExistingPlaceBasedOnExternalUrlsSearch(): void
{
Place::factory(10)->create();
@ -86,7 +87,7 @@ class PlacesTest extends TestCase
$this->assertCount(11, Place::all());
}
/** @test */
#[Test]
public function placeServiceRequiresNameWhenCreatingNewPlace(): void
{
$this->expectException(InvalidArgumentException::class);
@ -96,7 +97,7 @@ class PlacesTest extends TestCase
$service->createPlaceFromCheckin(['foo' => 'bar']);
}
/** @test */
#[Test]
public function placeServiceRequiresLatitudeWhenCreatingNewPlace(): void
{
$this->expectException(InvalidArgumentException::class);
@ -106,7 +107,7 @@ class PlacesTest extends TestCase
$service->createPlaceFromCheckin(['properties' => ['name' => 'bar']]);
}
/** @test */
#[Test]
public function placeServiceCanUpdateExternalUrls(): void
{
$place = Place::factory()->create([

View file

@ -8,13 +8,15 @@ use App\Models\Bookmark;
use App\Models\Note;
use App\Models\Tag;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class TagsTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function canGetAssociatedNotes(): void
{
$note = Note::factory()->create();
@ -23,7 +25,7 @@ class TagsTest extends TestCase
$this->assertCount(1, $tag->notes);
}
/** @test */
#[Test]
public function canGetAssociatedBookmarks(): void
{
$bookmark = Bookmark::factory()->create();
@ -32,11 +34,8 @@ class TagsTest extends TestCase
$this->assertCount(1, $tag->bookmarks);
}
/**
* @test
*
* @dataProvider tagsProvider
*/
#[Test]
#[DataProvider('tagsProvider')]
public function canNormalize(string $input, string $expected): void
{
$this->assertSame($expected, Tag::normalize($input));

View file

@ -10,13 +10,14 @@ use Codebird\Codebird;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class WebMentionTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function commentableMethodLinksToNotes(): void
{
$note = Note::factory()->create();
@ -27,7 +28,7 @@ class WebMentionTest extends TestCase
$this->assertInstanceOf(Note::class, $webmention->commentable);
}
/** @test */
#[Test]
public function publishedAttributeUsesUpdatedAtWhenNoRelevantMf2Data(): void
{
$webmention = new WebMention;
@ -36,7 +37,7 @@ class WebMentionTest extends TestCase
$this->assertEquals($updated_at->toDayDateTimeString(), $webmention->published);
}
/** @test */
#[Test]
public function publishedAttributeUsesUpdatedAtWhenErrorParsingMf2Data(): void
{
$webmention = new WebMention;
@ -54,7 +55,7 @@ class WebMentionTest extends TestCase
$this->assertEquals($updated_at->toDayDateTimeString(), $webmention->published);
}
/** @test */
#[Test]
public function createPhotoLinkDoesNothingWithGenericUrlAndNoLocallySavedImage(): void
{
$webmention = new WebMention;
@ -63,7 +64,7 @@ class WebMentionTest extends TestCase
$this->assertEquals($expected, $webmention->createPhotoLink($homepage));
}
/** @test */
#[Test]
public function createPhotoLinkReturnsLocallySavedImageUrlIfItExists(): void
{
$webmention = new WebMention;
@ -72,7 +73,7 @@ class WebMentionTest extends TestCase
$this->assertEquals($expected, $webmention->createPhotoLink($homepage));
}
/** @test */
#[Test]
public function createPhotoLinkDealsWithSpecialCaseOfDirectTwitterPhotoLinks(): void
{
$webmention = new WebMention;
@ -81,7 +82,7 @@ class WebMentionTest extends TestCase
$this->assertEquals($expected, $webmention->createPhotoLink($twitterProfileImage));
}
/** @test */
#[Test]
public function createPhotoLinkReturnsCachedTwitterPhotoLinks(): void
{
$webmention = new WebMention;
@ -91,16 +92,15 @@ class WebMentionTest extends TestCase
$this->assertEquals($expected, $webmention->createPhotoLink($twitterURL));
}
/** @test */
#[Test]
public function createPhotoLinkResolvesTwitterPhotoLinks(): void
{
$info = (object) [
'profile_image_url_https' => 'https://pbs.twimg.com/static_profile_link.jpg',
];
$codebirdMock = $this->getMockBuilder(Codebird::class)
->addMethods(['users_show'])
->getMock();
$codebirdMock->method('users_show')
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
$codebirdMock->method('__call')
->with('users_show', $this->anything())
->willReturn($info);
$this->app->instance(Codebird::class, $codebirdMock);
@ -117,14 +117,14 @@ class WebMentionTest extends TestCase
$this->assertEquals($expected, $webmention->createPhotoLink($twitterURL));
}
/** @test */
#[Test]
public function getReplyAttributeDefaultsToNull(): void
{
$webmention = new WebMention;
$this->assertNull($webmention->reply);
}
/** @test */
#[Test]
public function getReplyAttributeWithMf2WithoutHtmlReturnsNull(): void
{
$webmention = new WebMention;