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
commit 1dfa17abca
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
51 changed files with 1404 additions and 2403 deletions

View file

@ -12,7 +12,7 @@ class ExampleTest extends DuskTestCase
*
* @return void
*/
public function testBasicExample()
public function test_basic_example()
{
$this->browse(function (Browser $browser) {
$browser->visit('/')

View file

@ -6,13 +6,14 @@ namespace Tests\Feature\Admin;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class AdminHomeControllerTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function adminHomepageLoads(): void
{
$user = User::factory()->make();

View file

@ -5,25 +5,26 @@ declare(strict_types=1);
namespace Tests\Feature\Admin;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class AdminTest extends TestCase
{
/** @test */
#[Test]
public function adminPageRedirectsUnauthorisedUsersToLoginPage(): void
{
$response = $this->get('/admin');
$response->assertRedirect('/login');
}
/** @test */
#[Test]
public function loginPageLoads(): void
{
$response = $this->get('/login');
$response->assertViewIs('login');
}
/** @test */
#[Test]
public function loginAttemptWithBadCredentialsFails(): void
{
$response = $this->post('/login', [
@ -33,7 +34,7 @@ class AdminTest extends TestCase
$response->assertRedirect('/login');
}
/** @test */
#[Test]
public function loginSucceeds(): void
{
User::factory([
@ -49,7 +50,7 @@ class AdminTest extends TestCase
$response->assertRedirect('/admin');
}
/** @test */
#[Test]
public function whenLoggedInRedirectsToAdminPage(): void
{
$user = User::factory()->create();
@ -57,14 +58,14 @@ class AdminTest extends TestCase
$response->assertRedirect('/');
}
/** @test */
#[Test]
public function loggedOutUsersSimplyRedirected(): void
{
$response = $this->get('/logout');
$response->assertRedirect('/');
}
/** @test */
#[Test]
public function loggedInUsersShownLogoutForm(): void
{
$user = User::factory()->create();
@ -72,7 +73,7 @@ class AdminTest extends TestCase
$response->assertViewIs('logout');
}
/** @test */
#[Test]
public function loggedInUsersCanLogout(): void
{
$user = User::factory()->create();

View file

@ -9,13 +9,14 @@ use App\Models\User;
use Faker\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ArticlesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function adminArticlesPageLoads(): void
{
$user = User::factory()->make();
@ -25,7 +26,7 @@ class ArticlesTest extends TestCase
$response->assertSeeText('Select article to edit:');
}
/** @test */
#[Test]
public function adminCanLoadFormToCreateArticle(): void
{
$user = User::factory()->make();
@ -35,7 +36,7 @@ class ArticlesTest extends TestCase
$response->assertSeeText('Title (URL)');
}
/** @test */
#[Test]
public function admiNCanCreateNewArticle(): void
{
$user = User::factory()->make();
@ -48,7 +49,7 @@ class ArticlesTest extends TestCase
$this->assertDatabaseHas('articles', ['title' => 'Test Title']);
}
/** @test */
#[Test]
public function adminCanCreateNewArticleWithFile(): void
{
$user = User::factory()->make();
@ -73,7 +74,7 @@ class ArticlesTest extends TestCase
]);
}
/** @test */
#[Test]
public function articleCanLoadFormToEditArticle(): void
{
$user = User::factory()->make();
@ -86,7 +87,7 @@ class ArticlesTest extends TestCase
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
}
/** @test */
#[Test]
public function adminCanEditArticle(): void
{
$user = User::factory()->make();
@ -104,7 +105,7 @@ class ArticlesTest extends TestCase
]);
}
/** @test */
#[Test]
public function adminCanDeleteArticle(): void
{
$user = User::factory()->make();

View file

@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
use App\Models\Bio;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class BioTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function adminBiosPageLoads(): void
{
$user = User::factory()->make();
@ -23,7 +24,7 @@ class BioTest extends TestCase
$response->assertSeeText('Edit bio');
}
/** @test */
#[Test]
public function adminCanCreateBio(): void
{
$user = User::factory()->make();
@ -36,7 +37,7 @@ class BioTest extends TestCase
$this->assertDatabaseHas('bios', ['content' => 'Bio content']);
}
/** @test */
#[Test]
public function adminCanLoadExistingBio(): void
{
$user = User::factory()->make();
@ -49,7 +50,7 @@ class BioTest extends TestCase
$response->assertSeeText('This is <em>my</em> bio. It uses <strong>HTML</strong>.');
}
/** @test */
#[Test]
public function adminCanEditBio(): void
{
$user = User::factory()->make();

View file

@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
use App\Models\MicropubClient;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ClientsTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function clientsPageLoads(): void
{
$user = User::factory()->make();
@ -23,7 +24,7 @@ class ClientsTest extends TestCase
$response->assertSeeText('Clients');
}
/** @test */
#[Test]
public function adminCanLoadFormToCreateClient(): void
{
$user = User::factory()->make();
@ -33,7 +34,7 @@ class ClientsTest extends TestCase
$response->assertSeeText('New Client');
}
/** @test */
#[Test]
public function adminCanCreateNewClient(): void
{
$user = User::factory()->make();
@ -49,7 +50,7 @@ class ClientsTest extends TestCase
]);
}
/** @test */
#[Test]
public function adminCanLoadEditFormForClient(): void
{
$user = User::factory()->make();
@ -62,7 +63,7 @@ class ClientsTest extends TestCase
$response->assertSee('https://jbl5.dev/notes/new');
}
/** @test */
#[Test]
public function adminCanEditClient(): void
{
$user = User::factory()->make();
@ -80,7 +81,7 @@ class ClientsTest extends TestCase
]);
}
/** @test */
#[Test]
public function adminCanDeleteClient(): void
{
$user = User::factory()->make();

View file

@ -12,6 +12,7 @@ use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ContactsTest extends TestCase
@ -27,7 +28,7 @@ class ContactsTest extends TestCase
parent::tearDown();
}
/** @test */
#[Test]
public function contactIndexPageLoads(): void
{
$user = User::factory()->make();
@ -36,7 +37,7 @@ class ContactsTest extends TestCase
$response->assertViewIs('admin.contacts.index');
}
/** @test */
#[Test]
public function contactCreatePageLoads(): void
{
$user = User::factory()->make();
@ -45,7 +46,7 @@ class ContactsTest extends TestCase
$response->assertViewIs('admin.contacts.create');
}
/** @test */
#[Test]
public function adminCanCreateNewContact(): void
{
$user = User::factory()->make();
@ -62,7 +63,7 @@ class ContactsTest extends TestCase
]);
}
/** @test */
#[Test]
public function adminCanSeeFormToEditContact(): void
{
$user = User::factory()->make();
@ -72,7 +73,7 @@ class ContactsTest extends TestCase
$response->assertViewIs('admin.contacts.edit');
}
/** @test */
#[Test]
public function adminCanUpdateContact(): void
{
$user = User::factory()->make();
@ -91,7 +92,7 @@ class ContactsTest extends TestCase
]);
}
/** @test */
#[Test]
public function adminCanEditContactAndUploadAvatar(): void
{
copy(__DIR__ . '/../../aaron.png', sys_get_temp_dir() . '/tantek.png');
@ -114,7 +115,7 @@ class ContactsTest extends TestCase
);
}
/** @test */
#[Test]
public function adminCanDeleteContact(): void
{
$user = User::factory()->make();
@ -132,7 +133,7 @@ class ContactsTest extends TestCase
]);
}
/** @test */
#[Test]
public function adminCanTriggerRetrievalOfRemoteAvatar(): void
{
$html = <<<'HTML'
@ -161,7 +162,7 @@ class ContactsTest extends TestCase
);
}
/** @test */
#[Test]
public function gettingRemoteAvatarFailsGracefullyWithRemoteNotFound(): void
{
$mock = new MockHandler([
@ -178,7 +179,7 @@ class ContactsTest extends TestCase
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
}
/** @test */
#[Test]
public function gettingRemoteAvatarFailsGracefullyWithRemoteError(): void
{
$html = <<<'HTML'
@ -201,7 +202,7 @@ class ContactsTest extends TestCase
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
}
/** @test */
#[Test]
public function gettingRemoteAvatarFailsGracefullyForContactWithNoHompage(): void
{
$contact = Contact::create([

View file

@ -9,13 +9,14 @@ use App\Models\Like;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class LikesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function likesPageLoads(): void
{
$user = User::factory()->make();
@ -25,7 +26,7 @@ class LikesTest extends TestCase
$response->assertSeeText('Likes');
}
/** @test */
#[Test]
public function likeCreateFormLoads(): void
{
$user = User::factory()->make();
@ -35,7 +36,7 @@ class LikesTest extends TestCase
$response->assertSeeText('New Like');
}
/** @test */
#[Test]
public function adminCanCreateLike(): void
{
Queue::fake();
@ -51,7 +52,7 @@ class LikesTest extends TestCase
Queue::assertPushed(ProcessLike::class);
}
/** @test */
#[Test]
public function likeEditFormLoads(): void
{
$user = User::factory()->make();
@ -62,7 +63,7 @@ class LikesTest extends TestCase
$response->assertSee('Edit Like');
}
/** @test */
#[Test]
public function adminCanEditLike(): void
{
Queue::fake();
@ -80,7 +81,7 @@ class LikesTest extends TestCase
Queue::assertPushed(ProcessLike::class);
}
/** @test */
#[Test]
public function adminCanDeleteLike(): void
{
$like = Like::factory()->create();

View file

@ -9,13 +9,14 @@ use App\Models\Note;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class NotesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function notesPageLoads(): void
{
$user = User::factory()->make();
@ -24,7 +25,7 @@ class NotesTest extends TestCase
$response->assertViewIs('admin.notes.index');
}
/** @test */
#[Test]
public function noteCreatePageLoads(): void
{
$user = User::factory()->make();
@ -33,7 +34,7 @@ class NotesTest extends TestCase
$response->assertViewIs('admin.notes.create');
}
/** @test */
#[Test]
public function adminCanCreateNewNote(): void
{
$user = User::factory()->make();
@ -47,7 +48,7 @@ class NotesTest extends TestCase
]);
}
/** @test */
#[Test]
public function noteEditFormLoads(): void
{
$user = User::factory()->make();
@ -57,7 +58,7 @@ class NotesTest extends TestCase
$response->assertViewIs('admin.notes.edit');
}
/** @test */
#[Test]
public function adminCanEditNote(): void
{
Queue::fake();
@ -76,7 +77,7 @@ class NotesTest extends TestCase
Queue::assertPushed(SendWebMentions::class);
}
/** @test */
#[Test]
public function adminCanDeleteNote(): void
{
$user = User::factory()->make();

View file

@ -7,13 +7,14 @@ namespace Tests\Feature\Admin;
use App\Models\Place;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class PlacesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function placesPageLoads(): void
{
$user = User::factory()->make();
@ -22,7 +23,7 @@ class PlacesTest extends TestCase
$response->assertViewIs('admin.places.index');
}
/** @test */
#[Test]
public function createPlacePageLoads(): void
{
$user = User::factory()->make();
@ -31,7 +32,7 @@ class PlacesTest extends TestCase
$response->assertViewIs('admin.places.create');
}
/** @test */
#[Test]
public function adminCanCreateNewPlace(): void
{
$user = User::factory()->make();
@ -48,7 +49,7 @@ class PlacesTest extends TestCase
]);
}
/** @test */
#[Test]
public function editPlacePageLoads(): void
{
$user = User::factory()->make();
@ -58,7 +59,7 @@ class PlacesTest extends TestCase
$response->assertViewIs('admin.places.edit');
}
/** @test */
#[Test]
public function adminCanUpdatePlace(): void
{
$user = User::factory()->make();

View file

@ -7,20 +7,21 @@ namespace Tests\Feature;
use App\Models\Article;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Jonnybarnes\IndieWeb\Numbers;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ArticlesTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function articlesPageLoads(): void
{
$response = $this->get('/blog');
$response->assertViewIs('articles.index');
}
/** @test */
#[Test]
public function singleArticlePageLoads()
{
$article = Article::factory()->create();
@ -28,7 +29,7 @@ class ArticlesTest extends TestCase
$response->assertViewIs('articles.show');
}
/** @test */
#[Test]
public function wrongDateInUrlRedirectsToCorrectDate()
{
$article = Article::factory()->create();
@ -36,7 +37,7 @@ class ArticlesTest extends TestCase
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/' . $article->titleurl);
}
/** @test */
#[Test]
public function oldUrlsWithIdAreRedirected()
{
$article = Article::factory()->create();
@ -45,21 +46,21 @@ class ArticlesTest extends TestCase
$response->assertRedirect($article->link);
}
/** @test */
#[Test]
public function unknownSlugGetsNotFoundResponse()
{
$response = $this->get('/blog/' . date('Y') . '/' . date('m') . '/unknown-slug');
$response->assertNotFound();
}
/** @test */
#[Test]
public function unknownArticleIdGetsNotFoundResponse()
{
$response = $this->get('/blog/s/22');
$response->assertNotFound();
}
/** @test */
#[Test]
public function someUrlsDoNotParseCorrectly(): void
{
$response = $this->get('/blog/feed.js');

View file

@ -8,6 +8,7 @@ use App\Jobs\ProcessBookmark;
use App\Models\Bookmark;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
use Tests\TestToken;
@ -15,14 +16,14 @@ class BookmarksTest extends TestCase
{
use RefreshDatabase, TestToken;
/** @test */
#[Test]
public function bookmarksPageLoadsWithoutError(): void
{
$response = $this->get('/bookmarks');
$response->assertViewIs('bookmarks.index');
}
/** @test */
#[Test]
public function singleBookmarkPageLoadsWithoutError(): void
{
$bookmark = Bookmark::factory()->create();
@ -30,7 +31,7 @@ class BookmarksTest extends TestCase
$response->assertViewIs('bookmarks.show');
}
/** @test */
#[Test]
public function whenBookmarkIsAddedUsingHttpSyntaxCheckJobToTakeScreenshotIsInvoked(): void
{
Queue::fake();
@ -48,7 +49,7 @@ class BookmarksTest extends TestCase
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
}
/** @test */
#[Test]
public function whenBookmarkIsAddedUsingJsonSyntaxCheckJobToTakeScreenshotIsInvoked(): void
{
Queue::fake();
@ -68,7 +69,7 @@ class BookmarksTest extends TestCase
$this->assertDatabaseHas('bookmarks', ['url' => 'https://example.org/blog-post']);
}
/** @test */
#[Test]
public function whenTheBookmarkIsCreatedCheckNecessaryTagsAreAlsoCreated(): void
{
Queue::fake();

View file

@ -6,6 +6,7 @@ namespace Tests\Feature;
use App\Models\Contact;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class ContactsTest extends TestCase
@ -14,9 +15,8 @@ class ContactsTest extends TestCase
/**
* Check the `/contacts` page gives a good response.
*
* @test
*/
#[Test]
public function contactsPageLoadsWithoutError(): void
{
$response = $this->get('/contacts');
@ -25,9 +25,8 @@ class ContactsTest extends TestCase
/**
* Test an individual contact page with default profile image.
*
* @test
*/
#[Test]
public function contactPageShouldFallbackToDefaultProfilePic(): void
{
Contact::factory()->create([
@ -39,9 +38,8 @@ class ContactsTest extends TestCase
/**
* Test an individual contact page with a specific profile image.
*
* @test
*/
#[Test]
public function contactPageShouldUseSpecificProfilePicIfPresent(): void
{
Contact::factory()->create([
@ -52,7 +50,7 @@ class ContactsTest extends TestCase
$response->assertViewHas('image', '/assets/profile-images/aaronparecki.com/image');
}
/** @test */
#[Test]
public function unknownContactReturnsNotFoundResponse(): void
{
$response = $this->get('/contacts/unknown');

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
use Tests\TestToken;
@ -11,7 +12,7 @@ class CorsHeadersTest extends TestCase
{
use TestToken;
/** @test */
#[Test]
public function checkCorsHeadersOnMediaEndpoint(): void
{
$response = $this->call(
@ -25,7 +26,7 @@ class CorsHeadersTest extends TestCase
$response->assertHeader('Access-Control-Allow-Origin', '*');
}
/** @test */
#[Test]
public function checkForNoCorsHeaderOnNonMediaEndpointLinks(): void
{
$response = $this->get('/blog');

View file

@ -8,6 +8,7 @@ use App\Models\Article;
use App\Models\Note;
use App\Models\Place;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class FeedsTest extends TestCase
@ -16,9 +17,8 @@ class FeedsTest extends TestCase
/**
* Test the blog RSS feed.
*
* @test
*/
#[Test]
public function blogRssFeedIsPresent(): void
{
Article::factory()->count(3)->create();
@ -29,9 +29,8 @@ class FeedsTest extends TestCase
/**
* Test the notes RSS feed.
*
* @test
*/
#[Test]
public function notesRssFeedIsPresent(): void
{
Note::factory()->count(3)->create();
@ -42,9 +41,8 @@ class FeedsTest extends TestCase
/**
* Test the blog RSS feed.
*
* @test
*/
#[Test]
public function blogAtomFeedIsPresent(): void
{
Article::factory()->count(3)->create();
@ -53,7 +51,7 @@ class FeedsTest extends TestCase
$response->assertOk();
}
/** @test */
#[Test]
public function blogJf2FeedIsPresent(): void
{
Article::factory()->count(3)->create();
@ -77,9 +75,8 @@ class FeedsTest extends TestCase
/**
* Test the notes RSS feed.
*
* @test
*/
#[Test]
public function notesAtomFeedIsPresent(): void
{
Note::factory()->count(3)->create();
@ -90,9 +87,8 @@ class FeedsTest extends TestCase
/**
* Test the blog JSON feed.
*
* @test
*/
#[Test]
public function blogJsonFeedIsPresent(): void
{
Article::factory()->count(3)->create();
@ -103,9 +99,8 @@ class FeedsTest extends TestCase
/**
* Test the notes JSON feed.
*
* @test
*/
#[Test]
public function notesJsonFeedIsPresent(): void
{
Note::factory()->count(3)->create();
@ -114,7 +109,7 @@ class FeedsTest extends TestCase
$response->assertOk();
}
/** @test */
#[Test]
public function notesJf2FeedIsPresent(): void
{
Note::factory()->count(3)->create();
@ -139,9 +134,8 @@ class FeedsTest extends TestCase
/**
* Each JSON feed item must have one of `content_text` or `content_html`,
* and whichever one they have can’t be `null`.
*
* @test
*/
#[Test]
public function jsonFeedsHaveRequiredAttributes(): void
{
Note::factory()->count(3)->create();
@ -161,7 +155,7 @@ class FeedsTest extends TestCase
}
}
/** @test */
#[Test]
public function jsonNoteFeedLoadsPlaceDataWithoutLazyLoading(): void
{
$place = Place::factory()->create();

View file

@ -7,13 +7,14 @@ use App\Models\Bookmark;
use App\Models\Like;
use App\Models\Note;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class FrontPageTest extends TestCase
{
use RefreshDatabase;
/** @test */
#[Test]
public function frontPageLoadsAllContent(): void
{
Note::factory()->create(['note' => 'Note 1']);

View file

@ -3,15 +3,15 @@
namespace Tests\Feature;
use App\Models\User;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class HorizonTest extends TestCase
{
/**
* Horizon has its own test suite, here we just test it has been installed successfully.
*
* @test
*/
#[Test]
public function horizonIsInstalled(): void
{
$user = User::factory()->create([

View file

@ -31,8 +31,8 @@ class IndieAuthTest extends TestCase
'authorization_endpoint' => route('indieauth.start'),
'token_endpoint' => route('indieauth.token'),
'code_challenge_methods_supported' => ['S256'],
//'introspection_endpoint' => 'introspection_endpoint',
//'introspection_endpoint_auth_methods_supported' => ['none'],
// 'introspection_endpoint' => 'introspection_endpoint',
// 'introspection_endpoint_auth_methods_supported' => ['none'],
]);
}

View file

@ -14,6 +14,7 @@ use GuzzleHttp\Psr7\Response;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Jonnybarnes\WebmentionsParser\Authorship;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
use Tests\TestToken;
@ -22,14 +23,14 @@ class LikesTest extends TestCase
use RefreshDatabase;
use TestToken;
/** @test */
#[Test]
public function likesPageHasCorrectView(): void
{
$response = $this->get('/likes');
$response->assertViewIs('likes.index');
}
/** @test */
#[Test]
public function singleLikePageHasCorrectView(): void
{
$like = Like::factory()->create();
@ -37,7 +38,7 @@ class LikesTest extends TestCase
$response->assertViewIs('likes.show');
}
/** @test */
#[Test]
public function checkLikeCreatedFromMicropubApiRequests(): void
{
Queue::fake();
@ -57,7 +58,7 @@ class LikesTest extends TestCase
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
}
/** @test */
#[Test]
public function checkLikeCreatedFromMicropubWebRequests(): void
{
Queue::fake();
@ -75,7 +76,7 @@ class LikesTest extends TestCase
$this->assertDatabaseHas('likes', ['url' => 'https://example.org/blog-post']);
}
/** @test */
#[Test]
public function likeWithSimpleAuthor(): void
{
$like = new Like;
@ -114,7 +115,7 @@ class LikesTest extends TestCase
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
}
/** @test */
#[Test]
public function likeWithHCard(): void
{
$like = new Like;
@ -157,7 +158,7 @@ class LikesTest extends TestCase
$this->assertEquals('Fred Bloggs', Like::find($id)->author_name);
}
/** @test */
#[Test]
public function likeWithoutMicroformats(): void
{
$like = new Like;
@ -193,7 +194,7 @@ class LikesTest extends TestCase
$this->assertNull(Like::find($id)->author_name);
}
/** @test */
#[Test]
public function likeThatIsATweet(): void
{
$like = new Like;
@ -219,10 +220,9 @@ class LikesTest extends TestCase
'author_url' => 'https://twitter.com/jonnybarnes',
'html' => '<div>HTML of the tweet embed</div>',
];
$codebirdMock = $this->getMockBuilder(Codebird::class)
->addMethods(['statuses_oembed'])
->getMock();
$codebirdMock->method('statuses_oembed')
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
$codebirdMock->method('__call')
->with('statuses_oembed', $this->anything())
->willReturn($info);
$this->app->instance(Codebird::class, $codebirdMock);
@ -233,7 +233,7 @@ class LikesTest extends TestCase
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
}
/** @test */
#[Test]
public function noErrorForFailureToPosseWithBridgy(): void
{
$like = new Like;
@ -257,10 +257,9 @@ class LikesTest extends TestCase
'author_url' => 'https://twitter.com/jonnybarnes',
'html' => '<div>HTML of the tweet embed</div>',
];
$codebirdMock = $this->getMockBuilder(Codebird::class)
->addMethods(['statuses_oembed'])
->getMock();
$codebirdMock->method('statuses_oembed')
$codebirdMock = $this->createPartialMock(Codebird::class, ['__call']);
$codebirdMock->method('__call')
->with('statuses_oembed', $this->anything())
->willReturn($info);
$this->app->instance(Codebird::class, $codebirdMock);
@ -271,7 +270,7 @@ class LikesTest extends TestCase
$this->assertEquals('Jonny Barnes', Like::find($id)->author_name);
}
/** @test */
#[Test]
public function unknownLikeGivesNotFoundResponse(): void
{
$response = $this->get('/likes/202');

View file

@ -15,6 +15,7 @@ use Carbon\Carbon;
use Faker\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
use Tests\TestToken;
@ -23,7 +24,7 @@ class MicropubControllerTest extends TestCase
use RefreshDatabase;
use TestToken;
/** @test */
#[Test]
public function micropubGetRequestWithoutTokenReturnsErrorResponse(): void
{
$response = $this->get('/api/post');
@ -31,7 +32,7 @@ class MicropubControllerTest extends TestCase
$response->assertJsonFragment(['error_description' => 'No access token was provided in the request']);
}
/** @test */
#[Test]
public function micropubGetRequestWithoutValidTokenReturnsErrorResponse(): void
{
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer abc123']);
@ -42,9 +43,8 @@ class MicropubControllerTest extends TestCase
/**
* Test a GET request for the micropub endpoint with a valid token gives a
* 200 response. Check token information is also returned in the response.
*
* @test
*/
#[Test]
public function micropubGetRequestWithValidTokenReturnsOkResponse(): void
{
$response = $this->get('/api/post', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
@ -52,14 +52,14 @@ class MicropubControllerTest extends TestCase
$response->assertJsonFragment(['response' => 'token']);
}
/** @test */
#[Test]
public function micropubClientsCanRequestSyndicationTargetsCanBeEmpty(): void
{
$response = $this->get('/api/post?q=syndicate-to', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
$response->assertJsonFragment(['syndicate-to' => []]);
}
/** @test */
#[Test]
public function micropubClientsCanRequestSyndicationTargetsPopulatesFromModel(): void
{
$syndicationTarget = SyndicationTarget::factory()->create();
@ -67,7 +67,7 @@ class MicropubControllerTest extends TestCase
$response->assertJsonFragment(['uid' => $syndicationTarget->uid]);
}
/** @test */
#[Test]
public function micropubClientsCanRequestKnownNearbyPlaces(): void
{
Place::factory()->create([
@ -80,8 +80,6 @@ class MicropubControllerTest extends TestCase
}
/**
* @test
*
* @todo Add uncertainty parameter
*
public function micropubClientsCanRequestKnownNearbyPlacesWithUncertaintyParameter(): void
@ -89,22 +87,21 @@ class MicropubControllerTest extends TestCase
$response = $this->get('/api/post?q=geo:53.5,-2.38', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
$response->assertJson(['places' => [['slug' => 'the-bridgewater-pub']]]);
}*/
/** @test */
#[Test]
public function returnEmptyResultWhenMicropubClientRequestsKnownNearbyPlaces(): void
{
$response = $this->get('/api/post?q=geo:1.23,4.56', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
$response->assertJson(['places' => []]);
}
/** @test */
#[Test]
public function micropubClientCanRequestEndpointConfig(): void
{
$response = $this->get('/api/post?q=config', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
$response->assertJsonFragment(['media-endpoint' => route('media-endpoint')]);
}
/** @test */
#[Test]
public function micropubClientCanCreateNewNote(): void
{
$faker = Factory::create();
@ -123,7 +120,7 @@ class MicropubControllerTest extends TestCase
$this->assertDatabaseHas('notes', ['note' => $note]);
}
/** @test */
#[Test]
public function micropubClientCanRequestTheNewNoteIsSyndicatedToMastodonAndBluesky(): void
{
Queue::fake();
@ -157,7 +154,7 @@ class MicropubControllerTest extends TestCase
Queue::assertPushed(SyndicateNoteToBluesky::class);
}
/** @test */
#[Test]
public function micropubClientsCanCreateNewPlaces(): void
{
$response = $this->post(
@ -173,7 +170,7 @@ class MicropubControllerTest extends TestCase
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
}
/** @test */
#[Test]
public function micropubClientsCanCreateNewPlacesWithOldLocationSyntax(): void
{
$response = $this->post(
@ -190,7 +187,7 @@ class MicropubControllerTest extends TestCase
$this->assertDatabaseHas('places', ['slug' => 'the-barton-arms']);
}
/** @test */
#[Test]
public function micropubClientWebRequestWithInvalidTokenReturnsErrorResponse(): void
{
$response = $this->post(
@ -205,7 +202,7 @@ class MicropubControllerTest extends TestCase
$response->assertJson(['error' => 'invalid_token']);
}
/** @test */
#[Test]
public function micropubClientWebRequestWithTokenWithoutAnyScopesReturnsErrorResponse(): void
{
$response = $this->post(
@ -220,7 +217,7 @@ class MicropubControllerTest extends TestCase
$response->assertJson(['error_description' => 'The provided token has no scopes']);
}
/** @test */
#[Test]
public function micropubClientWebRequestWithTokenWithoutCreateScopesReturnsErrorResponse(): void
{
$response = $this->post(
@ -238,9 +235,8 @@ class MicropubControllerTest extends TestCase
/**
* Test a valid micropub requests using JSON syntax creates a new note.
*
* @test
*/
#[Test]
public function micropubClientApiRequestCreatesNewNote(): void
{
Queue::fake();
@ -286,9 +282,8 @@ class MicropubControllerTest extends TestCase
/**
* Test a valid micropub requests using JSON syntax creates a new note with
* existing self-created place.
*
* @test
*/
#[Test]
public function micropubClientApiRequestCreatesNewNoteWithExistingPlaceInLocationData(): void
{
$place = new Place;
@ -317,9 +312,8 @@ class MicropubControllerTest extends TestCase
/**
* Test a valid micropub requests using JSON syntax creates a new note with
* a new place defined in the location block.
*
* @test
*/
#[Test]
public function micropubClientApiRequestCreatesNewNoteWithNewPlaceInLocationData(): void
{
$faker = Factory::create();
@ -353,9 +347,8 @@ class MicropubControllerTest extends TestCase
/**
* Test a valid micropub requests using JSON syntax creates a new note without
* a new place defined in the location block if there is missing data.
*
* @test
*/
#[Test]
public function micropubClientApiRequestCreatesNewNoteWithoutNewPlaceInLocationData(): void
{
$faker = Factory::create();
@ -387,9 +380,8 @@ class MicropubControllerTest extends TestCase
/**
* Test a micropub requests using JSON syntax without a token returns an
* error. Also check the message.
*
* @test
*/
#[Test]
public function micropubClientApiRequestWithoutTokenReturnsError(): void
{
$faker = Factory::create();
@ -414,9 +406,8 @@ class MicropubControllerTest extends TestCase
/**
* Test a micropub requests using JSON syntax without a valid token returns
* an error. Also check the message.
*
* @test
*/
#[Test]
public function micropubClientApiRequestWithTokenWithInsufficientPermissionReturnsError(): void
{
$faker = Factory::create();
@ -439,7 +430,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(401);
}
/** @test */
#[Test]
public function micropubClientApiRequestForUnsupportedPostTypeReturnsError(): void
{
$response = $this->postJson(
@ -460,7 +451,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(500);
}
/** @test */
#[Test]
public function micropubClientApiRequestCreatesNewPlace(): void
{
$faker = Factory::create();
@ -480,7 +471,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(201);
}
/** @test */
#[Test]
public function micropubClientApiRequestCreatesNewPlaceWithUncertaintyParameter(): void
{
$faker = Factory::create();
@ -500,7 +491,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(201);
}
/** @test */
#[Test]
public function micropubClientApiRequestUpdatesExistingNote(): void
{
$note = Note::factory()->create();
@ -520,7 +511,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(200);
}
/** @test */
#[Test]
public function micropubClientApiRequestUpdatesNoteSyndicationLinks(): void
{
$note = Note::factory()->create();
@ -547,7 +538,7 @@ class MicropubControllerTest extends TestCase
]);
}
/** @test */
#[Test]
public function micropubClientApiRequestAddsImageToNote(): void
{
$note = Note::factory()->create();
@ -570,7 +561,7 @@ class MicropubControllerTest extends TestCase
]);
}
/** @test */
#[Test]
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonNoteModel(): void
{
$response = $this->postJson(
@ -589,7 +580,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(500);
}
/** @test */
#[Test]
public function micropubClientApiRequestReturnsErrorTryingToUpdateNonExistingNote(): void
{
$response = $this->postJson(
@ -608,7 +599,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(404);
}
/** @test */
#[Test]
public function micropubClientApiRequestReturnsErrorWhenTryingToUpdateUnsupportedProperty(): void
{
$note = Note::factory()->create();
@ -628,7 +619,7 @@ class MicropubControllerTest extends TestCase
->assertStatus(500);
}
/** @test */
#[Test]
public function micropubClientApiRequestWithTokenWithInsufficientScopeReturnsError(): void
{
$response = $this->postJson(
@ -647,7 +638,7 @@ class MicropubControllerTest extends TestCase
->assertJson(['error' => 'insufficient_scope']);
}
/** @test */
#[Test]
public function micropubClientApiRequestCanReplaceNoteSyndicationTargets(): void
{
$note = Note::factory()->create();
@ -674,7 +665,7 @@ class MicropubControllerTest extends TestCase
]);
}
/** @test */
#[Test]
public function micropubClientWebRequestCanEncodeTokenWithinTheForm(): void
{
$faker = Factory::create();
@ -692,7 +683,7 @@ class MicropubControllerTest extends TestCase
$this->assertDatabaseHas('notes', ['note' => $note]);
}
/** @test */
#[Test]
public function micropubClientApiRequestCreatesArticlesWhenItIncludesTheNameProperty(): void
{
$faker = Factory::create();

Some files were not shown because too many files have changed in this diff Show more