Finish re-working tests to run on test database

This commit is contained in:
Jonny Barnes 2021-08-31 12:28:00 +01:00
parent 09fc211623
commit 1abca77bdc
50 changed files with 535 additions and 265 deletions

View file

@ -25,8 +25,8 @@ class ActivityStreamTest extends TestCase
/** @test */
public function requestForNoteIncludesActivityStreamData(): void
{
$note = Note::find(11);
$response = $this->get('/notes/B', ['Accept' => 'application/activity+json']);
$note = Note::factory()->create();
$response = $this->get($note->longurl, ['Accept' => 'application/activity+json']);
$response->assertHeader('Content-Type', 'application/activity+json');
$response->assertJson([
'@context' => 'https://www.w3.org/ns/activitystreams',

View file

@ -4,15 +4,16 @@ declare(strict_types=1);
namespace Tests\Feature\Admin;
use App\Models\Article;
use App\Models\User;
use Faker\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class ArticlesTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
/** @test */
public function adminArticlesPageLoads(): void
@ -76,9 +77,12 @@ class ArticlesTest extends TestCase
public function articleCanLoadFormToEditArticle(): void
{
$user = User::factory()->make();
$article = Article::factory()->create([
'main' => 'This is *my* new blog. It uses `Markdown`.',
]);
$response = $this->actingAs($user)
->get('/admin/blog/1/edit');
->get('/admin/blog/' . $article->id . '/edit');
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
}
@ -86,9 +90,10 @@ class ArticlesTest extends TestCase
public function adminCanEditArticle(): void
{
$user = User::factory()->make();
$article = Article::factory()->create();
$this->actingAs($user)
->post('/admin/blog/1', [
->post('/admin/blog/' . $article->id, [
'_method' => 'PUT',
'title' => 'My New Blog',
'main' => 'This article has been edited',
@ -103,13 +108,14 @@ class ArticlesTest extends TestCase
public function adminCanDeleteArticle(): void
{
$user = User::factory()->make();
$article = Article::factory()->create();
$this->actingAs($user)
->post('/admin/blog/1', [
->post('/admin/blog/' . $article->id, [
'_method' => 'DELETE',
]);
$this->assertSoftDeleted('articles', [
'title' => 'My New Blog',
'title' => $article->title,
]);
}
}

View file

@ -4,13 +4,14 @@ declare(strict_types=1);
namespace Tests\Feature\Admin;
use App\Models\MicropubClient;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ClientsTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
/** @test */
public function clientsPageLoads(): void
@ -52,9 +53,12 @@ class ClientsTest extends TestCase
public function adminCanLoadEditFormForClient(): void
{
$user = User::factory()->make();
$client = MicropubClient::factory()->create([
'client_url' => 'https://jbl5.dev/notes/new',
]);
$response = $this->actingAs($user)
->get('/admin/clients/1/edit');
->get('/admin/clients/' . $client->id . '/edit');
$response->assertSee('https://jbl5.dev/notes/new');
}
@ -62,9 +66,10 @@ class ClientsTest extends TestCase
public function adminCanEditClient(): void
{
$user = User::factory()->make();
$client = MicropubClient::factory()->create();
$this->actingAs($user)
->post('/admin/clients/1', [
->post('/admin/clients/' . $client->id, [
'_method' => 'PUT',
'client_url' => 'https://jbl5.dev/notes/new',
'client_name' => 'JBL5dev',
@ -79,9 +84,12 @@ class ClientsTest extends TestCase
public function adminCanDeleteClient(): void
{
$user = User::factory()->make();
$client = MicropubClient::factory()->create([
'client_url' => 'https://jbl5.dev/notes/new',
]);
$this->actingAs($user)
->post('/admin/clients/1', [
->post('/admin/clients/' . $client->id, [
'_method' => 'DELETE',
]);
$this->assertDatabaseMissing('clients', [

View file

@ -10,13 +10,13 @@ use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Tests\TestCase;
class ContactsTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
protected function tearDown(): void
{
@ -66,8 +66,9 @@ class ContactsTest extends TestCase
public function adminCanSeeFormToEditContact(): void
{
$user = User::factory()->make();
$contact = Contact::factory()->create();
$response = $this->actingAs($user)->get('/admin/contacts/1/edit');
$response = $this->actingAs($user)->get('/admin/contacts/' . $contact->id . '/edit');
$response->assertViewIs('admin.contacts.edit');
}
@ -75,8 +76,9 @@ class ContactsTest extends TestCase
public function adminCanUpdateContact(): void
{
$user = User::factory()->make();
$contact = Contact::factory()->create();
$this->actingAs($user)->post('/admin/contacts/1', [
$this->actingAs($user)->post('/admin/contacts/' . $contact->id, [
'_method' => 'PUT',
'name' => 'Tantek Celik',
'nick' => 'tantek',
@ -96,8 +98,9 @@ class ContactsTest extends TestCase
$path = sys_get_temp_dir() . '/tantek.png';
$file = new UploadedFile($path, 'tantek.png', 'image/png', null, true);
$user = User::factory()->make();
$contact = Contact::factory()->create();
$this->actingAs($user)->post('/admin/contacts/1', [
$this->actingAs($user)->post('/admin/contacts/' . $contact->id, [
'_method' => 'PUT',
'name' => 'Tantek Celik',
'nick' => 'tantek',
@ -115,8 +118,13 @@ class ContactsTest extends TestCase
public function adminCanDeleteContact(): void
{
$user = User::factory()->make();
$contact = Contact::factory()->create(['nick' => 'tantek']);
$this->actingAs($user)->post('/admin/contacts/1', [
$this->assertDatabaseHas('contacts', [
'nick' => 'tantek',
]);
$this->actingAs($user)->post('/admin/contacts/' . $contact->id, [
'_method' => 'DELETE',
]);
$this->assertDatabaseMissing('contacts', [
@ -132,7 +140,7 @@ class ContactsTest extends TestCase
<img class="u-photo" alt="" src="http://tantek.com/tantek.png">
</div>
HTML;
$file = fopen(__DIR__ . '/../../aaron.png', 'r');
$file = fopen(__DIR__ . '/../../aaron.png', 'rb');
$mock = new MockHandler([
new Response(200, ['Content-Type' => 'text/html'], $html),
new Response(200, ['Content-Type' => 'iamge/png'], $file),
@ -141,8 +149,11 @@ class ContactsTest extends TestCase
$client = new Client(['handler' => $handler]);
$this->app->instance(Client::class, $client);
$user = User::factory()->make();
$contact = Contact::factory()->create([
'homepage' => 'https://tantek.com',
]);
$this->actingAs($user)->get('/admin/contacts/1/getavatar');
$this->actingAs($user)->get('/admin/contacts/' . $contact->id . '/getavatar');
$this->assertFileEquals(
__DIR__ . '/../../aaron.png',
@ -160,10 +171,11 @@ class ContactsTest extends TestCase
$client = new Client(['handler' => $handler]);
$this->app->instance(Client::class, $client);
$user = User::factory()->make();
$contact = Contact::factory()->create();
$response = $this->actingAs($user)->get('/admin/contacts/1/getavatar');
$response = $this->actingAs($user)->get('/admin/contacts/' . $contact->id . '/getavatar');
$response->assertRedirect('/admin/contacts/1/edit');
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
}
/** @test */
@ -182,10 +194,11 @@ class ContactsTest extends TestCase
$client = new Client(['handler' => $handler]);
$this->app->instance(Client::class, $client);
$user = User::factory()->make();
$contact = Contact::factory()->create();
$response = $this->actingAs($user)->get('/admin/contacts/1/getavatar');
$response = $this->actingAs($user)->get('/admin/contacts/' . $contact->id . '/getavatar');
$response->assertRedirect('/admin/contacts/1/edit');
$response->assertRedirect('/admin/contacts/' . $contact->id . '/edit');
}
/** @test */

View file

@ -7,13 +7,13 @@ namespace Tests\Feature\Admin;
use App\Jobs\ProcessLike;
use App\Models\Like;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class LikesTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
/** @test */
public function likesPageLoads(): void
@ -55,9 +55,10 @@ class LikesTest extends TestCase
public function likeEditFormLoads(): void
{
$user = User::factory()->make();
$like = Like::factory()->create();
$response = $this->actingAs($user)
->get('/admin/likes/1/edit');
->get('/admin/likes/' . $like->id . '/edit');
$response->assertSee('Edit Like');
}
@ -66,9 +67,10 @@ class LikesTest extends TestCase
{
Queue::fake();
$user = User::factory()->make();
$like = Like::factory()->create();
$this->actingAs($user)
->post('/admin/likes/1', [
->post('/admin/likes/' . $like->id, [
'_method' => 'PUT',
'like_url' => 'https://example.com',
]);
@ -81,12 +83,12 @@ class LikesTest extends TestCase
/** @test */
public function adminCanDeleteLike(): void
{
$like = Like::find(1);
$like = Like::factory()->create();
$url = $like->url;
$user = User::factory()->make();
$this->actingAs($user)
->post('/admin/likes/1', [
->post('/admin/likes/' . $like->id, [
'_method' => 'DELETE',
]);
$this->assertDatabaseMissing('likes', [

View file

@ -5,14 +5,15 @@ declare(strict_types=1);
namespace Tests\Feature\Admin;
use App\Jobs\SendWebMentions;
use App\Models\Note;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class NotesTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
/** @test */
public function notesPageLoads(): void
@ -49,8 +50,9 @@ class NotesTest extends TestCase
public function noteEditFormLoads(): void
{
$user = User::factory()->make();
$note = Note::factory()->create();
$response = $this->actingAs($user)->get('/admin/notes/1/edit');
$response = $this->actingAs($user)->get('/admin/notes/' . $note->id . '/edit');
$response->assertViewIs('admin.notes.edit');
}
@ -59,8 +61,9 @@ class NotesTest extends TestCase
{
Queue::fake();
$user = User::factory()->make();
$note = Note::factory()->create();
$this->actingAs($user)->post('/admin/notes/1', [
$this->actingAs($user)->post('/admin/notes/' . $note->id, [
'_method' => 'PUT',
'content' => 'An edited note',
'webmentions' => true,
@ -76,12 +79,13 @@ class NotesTest extends TestCase
public function adminCanDeleteNote(): void
{
$user = User::factory()->make();
$note = Note::factory()->create();
$this->actingAs($user)->post('/admin/notes/1', [
$this->actingAs($user)->post('/admin/notes/' . $note->id, [
'_method' => 'DELETE',
]);
$this->assertSoftDeleted('notes', [
'id' => '1',
'id' => $note->id,
]);
}
}

View file

@ -4,13 +4,14 @@ declare(strict_types=1);
namespace Tests\Feature\Admin;
use App\Models\Place;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PlacesTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
/** @test */
public function placesPageLoads(): void
@ -51,8 +52,9 @@ class PlacesTest extends TestCase
public function editPlacePageLoads(): void
{
$user = User::factory()->make();
$place = Place::factory()->create();
$response = $this->actingAs($user)->get('/admin/places/1/edit');
$response = $this->actingAs($user)->get('/admin/places/' . $place->id . '/edit');
$response->assertViewIs('admin.places.edit');
}
@ -60,8 +62,11 @@ class PlacesTest extends TestCase
public function adminCanUpdatePlace(): void
{
$user = User::factory()->make();
$place = Place::factory()->create([
'name' => 'The Bridgewater Pub',
]);
$this->actingAs($user)->post('/admin/places/1', [
$this->actingAs($user)->post('/admin/places/' . $place->id, [
'_method' => 'PUT',
'name' => 'The Bridgewater',
'description' => 'Who uses “Pub” anyway',

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Article;
use Jonnybarnes\IndieWeb\Numbers;
use Tests\TestCase;
class ArticlesTest extends TestCase
@ -18,22 +20,26 @@ class ArticlesTest extends TestCase
/** @test */
public function singleArticlePageLoads()
{
$response = $this->get('/blog/' . date('Y') . '/' . date('m') . '/some-code-i-did');
$article = Article::factory()->create();
$response = $this->get($article->link);
$response->assertViewIs('articles.show');
}
/** @test */
public function wrongDateInUrlRedirectsToCorrectDate()
{
$response = $this->get('/blog/1900/01/some-code-i-did');
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/some-code-i-did');
$article = Article::factory()->create();
$response = $this->get('/blog/1900/01/' . $article->titleurl);
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/' . $article->titleurl);
}
/** @test */
public function oldUrlsWithIdAreRedirected()
{
$response = $this->get('/blog/s/2');
$response->assertRedirect('/blog/' . date('Y') . '/' . date('m') . '/some-code-i-did');
$article = Article::factory()->create();
$num60Id = resolve(Numbers::class)->numto60($article->id);
$response = $this->get('/blog/s/' . $num60Id);
$response->assertRedirect($article->link);
}
/** @test */

View file

@ -6,14 +6,15 @@ namespace Tests\Feature;
use App\Jobs\ProcessBookmark;
use App\Jobs\SyndicateBookmarkToTwitter;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use App\Models\Bookmark;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
use Tests\TestToken;
class BookmarksTest extends TestCase
{
use DatabaseTransactions, TestToken;
use RefreshDatabase, TestToken;
/** @test */
public function bookmarksPageLoadsWithoutError(): void
@ -25,7 +26,8 @@ class BookmarksTest extends TestCase
/** @test */
public function singleBookmarkPageLoadsWithoutError(): void
{
$response = $this->get('/bookmarks/1');
$bookmark = Bookmark::factory()->create();
$response = $this->get('/bookmarks/' . $bookmark->id);
$response->assertViewIs('bookmarks.show');
}

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Contact;
use App\Models\Note;
use Tests\TestCase;
class BridgyPosseTest extends TestCase
@ -11,9 +13,15 @@ class BridgyPosseTest extends TestCase
/** @test */
public function notesWeWantCopiedToTwitterShouldHaveNecessaryMarkup(): void
{
$response = $this->get('/notes/4');
Contact::factory()->create([
'nick' => 'joe',
'twitter' => 'joe__',
]);
$note = Note::factory()->create(['note' => 'Hi @joe']);
$response = $this->get($note->longurl);
$html = $response->content();
$this->assertTrue(is_string(mb_stristr($html, 'p-bridgy-twitter-content')));
$this->assertStringContainsString('p-bridgy-twitter-content', $html);
}
}

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Contact;
use Tests\TestCase;
class ContactsTest extends TestCase
@ -26,6 +27,9 @@ class ContactsTest extends TestCase
*/
public function contactPageShouldFallbackToDefaultProfilePic(): void
{
Contact::factory()->create([
'nick' => 'tantek',
]);
$response = $this->get('/contacts/tantek');
$response->assertViewHas('image', '/assets/profile-images/default-image');
}
@ -37,6 +41,10 @@ class ContactsTest extends TestCase
*/
public function contactPageShouldUseSpecificProfilePicIfPresent(): void
{
Contact::factory()->create([
'nick' => 'aaron',
'homepage' => 'https://aaronparecki.com',
]);
$response = $this->get('/contacts/aaron');
$response->assertViewHas('image', '/assets/profile-images/aaronparecki.com/image');
}

View file

@ -11,7 +11,7 @@ use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
use Jonnybarnes\WebmentionsParser\Authorship;
use Tests\TestCase;
@ -19,7 +19,7 @@ use Tests\TestToken;
class LikesTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
use TestToken;
/** @test */
@ -32,7 +32,8 @@ class LikesTest extends TestCase
/** @test */
public function singleLikePageHasCorrectView(): void
{
$response = $this->get('/likes/1');
$like = Like::factory()->create();
$response = $this->get('/likes/' . $like->id);
$response->assertViewIs('likes.show');
}

View file

@ -5,17 +5,16 @@ declare(strict_types=1);
namespace Tests\Feature;
use Faker\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Jobs\{SendWebMentions, SyndicateNoteToTwitter};
use App\Models\{Media, Place};
use App\Models\{Media, Note, Place};
use Carbon\Carbon;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
use Tests\TestToken;
use Tests\{TestCase, TestToken};
class MicropubControllerTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
use TestToken;
/** @test */
@ -57,6 +56,11 @@ class MicropubControllerTest extends TestCase
/** @test */
public function micropubClientsCanRequestKnownNearbyPlaces(): void
{
Place::factory()->create([
'name' => 'The Bridgewater Pub',
'latitude' => '53.5',
'longitude' => '-2.38',
]);
$response = $this->get('/api/post?q=geo:53.5,-2.38', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
$response->assertJson(['places' => [['slug' => 'the-bridgewater-pub']]]);
}
@ -64,12 +68,12 @@ class MicropubControllerTest extends TestCase
/**
* @test
* @todo Add uncertainty parameter
*/
*
public function micropubClientsCanRequestKnownNearbyPlacesWithUncertaintyParameter(): void
{
$response = $this->get('/api/post?q=geo:53.5,-2.38', ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
$response->assertJson(['places' => [['slug' => 'the-bridgewater-pub']]]);
}
}*/
/** @test */
public function returnEmptyResultWhenMicropubClientRequestsKnownNearbyPlaces(): void
@ -459,11 +463,12 @@ class MicropubControllerTest extends TestCase
/** @test */
public function micropubClientApiRequestUpdatesExistingNote(): void
{
$note = Note::factory()->create();
$response = $this->postJson(
'/api/post',
[
'action' => 'update',
'url' => config('app.url') . '/notes/A',
'url' => $note->longurl,
'replace' => [
'content' => ['replaced content'],
],
@ -478,11 +483,12 @@ class MicropubControllerTest extends TestCase
/** @test */
public function micropubClientApiRequestUpdatesNoteSyndicationLinks(): void
{
$note = Note::factory()->create();
$response = $this->postJson(
'/api/post',
[
'action' => 'update',
'url' => config('app.url') . '/notes/A',
'url' => $note->longurl,
'add' => [
'syndication' => [
'https://www.swarmapp.com/checkin/123',
@ -504,11 +510,12 @@ class MicropubControllerTest extends TestCase
/** @test */
public function micropubClientApiRequestAddsImageToNote(): void
{
$note = Note::factory()->create();
$response = $this->postJson(
'/api/post',
[
'action' => 'update',
'url' => config('app.url') . '/notes/A',
'url' => $note->longurl,
'add' => [
'photo' => ['https://example.org/photo.jpg'],
],
@ -564,11 +571,12 @@ class MicropubControllerTest extends TestCase
/** @test */
public function micropubClientApiRequestReturnsErrorWhenTryingToUpdateUnsupportedProperty(): void
{
$note = Note::factory()->create();
$response = $this->postJson(
'/api/post',
[
'action' => 'update',
'url' => config('app.url') . '/notes/A',
'url' => $note->longurl,
'morph' => [ // or any other unsupported update type
'syndication' => ['https://www.swarmapp.com/checkin/123'],
],
@ -602,11 +610,12 @@ class MicropubControllerTest extends TestCase
/** @test */
public function micropubClientApiRequestCanReplaceNoteSyndicationTargets(): void
{
$note = Note::factory()->create();
$response = $this->postJson(
'/api/post',
[
'action' => 'update',
'url' => config('app.url') . '/notes/B',
'url' => $note->longurl,
'replace' => [
'syndication' => [
'https://www.swarmapp.com/checkin/the-id',

View file

@ -4,21 +4,22 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Note;
use Tests\TestCase;
class NotesControllerTest extends TestCase
{
/*
/**
* Test the `/notes` page returns 200, this should
* mean the database is being hit.
*
* @test
*
*/
public function notesPageLoads(): void
{
$response = $this->get('/notes');
$response->assertStatus(200);
}*/
}
/**
* Test a specific note.
@ -27,10 +28,12 @@ class NotesControllerTest extends TestCase
*/
public function specificNotePageLoads(): void
{
$response = $this->get('/notes/D');
$note = Note::factory()->create();
$response = $this->get($note->longurl);
$response->assertViewHas('note');
}
/** @todo */
/* @test *
public function noteReplyingToTweet(): void
{
@ -45,8 +48,9 @@ class NotesControllerTest extends TestCase
*/
public function oldNoteUrlsRedirect(): void
{
$response = $this->get('/note/11');
$response->assertRedirect(config('app.url') . '/notes/B');
$note = Note::factory()->create();
$response = $this->get('/note/' . $note->id);
$response->assertRedirect($note->longurl);
}
/**

View file

@ -6,13 +6,14 @@ namespace Tests\Feature;
use App\Models\WebMention;
use Illuminate\FileSystem\FileSystem;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Artisan;
use Tests\TestCase;
class ParseCachedWebMentionsTest extends TestCase
{
use DatabaseTransactions;
use RefreshDatabase;
protected function setUp(): void
{
@ -27,6 +28,16 @@ class ParseCachedWebMentionsTest extends TestCase
/** @test */
public function parseWebmentionHtml(): void
{
$webmentionAaron = WebMention::factory()->create([
'source' => 'https://aaronpk.localhost/reply/1',
'created_at' => Carbon::now()->subDays(5),
'updated_at' => Carbon::now()->subDays(5),
]);
$webmentionTantek = WebMention::factory()->create([
'source' => 'http://tantek.com/',
'created_at' => Carbon::now()->subDays(5),
'updated_at' => Carbon::now()->subDays(5),
]);
$this->assertFileExists(storage_path('HTML') . '/https/aaronpk.localhost/reply/1');
$this->assertFileExists(storage_path('HTML') . '/http/tantek.com/index.html');
$htmlAaron = file_get_contents(storage_path('HTML') . '/https/aaronpk.localhost/reply/1');
@ -40,8 +51,9 @@ class ParseCachedWebMentionsTest extends TestCase
Artisan::call('webmentions:parsecached');
$webmentionAaron = WebMention::find(1);
$webmentionTantek = WebMention::find(2);
$webmentionAaron = WebMention::find($webmentionAaron->id);
$webmentionTantek = WebMention::find($webmentionTantek->id);
$this->assertTrue($webmentionAaron->updated_at->gt($webmentionAaron->created_at));
$this->assertTrue($webmentionTantek->updated_at->gt($webmentionTantek->created_at));
}

View file

@ -27,8 +27,8 @@ class PlacesTest extends TestCase
*/
public function singlePlacePageLoads(): void
{
$place = Place::where('slug', 'the-bridgewater-pub')->first();
$response = $this->get('/places/the-bridgewater-pub');
$place = Place::factory()->create();
$response = $this->get($place->longurl);
$response->assertViewHas('place', $place);
}

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Jobs\DownloadWebMention;
use App\Models\WebMention;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
@ -16,6 +17,8 @@ class ReDownloadWebMentionsTest extends TestCase
{
Queue::fake();
WebMention::factory()->create();
Artisan::call('webmentions:redownload');
Queue::assertPushed(DownloadWebMention::class);

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Models\Note;
use Tests\TestCase;
class SearchControllerTest extends TestCase
@ -11,6 +12,9 @@ class SearchControllerTest extends TestCase
/** @test */
public function searchPageReturnsResult(): void
{
Note::factory()->create([
'note' => 'I love [duckduckgo.com](https://duckduckgo.com)',
]);
$response = $this->get('/search?terms=love');
$response->assertSee('duckduckgo.com');
}

View file

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Jobs\ProcessWebMention;
use App\Models\Note;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
@ -73,13 +74,15 @@ class WebMentionsControllerTest extends TestCase
}
/** @test */
public function legitimateWebmentionTriggersProcesswebmentionJob(): void
public function legitimateWebmentionTriggersProcessWebmentionJob(): void
{
Queue::fake();
$note = Note::factory()->create();
$response = $this->call('POST', '/webmention', [
'source' => 'https://example.org/post/123',
'target' => config('app.url') . '/notes/B'
'target' => $note->longurl,
]);
$response->assertStatus(202);