Giter VIP home page Giter VIP logo

test-laravel-blade-basics's Introduction

Test Your Laravel Blade Skills

This repository is a test for you: perform a set of tasks listed below, and fix the PHPUnit tests, which are currently intentionally failing.

To test if all the functions work correctly, there are PHPUnit tests in tests/Feature/ViewsTest.php file.

In the very beginning, if you run php artisan test, or vendor/bin/phpunit, all 8 tests fail. Your task is to make those tests pass.

How to Submit Your Solution

If you want to submit your solution, you should make a Pull Request to the main branch. It will automatically run the tests via Github Actions and will show you/me if the test pass.

If you don't know how to make a Pull Request, here's my video with instructions.

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 :)

Questions / Problems?

If you're struggling with some of the tasks, or you have suggestions how to improve the task, create a Github Issue.

Good luck!


Task 1. Passing Data to Views.

File app/Http/Controllers/HomeController.php, method users(), pass the $usersCount to the View.

Test method test_users_list_get_with_values().


Task 2. Prevent the XSS Attack.

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.

Test method test_script_alert_does_not_fire_modal.


Task 3. Loop in the Table.

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.

Test method test_loop_shows_table_or_empty().


Task 4. Styling Table Rows.

Three sub-tasks related to the table and loop, all in file resources/views/rows.blade.php:

  • in the first column, add the row number: 1, 2, etc.
  • only every second row (2nd, 4th, etc) should have CSS class "bg-red-100"
  • only the FIRST row should have email column with "font-bold"

Test method test_rows_styled_with_number().


Task 5. Logged-in User.

In the file resources/views/authenticated.blade.php, show the appropriate text, if the user is/isn't logged in.

If the user is logged in, show their email.

Test method test_authenticated().


Task 6. Include File.

In the file resources/views/include.blade.php, include another Blade file resources/views/includes/row.blade.php, passing the parameter correctly.

Test method test_include_row().


Task 7. Global Variable.

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.

Test method test_meta_title().


Task 8. Layouts.

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).

Test method test_layout().

test-laravel-blade-basics's People

Contributors

jareknikolasettl avatar povilaskorop avatar krekas avatar thinkverse avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.