A little while ago I blogged about the new functional testing opportunities you get with the sfTesterResponse::isValid() method introduced in symfony 1.3. Since then I have played around with sfTesterResponse a bit again and found out that it is more powerfull then you might think when it comes down to testing elements in your Google Sitemaps.
Since sfTesterResponse tries to load your response as DOMDocument object the sfTesterResponse::checkElement() method has access to all the node objects of your response (even when using CSS selector expressions!). This gives you the opportunity to test your XML, HTML, XHTML, etc. response against CSS selector expressions which makes testing a lot easier.
So, if you for example want to test the elements of your dynamically generated Google Sitemap files you can by doing something like the following:
<?php // ... bootstraping of your tests $browser-> // ... tests your run before with('response')->begin()-> // ... other response tests (eg. isValid(), etc.) checkElement('url:first loc', 'http://www.example.com/index.php/')-> end() // ... tests your run after ?>
This code will test if your first url element in your Google Sitemap has a loc element with the value 'http://www.example.com/index.php/'.
This work by Dennis Benkert is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
© 2009 by Dennis Benkert - legal information