Skip to content

OVNICap/LaravelTest

Repository files navigation

Laravel test

  • Clone/fork this project
  • Install composer dependencies
  • Edit only the app directory to pass the tests (./vendor/bin/phpunit)

To run the app locally, use composer:

git clone https://github.com/OVNICap/LaravelTest
cd LaravelTest
composer install
php artisan seed
php artisan serve

Then you will be able to see the application on http://localhost:8000

You can also use an online IDE such as GitPod: https://gitpod.io/#https://github.com/OVNICap/LaravelTest

The exercise

Here we use log files as a simplified storage system. By running php artisan seed (you can check what this seeder does in the source code), 4 files are created with random data: storage/logs/daily/2022-04-01.log, storage/logs/daily/2022-04-02.log, storage/logs/daily/2022-04-03.log and storage/logs/daily/2022-04-04.log, each file represent a day, each line of file represent a hit (1 display of an advertisement in someone's browser).

Each line always contains a date-time on 26 characters and an IP on 20 characters.

Currently, the Controller::index and CounterService::countLines methods return fake data. Modify it to return the actual number of lines for each file. (The display of those values as line chart is already working as you can see by running the app with php artisan serve).

You should run composer test and make the unit tests pass:

  • First one checks values returned by index() are the ones expected (your main goal).
  • Second one checks index() can filter the output by dates start and end (included) given as params from URL query.
  • The third one checks that index() is fast enough to be called at least 2000 times per second (your bonus goal).

Submit

Send a ZIP archive with your app directory (any modification done elsewhere will be ignored).

You can run:

php artisan zip

To produce the app.zip automatically in the project root directory.

About

Test using Laravel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published