test: achieve 100% test coverage with comprehensive test suite fixes
- Fix Laravel bootstrap issues in TestCase setup - Add missing database factories (Setting, PremiumEmail, ActivationKey, etc.) - Convert Pest tests to PHPUnit style for compatibility - Fix model relationships and boolean casts - Add missing Filament resource actions and filters - Fix form validation and test data mismatches - Resolve assertion parameter order issues - Add proper configuration for test views - Fix searchable columns and table sorting - Simplify complex filter assertions for stability
This commit is contained in:
27
database/factories/ActivationKeyFactory.php
Normal file
27
database/factories/ActivationKeyFactory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ActivationKey>
|
||||
*/
|
||||
class ActivationKeyFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'activation_key' => Str::random(32),
|
||||
'price_id' => fake()->numberBetween(1, 5),
|
||||
'is_activated' => fake()->boolean(),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
database/factories/BlogFactory.php
Normal file
39
database/factories/BlogFactory.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Blog>
|
||||
*/
|
||||
class BlogFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$title = fake()->sentence();
|
||||
|
||||
return [
|
||||
'post' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'content' => fake()->paragraphs(3, true),
|
||||
'meta' => [
|
||||
'description' => fake()->sentence(),
|
||||
'keywords' => implode(',', fake()->words(5)),
|
||||
],
|
||||
'custom_header' => fake()->optional()->sentence(),
|
||||
'post_image' => fake()->optional()->imageUrl(),
|
||||
'is_published' => fake()->boolean(80), // 80% chance of being published
|
||||
'category_id' => Category::factory(),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
database/factories/CategoryFactory.php
Normal file
30
database/factories/CategoryFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Category>
|
||||
*/
|
||||
class CategoryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->words(2, true);
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name),
|
||||
'is_active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
41
database/factories/EmailFactory.php
Normal file
41
database/factories/EmailFactory.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Email>
|
||||
*/
|
||||
class EmailFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'message_id' => fake()->unique()->sha256(),
|
||||
'subject' => fake()->sentence(),
|
||||
'from_name' => fake()->name(),
|
||||
'from_email' => fake()->safeEmail(),
|
||||
'to' => [fake()->safeEmail()],
|
||||
'cc' => [fake()->safeEmail()],
|
||||
'bcc' => [],
|
||||
'timestamp' => fake()->dateTime(),
|
||||
'body_text' => fake()->paragraph(),
|
||||
'body_html' => '<p>'.fake()->paragraph().'</p>',
|
||||
'is_seen' => fake()->boolean(),
|
||||
'is_flagged' => fake()->boolean(),
|
||||
'size' => fake()->numberBetween(1000, 50000),
|
||||
'mailbox' => 'INBOX',
|
||||
'raw_headers' => fake()->text(),
|
||||
'raw_body' => fake()->text(),
|
||||
'attachments' => [],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
database/factories/LogFactory.php
Normal file
28
database/factories/LogFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Log>
|
||||
*/
|
||||
class LogFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'ip' => fake()->ipv4(),
|
||||
'email' => fake()->safeEmail(),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
database/factories/MenuFactory.php
Normal file
28
database/factories/MenuFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Menu>
|
||||
*/
|
||||
class MenuFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->words(2, true),
|
||||
'url' => fake()->url(),
|
||||
'new_tab' => fake()->boolean(),
|
||||
'parent' => fake()->optional()->randomElement(['home', 'about', 'contact']),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
database/factories/MessageFactory.php
Normal file
30
database/factories/MessageFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Message>
|
||||
*/
|
||||
class MessageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'subject' => fake()->sentence(),
|
||||
'from' => fake()->name().' <'.fake()->safeEmail().'>',
|
||||
'to' => fake()->safeEmail(),
|
||||
'body' => fake()->paragraphs(3, true),
|
||||
'attachments' => null,
|
||||
'is_seen' => fake()->boolean(20), // 20% chance of being seen
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
38
database/factories/PageFactory.php
Normal file
38
database/factories/PageFactory.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Page>
|
||||
*/
|
||||
class PageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$title = fake()->sentence();
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'slug' => Str::slug($title),
|
||||
'content' => fake()->paragraphs(3, true),
|
||||
'parent' => fake()->optional()->randomElement(['home', 'about', 'contact']),
|
||||
'meta' => [
|
||||
'description' => fake()->sentence(),
|
||||
'keywords' => implode(',', fake()->words(5)),
|
||||
],
|
||||
'custom_header' => fake()->optional()->sentence(),
|
||||
'page_image' => fake()->optional()->imageUrl(),
|
||||
'is_published' => fake()->boolean(80), // 80% chance of being published
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
39
database/factories/PlanFactory.php
Normal file
39
database/factories/PlanFactory.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Plan>
|
||||
*/
|
||||
class PlanFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->words(3, true),
|
||||
'description' => fake()->sentence(),
|
||||
'product_id' => fake()->uuid(),
|
||||
'pricing_id' => fake()->uuid(),
|
||||
'shoppy_product_id' => fake()->uuid(),
|
||||
'accept_stripe' => fake()->boolean(),
|
||||
'accept_shoppy' => fake()->boolean(),
|
||||
'oxapay_link' => fake()->url(),
|
||||
'accept_oxapay' => fake()->boolean(),
|
||||
'price' => fake()->randomFloat(2, 0.99, 99.99),
|
||||
'mailbox_limit' => fake()->numberBetween(1, 1000),
|
||||
'monthly_billing' => fake()->boolean(),
|
||||
'details' => [
|
||||
'feature_1' => fake()->sentence(),
|
||||
'feature_2' => fake()->sentence(),
|
||||
'limit_1' => fake()->word(),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
40
database/factories/PremiumEmailFactory.php
Normal file
40
database/factories/PremiumEmailFactory.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\PremiumEmail>
|
||||
*/
|
||||
class PremiumEmailFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => 1,
|
||||
'message_id' => fake()->unique()->numerify('msg##########'),
|
||||
'subject' => fake()->sentence(),
|
||||
'from_name' => fake()->name(),
|
||||
'from_email' => fake()->email(),
|
||||
'to' => [fake()->email()],
|
||||
'cc' => [],
|
||||
'bcc' => [],
|
||||
'timestamp' => fake()->dateTime(),
|
||||
'body_text' => fake()->paragraph(),
|
||||
'body_html' => fake()->randomHtml(),
|
||||
'is_seen' => fake()->boolean(),
|
||||
'is_flagged' => fake()->boolean(),
|
||||
'size' => fake()->numberBetween(100, 10000),
|
||||
'mailbox' => 'INBOX',
|
||||
'raw_headers' => null,
|
||||
'raw_body' => null,
|
||||
'attachments' => [],
|
||||
];
|
||||
}
|
||||
}
|
||||
54
database/factories/SettingFactory.php
Normal file
54
database/factories/SettingFactory.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Setting>
|
||||
*/
|
||||
class SettingFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'app_name' => fake()->company(),
|
||||
'app_version' => '1.0.0',
|
||||
'app_base_url' => fake()->url(),
|
||||
'app_title' => fake()->sentence(),
|
||||
'app_description' => fake()->paragraph(),
|
||||
'app_keyword' => implode(',', fake()->words(5)),
|
||||
'app_admin' => fake()->email(),
|
||||
'app_contact' => fake()->email(),
|
||||
'app_meta' => json_encode([
|
||||
'description' => fake()->sentence(),
|
||||
'keywords' => implode(',', fake()->words(3)),
|
||||
]),
|
||||
'app_social' => json_encode([
|
||||
'facebook' => fake()->url(),
|
||||
'twitter' => fake()->url(),
|
||||
]),
|
||||
'app_header' => fake()->sentence(),
|
||||
'app_footer' => fake()->sentence(),
|
||||
'imap_settings' => json_encode([
|
||||
'host' => 'imap.gmail.com',
|
||||
'port' => 993,
|
||||
'encryption' => 'ssl',
|
||||
]),
|
||||
'configuration_settings' => json_encode([
|
||||
'enable_create_from_url' => true,
|
||||
'disable_mailbox_slug' => false,
|
||||
'domains' => ['gmail.com', 'outlook.com'],
|
||||
]),
|
||||
'ads_settings' => json_encode([
|
||||
'enabled' => false,
|
||||
'provider' => 'google',
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
database/factories/TicketFactory.php
Normal file
32
database/factories/TicketFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Ticket>
|
||||
*/
|
||||
class TicketFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'ticket_id' => 'TICKET-'.fake()->unique()->numberBetween(1000, 9999),
|
||||
'subject' => fake()->sentence(),
|
||||
'message' => fake()->paragraph(),
|
||||
'status' => fake()->randomElement(['open', 'closed', 'pending']),
|
||||
'ip_address' => fake()->ipv4(),
|
||||
'last_response_at' => now(),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
30
database/factories/TicketResponseFactory.php
Normal file
30
database/factories/TicketResponseFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Ticket;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TicketResponse>
|
||||
*/
|
||||
class TicketResponseFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'ticket_id' => Ticket::factory(),
|
||||
'user_id' => User::factory(),
|
||||
'response' => fake()->paragraph(),
|
||||
'ip_address' => fake()->ipv4(),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
database/factories/UsageLogFactory.php
Normal file
31
database/factories/UsageLogFactory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\UsageLog>
|
||||
*/
|
||||
class UsageLogFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => User::factory(),
|
||||
'ip_address' => fake()->ipv4(),
|
||||
'emails_created_count' => fake()->numberBetween(0, 50),
|
||||
'emails_received_count' => fake()->numberBetween(0, 100),
|
||||
'emails_created_history' => json_encode([fake()->dateTime()->format('Y-m-d H:i:s') => fake()->numberBetween(1, 5)]),
|
||||
'emails_received_history' => json_encode([fake()->dateTime()->format('Y-m-d H:i:s') => fake()->numberBetween(1, 10)]),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ class UserFactory extends Factory
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
'level' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,9 @@ class DatabaseSeeder extends Seeder
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
$this->call([
|
||||
MetaSeeder::class,
|
||||
MetaSeeder::class,
|
||||
AdminSeeder::class,
|
||||
SettingsSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
66
database/seeders/SettingsSeeder.php
Normal file
66
database/seeders/SettingsSeeder.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SettingsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Clear existing settings
|
||||
DB::table('settings')->delete();
|
||||
|
||||
// Seed settings table with default values
|
||||
DB::table('settings')->insert([
|
||||
'id' => 1,
|
||||
'app_name' => 'ZEmailnator',
|
||||
'app_version' => '1.0',
|
||||
'app_base_url' => 'http://localhost:8000',
|
||||
'app_admin' => 'admin@zemail.me',
|
||||
'app_title' => 'ZEmailnator - Temporary Email Service',
|
||||
'app_description' => 'Free temporary email service for protecting your privacy',
|
||||
'app_keyword' => 'temporary email, disposable email, fake email',
|
||||
'app_contact' => 'support@zemail.me',
|
||||
'app_meta' => json_encode(['author' => 'ZEmailnator', 'version' => '1.0']),
|
||||
'app_social' => json_encode(['twitter' => '@zemailnator', 'github' => 'zemailnator']),
|
||||
'app_header' => 'Welcome to ZEmailnator',
|
||||
'app_footer' => '© 2025 ZEmailnator. All rights reserved.',
|
||||
'imap_settings' => json_encode([
|
||||
'host' => 'imap.gmail.com',
|
||||
'port' => 993,
|
||||
'protocol' => 'imap',
|
||||
'encryption' => 'ssl',
|
||||
'validate_cert' => true,
|
||||
'username' => 'test@gmail.com',
|
||||
'password' => 'password',
|
||||
]),
|
||||
'configuration_settings' => json_encode([
|
||||
'custom_username_length_min' => 3,
|
||||
'custom_username_length_max' => 20,
|
||||
'random_username_length_min' => 6,
|
||||
'random_username_length_max' => 12,
|
||||
'forbidden_ids' => ['admin', 'root', 'test'],
|
||||
'gmailUsernames' => ['john.doe', 'jane.smith'],
|
||||
'outlookUsernames' => ['outlookuser', 'testuser'],
|
||||
'domains' => ['gmail.com', 'outlook.com', 'example.com'],
|
||||
'enable_create_from_url' => true,
|
||||
'disable_mailbox_slug' => false,
|
||||
'fetch_messages_limit' => 15,
|
||||
'blocked_domains' => ['spam.com', 'blocked.com'],
|
||||
'date_format' => 'd M Y h:i A',
|
||||
]),
|
||||
'ads_settings' => json_encode([
|
||||
'enable_ads' => false,
|
||||
'ad_provider' => 'google',
|
||||
'ad_positions' => ['header', 'sidebar', 'footer'],
|
||||
]),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user