chore: code refactor via rector
This commit is contained in:
@@ -4,7 +4,6 @@ namespace Tests\Feature\Livewire\Auth;
|
||||
|
||||
use App\Livewire\Auth\Login;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
@@ -13,6 +12,7 @@ use Tests\TestCase;
|
||||
|
||||
class LoginTest extends TestCase
|
||||
{
|
||||
public $user;
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -24,7 +24,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_renders_the_login_component()
|
||||
public function it_renders_the_login_component(): void
|
||||
{
|
||||
$component = Livewire::test(Login::class);
|
||||
|
||||
@@ -34,7 +34,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_required_email_field()
|
||||
public function it_validates_required_email_field(): void
|
||||
{
|
||||
$component = Livewire::test(Login::class);
|
||||
|
||||
@@ -44,7 +44,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_email_format()
|
||||
public function it_validates_email_format(): void
|
||||
{
|
||||
$component = Livewire::test(Login::class);
|
||||
|
||||
@@ -54,7 +54,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_required_password_field()
|
||||
public function it_validates_required_password_field(): void
|
||||
{
|
||||
$component = Livewire::test(Login::class);
|
||||
|
||||
@@ -64,7 +64,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_authenticates_user_with_valid_credentials()
|
||||
public function it_authenticates_user_with_valid_credentials(): void
|
||||
{
|
||||
$component = Livewire::test(Login::class);
|
||||
|
||||
@@ -77,7 +77,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_fails_authentication_with_invalid_credentials()
|
||||
public function it_fails_authentication_with_invalid_credentials(): void
|
||||
{
|
||||
$component = Livewire::test(Login::class);
|
||||
|
||||
@@ -88,7 +88,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_handles_rate_limiting()
|
||||
public function it_handles_rate_limiting(): void
|
||||
{
|
||||
// Clear any existing rate limit attempts
|
||||
RateLimiter::clear('login:'.request()->ip());
|
||||
@@ -110,7 +110,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_redirects_authenticated_users_away()
|
||||
public function it_redirects_authenticated_users_away(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
@@ -121,7 +121,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_handles_lockout_event()
|
||||
public function it_handles_lockout_event(): void
|
||||
{
|
||||
// Clear any existing rate limit attempts
|
||||
RateLimiter::clear('login:'.request()->ip());
|
||||
@@ -143,7 +143,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_clears_session_after_successful_login()
|
||||
public function it_clears_session_after_successful_login(): void
|
||||
{
|
||||
Session::put('old_url', '/some-page');
|
||||
|
||||
@@ -159,7 +159,7 @@ class LoginTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_remember_me_functionality_works()
|
||||
public function it_remember_me_functionality_works(): void
|
||||
{
|
||||
$component = Livewire::test(Login::class);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use Tests\TestCase;
|
||||
class RegisterTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function it_renders_the_register_component()
|
||||
public function it_renders_the_register_component(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -25,7 +25,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_required_name_field()
|
||||
public function it_validates_required_name_field(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -38,7 +38,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_required_email_field()
|
||||
public function it_validates_required_email_field(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -51,7 +51,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_email_format()
|
||||
public function it_validates_email_format(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -65,7 +65,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_required_password_field()
|
||||
public function it_validates_required_password_field(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -78,7 +78,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_password_confirmation()
|
||||
public function it_validates_password_confirmation(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -92,7 +92,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_creates_user_with_valid_data()
|
||||
public function it_creates_user_with_valid_data(): void
|
||||
{
|
||||
Event::fake();
|
||||
|
||||
@@ -110,12 +110,12 @@ class RegisterTest extends TestCase
|
||||
'email' => 'test@gmail.com',
|
||||
]);
|
||||
|
||||
$this->assertAuthenticatedAs(User::where('email', 'test@gmail.com')->first());
|
||||
$this->assertAuthenticatedAs(User::query()->where('email', 'test@gmail.com')->first());
|
||||
Event::assertDispatched(Registered::class);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_hashes_password_before_storing()
|
||||
public function it_hashes_password_before_storing(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -126,12 +126,12 @@ class RegisterTest extends TestCase
|
||||
->set('password_confirmation', 'Password123!')
|
||||
->call('register');
|
||||
|
||||
$user = User::where('email', 'test@gmail.com')->first();
|
||||
$user = User::query()->where('email', 'test@gmail.com')->first();
|
||||
$this->assertTrue(Hash::check('Password123!', $user->password));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_prevents_duplicate_email_registration()
|
||||
public function it_prevents_duplicate_email_registration(): void
|
||||
{
|
||||
// Create existing user
|
||||
User::factory()->create(['email' => 'test@gmail.com']);
|
||||
@@ -148,7 +148,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_redirects_after_successful_registration()
|
||||
public function it_redirects_after_successful_registration(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -163,7 +163,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_logs_in_user_after_registration()
|
||||
public function it_logs_in_user_after_registration(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -179,7 +179,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_handles_maximum_name_length()
|
||||
public function it_handles_maximum_name_length(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
@@ -193,7 +193,7 @@ class RegisterTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_handles_password_validation()
|
||||
public function it_handles_password_validation(): void
|
||||
{
|
||||
$component = Livewire::test(Register::class);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature\Livewire;
|
||||
|
||||
use App\Livewire\Dashboard\Dashboard;
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -10,6 +11,7 @@ use Tests\TestCase;
|
||||
|
||||
class DashboardTest extends TestCase
|
||||
{
|
||||
public $user;
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -30,18 +32,18 @@ class DashboardTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_renders_dashboard_component()
|
||||
public function it_renders_dashboard_component(): void
|
||||
{
|
||||
$component = Livewire::test(\App\Livewire\Dashboard\Dashboard::class);
|
||||
$component = Livewire::test(Dashboard::class);
|
||||
|
||||
$component->assertStatus(200);
|
||||
$component->assertViewIs('livewire.dashboard.dashboard');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_displays_user_information()
|
||||
public function it_displays_user_information(): void
|
||||
{
|
||||
$component = Livewire::test(\App\Livewire\Dashboard\Dashboard::class);
|
||||
$component = Livewire::test(Dashboard::class);
|
||||
|
||||
// Check that dashboard renders with usage statistics
|
||||
$component->assertSee('Mailbox Created');
|
||||
@@ -50,9 +52,9 @@ class DashboardTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_shows_subscription_status()
|
||||
public function it_shows_subscription_status(): void
|
||||
{
|
||||
$component = Livewire::test(\App\Livewire\Dashboard\Dashboard::class);
|
||||
$component = Livewire::test(Dashboard::class);
|
||||
|
||||
// Test that the component displays subscription pricing section (since user is not subscribed)
|
||||
$component->assertSee('Purchase Subscription');
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
namespace Tests\Feature\Livewire;
|
||||
|
||||
use App\Models\Email;
|
||||
use App\Livewire\Home;
|
||||
use App\Livewire\Frontend\Mailbox;
|
||||
use Exception;
|
||||
use App\Models\Blog;
|
||||
use App\Livewire\ListBlog;
|
||||
use App\Models\Page;
|
||||
use App\Models\ZEmail;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Livewire\Livewire;
|
||||
@@ -11,18 +16,18 @@ use Tests\TestCase;
|
||||
class FrontendTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function it_renders_home_component()
|
||||
public function it_renders_home_component(): void
|
||||
{
|
||||
$component = Livewire::test(\App\Livewire\Home::class);
|
||||
$component = Livewire::test(Home::class);
|
||||
|
||||
$component->assertStatus(200);
|
||||
$component->assertViewIs('livewire.home');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_checks_for_messages_in_home_component()
|
||||
public function it_checks_for_messages_in_home_component(): void
|
||||
{
|
||||
$component = Livewire::test(\App\Livewire\Home::class);
|
||||
$component = Livewire::test(Home::class);
|
||||
|
||||
// Test that the component can render without errors
|
||||
$component->assertStatus(200);
|
||||
@@ -30,7 +35,7 @@ class FrontendTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_renders_mailbox_component_with_existing_email()
|
||||
public function it_renders_mailbox_component_with_existing_email(): void
|
||||
{
|
||||
// Mock existing email in cookie
|
||||
Cookie::queue('email', 'test@example.com', 43800);
|
||||
@@ -40,32 +45,32 @@ class FrontendTest extends TestCase
|
||||
->shouldReceive('getEmail')
|
||||
->andReturn('test@example.com');
|
||||
|
||||
$component = Livewire::test(\App\Livewire\Frontend\Mailbox::class);
|
||||
$component = Livewire::test(Mailbox::class);
|
||||
|
||||
// Component might redirect if email validation fails, so check for either status or redirect
|
||||
try {
|
||||
$component->assertStatus(200);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception) {
|
||||
$component->assertRedirect('/');
|
||||
}
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_redirects_home_when_no_email_in_mailbox()
|
||||
public function it_redirects_home_when_no_email_in_mailbox(): void
|
||||
{
|
||||
// Ensure no email cookie exists
|
||||
Cookie::queue('email', '', -1);
|
||||
|
||||
$component = Livewire::test(\App\Livewire\Frontend\Mailbox::class);
|
||||
$component = Livewire::test(Mailbox::class);
|
||||
|
||||
$component->assertRedirect('/');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_renders_blog_component()
|
||||
public function it_renders_blog_component(): void
|
||||
{
|
||||
// Create a blog post with the slug we're testing
|
||||
$blog = \App\Models\Blog::factory()->create(['slug' => 'test-slug']);
|
||||
Blog::factory()->create(['slug' => 'test-slug']);
|
||||
|
||||
$component = Livewire::test(\App\Livewire\Blog::class, ['slug' => 'test-slug']);
|
||||
|
||||
@@ -73,18 +78,18 @@ class FrontendTest extends TestCase
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_renders_list_blog_component()
|
||||
public function it_renders_list_blog_component(): void
|
||||
{
|
||||
$component = Livewire::test(\App\Livewire\ListBlog::class);
|
||||
$component = Livewire::test(ListBlog::class);
|
||||
|
||||
$component->assertStatus(200);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_renders_page_component()
|
||||
public function it_renders_page_component(): void
|
||||
{
|
||||
// Create a page with the slug we're testing and ensure it's published
|
||||
$page = \App\Models\Page::factory()->create([
|
||||
Page::factory()->create([
|
||||
'slug' => 'test-slug',
|
||||
'is_published' => true,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user