-
Notifications
You must be signed in to change notification settings - Fork 1
2. Debugging and Unit testing
First time you run PHPunit (right-click phpunit.xml and click run) it will try to scare you with a big dialog box. If you already setup a PHP cli interpreter then just click the Fix button and you should be done. Otherwise follow the PHP interpreter section and select the new interpreter.
Tests are probably going to run but they will mostly fail at this point. There are 2 fixes that need to be made before you can move on :
- For PHP to execute database commands properly it our testing environment we need to enable the sqlite driver that comes with it. Enable pdo_sqlite in Laragon's Menu > PHP > Extensions. If you're not planning to run tests locally you're done here.
- To run local tests, more specifically the UI ones, you need to swap a variable in your .env file. Change DB_CONNECTION to
dusk
when you're performing dusk unit tests locally. Otherwise don't touch this and expect only the Feature and Unit test suites to pass, Dusk tests will fail. NOTE : ONLY KEEP THIS CHANGE FOR THE TEST RUNS, YOU SHOULD KEEP IT SET TOMYSQL
DATABASE IN ALL OTHER CASES
I'll probably hook you up with examples later, just remind me.
For now you can start by taking a look at files in your {path to project root}\tests\
folder
We'll be mostly using the laravel debugbar and PHPunit because we need CI on our code but its nice to be able to quickly debug things with breakpoints like any type-safe language, so we'll be installing xDebug do deal with it.
- Download the appropriate version of xDebug (Yours should be 7.2 64bit VC15 TS) click here for direct link
- Move it into your php path inside the ext folder :
{path to laragon}\bin\php\{some_php_version}\ext\
- Rename it to simply
php_xdebug.dll
- Open Laragon's menu > PHP and choose php.ini
- Copy & Paste these lines to the bottom of the file
[XDebug] xdebug.remote_enable = 1 xdebug.remote_handler = dbgp xdebug.remote_host = localhost xdebug.remote_port = 9000
- Finally Restart Laragon and enable xdebug in Menu > PHP > Extensions.
Quick test :
open the window you saw in the PHP interpreter section and refresh your interpreter, it should now say you have xdebug 2.6.0rc1 installed as your debugger.
- Open Run > Edit Configurations
- Click +, choose PHP Web Application and write the start url as
http://soen341.oo
- Click on the 3 dots near server
- Add a new entry as [name wtvr] with host
localhost
on port80
withXDebug
- Ignore path mapping, we're local
- Add a new entry as [name wtvr] with host
- Back in PHP Web App config choose your new server
- You can now run debug which will open a new XDebug session and send you to the index page.
Add breakpoints as you wish, dig through objects and step through as much as your heart desires.
You can tell PHPStorm to listen for incoming PHP Debug connections so you won't have to always run the file manually and navigate to the correct page.
- Copy & paste these extra lines to the bottom of your php.ini
xdebug.remote_autostart = 1
xdebug.idekey = "PHPSTORM"
- In PHPStorm, find the Tools dropdown > DBGp proxy > Configure
- Use the ide key
PHPSTORM
, hostlocalhost
, and port9000
. - In the Run dropdown toogle the Start Listening to PHP Debug Connections at the bottom of the menu
You can now set your breakpoints then switch to the browser and navigate to the pages you want, PHPStorm will pop up on its own when the server hits your breakpoints.
Just cloned? start here - Ready, Set, Debug! - Compiling front-end - Go back home
Below are some useful coding standards you should abide by.
- Create branches per user story / feature as much as possible.
- Make sure your commit passed CI before making a PR.
- Write descriptive commits that reference issues.
- Specify
fixes | closes #<issue id>
at the end of your commits when appropriate. - HTML & CSS
- Javascript
Below are the minutes from each team meeting.
This is a good place to get help.