Rename the tests to pass phpcs checks
This commit is contained in:
parent
3946e9aac4
commit
d5bbed1eac
52 changed files with 1329 additions and 1062 deletions
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminHomeControllerTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_admin_homepage()
|
||||
/** @test */
|
||||
public function adminHomepageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
|
|
@ -1,24 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminTest extends TestCase
|
||||
{
|
||||
public function test_admin_page_redirects_to_login()
|
||||
/** @test */
|
||||
public function adminPageRedirectsUnauthedUsersToLoginPage(): void
|
||||
{
|
||||
$response = $this->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',
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use Faker\Factory;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ArticlesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_index_page()
|
||||
/** @test */
|
||||
public function adminArticlesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -20,7 +24,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 +34,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 +47,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,7 +72,8 @@ class ArticlesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_see_edit_form()
|
||||
/** @test */
|
||||
public function articleCanLoadFormToEditArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -74,7 +82,8 @@ class ArticlesTest extends TestCase
|
|||
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
|
||||
}
|
||||
|
||||
public function test_edit_article()
|
||||
/** @test */
|
||||
public function adminCanEditArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -90,7 +99,8 @@ class ArticlesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_delete_article()
|
||||
/** @test */
|
||||
public function adminCanDeleteArticle(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ClientsTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_index_page()
|
||||
/** @test */
|
||||
public function clientsPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -19,7 +22,8 @@ class ClientsTest extends TestCase
|
|||
$response->assertSeeText('Clients');
|
||||
}
|
||||
|
||||
public function test_create_page()
|
||||
/** @test */
|
||||
public function adminCanLoadFormToCreateClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -28,7 +32,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,7 +48,8 @@ class ClientsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_see_edit_form()
|
||||
/** @test */
|
||||
public function adminCanLoadEditFormForClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -52,7 +58,8 @@ class ClientsTest extends TestCase
|
|||
$response->assertSee('https://jbl5.dev/notes/new');
|
||||
}
|
||||
|
||||
public function test_edit_client()
|
||||
/** @test */
|
||||
public function adminCanEditClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -68,7 +75,8 @@ class ClientsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_delete_client()
|
||||
/** @test */
|
||||
public function adminCanDeleteClient(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Models\Contact;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ContactsTest extends TestCase
|
||||
{
|
||||
|
@ -25,7 +27,8 @@ class ContactsTest extends TestCase
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function test_index_page()
|
||||
/** @test */
|
||||
public function contactIndexPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->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,7 +62,8 @@ class ContactsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_see_edit_form()
|
||||
/** @test */
|
||||
public function adminCanSeeFormToEditContact(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -65,7 +71,8 @@ class ContactsTest extends TestCase
|
|||
$response->assertViewIs('admin.contacts.edit');
|
||||
}
|
||||
|
||||
public function test_update_contact_no_uploaded_avatar()
|
||||
/** @test */
|
||||
public function adminCanUpdateContact(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -82,7 +89,8 @@ 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';
|
||||
|
@ -103,7 +111,8 @@ class ContactsTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function test_delete_contact()
|
||||
/** @test */
|
||||
public function adminCanDeleteContact(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -115,13 +124,14 @@ class ContactsTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_get_avatar_method()
|
||||
/** @test */
|
||||
public function adminCanTriggerRetrievalOfRemoteAvatar(): void
|
||||
{
|
||||
$html = <<<HTML
|
||||
<div class="h-card">
|
||||
<img class="u-photo" src="http://tantek.com/tantek.png">
|
||||
</div>
|
||||
HTML;
|
||||
<div class="h-card">
|
||||
<img class="u-photo" alt="" src="http://tantek.com/tantek.png">
|
||||
</div>
|
||||
HTML;
|
||||
$file = fopen(__DIR__ . '/../../aaron.png', 'r');
|
||||
$mock = new MockHandler([
|
||||
new Response(200, ['Content-Type' => 'text/html'], $html),
|
||||
|
@ -140,7 +150,8 @@ HTML;
|
|||
);
|
||||
}
|
||||
|
||||
public function test_get_avatar_method_redirects_with_failed_homepage()
|
||||
/** @test */
|
||||
public function gettingRemoteAvatarFailsGracefullyWithRemoteNotFound(): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
new Response(404),
|
||||
|
@ -155,13 +166,14 @@ HTML;
|
|||
$response->assertRedirect('/admin/contacts/1/edit');
|
||||
}
|
||||
|
||||
public function test_get_avatar_method_redirects_with_failed_avatar_download()
|
||||
/** @test */
|
||||
public function gettingRemoteAvatarFailsGracefullyWithRemoteError(): void
|
||||
{
|
||||
$html = <<<HTML
|
||||
<div class="h-card">
|
||||
<img class="u-photo" src="http://tantek.com/tantek.png">
|
||||
</div>
|
||||
HTML;
|
||||
<div class="h-card">
|
||||
<img class="u-photo" src="http://tantek.com/tantek.png">
|
||||
</div>
|
||||
HTML;
|
||||
$mock = new MockHandler([
|
||||
new Response(200, ['Content-Type' => 'text/html'], $html),
|
||||
new Response(404),
|
||||
|
@ -176,7 +188,8 @@ HTML;
|
|||
$response->assertRedirect('/admin/contacts/1/edit');
|
||||
}
|
||||
|
||||
public function test_get_avatar_for_contact_with_no_homepage()
|
||||
/** @test */
|
||||
public function gettingRemoteAvatarFailsGracefullyForContactWithNoHompage(): void
|
||||
{
|
||||
$contact = Contact::create([
|
||||
'nick' => 'fred',
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Like;
|
||||
use App\Jobs\ProcessLike;
|
||||
use App\Models\Like;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LikesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_index_page()
|
||||
/** @test */
|
||||
public function likesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -22,7 +25,8 @@ class LikesTest extends TestCase
|
|||
$response->assertSeeText('Likes');
|
||||
}
|
||||
|
||||
public function test_create_page()
|
||||
/** @test */
|
||||
public function likeCreateFormLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -31,7 +35,8 @@ class LikesTest extends TestCase
|
|||
$response->assertSeeText('New Like');
|
||||
}
|
||||
|
||||
public function test_create_new_like()
|
||||
/** @test */
|
||||
public function adminCanCreateLike(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$user = User::factory()->make();
|
||||
|
@ -46,7 +51,8 @@ class LikesTest extends TestCase
|
|||
Queue::assertPushed(ProcessLike::class);
|
||||
}
|
||||
|
||||
public function test_see_edit_form()
|
||||
/** @test */
|
||||
public function likeEditFormLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -55,7 +61,8 @@ class LikesTest extends TestCase
|
|||
$response->assertSee('Edit Like');
|
||||
}
|
||||
|
||||
public function test_edit_like()
|
||||
/** @test */
|
||||
public function adminCanEditLike(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$user = User::factory()->make();
|
||||
|
@ -71,7 +78,8 @@ class LikesTest extends TestCase
|
|||
Queue::assertPushed(ProcessLike::class);
|
||||
}
|
||||
|
||||
public function test_delete_like()
|
||||
/** @test */
|
||||
public function adminCanDeleteLike(): void
|
||||
{
|
||||
$like = Like::find(1);
|
||||
$url = $like->url;
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
use App\Jobs\SendWebMentions;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Tests\TestCase;
|
||||
|
||||
class NotesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_index_page()
|
||||
/** @test */
|
||||
public function notesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -20,7 +23,8 @@ class NotesTest extends TestCase
|
|||
$response->assertViewIs('admin.notes.index');
|
||||
}
|
||||
|
||||
public function test_create_page()
|
||||
/** @test */
|
||||
public function noteCreatePageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -28,7 +32,8 @@ class NotesTest extends TestCase
|
|||
$response->assertViewIs('admin.notes.create');
|
||||
}
|
||||
|
||||
public function test_create_a_new_note()
|
||||
/** @test */
|
||||
public function adminCanCreateNewNote(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -40,7 +45,8 @@ class NotesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_edit_page()
|
||||
/** @test */
|
||||
public function noteEditFormLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -48,7 +54,8 @@ class NotesTest extends TestCase
|
|||
$response->assertViewIs('admin.notes.edit');
|
||||
}
|
||||
|
||||
public function test_edit_a_note()
|
||||
/** @test */
|
||||
public function adminCanEditNote(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$user = User::factory()->make();
|
||||
|
@ -65,7 +72,8 @@ class NotesTest extends TestCase
|
|||
Queue::assertPushed(SendWebMentions::class);
|
||||
}
|
||||
|
||||
public function test_delete_note()
|
||||
/** @test */
|
||||
public function adminCanDeleteNote(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Admin;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlacesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_index_page()
|
||||
/** @test */
|
||||
public function placesPageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -18,7 +21,8 @@ class PlacesTest extends TestCase
|
|||
$response->assertViewIs('admin.places.index');
|
||||
}
|
||||
|
||||
public function test_create_page()
|
||||
/** @test */
|
||||
public function createPlacePageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -26,7 +30,8 @@ class PlacesTest extends TestCase
|
|||
$response->assertViewIs('admin.places.create');
|
||||
}
|
||||
|
||||
public function test_create_new_place()
|
||||
/** @test */
|
||||
public function adminCanCreateNewPlace(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -42,7 +47,8 @@ class PlacesTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_edit_page()
|
||||
/** @test */
|
||||
public function editPlacePageLoads(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
@ -50,7 +56,8 @@ class PlacesTest extends TestCase
|
|||
$response->assertViewIs('admin.places.edit');
|
||||
}
|
||||
|
||||
public function test_updating_a_place()
|
||||
/** @test */
|
||||
public function adminCanUpdatePlace(): void
|
||||
{
|
||||
$user = User::factory()->make();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue