Michelangelo van Dam gave recently a presentation about testing Zend Framework applications. His presentation triggered discussion and lots of questions about setting up testing environment for Zend Framework. Because of that he decided to post tutorial about creating the environment, writing simple test, running it and generating some metrics.
We start off by setting our environment best fitted for our unit testing. I use a virtual linux system for this, using VMWare, but with some extra background research these global settings can be applied for your own (test) environment as well.
This is well written introductory tutorial about testing action controllers. It lets you start testing action controllers in 5 minutes.
Testing Zend Framework can be very tricky. The team tries to make framework based applications as much testable as possible, but there are still parts of Zend Framework’s written the way it’s hard to test code based on it. Recently Georgio Sironi was writing about testing view helpers. Today Federico Cargnelutti writes about testing action controllers using mocks.
Unit testing controllers independently has a number of advantages:
- You can develop controllers test-first (TDD).
- It allows you to develop and test all of your controller code before developing any of the view scripts.
- It helps you quickly identify problems in the controller, rather than problems in one of the combination of Model, View and Controller.
What is very interesting about Federico’s post, is that he not only shows example test, but also points reader to some framework’s known issues preventing developers to test particular things. Naturally solution for mention issues is also provided.
At first I didn’t want to publish news about another Zend Framework tutorial. There is quick start guide in official manual and it should be enough. Well, I have realized recently that quick start guide isn’t that quick nor simple anymore. Otherwise people wouldn’t ask about Zend Framework basics like querying database or printing “Hello world”.
PHPEveryday.com contributors had to think the same way. A new set of Zend Framework tutorials has been published on the website. It’s nice overview and Zend Framework and introduction to such components like action controller, database, session, registry and authentication. Pretty much everything one needs to know to start developing in Zend Framework. If you think that official quick start guide is more confusing than helpful, try these tutorials.
I have just published a note about Thomas Weidner working on creating single resource of Zend_Validate error message translations. There is one more useful tool for translators, this time from Pascal Opitz. Pascal has created a helper script that scans view files for untranslated messages and changes them into translate view helper calls.
Manual copy and paste jobs are a pain. Faced with the prospect of internationalizing 30+ big view files, I thought there had to be a better way. When I started to use the reg exp search facility in Textmate, the penny dropped. A helper script is what was needed.
As Pascal writes, his solution is not perfect, but it does the job and can be easily extended. It looks like nice addition to framework’s logging facility of not translated messages. Especially when one has to translate lots of files.
One of most common questions about Zend Framework I hear is availability of Zend_Validate translations. Developers wonder why there is no single resource of all Zend_Validate error messages. Well, there is now. Thomas Weidner is working on creating such resource.
So I created translation resources for Zend_Validate’s error messages. For now you can find them within the Incubator. Look into /incubator/resources/translate/en/Zend_Validate.php. Use the Array Adapter to load them. You can already find pre-translated messages for english (of course) and german.
Although it is still unofficial, it should be already very helpful for everyone working on developing applications supporting multiple languages.