Christer’s blog o’ fun

August 17, 2009

Force Zend_Http_Client_Adapter_Test to fail

Filed under: PHP, Technology, Work related — Tags: , , , , — christer @ 2:25 pm

At work we have a component in our internal framework for fetching content from remote sources. The component utilizes something called availability caching which means that it will cache the remote content and use it when the remote server is down. We use Zend_Http_Client internally and to fully test our component we needed the remote server (which is not really a remote server at all in our test suite) to fail on demand.

In our tests we simply use the Zend_Http_Client_Adapter_Test adapter with the Zend_Http_Client instance instead of the default adapter. Using this we can tell the client what to return so we can make sure our own component behaves like it should. I implemented a method in the test adapter called setNextRequestWillFail() which takes a boolean flag as a parameter. The result when calling this method with boolean true is that the adapter will throw a Zend_Http_Client_Adapter_Exception exception on the next request. This allowed us to force the “remote server” to fail so we could test our availability cache.

The fix has been commited to Zend Framework trunk and will hopefully be added soon.

August 14, 2009

Small contribution to phploc

Filed under: PHP, Technology — Tags: , , , , — christer @ 12:27 pm

From http://github.com/sebastianbergmann/phploc/tree/master:

phploc is a tool for quickly measuring the size of a PHP project.

I just made a small contribution to it by adding counters for constants and class constants. My account over at github is located at http://github.com/christeredvartsen. Sebastian pushed it to the master repository about an hour ago.

I have also patched our phpUnderControl installation at work to output this information and contacted Manuel Pichler about it. More about that later!

August 3, 2009

AOTW 28, 2009: Satyricon – Volcano

Filed under: AOTW, Music — Tags: , , — christer @ 2:25 pm

The award for week 28 goes to Volcano by the Norwegian black metallers Satyricon.

My favorite tracks:

Spotify: http://open.spotify.com/album/6p2HHKAfZu0LE1oMPw3xzF

Finished my first bicycle race

Filed under: Cycling — Tags: , , , — christer @ 1:05 pm

Last Saturday I finished my first MTB race: Grenserittet Cross Countries. This race is the largest in Sweden and the second largest in Norway. It starts in Strömstad, Sweden and ends in Halden, Norway 81 kilometers later.

I finished in 3 hours and 49 minutes. My goal was to beat the 4 hour mark so I’m quite happy with the result. Hopefully I’ll be able to participate next year as well!

Blog at WordPress.com.