diff --git a/.github/workflows/dusk.yml b/.github/workflows/dusk.yml index 842a266..baeea5f 100644 --- a/.github/workflows/dusk.yml +++ b/.github/workflows/dusk.yml @@ -91,11 +91,9 @@ jobs: run: php artisan route:cache - name: Upgrade Chrome Driver - run: php artisan dusk:chrome-driver --detect - - name: Start Chrome Driver run: | + php artisan dusk:chrome-driver --detect chmod -R 0755 vendor/laravel/dusk/bin/ - ./vendor/laravel/dusk/bin/chromedriver-linux & - name: Run Laravel Server run: php artisan serve --no-reload & @@ -125,13 +123,13 @@ jobs: - name: Upload Screenshots if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: screenshots path: tests/Browser/screenshots - name: Upload Console Logs if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: console path: tests/Browser/console diff --git a/.gitignore b/.gitignore index 75f84f8..6381d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ .env .env.backup .env.production +.env.dusk.* .phpunit.result.cache .php_cs.cache .phpstorm.meta.php diff --git a/app/Helpers/StringHelper.php b/app/Helpers/StringHelper.php index 2d77f6e..4462530 100644 --- a/app/Helpers/StringHelper.php +++ b/app/Helpers/StringHelper.php @@ -6,7 +6,7 @@ class StringHelper { - public static function sanitizeNameForURL(string $name): string + public static function sanitizeNameForURL(?string $name): ?string { $string = str_replace(['[\', \']'], '', $name); $string = preg_replace('/\[.*\]/U', '', $string); @@ -25,7 +25,7 @@ public static function sanitizeNameForURL(string $name): string * - ucfirst it * so it becomes "Jean-Jacques" */ - public static function formatNameFromDB(string $name): string + public static function formatNameFromDB(?string $name): ?string { $formattedName = Str::ucfirst(Str::lower($name)); diff --git a/app/Http/Controllers/FemaleNameController.php b/app/Http/Controllers/FemaleNameController.php index 1d4668a..966364f 100644 --- a/app/Http/Controllers/FemaleNameController.php +++ b/app/Http/Controllers/FemaleNameController.php @@ -17,12 +17,10 @@ class FemaleNameController extends Controller public function index(Request $request): View { // get the page parameter from the url - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters-female', 604800, fn () => FemaleNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('all-names-female-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'female') ->orderBy('total', 'desc') @@ -47,15 +45,13 @@ public function index(Request $request): View public function letter(Request $request): View { $requestedLetter = $request->attributes->get('letter'); - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters-female', 604800, fn () => FemaleNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('female-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'female') - ->where('name', 'like', $requestedLetter . '%') + ->where('name', 'like', Str::upper($requestedLetter) . '%') ->orderBy('total', 'desc') ->paginate(40) ); @@ -71,7 +67,7 @@ public function letter(Request $request): View 'letters' => $letters, 'names' => $names, 'namesPagination' => $namesPagination, - 'activeLetter' => Str::ucfirst($requestedLetter), + 'activeLetter' => Str::upper($requestedLetter), 'favorites' => $favoritedNamesForLoggedUser, ]); } diff --git a/app/Http/Controllers/LocaleController.php b/app/Http/Controllers/LocaleController.php deleted file mode 100644 index 14330ae..0000000 --- a/app/Http/Controllers/LocaleController.php +++ /dev/null @@ -1,19 +0,0 @@ - $locale]); - - return back(); - } -} diff --git a/app/Http/Controllers/MaleNameController.php b/app/Http/Controllers/MaleNameController.php index ce7a162..63e0664 100644 --- a/app/Http/Controllers/MaleNameController.php +++ b/app/Http/Controllers/MaleNameController.php @@ -17,12 +17,10 @@ class MaleNameController extends Controller public function index(Request $request): View { // get the page parameter from the url - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters-male', 604800, fn () => MaleNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('all-names-male-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'male') ->orderBy('total', 'desc') @@ -47,15 +45,13 @@ public function index(Request $request): View public function letter(Request $request): View { $requestedLetter = $request->attributes->get('letter'); - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters-male', 604800, fn () => MaleNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('male-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') ->where('gender', 'male') - ->where('name', 'like', $requestedLetter . '%') + ->where('name', 'like', Str::upper($requestedLetter) . '%') ->orderBy('total', 'desc') ->paginate(40) ); @@ -71,7 +67,7 @@ public function letter(Request $request): View 'letters' => $letters, 'names' => $names, 'namesPagination' => $namesPagination, - 'activeLetter' => Str::ucfirst($requestedLetter), + 'activeLetter' => Str::upper($requestedLetter), 'favorites' => $favoritedNamesForLoggedUser, ]); } diff --git a/app/Http/Controllers/MixteNameController.php b/app/Http/Controllers/MixteNameController.php index b0bf217..192830d 100644 --- a/app/Http/Controllers/MixteNameController.php +++ b/app/Http/Controllers/MixteNameController.php @@ -17,12 +17,10 @@ class MixteNameController extends Controller public function index(Request $request): View { // get the page parameter from the url - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters-mixte', 604800, fn () => MixteNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('all-names-mixte-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') ->where('unisex', 1) ->orderBy('total', 'desc') @@ -47,15 +45,13 @@ public function index(Request $request): View public function letter(Request $request): View { $requestedLetter = $request->attributes->get('letter'); - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters-mixte', 604800, fn () => MixteNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('mixte-letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') ->where('unisex', 1) - ->where('name', 'like', $requestedLetter . '%') + ->where('name', 'like', Str::upper($requestedLetter) . '%') ->orderBy('total', 'desc') ->paginate(40) ); @@ -71,7 +67,7 @@ public function letter(Request $request): View 'letters' => $letters, 'names' => $names, 'namesPagination' => $namesPagination, - 'activeLetter' => Str::ucfirst($requestedLetter), + 'activeLetter' => Str::upper($requestedLetter), 'favorites' => $favoritedNamesForLoggedUser, ]); } diff --git a/app/Http/Controllers/NameController.php b/app/Http/Controllers/NameController.php index a88687c..c3e52e4 100644 --- a/app/Http/Controllers/NameController.php +++ b/app/Http/Controllers/NameController.php @@ -19,12 +19,10 @@ class NameController extends Controller public function index(Request $request): View { // get the page parameter from the url - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters', 604800, fn () => AllNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('all-names-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') ->orderBy('total', 'desc') ->paginate(40) @@ -90,14 +88,12 @@ public function show(Request $request): View public function letter(Request $request): View { $requestedLetter = $request->attributes->get('letter'); - $requestedPage = $request->query('page') ?? 1; + $requestedPage = Paginator::resolveCurrentPage(); $letters = Cache::remember('all-letters', 604800, fn () => AllNamesViewModel::index()); - Paginator::currentPageResolver(fn () => $requestedPage); - $namesPagination = Cache::remember('letter-' . $requestedLetter . '-page-' . $requestedPage, 604800, fn () => Name::where('name', '!=', '_PRENOMS_RARES') - ->where('name', 'like', $requestedLetter . '%') + ->where('name', 'like', Str::upper($requestedLetter) . '%') ->orderBy('total', 'desc') ->paginate(40) ); @@ -113,7 +109,7 @@ public function letter(Request $request): View 'letters' => $letters, 'names' => $names, 'namesPagination' => $namesPagination, - 'activeLetter' => Str::ucfirst($requestedLetter), + 'activeLetter' => Str::upper($requestedLetter), 'favorites' => $favoritedNamesForLoggedUser, ]); } diff --git a/app/Http/Middleware/CheckLetter.php b/app/Http/Middleware/CheckLetter.php index ebca0ad..a080d0f 100644 --- a/app/Http/Middleware/CheckLetter.php +++ b/app/Http/Middleware/CheckLetter.php @@ -27,7 +27,7 @@ public function handle(Request $request, Closure $next): Response return redirect()->route('home.index'); } - $request->attributes->add(['letter' => Str::lcfirst($requestedLetter)]); + $request->attributes->add(['letter' => Str::lower($requestedLetter)]); return $next($request); } diff --git a/app/Http/Middleware/CheckList.php b/app/Http/Middleware/CheckList.php index aa00b11..c9a42cb 100644 --- a/app/Http/Middleware/CheckList.php +++ b/app/Http/Middleware/CheckList.php @@ -21,9 +21,7 @@ public function handle(Request $request, Closure $next): Response $requestedId = $request->route()->parameter('liste'); try { - $list = Cache::remember('route-list-' . $requestedId, 604800, function () use ($requestedId) { - return NameList::findOrFail($requestedId); - }); + $list = Cache::remember('route-list-' . $requestedId, 604800, fn () => NameList::findOrFail($requestedId)); if (! auth()->check() && ! $list->is_public) { return redirect()->route('home.index'); diff --git a/app/Http/Middleware/CheckName.php b/app/Http/Middleware/CheckName.php index a9c5c89..d201565 100644 --- a/app/Http/Middleware/CheckName.php +++ b/app/Http/Middleware/CheckName.php @@ -21,9 +21,7 @@ public function handle(Request $request, Closure $next): Response $requestedId = $request->route()->parameter('id'); try { - $name = Cache::remember('route-name-' . $requestedId, 604800, function () use ($requestedId) { - return Name::findOrFail($requestedId); - }); + $name = Cache::remember('route-name-' . $requestedId, 604800, fn () => Name::findOrFail($requestedId)); $request->attributes->add(['name' => $name]); diff --git a/app/Http/ViewModels/Home/HomeViewModel.php b/app/Http/ViewModels/Home/HomeViewModel.php index 1b06241..8570a21 100644 --- a/app/Http/ViewModels/Home/HomeViewModel.php +++ b/app/Http/ViewModels/Home/HomeViewModel.php @@ -61,19 +61,19 @@ public static function nameSpotlight(): array ->inRandomOrder() ->first(); - return Name::whereIn('id', $id) + return Name::whereIn('id', $id ?? []) ->select('id', 'name', 'origins') ->first(); }); return [ - 'id' => $name->id, - 'name' => StringHelper::formatNameFromDB($name->name), - 'origins' => Str::words($name->origins, 50, '...'), - 'url' => route('name.show', [ + 'id' => optional($name)->id, + 'name' => StringHelper::formatNameFromDB(optional($name)->name), + 'origins' => Str::words(optional($name)->origins, 50, '...'), + 'url' => $name ? route('name.show', [ 'id' => $name->id, 'name' => StringHelper::sanitizeNameForURL($name->name), - ]), + ]) : '', ]; } diff --git a/app/Http/ViewModels/Names/AllNamesViewModel.php b/app/Http/ViewModels/Names/AllNamesViewModel.php index 848e930..5d7c233 100644 --- a/app/Http/ViewModels/Names/AllNamesViewModel.php +++ b/app/Http/ViewModels/Names/AllNamesViewModel.php @@ -26,7 +26,7 @@ public static function index(): Collection $letters->push([ 'letter' => $letter, 'count' => Number::format($count), - 'url' => route('name.letter', ['letter' => Str::lcfirst($letter)]), + 'url' => route('name.letter', ['letter' => Str::lower($letter)]), ]); } diff --git a/composer.json b/composer.json index ad79fa0..7f47cf4 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "require-dev": { "amirami/localizator": "^0.12.1@alpha", "barryvdh/laravel-debugbar": "^3.9", + "brianium/paratest": "^7.4", "fakerphp/faker": "^1.9", "larastan/larastan": "^2.7", "laravel/breeze": "^1.26", diff --git a/composer.lock b/composer.lock index bbe66ad..24ef4e0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3c14b2992c95cc1c6eacae022fe5d8c2", + "content-hash": "5bcaf7719eecec7efd2c10b6d7af3f6f", "packages": [ { "name": "blade-ui-kit/blade-heroicons", @@ -8028,6 +8028,100 @@ }, "time": "2023-06-14T05:06:27+00:00" }, + { + "name": "brianium/paratest", + "version": "v7.4.1", + "source": { + "type": "git", + "url": "https://github.com/paratestphp/paratest.git", + "reference": "b2830e330011d59a799c0002e118f5b4bbdb9604" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/b2830e330011d59a799c0002e118f5b4bbdb9604", + "reference": "b2830e330011d59a799c0002e118f5b4bbdb9604", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-simplexml": "*", + "fidry/cpu-core-counter": "^1.0.0", + "jean85/pretty-package-versions": "^2.0.5", + "php": "~8.2.0 || ~8.3.0", + "phpunit/php-code-coverage": "^10.1.11 || ^11.0.0", + "phpunit/php-file-iterator": "^4.1.0 || ^5.0.0", + "phpunit/php-timer": "^6.0.0 || ^7.0.0", + "phpunit/phpunit": "^10.5.9 || ^11.0.2", + "sebastian/environment": "^6.0.1 || ^7.0.0", + "symfony/console": "^6.4.3 || ^7.0.3", + "symfony/process": "^6.4.3 || ^7.0.3" + }, + "require-dev": { + "doctrine/coding-standard": "^12.0.0", + "ext-pcov": "*", + "ext-posix": "*", + "phpstan/phpstan": "^1.10.57", + "phpstan/phpstan-deprecation-rules": "^1.1.4", + "phpstan/phpstan-phpunit": "^1.3.15", + "phpstan/phpstan-strict-rules": "^1.5.2", + "squizlabs/php_codesniffer": "^3.8.1", + "symfony/filesystem": "^6.4.3 || ^7.0.3" + }, + "bin": [ + "bin/paratest", + "bin/paratest.bat", + "bin/paratest_for_phpstorm" + ], + "type": "library", + "autoload": { + "psr-4": { + "ParaTest\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Scaturro", + "email": "scaturrob@gmail.com", + "role": "Developer" + }, + { + "name": "Filippo Tessarotto", + "email": "zoeslam@gmail.com", + "role": "Developer" + } + ], + "description": "Parallel testing for PHP", + "homepage": "https://github.com/paratestphp/paratest", + "keywords": [ + "concurrent", + "parallel", + "phpunit", + "testing" + ], + "support": { + "issues": "https://github.com/paratestphp/paratest/issues", + "source": "https://github.com/paratestphp/paratest/tree/v7.4.1" + }, + "funding": [ + { + "url": "https://github.com/sponsors/Slamdunk", + "type": "github" + }, + { + "url": "https://paypal.me/filippotessarotto", + "type": "paypal" + } + ], + "time": "2024-02-06T13:50:28+00:00" + }, { "name": "composer/class-map-generator", "version": "1.1.0", @@ -8703,6 +8797,65 @@ }, "time": "2020-07-09T08:09:16+00:00" }, + { + "name": "jean85/pretty-package-versions", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/Jean85/pretty-package-versions.git", + "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.0.0", + "php": "^7.1|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.17", + "jean85/composer-provided-replaced-stub-package": "^1.0", + "phpstan/phpstan": "^0.12.66", + "phpunit/phpunit": "^7.5|^8.5|^9.4", + "vimeo/psalm": "^4.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Jean85\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alessandro Lai", + "email": "alessandro.lai85@gmail.com" + } + ], + "description": "A library to get pretty versions strings of installed dependencies", + "keywords": [ + "composer", + "package", + "release", + "versions" + ], + "support": { + "issues": "https://github.com/Jean85/pretty-package-versions/issues", + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5" + }, + "time": "2021-10-08T21:21:46+00:00" + }, { "name": "larastan/larastan", "version": "v2.8.1", diff --git a/database/factories/NameFactory.php b/database/factories/NameFactory.php index 8c3ae14..157ab6c 100644 --- a/database/factories/NameFactory.php +++ b/database/factories/NameFactory.php @@ -3,14 +3,13 @@ namespace Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; +use Illuminate\Support\Str; /** * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Name> */ class NameFactory extends Factory { - protected static ?string $password; - /** * Define the model's default state. * @@ -19,8 +18,8 @@ class NameFactory extends Factory public function definition(): array { return [ - 'gender' => 'male', - 'name' => fake()->name(), + 'gender' => fake()->randomElement(['male', 'female']), + 'name' => fn (array $attributes) => Str::ucfirst(fake()->firstName($attributes['gender'])), 'origins' => fake()->sentence(), 'personality' => fake()->sentence(), 'country_of_origin' => fake()->word(), @@ -30,9 +29,49 @@ public function definition(): array 'litterature_artistics_references' => fake()->sentence(), 'similar_names_in_other_languages' => fake()->sentence(), 'klingon_translation' => fake()->sentence(), - 'unisex' => true, - 'total' => 1, + 'unisex' => fake()->boolean, + 'total' => fake()->numberBetween(1, 100000), 'page_views' => 1, ]; } + + /** + * Indicate that the gender is male + */ + public function male(): Factory + { + return $this->state(fn (array $attributes) => [ + 'gender' => 'male', + ]); + } + + /** + * Indicate that the gender is female + */ + public function female(): Factory + { + return $this->state(fn (array $attributes) => [ + 'gender' => 'female', + ]); + } + + /** + * Indicate that the model is unisex + */ + public function unisex(): Factory + { + return $this->state(fn (array $attributes) => [ + 'unisex' => true, + ]); + } + + /** + * Indicate that the model is not unisex + */ + public function specific(): Factory + { + return $this->state(fn (array $attributes) => [ + 'unisex' => false, + ]); + } } diff --git a/database/factories/NoteFactory.php b/database/factories/NoteFactory.php index c161a7e..d0d088f 100644 --- a/database/factories/NoteFactory.php +++ b/database/factories/NoteFactory.php @@ -11,8 +11,6 @@ */ class NoteFactory extends Factory { - protected static ?string $password; - /** * Define the model's default state. * diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index a9f4519..80d7596 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -12,11 +12,5 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // \App\Models\User::factory(10)->create(); - - // \App\Models\User::factory()->create([ - // 'name' => 'Test User', - // 'email' => 'test@example.com', - // ]); } } diff --git a/routes/web.php b/routes/web.php index 1ca5ed2..0ea4c2d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -35,7 +35,7 @@ Route::middleware(['letter'])->group(function (): void { Route::get('prenoms/garcons/{letter}', [MaleNameController::class, 'letter'])->name('name.garcon.letter'); Route::get('prenoms/filles/{letter}', [FemaleNameController::class, 'letter'])->name('name.fille.letter'); - Route::get('prenoms/mixte/{letter}', [MixteNameController::class, 'letter'])->name('name.mixte.letter'); + Route::get('prenoms/mixtes/{letter}', [MixteNameController::class, 'letter'])->name('name.mixte.letter'); Route::get('prenoms/{letter}', [NameController::class, 'letter'])->name('name.letter'); }); diff --git a/tests/.env.ci.dusk b/tests/.env.ci.dusk index 35de6ba..c76b5a3 100644 --- a/tests/.env.ci.dusk +++ b/tests/.env.ci.dusk @@ -1,4 +1,4 @@ -APP_NAME=touslesprenoms +APP_NAME=TousLesPrenoms APP_ENV=local APP_KEY= APP_DEBUG=true @@ -15,7 +15,7 @@ DB_DATABASE=touslesprenoms DB_USERNAME=root DB_PASSWORD=root -BROADCAST_DRIVER=log +DEBUGBAR_ENABLED=false CACHE_DRIVER=file FILESYSTEM_DISK=local QUEUE_CONNECTION=sync @@ -36,24 +36,3 @@ MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS="hello@example.com" MAIL_FROM_NAME="${APP_NAME}" - -AWS_ACCESS_KEY_ID= -AWS_SECRET_ACCESS_KEY= -AWS_DEFAULT_REGION=us-east-1 -AWS_BUCKET= -AWS_USE_PATH_STYLE_ENDPOINT=false - -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= -PUSHER_HOST= -PUSHER_PORT=443 -PUSHER_SCHEME=https -PUSHER_APP_CLUSTER=mt1 - -VITE_APP_NAME="${APP_NAME}" -VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" -VITE_PUSHER_HOST="${PUSHER_HOST}" -VITE_PUSHER_PORT="${PUSHER_PORT}" -VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" -VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/tests/.env.ci.mysql b/tests/.env.ci.mysql index f5394c0..a7a9623 100644 --- a/tests/.env.ci.mysql +++ b/tests/.env.ci.mysql @@ -1,9 +1,9 @@ # ENV FILE FOR THE GITHUB ACTION RUNNING MYSQL -APP_NAME=Laravel +APP_NAME=TousLesPrenoms APP_ENV=testing APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg= APP_DEBUG=true -APP_URL=https://touslesprenoms.test +APP_URL=http://localhost DB_CONNECTION=mysql DB_HOST=127.0.0.1 @@ -12,8 +12,6 @@ DB_DATABASE=touslesprenoms DB_USERNAME=root DB_PASSWORD=root -BROADCAST_DRIVER=log - DEBUGBAR_ENABLED=false CACHE_DRIVER=array QUEUE_CONNECTION=sync @@ -21,6 +19,3 @@ SESSION_DRIVER=file MAIL_MAILER=array SCOUT_DRIVER=collection - -LEMON_SQUEEZY_ACTIVATE=true -LEMON_SQUEEZY_URL=https://bivouac.lemonsqueezy.com/ diff --git a/tests/.env.ci.pgsql b/tests/.env.ci.pgsql index ab926a5..f4645fd 100644 --- a/tests/.env.ci.pgsql +++ b/tests/.env.ci.pgsql @@ -1,9 +1,9 @@ -# ENV FILE FOR THE GITHUB ACTION RUNNING MYSQL -APP_NAME=Laravel +# ENV FILE FOR THE GITHUB ACTION RUNNING POSTGRESQL +APP_NAME=TousLesPrenoms APP_ENV=testing APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg= APP_DEBUG=true -APP_URL=https://touslesprenoms.test +APP_URL=http://localhost DB_CONNECTION=pgsql DB_HOST=127.0.0.1 @@ -12,15 +12,10 @@ DB_DATABASE=touslesprenoms DB_USERNAME=touslesprenoms DB_PASSWORD=secret -BROADCAST_DRIVER=log - DEBUGBAR_ENABLED=false -CACHE_DRIVER=array +CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=file MAIL_MAILER=array SCOUT_DRIVER=collection - -LEMON_SQUEEZY_ACTIVATE=true -LEMON_SQUEEZY_URL=https://bivouac.lemonsqueezy.com/ diff --git a/tests/.env.ci.sqlite b/tests/.env.ci.sqlite index 6a3a1a1..5c6c34c 100644 --- a/tests/.env.ci.sqlite +++ b/tests/.env.ci.sqlite @@ -1,15 +1,13 @@ # ENV FILE FOR THE GITHUB ACTION RUNNING SQLITE -APP_NAME=Laravel +APP_NAME=TousLesPrenoms APP_ENV=testing APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg= APP_DEBUG=true -APP_URL=https://touslesprenoms.test +APP_URL=http://localhost DB_CONNECTION=sqlite DB_DATABASE=database/database.sqlite -BROADCAST_DRIVER=log - DEBUGBAR_ENABLED=false CACHE_DRIVER=array QUEUE_CONNECTION=sync @@ -17,6 +15,3 @@ SESSION_DRIVER=file MAIL_MAILER=array SCOUT_DRIVER=collection - -LEMON_SQUEEZY_ACTIVATE=true -LEMON_SQUEEZY_URL=https://bivouac.lemonsqueezy.com/ diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/HomeTest.php similarity index 52% rename from tests/Browser/ExampleTest.php rename to tests/Browser/HomeTest.php index a2957b5..1dceda6 100644 --- a/tests/Browser/ExampleTest.php +++ b/tests/Browser/HomeTest.php @@ -5,18 +5,18 @@ use Laravel\Dusk\Browser; use Tests\DuskTestCase; -class ExampleTest extends DuskTestCase +class HomeTest extends DuskTestCase { /** - * A basic browser test example. - * * @test */ - public function basicExample(): void + public function homePage(): void { $this->browse(function (Browser $browser): void { $browser->visit('/') - ->assertSee('Laravel'); + ->assertPathIs('/') + ->assertTitle(config('app.name')) + ->assertSee('Tous les prénoms'); }); } } diff --git a/tests/Feature/HomeTest.php b/tests/Feature/HomeTest.php new file mode 100644 index 0000000..15f0c10 --- /dev/null +++ b/tests/Feature/HomeTest.php @@ -0,0 +1,22 @@ +create(); + + $response = $this->get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/Feature/NameTest.php b/tests/Feature/NameTest.php new file mode 100644 index 0000000..6bf0387 --- /dev/null +++ b/tests/Feature/NameTest.php @@ -0,0 +1,117 @@ +create(); + + $response = $this->get('/prenoms'); + + $response->assertStatus(200); + $response->assertSee($names[0]->name); + } + + #[Test] + public function name_letter_can_be_rendered(): void + { + $name = Name::factory()->create(); + + $response = $this->get('/prenoms/' . $name->name[0]); + + $response->assertStatus(200); + $response->assertSee('Tous les prénoms commençant par la lettre ' . Str::upper($name->name[0])); + $response->assertSee($name->name); + } + + #[Test] + public function male_screen_can_be_rendered(): void + { + $names = Name::factory(10)->male()->create(); + + $response = $this->get('/prenoms/garcons'); + + $response->assertStatus(200); + $response->assertSee($names[0]->name); + } + + #[Test] + public function male_letter_can_be_rendered(): void + { + $name = Name::factory()->male()->create(); + + $response = $this->get('/prenoms/garcons/' . $name->name[0]); + + $response->assertStatus(200); + $response->assertSee('Tous les prénoms masculins commençant par la lettre ' . Str::upper($name->name[0])); + $response->assertSee($name->name); + } + + #[Test] + public function female_screen_can_be_rendered(): void + { + $names = Name::factory(10)->female()->create(); + + $response = $this->get('/prenoms/filles'); + + $response->assertStatus(200); + $response->assertSee($names[0]->name); + } + + #[Test] + public function female_letter_can_be_rendered(): void + { + $name = Name::factory()->female()->create(); + + $response = $this->get('/prenoms/filles/' . $name->name[0]); + + $response->assertStatus(200); + $response->assertSee('Tous les prénoms féminins commençant par la lettre ' . Str::upper($name->name[0])); + $response->assertSee($name->name); + } + + #[Test] + public function unisex_screen_can_be_rendered(): void + { + $names = Name::factory(10)->unisex()->create(); + + $response = $this->get('/prenoms/mixtes'); + + $response->assertStatus(200); + $response->assertSee($names[0]->name); + } + + #[Test] + public function unisex_letter_can_be_rendered(): void + { + $name = Name::factory()->unisex()->create(); + + $response = $this->get("/prenoms/mixtes/{$name->name[0]}"); + + $response->assertStatus(200); + $response->assertSee('Tous les prénoms mixtes commençant par la lettre ' . Str::upper($name->name[0])); + $response->assertSee($name->name); + } + + #[Test] + public function name_page_can_be_rendered(): void + { + $name = Name::factory()->create(); + + $response = $this->get("/prenoms/$name->id/" . Str::slug($name->name)); + + $response->assertStatus(200); + $response->assertSee($name->name); + } +} diff --git a/tests/Feature/SearchTest.php b/tests/Feature/SearchTest.php new file mode 100644 index 0000000..36e6db8 --- /dev/null +++ b/tests/Feature/SearchTest.php @@ -0,0 +1,43 @@ +get('/recherche'); + + $response->assertStatus(200); + } + + #[Test] + public function search_can_be_triggered(): void + { + $name = \App\Models\Name::factory()->create(); + + $response = $this->post('/recherche', ['term' => $name->name]); + + $response->assertStatus(200); + $response->assertSee($name->name); + } + + #[Test] + public function name_can_be_found(): void + { + $names = \App\Models\Name::factory(10)->create(); + + $response = $this->post('/recherche', ['term' => Str::substr($names[0]->name, 0, 3)]); + + $response->assertStatus(200); + $response->assertSee($names[0]->name); + } +} diff --git a/tests/Unit/ViewModels/Names/NameViewModelTest.php b/tests/Unit/ViewModels/Names/NameViewModelTest.php index bcc56b5..2273a55 100644 --- a/tests/Unit/ViewModels/Names/NameViewModelTest.php +++ b/tests/Unit/ViewModels/Names/NameViewModelTest.php @@ -209,8 +209,8 @@ public function it_gets_the_data_to_feed_the_json_schema_ld_file(): void /** @test */ public function it_gets_a_collection_of_related_names(): void { - $name1 = Name::factory()->create(); - $name = Name::factory()->create([ + $name1 = Name::factory()->female()->create(); + $name = Name::factory()->female()->create([ 'name' => 'HÉLOÏSE', ]);