Upgrade to Laravel 13

This commit is contained in:
Jonny Barnes 2026-04-07 09:01:19 +01:00
commit 9f012b01e4
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
117 changed files with 1878 additions and 2215 deletions

View file

@ -18,8 +18,8 @@ class DownloadWebMentionJobTest extends TestCase
protected function tearDown(): void
{
$fs = new FileSystem;
if ($fs->exists(storage_path() . '/HTML/https')) {
$fs->deleteDirectory(storage_path() . '/HTML/https');
if ($fs->exists(storage_path().'/HTML/https')) {
$fs->deleteDirectory(storage_path().'/HTML/https');
}
parent::tearDown();
}
@ -34,7 +34,7 @@ class DownloadWebMentionJobTest extends TestCase
<a class="u-like-of" href=""></a>
</div>
HTML;
$html = str_replace('href=""', 'href="' . config('app.url') . '/notes/A"', $html);
$html = str_replace('href=""', 'href="'.config('app.url').'/notes/A"', $html);
$mock = new MockHandler([
new Response(200, ['X-Foo' => 'Bar'], $html),
new Response(200, ['X-Foo' => 'Bar'], $html),
@ -49,7 +49,7 @@ class DownloadWebMentionJobTest extends TestCase
$job->handle($client);
$this->assertFileDoesNotExist(storage_path('HTML/https/example.org/reply') . '/1.' . date('Y-m-d') . '.backup');
$this->assertFileDoesNotExist(storage_path('HTML/https/example.org/reply').'/1.'.date('Y-m-d').'.backup');
}
#[Test]
@ -68,8 +68,8 @@ class DownloadWebMentionJobTest extends TestCase
<a class="u-repost-of" href=""></a>
</div>
HTML;
$html = str_replace('href=""', 'href="' . config('app.url') . '/notes/A"', $html);
$html2 = str_replace('href=""', 'href="' . config('app.url') . '/notes/A"', $html2);
$html = str_replace('href=""', 'href="'.config('app.url').'/notes/A"', $html);
$html2 = str_replace('href=""', 'href="'.config('app.url').'/notes/A"', $html2);
$mock = new MockHandler([
new Response(200, ['X-Foo' => 'Bar'], $html),
new Response(200, ['X-Foo' => 'Bar'], $html2),
@ -84,7 +84,7 @@ class DownloadWebMentionJobTest extends TestCase
$job->handle($client);
$this->assertFileExists(storage_path('HTML/https/example.org/reply') . '/1.' . date('Y-m-d') . '.backup');
$this->assertFileExists(storage_path('HTML/https/example.org/reply').'/1.'.date('Y-m-d').'.backup');
}
#[Test]
@ -97,7 +97,7 @@ class DownloadWebMentionJobTest extends TestCase
<a class="u-like-of" href=""></a>
</div>
HTML;
$html = str_replace('href=""', 'href="' . config('app.url') . '/notes/A"', $html);
$html = str_replace('href=""', 'href="'.config('app.url').'/notes/A"', $html);
$mock = new MockHandler([
new Response(200, ['X-Foo' => 'Bar'], $html),
]);

View file

@ -20,18 +20,18 @@ class ProcessMediaJobTest extends TestCase
$job = new ProcessMedia('file.txt');
$job->handle($manager);
$this->assertFileDoesNotExist(storage_path('app/media/') . 'file.txt');
$this->assertFileDoesNotExist(storage_path('app/media/').'file.txt');
}
#[Test]
public function small_images_are_not_resized(): void
{
$manager = app()->make(ImageManager::class);
Storage::disk('local')->put('media/aaron.png', file_get_contents(__DIR__ . '/../../aaron.png'));
Storage::disk('local')->put('media/aaron.png', file_get_contents(__DIR__.'/../../aaron.png'));
$job = new ProcessMedia('aaron.png');
$job->handle($manager);
$this->assertFileDoesNotExist(storage_path('app/media/') . 'aaron.png');
$this->assertFileDoesNotExist(storage_path('app/media/').'aaron.png');
// Tidy up files created by the job
Storage::disk('local')->delete('public/media/aaron.png');
@ -51,7 +51,7 @@ class ProcessMediaJobTest extends TestCase
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');
$this->assertFileDoesNotExist(storage_path('app/media/').'test-image.jpg');
// Tidy up files created by the job
Storage::disk('public')->delete('media/test-image.jpg');

View file

@ -27,8 +27,8 @@ class ProcessWebMentionJobTest extends TestCase
protected function tearDown(): void
{
$fs = new FileSystem;
if ($fs->exists(storage_path() . '/HTML/https')) {
$fs->deleteDirectory(storage_path() . '/HTML/https');
if ($fs->exists(storage_path().'/HTML/https')) {
$fs->deleteDirectory(storage_path().'/HTML/https');
}
parent::tearDown();
}
@ -64,7 +64,7 @@ class ProcessWebMentionJobTest extends TestCase
I liked <a class="u-like-of" href="/notes/1">a note</a>.
</div>
HTML;
$html = str_replace('href="', 'href="' . config('app.url'), $html);
$html = str_replace('href="', 'href="'.config('app.url'), $html);
$mock = new MockHandler([
new Response(200, [], $html),
]);
@ -117,7 +117,7 @@ class ProcessWebMentionJobTest extends TestCase
'source' => $source,
'type' => 'in-reply-to',
// phpcs:ignore Generic.Files.LineLength.TooLong
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"content": [{"html": "Updated reply", "value": "Updated reply"}], "in-reply-to": ["' . $note->uri . '"]}}], "rel-urls": []}',
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"content": [{"html": "Updated reply", "value": "Updated reply"}], "in-reply-to": ["'.$note->uri.'"]}}], "rel-urls": []}',
]);
}
@ -142,7 +142,7 @@ class ProcessWebMentionJobTest extends TestCase
$source = 'https://example.org/reply/1';
$webmention = new WebMention;
$webmention->source = $source;
$webmention->target = config('app.url') . '/notes/E';
$webmention->target = config('app.url').'/notes/E';
$webmention->type = 'in-reply-to';
$webmention->save();
@ -179,7 +179,7 @@ class ProcessWebMentionJobTest extends TestCase
$source = 'https://example.org/reply/1';
$webmention = new WebMention;
$webmention->source = $source;
$webmention->target = config('app.url') . '/notes/E';
$webmention->target = config('app.url').'/notes/E';
$webmention->type = 'like-of';
$webmention->save();
@ -207,7 +207,7 @@ class ProcessWebMentionJobTest extends TestCase
I liked <a class="u-like-of" href="/notes/1">a note</a>.
</div>
HTML;
$html = str_replace('href="', 'href="' . config('app.url'), $html);
$html = str_replace('href="', 'href="'.config('app.url'), $html);
$mock = new MockHandler([
new Response(200, [], $html),
]);
@ -248,7 +248,7 @@ class ProcessWebMentionJobTest extends TestCase
$source = 'https://example.org/reply/1';
$webmention = new WebMention;
$webmention->source = $source;
$webmention->target = config('app.url') . '/notes/E';
$webmention->target = config('app.url').'/notes/E';
$webmention->type = 'repost-of';
$webmention->save();

View file

@ -18,9 +18,9 @@ class SaveProfileImageJobTest extends TestCase
{
protected function tearDown(): void
{
if (file_exists(public_path() . '/assets/profile-images/example.org/image')) {
unlink(public_path() . '/assets/profile-images/example.org/image');
rmdir(public_path() . '/assets/profile-images/example.org');
if (file_exists(public_path().'/assets/profile-images/example.org/image')) {
unlink(public_path().'/assets/profile-images/example.org/image');
rmdir(public_path().'/assets/profile-images/example.org');
}
parent::tearDown();
}
@ -77,7 +77,7 @@ class SaveProfileImageJobTest extends TestCase
$job = new SaveProfileImage($mf);
$job->handle($authorship);
$this->assertFileExists(public_path() . '/assets/profile-images/example.org/image');
$this->assertFileExists(public_path().'/assets/profile-images/example.org/image');
}
#[Test]
@ -103,8 +103,8 @@ class SaveProfileImageJobTest extends TestCase
$job = new SaveProfileImage($mf);
$job->handle($authorship);
$this->assertFileEquals(
public_path() . '/assets/profile-images/default-image',
public_path() . '/assets/profile-images/example.org/image'
public_path().'/assets/profile-images/default-image',
public_path().'/assets/profile-images/example.org/image'
);
}
@ -133,7 +133,7 @@ class SaveProfileImageJobTest extends TestCase
$job = new SaveProfileImage($mf);
$job->handle($authorship);
$this->assertFileExists(public_path() . '/assets/profile-images/example.org/image');
$this->assertFileExists(public_path().'/assets/profile-images/example.org/image');
}
#[Test]
@ -164,6 +164,6 @@ class SaveProfileImageJobTest extends TestCase
$job = new SaveProfileImage($mf);
$job->handle($authorship);
$this->assertFileExists(public_path() . '/assets/profile-images/example.org/image');
$this->assertFileExists(public_path().'/assets/profile-images/example.org/image');
}
}

View file

@ -7,6 +7,7 @@ namespace Tests\Unit\Jobs;
use App\Jobs\SaveScreenshot;
use App\Models\Bookmark;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
@ -27,7 +28,7 @@ class SaveScreenshotJobTest extends TestCase
$guzzleMock = new MockHandler([
new Response(201, ['Content-Type' => 'application/json'], '{"data":{"id":"68d52633-e170-465e-b13e-746c97d01ffb","job_id":null,"status":"finished","credits":null,"code":null,"message":null,"percent":100,"operation":"capture-website","engine":"chrome","engine_version":"107","result":null,"created_at":"2023-01-07T21:05:48+00:00","started_at":null,"ended_at":null,"retry_of_task_id":null,"copy_of_task_id":null,"user_id":61485254,"priority":-10,"host_name":null,"storage":"ceph-fra","depends_on_task_ids":[],"links":{"self":"https:\/\/api.cloudconvert.com\/v2\/tasks\/68d52633-e170-465e-b13e-746c97d01ffb"}}}'),
new Response(201, ['Content-Type' => 'application/json'], '{"data":{"id":"27f33137-cc03-4468-aba4-1e1aa8c096fb","job_id":null,"status":"finished","credits":null,"code":null,"message":null,"percent":100,"operation":"export\/url","result":null,"created_at":"2023-01-07T21:10:02+00:00","started_at":null,"ended_at":null,"retry_of_task_id":null,"copy_of_task_id":null,"user_id":61485254,"priority":-10,"host_name":null,"storage":"ceph-fra","depends_on_task_ids":["68d52633-e170-465e-b13e-746c97d01ffb"],"links":{"self":"https:\/\/api.cloudconvert.com\/v2\/tasks\/27f33137-cc03-4468-aba4-1e1aa8c096fb"}}}'),
new Response(200, ['Content-Type' => 'image/png'], fopen(__DIR__ . '/../../theverge.com.png', 'rb')),
new Response(200, ['Content-Type' => 'image/png'], fopen(__DIR__.'/../../theverge.com.png', 'rb')),
]);
$guzzleHandler = HandlerStack::create($guzzleMock);
$guzzleClient = new Client(['handler' => $guzzleHandler]);
@ -45,7 +46,7 @@ class SaveScreenshotJobTest extends TestCase
}
// Retry connection exceptions
if ($exception instanceof \GuzzleHttp\Exception\ConnectException) {
if ($exception instanceof ConnectException) {
return true;
}
@ -82,7 +83,7 @@ class SaveScreenshotJobTest extends TestCase
$bookmark->refresh();
$this->assertEquals('68d52633-e170-465e-b13e-746c97d01ffb', $bookmark->screenshot);
Storage::disk('public')->assertExists('/assets/img/bookmarks/' . $bookmark->screenshot . '.png');
Storage::disk('public')->assertExists('/assets/img/bookmarks/'.$bookmark->screenshot.'.png');
}
#[Test]
@ -92,7 +93,7 @@ class SaveScreenshotJobTest extends TestCase
$guzzleMock = new MockHandler([
new Response(201, ['Content-Type' => 'application/json'], '{"id":1,"data":{"id":"68d52633-e170-465e-b13e-746c97d01ffb","job_id":null,"status":"waiting","credits":null,"code":null,"message":null,"percent":100,"operation":"capture-website","engine":"chrome","engine_version":"107","result":null,"created_at":"2023-01-07T21:05:48+00:00","started_at":null,"ended_at":null,"retry_of_task_id":null,"copy_of_task_id":null,"user_id":61485254,"priority":-10,"host_name":null,"storage":"ceph-fra","depends_on_task_ids":[],"links":{"self":"https:\/\/api.cloudconvert.com\/v2\/tasks\/68d52633-e170-465e-b13e-746c97d01ffb"}}}'),
new Response(201, ['Content-Type' => 'application/json'], '{"id":2,"data":{"id":"27f33137-cc03-4468-aba4-1e1aa8c096fb","job_id":null,"status":"waiting","credits":null,"code":null,"message":null,"percent":100,"operation":"export\/url","result":null,"created_at":"2023-01-07T21:10:02+00:00","started_at":null,"ended_at":null,"retry_of_task_id":null,"copy_of_task_id":null,"user_id":61485254,"priority":-10,"host_name":null,"storage":"ceph-fra","depends_on_task_ids":["68d52633-e170-465e-b13e-746c97d01ffb"],"links":{"self":"https:\/\/api.cloudconvert.com\/v2\/tasks\/27f33137-cc03-4468-aba4-1e1aa8c096fb"}}}'),
new Response(200, ['Content-Type' => 'image/png'], fopen(__DIR__ . '/../../theverge.com.png', 'rb')),
new Response(200, ['Content-Type' => 'image/png'], fopen(__DIR__.'/../../theverge.com.png', 'rb')),
]);
$guzzleHandler = HandlerStack::create($guzzleMock);
$guzzleClient = new Client(['handler' => $guzzleHandler]);
@ -115,7 +116,7 @@ class SaveScreenshotJobTest extends TestCase
}
// Retry connection exceptions
if ($exception instanceof \GuzzleHttp\Exception\ConnectException) {
if ($exception instanceof ConnectException) {
return true;
}
@ -152,7 +153,7 @@ class SaveScreenshotJobTest extends TestCase
$bookmark->refresh();
$this->assertEquals('68d52633-e170-465e-b13e-746c97d01ffb', $bookmark->screenshot);
Storage::disk('public')->assertExists('/assets/img/bookmarks/' . $bookmark->screenshot . '.png');
Storage::disk('public')->assertExists('/assets/img/bookmarks/'.$bookmark->screenshot.'.png');
// Also assert we made the correct number of requests
$this->assertCount(2, $container);
// However with retries there should be more than 4 responses for the 2 requests

View file

@ -29,7 +29,7 @@ class SendWebMentionJobTest extends TestCase
{
$url = 'https://example.org/webmention';
$mock = new MockHandler([
new Response(200, ['Link' => '<' . $url . '>; rel="webmention"']),
new Response(200, ['Link' => '<'.$url.'>; rel="webmention"']),
]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);

View file

@ -25,7 +25,7 @@ class SyndicateNoteToBlueskyJobTest extends TestCase
$faker = Factory::create();
$randomNumber = $faker->randomNumber();
$mock = new MockHandler([
new Response(201, ['Location' => 'https://bsky.app/profile/jonnybarnes.uk/' . $randomNumber]),
new Response(201, ['Location' => 'https://bsky.app/profile/jonnybarnes.uk/'.$randomNumber]),
]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
@ -35,7 +35,7 @@ class SyndicateNoteToBlueskyJobTest extends TestCase
$job->handle($client);
$this->assertDatabaseHas('notes', [
'bluesky_url' => 'https://bsky.app/profile/jonnybarnes.uk/' . $randomNumber,
'bluesky_url' => 'https://bsky.app/profile/jonnybarnes.uk/'.$randomNumber,
]);
}
@ -49,7 +49,7 @@ class SyndicateNoteToBlueskyJobTest extends TestCase
$container = [];
$history = Middleware::history($container);
$mock = new MockHandler([
new Response(201, ['Location' => 'https://bsky.app/profile/jonnybarnes.uk/' . $randomNumber]),
new Response(201, ['Location' => 'https://bsky.app/profile/jonnybarnes.uk/'.$randomNumber]),
]);
$handler = HandlerStack::create($mock);
$handler->push($history);
@ -60,7 +60,7 @@ class SyndicateNoteToBlueskyJobTest extends TestCase
$job->handle($client);
$this->assertDatabaseHas('notes', [
'bluesky_url' => 'https://bsky.app/profile/jonnybarnes.uk/' . $randomNumber,
'bluesky_url' => 'https://bsky.app/profile/jonnybarnes.uk/'.$randomNumber,
]);
$expectedRequestContent = '{"type":["h-entry"],"properties":{"content":["This is a **test**"]}}';

View file

@ -25,7 +25,7 @@ class SyndicateNoteToMastodonJobTest extends TestCase
$faker = Factory::create();
$randomNumber = $faker->randomNumber();
$mock = new MockHandler([
new Response(201, ['Location' => 'https://mastodon.example/@jonny/' . $randomNumber]),
new Response(201, ['Location' => 'https://mastodon.example/@jonny/'.$randomNumber]),
]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
@ -35,7 +35,7 @@ class SyndicateNoteToMastodonJobTest extends TestCase
$job->handle($client);
$this->assertDatabaseHas('notes', [
'mastodon_url' => 'https://mastodon.example/@jonny/' . $randomNumber,
'mastodon_url' => 'https://mastodon.example/@jonny/'.$randomNumber,
]);
}
@ -49,7 +49,7 @@ class SyndicateNoteToMastodonJobTest extends TestCase
$container = [];
$history = Middleware::history($container);
$mock = new MockHandler([
new Response(201, ['Location' => 'https://mastodon.example/@jonny/' . $randomNumber]),
new Response(201, ['Location' => 'https://mastodon.example/@jonny/'.$randomNumber]),
]);
$handler = HandlerStack::create($mock);
$handler->push($history);
@ -60,7 +60,7 @@ class SyndicateNoteToMastodonJobTest extends TestCase
$job->handle($client);
$this->assertDatabaseHas('notes', [
'mastodon_url' => 'https://mastodon.example/@jonny/' . $randomNumber,
'mastodon_url' => 'https://mastodon.example/@jonny/'.$randomNumber,
]);
$expectedRequestContent = '{"type":["h-entry"],"properties":{"content":["This is a **test**"]}}';