background preloader

CakePHP Blogs

Facebook Twitter

@TheKeyboard. While recording some screencasts I was struggling to figure out how to get PHPUnit’s built-in object mocking tools to allow me to create what is known as a “test spy”. I talk about them briefly in my PHPUnit Cookbook but I think that what I wanted to do in this instance was beyond what PHPUnit could give me. I had some code-under-test that had a conditional statement inside a foreach() loop (aggravating my desire to use object calisthenics) and I wanted to make sure that both branches of the conditional statement got executed. I first tried something like this: I was using Aura.Sql and it’s Update and Delete objects. I also tried using $this->at(0) and $this->at(1) as well, I got errors ranging from “method query was not mocked” to problems complaining about expected values not showing up at the expected sequence.

I knew there had to be a better way, but I really wanted just to use PHPUnit’s built-in mocking. The code reads a lot smoother: Cake Development Corporation, the CakePHP Framework Experts. What Happends If It Actually Works? Categories. PHP5.5 has support for generators which are a powerful language feature available in other languages like Ruby and Python. While generators in PHP are very much like their Python counterparts, I wanted to give them a spin and try a few simple but useful examples of generators in action.

I recently had the opportunity to speak at PHP Conference Argentina . I’d like to thank Mariano and the other organizers for having me at the event. It was a fantastic opportunity for me to visit Buenos Aires, connect with some friends old and new, and give a new talk about my experiences working on CakePHP. In a previous post, I outlined some changes that would be coming for configuration in CakePHP 3.0. I try to keep fairly busy. Xhgui2 Profiling is a very interesting topic for me. A while back I posted on twitter that I had figured out how to use xdebug & vim and promised to do a blog post on how I got it all working.

Many of the web applications I build have to talk to other webservices. Build tool.