One can’t mock magic methods in PHPUnit, because of this error. Trying to configure method “getTrackingSent” which cannot be configured because it does not exist, has not been specified, is final, or is static So my workaround until now was to mock __call, like so: This is okay, if one needs only one or maybeContinue reading “Magento 2, PHPUnit and magic methods”
Tag Archives: phpunit
PHPUnit Code Sprint in Autumn
Last week I traveled to Munich to attend PHPCode Sprint. Once again Sebastian Bergmann invited to work together on PHPUnit, close issues, fix bugs and think weird behaviour by tests, PHPUnit itself and PHP through. A big shout out and thank you goes to celebrate company who hosted once gain the hackathon and took careContinue reading “PHPUnit Code Sprint in Autumn”
PHPUnit and anonymous classes as “mocks”
I implemented a process from login to a third party system. Because I wanted to be sure to use the right keys and don’t mix up anything between the login subscriber, the message creator and the handler which handles the message from the queue. In-memory queue for testing My first idea was to use anContinue reading “PHPUnit and anonymous classes as “mocks””
PHPUnit as a beginner
thePHP.cc is a company offering an education flat rate for PHP developer. Because we are on a good basis with them, they offered us a free seat and we are very happy to have one. The following blog post is the experience our junior developer Bruno Correia has so far. As a junior software developer,Continue reading “PHPUnit as a beginner”
PHPStorm: PHPUnit setUp and tearDown at the top of your class
If you are like me, you prefer your setUp and tearDown methods in your PHPunit tests to be at the top of your classes, so it is easy to see what is going on. But PHPStorm orders it’s methods by default by modifiers, which makes setUp and tearDown normally end up at the bottom. ButContinue reading “PHPStorm: PHPUnit setUp and tearDown at the top of your class”
Events: PHPUnit Code Sprint
Last week Friday/Saturday I had the privilege to join PHPUnit Code Sprint. It was a rather small event with only six people, but the competence was huge. I expected something like our FireGento hackathons, but due to the small group, we started with an introduction how PHPUnit was the last years and then Sebastian BergmannContinue reading “Events: PHPUnit Code Sprint”
PHP + PHPUnit: Don’t catch \Exception – because you don’t handle them properly
We implemented a payment extension for Montonio for Shopware 6 and while incorporating the feedback from the first Shopware code review I stumbled upon a weird bug in our unit test suite. It turns out the error I saw was not the error which happened. The problem For the payment extension we add a coupleContinue reading “PHP + PHPUnit: Don’t catch \Exception – because you don’t handle them properly”