|
| 1 | +## Test Your Laravel Blade Skills |
| 2 | + |
| 3 | +This repository is a test for you: perform a set of tasks listed below, and fix the PHPUnit tests, which are currently intentionally failing. |
| 4 | + |
| 5 | +To test if all the functions work correctly, there are PHPUnit tests in `tests/Feature/ViewsTest.php` file. |
| 6 | + |
| 7 | +In the very beginning, if you run `php artisan test`, or `vendor/bin/phpunit`, all 8 tests fail. |
| 8 | +Your task is to make those tests pass. |
| 9 | + |
| 10 | + |
| 11 | +## How to Submit Your Solution |
| 12 | + |
| 13 | +If you want to submit your solution, you should make a Pull Request to the `main` branch. |
| 14 | +It will automatically run the tests via Github Actions and will show you/me if the test pass. |
| 15 | + |
| 16 | +If you don't know how to make a Pull Request, [here's my video with instructions](https://www.youtube.com/watch?v=vEcT6JIFji0). |
| 17 | + |
| 18 | +This task is mostly self-served, so I'm not planning review or merge the Pull Requests. This test is for yourselves to assess your skills, the automated tests will be your answer if you passed the test :) |
| 19 | + |
| 20 | + |
| 21 | +## Questions / Problems? |
| 22 | + |
| 23 | +If you're struggling with some of the tasks, or you have suggestions how to improve the task, create a Github Issue. |
| 24 | + |
| 25 | +Good luck! |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## Task 1. Passing Data to Views. |
| 30 | + |
| 31 | +File `app/Http/Controllers/HomeController.php`, method `users()`, pass the `$usersCount` to the View. |
| 32 | + |
| 33 | +Test method `test_users_list_get_with_values()`. |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Task 2. Prevent the XSS Attack. |
| 38 | + |
| 39 | +The page `/alert` will show you a JavaScript alert. You need to change something in `resources/views/alert.blade.php` file, so that this alert would not be thrown, and instead just its HTML would be shown. |
| 40 | + |
| 41 | +Test method `test_script_alert_does_not_fire_modal`. |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## Task 3. Loop in the Table. |
| 46 | + |
| 47 | +The file `resources/views/table.blade.php` should show the loop of all users, or "No content" row, if no users are in the database. |
| 48 | + |
| 49 | +Test method `test_loop_shows_table_or_empty()`. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +## Task 4. Styling Table Rows. |
| 54 | + |
| 55 | +Three sub-tasks related to the table and loop, all in file `resources/views/rows.blade.php`: |
| 56 | + |
| 57 | +- in the first column, add the row number: 1, 2, etc. |
| 58 | +- only every second row (2nd, 4th, etc) should have CSS class "bg-red-100" |
| 59 | +- only the FIRST row should have email column with "font-bold" |
| 60 | + |
| 61 | +Test method `test_rows_styled_with_number()`. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## Task 5. Logged-in User. |
| 66 | + |
| 67 | +In the file `resources/views/authenticated.blade.php`, show the appropriate text, if the user is/isn't logged in. |
| 68 | + |
| 69 | +If the user is logged in, show their email. |
| 70 | + |
| 71 | +Test method `test_authenticated()`. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Task 6. Include File. |
| 76 | + |
| 77 | +In the file `resources/views/include.blade.php`, include another Blade file `resources/views/includes/row.blade.php`, passing the parameter correctly. |
| 78 | + |
| 79 | +Test method `test_include_row()`. |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Task 7. Global Variable. |
| 84 | + |
| 85 | +In the file `resources/views/layouts/app.blade.php`, there's a "global" variable `$metaTitle`. Pass its value to this view, for all pages, without touching any Controllers. |
| 86 | + |
| 87 | +Test method `test_meta_title()`. |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Task 8. |
| 92 | + |
| 93 | +Change the file `resources/views/layout.blade` to extend the `layouts/main.blade.php` (without Blade components) instead of `layouts/app.blade.php` (with Blade components). |
| 94 | + |
| 95 | +Test method `test_layout()`. |
0 commit comments