Software for the web
Hello and welcome to AVNet Labs, my portfolio and blog. I build accessible and standards-compliant websites and web applications that account for speed, accessibility and usability while adhering to web standards.
Hello and welcome to AVNet Labs, my portfolio and blog. I build accessible and standards-compliant websites and web applications that account for speed, accessibility and usability while adhering to web standards.
The last part of this series dealt with mocking and stubbing the controller action dependencies to get isolated unit tests. In this section we'll round up the controller tests.
When we left off, we had the following controller class: [php] <?php class IndexController extends Zend_Controller_Action { public function indexAction() { ...
In the last part we tested for the form elements on the home page to meet the first of our requirements. In this part we'll take on a few more requirements starting with the requirement that the form should be redisplayed when I submit invalid details.
For the details to be invalid it means we have validated the data and it failed validation. However our validation code is not done yet but we still need to ensure the controller and view do what we require when the details are invalid.
Zend_Form straddles both the view and model ...
I've just finished going through Zend Framework 1.8 Web Application Development, a new book by Keith Pope. Published by Packt Publishing this book which somehow manages to cater to the ZF beginner as well as the veteran developers is a must-read for anyone doing Zend Framework development.
First impressions are "this guy sure knows his stuff".
Subsequent impressions are "how the &^%$ did this guy know all this stuff?".
The first three chapters are aimed at ZF newbies but even at that I still found a lot of nuggets I had managed to overlook even after working with the Zend Framework for almost 2 years. The first two chapters kick off with a run-through of a Zend ...
In the first part of this series we set up our Zend Framework application and specified our requirements. In this part we'll tackle the first requirement - as a user, I want to visit the home page and see a form where I can enter my full name and email address.
As a first test, I'll make sure I can 'GET' the home page. I do this by testing the Index controller's Index action. I have shown my preferred test directory structure below but here again the Zend Framework has no set structure. [bash] tests |--application ...
Jani Hartikainen has an interesting unit testing series on his blog where he introduces and expands on unit testing php code with phpunit. It's a really good read and it pushed me to add his feed to my reader so I could stop going to the site daily to check for updates.
However, as useful as the series is, it doesn't provide answers to Zend Framework specific testing issues (and considering all the ZF-specific posts on his site, that's quite surprising). It is also aimed at beginner programmers. Most of the programmers I work with don't need ...
From a Virgin Media call center agent before trying to get me to upgrade my package at a 'discount': "Your name has been added to the list of our valued customers."
To me this seems to imply
I just read Bradley Holt's post on using HTML 5 forms with REST and HTTP methods and he mentioned the REST router in the recently released version 1.9 of the Zend Framework. The good news is we don't have to wait for mainstream support for HTML 5.
Zend Framework REST controller supports PUT and DELETE HTTP methods right now through overloading the POST method (ok, it's a bit of hack - but it's worked in Rails for ages). Although the ZF 1.9 announcement mentions using Zend_Rest_Route for public APIs, building any application (or parts of it) restfully has a couple of advantages:
I usually have a bunch of empty Db_Table classes in my Zend Framework apps which just exist to define table names and do the inherited CRUD stuff.
However, with the just released version 1.9 of the framework (currently in beta), I don't need to do this anymore. Zend_Db_Table is now a concrete implementation that accepts a table name as a parameter and can do all the CRUD stuff without needing a class to be defined.
Obviously, if custom code needs to be added to the Db_Table instance a class needs to be created but this will still go a long way towards cleaning up my models folder.
As an example: