Quantcast
Channel: Gabi Jack's Blog » PHP
Browsing all 4 articles
Browse latest View live

Accessing the value of a private property for unit testing

I was recently given the task of writing unit tests for a function  that instantiates a helper class and stores it in a private variable. It wasn’t hard to generate a  mock for the helper class and...

View Article



Moving and Deleting messages with PHP IMAP

PHP provides a great deal of functions to operate with the IMAP protocol, but implementing them isn’t always so straightforward. For example, how to best mark multiple messages as read or unread, move...

View Article

Quick Tip: Sorting arrays with array_multisort

Sometimes you need to sort an associative array in more than one way. Let’s say you have an array such as this one,  representing the toys inside a toy box. The keys are the name of the toy and the...

View Article

Accessing a Private Method for Testing

Sometimes, I come across a private method in one of the models that I really need to test. Rather than try to change the way the model is written, I’ve found a way around this limitation using...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images