diff --git a/app/Models/SocialAccount.php b/app/Models/SocialAccount.php new file mode 100644 index 0000000..12fae87 --- /dev/null +++ b/app/Models/SocialAccount.php @@ -0,0 +1,26 @@ + fake()->randomElement(SocialAccount::NETWORKS), + 'username' => fake()->userName(), + 'email' => fake()->safeEmail(), + 'password' => fake()->password(), + 'type' => fake()->optional()->randomElement(SocialAccount::TYPES), + ]; + } +} diff --git a/database/migrations/2026_07_18_114858_create_social_accounts_table.php b/database/migrations/2026_07_18_114858_create_social_accounts_table.php new file mode 100644 index 0000000..3e5db3b --- /dev/null +++ b/database/migrations/2026_07_18_114858_create_social_accounts_table.php @@ -0,0 +1,32 @@ +id(); + $table->enum('network', [ + 'twitter', 'instagram', 'facebook', 'reddit', + 'tiktok', 'linkedin', 'youtube', 'other', + ]); + $table->string('username'); + $table->string('email'); + $table->string('password'); + $table->enum('type', ['post', 'comment', 'like'])->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('social_accounts'); + } +}; diff --git a/tests/Feature/SocialAccountModelTest.php b/tests/Feature/SocialAccountModelTest.php new file mode 100644 index 0000000..2f3bc9c --- /dev/null +++ b/tests/Feature/SocialAccountModelTest.php @@ -0,0 +1,31 @@ + 'twitter', + 'username' => 'my_handle', + 'email' => 'handle@example.com', + 'password' => 'plain-text-password', + 'type' => 'post', + ]); + + expect($account->fresh()) + ->network->toBe('twitter') + ->username->toBe('my_handle') + ->email->toBe('handle@example.com') + ->password->toBe('plain-text-password') + ->type->toBe('post'); +}); + +test('a social account can be created with a null type', function () { + $account = SocialAccount::create([ + 'network' => 'instagram', + 'username' => 'my_handle', + 'email' => 'handle@example.com', + 'password' => 'plain-text-password', + ]); + + expect($account->fresh()->type)->toBeNull(); +});