diff --git a/.env.testing b/.env.testing new file mode 100644 index 00000000..f1d8986a --- /dev/null +++ b/.env.testing @@ -0,0 +1,40 @@ +APP_NAME="Trypost.it" +APP_ENV=testing +APP_KEY=base64:oWfTqkX5cJwaVV7c8/z9xjC4XLGzbsKmjSgZiHtvxlk= +APP_DEBUG=true +APP_URL=https://trypost.test + +DB_CONNECTION=pgsql +DB_HOST=127.0.0.1 +DB_PORT=5432 +DB_DATABASE=trypost_test +DB_USERNAME=root +DB_PASSWORD= + +# Test credentials for social platforms +LINKEDIN_CLIENT_ID=test-linkedin-client-id +LINKEDIN_CLIENT_SECRET=test-linkedin-client-secret + +X_CLIENT_ID=test-x-client-id +X_CLIENT_SECRET=test-x-client-secret + +TIKTOK_CLIENT_ID=test-tiktok-client-id +TIKTOK_CLIENT_SECRET=test-tiktok-client-secret + +FACEBOOK_CLIENT_ID=test-facebook-client-id +FACEBOOK_CLIENT_SECRET=test-facebook-client-secret + +INSTAGRAM_CLIENT_ID=test-instagram-client-id +INSTAGRAM_CLIENT_SECRET=test-instagram-client-secret + +THREADS_CLIENT_ID=test-threads-client-id +THREADS_CLIENT_SECRET=test-threads-client-secret + +GOOGLE_CLIENT_ID=test-google-client-id +GOOGLE_CLIENT_SECRET=test-google-client-secret + +PINTEREST_CLIENT_ID=test-pinterest-client-id +PINTEREST_CLIENT_SECRET=test-pinterest-client-secret + +UNSPLASH_ACCESS_KEY=test-unsplash-access-key +UNSPLASH_SECRET_KEY=test-unsplash-secret-key \ No newline at end of file diff --git a/app/Models/Language.php b/app/Models/Language.php index bebc8ba6..44a38a8b 100644 --- a/app/Models/Language.php +++ b/app/Models/Language.php @@ -3,12 +3,13 @@ namespace App\Models; use Illuminate\Database\Eloquent\Concerns\HasUuids; +use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; class Language extends Model { - use HasUuids; + use HasFactory, HasUuids; protected $fillable = [ 'name', diff --git a/database/factories/LanguageFactory.php b/database/factories/LanguageFactory.php new file mode 100644 index 00000000..0ae513ad --- /dev/null +++ b/database/factories/LanguageFactory.php @@ -0,0 +1,24 @@ + +*/ +class LanguageFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => 'English', + 'code' => 'en-US', + ]; + } +} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 80da5ac7..cba2d87b 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -2,6 +2,7 @@ namespace Database\Factories; +use App\Models\Language; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; @@ -29,6 +30,7 @@ public function definition(): array 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), + 'language_id' => Language::factory(), 'two_factor_secret' => null, 'two_factor_recovery_codes' => null, 'two_factor_confirmed_at' => null, diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 1e583ee3..03dc3353 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -14,7 +14,7 @@ public function up(): void Schema::create('languages', function (Blueprint $table) { $table->uuid('id')->primary(); $table->string('name'); - $table->string('code')->unique(); + $table->string('code'); $table->timestamps(); }); diff --git a/phpunit.xml b/phpunit.xml index 88b9d18b..63face99 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -28,6 +28,7 @@ + diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php new file mode 100644 index 00000000..117f0c91 --- /dev/null +++ b/tests/CreatesApplication.php @@ -0,0 +1,23 @@ +make(Kernel::class)->bootstrap(); + + return $app; + } +} diff --git a/tests/Feature/Settings/ProfileUpdateTest.php b/tests/Feature/Settings/ProfileUpdateTest.php index b4c4c378..08226fb4 100644 --- a/tests/Feature/Settings/ProfileUpdateTest.php +++ b/tests/Feature/Settings/ProfileUpdateTest.php @@ -20,6 +20,7 @@ ->patch(route('profile.update'), [ 'name' => 'Test User', 'email' => 'test@example.com', + 'language_id' => $user->language_id, ]); $response @@ -41,6 +42,7 @@ ->patch(route('profile.update'), [ 'name' => 'Test User', 'email' => $user->email, + 'language_id' => $user->language_id, ]); $response diff --git a/tests/TestCase.php b/tests/TestCase.php index dcf2e89e..29e8ad38 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -8,6 +8,8 @@ abstract class TestCase extends BaseTestCase { + use CreatesApplication; + /** * Indicates whether the default seeder should run before each test. *