Skip to content

Commit

Permalink
tests: fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Dec 10, 2024
1 parent 1f46153 commit 084c051
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@php artisan ide-helper:meta",
"@php artisan ide-helper:models --nowrite"
],
"test": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --colors=always"
"test": "@php artisan test"
},
"extra": {
"laravel": {
Expand Down
13 changes: 7 additions & 6 deletions tests/Feature/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
namespace Tests\Feature;

use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class AuthenticationTest extends TestCase
{
use RefreshDatabase;

public function test_login_screen_can_be_rendered()
#[Test]
public function login_screen_can_be_rendered()
{
$response = $this->get(route('auth.login'));

$response->assertStatus(200);
}

public function test_users_can_authenticate_using_the_login_screen()
#[Test]
public function users_can_authenticate_using_the_login_screen()
{
$user = User::factory()->create();

Expand All @@ -32,7 +32,8 @@ public function test_users_can_authenticate_using_the_login_screen()
$response->assertRedirect(route('admin.dashboard'));
}

public function test_users_can_not_authenticate_with_invalid_password()
#[Test]
public function users_can_not_authenticate_with_invalid_password()
{
$user = User::factory()->create();

Expand Down
13 changes: 7 additions & 6 deletions tests/Feature/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

use App\Models\User;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\URL;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class EmailVerificationTest extends TestCase
{
use RefreshDatabase;

public function test_email_verification_screen_can_be_rendered()
#[Test]
public function email_verification_screen_can_be_rendered()
{
$user = User::factory()->create([
'email_verified_at' => null,
Expand All @@ -26,7 +25,8 @@ public function test_email_verification_screen_can_be_rendered()
$response->assertStatus(200);
}

public function test_email_can_be_verified()
#[Test]
public function email_can_be_verified()
{
$user = User::factory()->create([
'email_verified_at' => null,
Expand All @@ -47,7 +47,8 @@ public function test_email_can_be_verified()
$response->assertRedirect(route('admin.dashboard') . '?verified=1');
}

public function test_email_is_not_verified_with_invalid_hash()
#[Test]
public function email_is_not_verified_with_invalid_hash()
{
$user = User::factory()->create([
'email_verified_at' => null,
Expand Down
17 changes: 11 additions & 6 deletions tests/Feature/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
namespace Tests\Feature;

use App\Models\Form;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class FormTest extends TestCase
{
/** @dataProvider fields */
public function test_it_generates_form_fields(array $expected)
#[Test]
#[DataProvider('fields')]
public function it_generates_form_fields(array $expected)
{
$form = Form::factory()
->withField($expected)
Expand Down Expand Up @@ -60,8 +63,9 @@ public function test_it_generates_form_fields(array $expected)
);
}

/** @dataProvider fields */
public function test_it_accepts_valid_submissions(array $expected, array $input)
#[Test]
#[DataProvider('fields')]
public function it_accepts_valid_submissions(array $expected, array $input)
{
$form = Form::factory()
->withField($expected)
Expand All @@ -76,8 +80,9 @@ public function test_it_accepts_valid_submissions(array $expected, array $input)
$response->assertValid($field->name);
}

/** @dataProvider fields */
public function test_it_rejects_invalid_submissions(array $expected, array $input)
#[Test]
#[DataProvider('fields')]
public function it_rejects_invalid_submissions(array $expected, array $input)
{
$form = Form::factory()
->withField($expected)
Expand Down
13 changes: 7 additions & 6 deletions tests/Feature/PasswordConfirmationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
namespace Tests\Feature;

use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class PasswordConfirmationTest extends TestCase
{
use RefreshDatabase;

public function test_confirm_password_screen_can_be_rendered()
#[Test]
public function confirm_password_screen_can_be_rendered()
{
$user = User::factory()->create();

Expand All @@ -21,7 +20,8 @@ public function test_confirm_password_screen_can_be_rendered()
$response->assertStatus(200);
}

public function test_password_can_be_confirmed()
#[Test]
public function password_can_be_confirmed()
{
$user = User::factory()->create();

Expand All @@ -33,7 +33,8 @@ public function test_password_can_be_confirmed()
$response->assertSessionHasNoErrors();
}

public function test_password_is_not_confirmed_with_invalid_password()
#[Test]
public function password_is_not_confirmed_with_invalid_password()
{
$user = User::factory()->create();

Expand Down
16 changes: 9 additions & 7 deletions tests/Feature/PasswordResetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;

class PasswordResetTest extends TestCase
{
use RefreshDatabase;

public function test_reset_password_link_screen_can_be_rendered()
#[Test]
public function reset_password_link_screen_can_be_rendered()
{
$response = $this->get(route('auth.password.request'));

$response->assertStatus(200);
}

public function test_reset_password_link_can_be_requested()
#[Test]
public function reset_password_link_can_be_requested()
{
Notification::fake();

Expand All @@ -32,7 +32,8 @@ public function test_reset_password_link_can_be_requested()
Notification::assertSentTo($user, ResetPassword::class);
}

public function test_reset_password_screen_can_be_rendered()
#[Test]
public function reset_password_screen_can_be_rendered()
{
Notification::fake();

Expand All @@ -49,7 +50,8 @@ public function test_reset_password_screen_can_be_rendered()
});
}

public function test_password_can_be_reset_with_valid_token()
#[Test]
public function password_can_be_reset_with_valid_token()
{
Notification::fake();

Expand Down
5 changes: 2 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Foundation\Testing\WithFaker;
use PHPUnit\Framework\Attributes\Before;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use LazilyRefreshDatabase;
use WithFaker;

/**
* @before
*/
#[Before]
public function boot(): void
{
$this->afterApplicationCreated(function () {
Expand Down

0 comments on commit 084c051

Please sign in to comment.