Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Search - "phpunit"
Wow, what a fucking mess this sunday was.
My boss wrote me an email that one route of a RESTful API we wrote for a customer was not working anymore and puking back a status 500 with some error mentioning invalid UTF-8 characters.
Not one single person has had touched nor changed the code on production in some 6 months, so what the fuck could it be?
Phpunit did not give any errors (running only locally), the code had no syntax errors and the DB dump did not contain any invalid bytes (tested with a hex editor).
WHAT THE FUCK?!
OK so I started to comment out lines (all tested directly on production of course) until the error vanished.
Guess what was the culprit?
In the code (PHP) we used strftime(...) to get nice time strings. Of course we set the correct locale on the server, thus having months and days formatted in German.
So, in Geman there is this one mysterious month called "März" which contains an umlaut character.
Calling strftime generated the date with März in it, but the server locale was de_CH.iso-8859-1 and not fucking de_CH.utf8, so the "ä" was returned as 0xE4 instead of 0xC3A4 (valid UTF-8), which json_encode(...) did not want to swallow but instead threw an exception.8
Disclaimer: I do not hate indian developers. There are always really good developers from india, its just my luck for not being to work with any of them.
There's this company that my current employer hired them to develop this web application together.
I managed to develop a module for the application, and I wrote some test cases for the module I was working on.
Each time I commit my work to our staging branch, I'll always run the test cases to make sure I didn't break any existing functionalities.
As they do not have permissions to commit directly to the staging branch, they a required to submit a PR for me to review, before merge them.
I've reminded them to run my test cases to make sure whatever their team has developed, doesn't break my modules. But i'm pretty sure, they never did.
Monkeys: hey, we have submitted multiple PRs for to fix some issues, can you merge them?
Me: did you run my test cases to make sure your changes didn't break anything? (You just have to run `phpunit` on the root project directory)
Me: can you guys run them? Make sure they all passing.
Monkeys: *ran command*
Monkeys: we ran the test cases, and there are some errors.
Me: then fix them.
Monkeys: but they are your work, and we do not wish to make any changes to your work.
Fuck this shit. So they broke stuff that I coded, but I have to fix the stuff?23
I'm going to start cutting off hands if people don't write unit tests...it's like eating your vegetables folks...2
WooCommerce is shit
Just try to find anything in the documentation on their retarded website and you will get what I am talking about.
A billion of unstructured links. With absolutely no sidebar or table of contents.
IMPOSSIBLE to find any fuck there.
It is far easier to build an e-store from scratch, than to customize their ugly monster.
Now look Laravel or PHPunit documentation to compare how it should be.
Going back to a php project after writing loads of typescript on a node stack, I suddenly miss the instantanious feedback loop on file save via `nodemon` for basic scripts and `mocha --watch --reporter min` for tests.
Using phpunit, I currently have to rerun the test manually whenever I feel like. Which now feels so annoying. Cause I didn't know besser.
Now I was searching for something similar in php and I find answers pointing me to use either set up some npm hooks or set up gulp task or to use pywatch. phpstorm also is supposed to support file watchers and run test on every save, yet setting them up feels clunky.
alias "phpunit-commit"="phpunit && git add . && git commit"
This have saved me so much time.
- if all GREEN, we add and commit to git
(Yes, theres likely tools for this, and some that run after pushing - but I've already avoided some faulty commits)3
Yesterday at 1:20 am, my first docker image build worked.
- I develop my software (a service in a micro-service architecture) in symfony
- I push it to bitbucket, CircleCI pull the code
- builds a new docker image
- Runs phpunit test using docker exec (lxc-exec, their docker exec doesn't work)
- If the test are successful, CircleCI push the image to hub.docker.com.
Took me hours to fix all the bugs and issues with this process. I feel so proud, yet soooooooooo tired fuck sakes.
I'll publish the template for everything,
- the Dockerfile for the perfect symfony2 image IMO (and I'll create a public symfony2 image)
- The circle.yml I used etc.
Give back to the community.
I love my job.5
PHP gurus / masochists.
I've been using Symfony components for new, isolated features in a legacy php application for awhile now. the time has come to integrate using the kernel, and routing for new endpoints while existing endpoints use the existing apache means of loading pages.
It's not my first rodeo doing this, but I'd appreciate any wisdom/resources/patterns you followed for anyone who's had to do the same.
My clients don't have the means to do hire the appropriate ammount of devs to do a proper port, so this is a long path towards modernization by ceasing to bolt on features to existing code and instead, when working on something, updating it to the new design pattern and then extending that, with a spec, documentation and code coverage.3
Forgot that I have separate sql connection for user model, which won't be affected by phpunit.xml, so that every time I run unit test, two new fake users appears in the database.
Luckily everything's local.
I just want to test my PHP code using phpunit on GitLab, what am I doing wrong?
# Install & enable Xdebug for code coverage reports
- pecl install xdebug
- docker-php-ext-enable xdebug
# Run our tests
# If Xdebug was installed you can generate a coverage report and see code coverage metrics.
- phpunit Test.php4