diff --git a/routes/web.php b/routes/web.php
index 6c27e427..e288fee6 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -65,7 +65,7 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::get('/', [AdminArticlesController::class, 'index']);
Route::get('/create', [AdminArticlesController::class, 'create']);
Route::post('/', [AdminArticlesController::class, 'store']);
- Route::get('/{id}/edit', [AdminArticlesController::class, 'edit']);
+ Route::get('/{article}/edit', [AdminArticlesController::class, 'edit']);
Route::put('/{id}', [AdminArticlesController::class, 'update']);
Route::delete('/{id}', [AdminArticlesController::class, 'destroy']);
});
diff --git a/tests/Feature/ActivityStreamTest.php b/tests/Feature/ActivityStreamTest.php
index be97dcb2..3453f220 100644
--- a/tests/Feature/ActivityStreamTest.php
+++ b/tests/Feature/ActivityStreamTest.php
@@ -1,18 +1,19 @@
get('/', ['Accept' => 'application/activity+json']);
$response->assertHeader('Content-Type', 'application/activity+json');
@@ -24,15 +25,11 @@ class ActivityStreamTest extends TestCase
]);
}
- /**
- * Test request to a single note returns AS2.0 data.
- *
- * @return void
- */
- public function test_single_note_returns_as_data()
+ /** @test */
+ public function requestForNoteIncludesActivityStreamData(): void
{
- $note = \App\Models\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',
diff --git a/tests/Feature/Admin/AdminHomeControllerTest.php b/tests/Feature/Admin/AdminHomeControllerTest.php
index 4bb06062..6658710d 100644
--- a/tests/Feature/Admin/AdminHomeControllerTest.php
+++ b/tests/Feature/Admin/AdminHomeControllerTest.php
@@ -1,16 +1,19 @@
make();
diff --git a/tests/Feature/Admin/AdminTest.php b/tests/Feature/Admin/AdminTest.php
index c90ba21a..4ae91055 100644
--- a/tests/Feature/Admin/AdminTest.php
+++ b/tests/Feature/Admin/AdminTest.php
@@ -1,24 +1,29 @@
get('/admin');
$response->assertRedirect('/login');
}
- public function test_login_page()
+ /** @test */
+ public function loginPageLoads(): void
{
$response = $this->get('/login');
$response->assertViewIs('login');
}
- public function test_attempt_login_with_bad_credentials()
+ /** @test */
+ public function loginAttemptWithBadCredentialsFails(): void
{
$response = $this->post('/login', [
'username' => 'bad',
diff --git a/tests/Feature/Admin/ArticlesTest.php b/tests/Feature/Admin/ArticlesTest.php
index c873a9c8..025e4638 100644
--- a/tests/Feature/Admin/ArticlesTest.php
+++ b/tests/Feature/Admin/ArticlesTest.php
@@ -1,17 +1,22 @@
make();
@@ -20,7 +25,8 @@ class ArticlesTest extends TestCase
$response->assertSeeText('Select article to edit:');
}
- public function test_create_page()
+ /** @test */
+ public function adminCanLoadFormToCreateArticle(): void
{
$user = User::factory()->make();
@@ -29,7 +35,8 @@ class ArticlesTest extends TestCase
$response->assertSeeText('Title (URL)');
}
- public function test_create_new_article()
+ /** @test */
+ public function admiNCanCreateNewArticle(): void
{
$user = User::factory()->make();
@@ -41,10 +48,11 @@ class ArticlesTest extends TestCase
$this->assertDatabaseHas('articles', ['title' => 'Test Title']);
}
- public function test_create_new_article_with_upload()
+ /** @test */
+ public function adminCanCreateNewArticleWithFile(): void
{
$user = User::factory()->make();
- $faker = \Faker\Factory::create();
+ $faker = Factory::create();
$text = $faker->text;
if ($fh = fopen(sys_get_temp_dir() . '/article.md', 'w')) {
fwrite($fh, $text);
@@ -65,21 +73,27 @@ class ArticlesTest extends TestCase
]);
}
- public function test_see_edit_form()
+ /** @test */
+ 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`.');
}
- public function test_edit_article()
+ /** @test */
+ 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',
@@ -90,16 +104,18 @@ class ArticlesTest extends TestCase
]);
}
- public function test_delete_article()
+ /** @test */
+ 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,
]);
}
}
diff --git a/tests/Feature/Admin/ClientsTest.php b/tests/Feature/Admin/ClientsTest.php
index ba598012..f9b33fd5 100644
--- a/tests/Feature/Admin/ClientsTest.php
+++ b/tests/Feature/Admin/ClientsTest.php
@@ -1,16 +1,20 @@
make();
@@ -19,7 +23,8 @@ class ClientsTest extends TestCase
$response->assertSeeText('Clients');
}
- public function test_create_page()
+ /** @test */
+ public function adminCanLoadFormToCreateClient(): void
{
$user = User::factory()->make();
@@ -28,7 +33,8 @@ class ClientsTest extends TestCase
$response->assertSeeText('New Client');
}
- public function test_create_new_client()
+ /** @test */
+ public function adminCanCreateNewClient(): void
{
$user = User::factory()->make();
@@ -43,21 +49,27 @@ class ClientsTest extends TestCase
]);
}
- public function test_see_edit_form()
+ /** @test */
+ 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');
}
- public function test_edit_client()
+ /** @test */
+ 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',
@@ -68,12 +80,16 @@ class ClientsTest extends TestCase
]);
}
- public function test_delete_client()
+ /** @test */
+ 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', [
diff --git a/tests/Feature/Admin/ContactsTest.php b/tests/Feature/Admin/ContactsTest.php
index 05dac0e4..61acb1b7 100644
--- a/tests/Feature/Admin/ContactsTest.php
+++ b/tests/Feature/Admin/ContactsTest.php
@@ -1,20 +1,22 @@
make();
@@ -33,7 +36,8 @@ class ContactsTest extends TestCase
$response->assertViewIs('admin.contacts.index');
}
- public function test_create_page()
+ /** @test */
+ public function contactCreatePageLoads(): void
{
$user = User::factory()->make();
@@ -41,7 +45,8 @@ class ContactsTest extends TestCase
$response->assertViewIs('admin.contacts.create');
}
- public function test_create_new_contact()
+ /** @test */
+ public function adminCanCreateNewContact(): void
{
$user = User::factory()->make();
@@ -57,19 +62,23 @@ class ContactsTest extends TestCase
]);
}
- public function test_see_edit_form()
+ /** @test */
+ 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');
}
- public function test_update_contact_no_uploaded_avatar()
+ /** @test */
+ 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',
@@ -82,14 +91,16 @@ class ContactsTest extends TestCase
]);
}
- public function test_edit_contact_with_uploaded_avatar()
+ /** @test */
+ public function adminCanEditContactAndUploadAvatar(): void
{
copy(__DIR__ . '/../../aaron.png', sys_get_temp_dir() . '/tantek.png');
$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',
@@ -103,11 +114,17 @@ class ContactsTest extends TestCase
);
}
- public function test_delete_contact()
+ /** @test */
+ 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', [
@@ -115,14 +132,15 @@ class ContactsTest extends TestCase
]);
}
- public function test_get_avatar_method()
+ /** @test */
+ public function adminCanTriggerRetrievalOfRemoteAvatar(): void
{
$html = <<
-

-
-HTML;
- $file = fopen(__DIR__ . '/../../aaron.png', 'r');
+