18 Jul 2010 @ 11:26 PM 

I figured having some unit tests for Maps, the MediaWiki extension to work with geographical data and display it by embedding dynamic maps into your articles, would be beneficial to it’s quality. It’s pretty hard to try cover all possible use cases with manual tests, and consumes a lot of time in any case. I therefore decided to try create some tests for the coordinate parser and formatter class, as it’s arguably the core feature of Maps.

PEAR logoI started off by trying to install plain PHPUnit, which is the most commonly used unit testing framework for PHP. This took me a while, as you are supposed to install it using PEAR (PHP Extension and Application Repository), a repository tool for PHP applications, and has never used this before. After two hours or so of messing around, I got both installed :) Then I went on investigating how I could best integrate this into my work-flow, and discovered that PHPUnit comes bundled with Zend Studio, seamlessly integrated, working completely out of the box o_O.

I then wrote a test case for the coordinate parsing and formatting class of Maps. I had a hard time getting it to work, as I needed to include MW itself, as the class uses MW functions. After some non-constructive discussion with several fellow MW devs I found a way to get it to work by including the maintenance script entry point, and tricking MW into thinking the call was made from a CLI. I now have a test case for the coordinate class, with tests for most of it’s functionality. Some more test data, and maybe some extra tests would be nice. A tricky thing in the case of this class is founding errors, which are hard to take into account, especially if you only want to allow them to a certain degree.

PHPUnit logoThis particular test case is already paying off, as it made me find 3 subtle errors in coordinate parsing or formatting, that did not show up in my manual tests, as I was not covering the test data causing the issues.

I’m now planning to maybe write test cases for the distance parser to, which should be rather easy to do. I probably won’t create any others for Maps, as it’s rather time consuming, and I have a lot of other things to do right now. When I create new classes that are suited for unit tests in the future, I’ll definitely write tests for them as I build them up though, as it’ll not cost a lot more time then doing manual tests, and will ensure the classes are really solid.

PHPUnit integration with Zend Studio

Posted By: Jeroen De Dauw
Last Edit: 23 Jul 2010 @ 05:08 PM

EmailPermalinkComments (0)
Tags
 17 Jul 2010 @ 2:02 AM 

Eclipse, the AWESOME IDEAbout a year back I decided I had to change my development environment from working on a remote server with a simple text editor to something more solid, if I wanted to do serious PHP development.

I went for Eclipse as IDE, which is without a doubt the most awesome IDE out there, as it’s completely open source, robust, and has a lot of extensions that make it usable for an awful lot of languages. For PHP there is the open source PHP Development Tools Project, and the commercial Eclipse based IDE build on top of this, Zend Studio. At that point having my development environment as mobile as possible was rather important, as I often occupied machines other then my laptop or my own desktop. Therefore I put both Eclipse and my server on an usb.

Zend Studio, Eclipse-based AWESOMENESSNow, a year later, a lot has changed, and I finally updated my tools accordingly. First of all, I’m now also using Linux, and plan to leave Windows into the dust bin soon, so prefer tools that work on both operating systems. Secondly, I now only develop on my laptop and own desktop machine, so portability is not as important any more. Also, I’m now doing a lot more serious PHP development as I was doing a year ago, and would benefit a lot from more decent debugging, testing and profiling tools.

What I did was throwing out my mobile web server and install Zend Studio, together with Zend Server Community Edition (which is free). They integrate in such a way that you can do code tracing, work with breakpoints, profile code, ect, all out of the box. If you are developing PHP applications like me and in search for a good tool, I can definitely recommend this. Zend Studio isn’t free, but it’s worth the price. Not going into a complete list of awesome stuff PDT and Zend Studio include, but this blog post, although a little dates, does a good job at it.

Zend logoIt’ll take me a while to integrate these features into my work-flow, as I’m not used to having them available, but I expect this to start paying off rather soon then late :) Also waiting on a new release of Zend Studio build on Eclipse 3.6 (Helios).

(O yeah, can’t write a post about Eclipse without saying: NetBeans fails :P )

Posted By: Jeroen De Dauw
Last Edit: 23 Jul 2010 @ 05:08 PM

EmailPermalinkComments (2)
Tags

 Last 50 Posts
 Back
Change Theme...
  • Users » 4744
  • Posts/Pages » 197
  • Comments » 156
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About me



    No Child Pages.