Attention: before starting the task, you should make sure that you have a working environment configured. Namely:
It is recommended to use Vagrant and the Homestead virtual machine. More details here: https://laravel.com/docs/5.8/homestead
The installation is shown in the OS Linux working environment:
git clone [email protected]:BinaryStudioAcademy/bsa-2019-php-1.git
cd bsa-2019-php-1
composer install
All tasks are divided into folders inside /src
.
Your task, in most cases, will be to supplement the existing code with the missing functionality. The data set for each task will be strictly defined for the purpose of verification in tests.
In the first task (Task1) you need to work with Street Fighter fighters.
You need to create some fighters based on the Fighter
class and use some of the data from the table.
Name | Image |
---|---|
Ryu | https://bit.ly/2E5Pouh |
Chun-Li | https://bit.ly/2Vie3lf |
Ken Masters | https://bit.ly/2VZ2tQd |
Next you need to work with the FightArena
class, implementing the methods
add
all
mostPowerful
(more attack, but less health)mostHealthy
(less attack, but more health)You can check yourself by running:
./vendor/bin/phpunit --testsuite task1
In the second task (Task2), you need to implement a simple generator (using yield
) that returns the following emoji:
'', '', '', '', ''.
To do this, you need to implement the generate
method in the EmojiGenerator
class.
You can check yourself by running:
./vendor/bin/phpunit --testsuite task2
In the third task (Task 3) we will practice with the built-in PHP web server. Your task is to render the list of fighters you created in task 1 and display the page using the built-in web server.
To do this, you need to fill the fighting arena in the index.php
file and implement the present
method of the FightArenaHtmlPresenter
class, based on the test code for the task.
If you are using Homestead, then first you need to stop nginx
.
sudo pkill nginx
Then start the built-in web server:
php -S 0.0.0.0:80 -t ./src/Task3
The command "sudo php -S 0.0.0.0:80 -t ./src/Task3" may be required.
The page will be available in the browser at:
http://192.168.10.10:80 - if you are using homestead
http://127.0.0.1:80 - if you run from a local machine
Some of the code is already contained in the index.php
file.
You can check yourself by running:
./vendor/bin/phpunit --testsuite task3
You may have already noticed that we use PHPUnit to check jobs. This is necessary in order to check whether your solutions meet our expectations (the proposed specification). If you were not previously familiar with PHPUnit, then don't worry. We will look at this in more detail in future lectures.
At this stage, you can assume that this is just an auto-check (like on codewars.com).
At first, all tests are “red”, i.e. broken. In order for them to become working (green) and there are no errors, you need to implement the necessary solutions.
What is the profit from tests?
What not to do
Running all tests:
./vendor/bin/phpunit
Running a test for a specific job:
./vendor/bin/phpunit --testsuite task1
Ideally, you should place your solution in a separate repository on Github or Bitbucket and send a link to it.
Ask questions in the comments to the assignment if you have any problems.
Forking this repository is prohibited !