Skip to content

Instantly share code, notes, and snippets.

@gcoop
Created April 1, 2011 12:37
Show Gist options
  • Save gcoop/898084 to your computer and use it in GitHub Desktop.
Save gcoop/898084 to your computer and use it in GitHub Desktop.
Template for PHP unit integration tests, testing HTML strings.
<?php
require_once 'test_integration_html_HTML.php';
/**
* Suite of tests for the home page.
*
* @usage
* 1. Just define more functions, any functions starting with the name test will be run.
* 2. Each test function should have one or more asserts. Try not too have too many.
* 3. Each function should test a bunch of similiar stuff for this page like, banners or spot list.
*
*/
class test_integration_html_Home
extends test_integration_html_HTML
{
function testGetHomepage()
{
/* Below doesn't work, bad doctype on current site - will probably be ok when we have HTML5 doctype on!
// XPATH test, got using FF plugin https://addons.mozilla.org/en-US/firefox/addon/xpath-checker/
// Install it, right click on item and click view xpath copy and paste.
$xpath_for_loadtime = '/x:html/x:body/x:div[2]/x:div/x:table/x:tbody/x:tr[3]/x:td/x:div/x:table/x:tbody/x:tr[2]/x:td[7]/x:div';
// Checks the '' (root) page/url (with query params array()) has the xpath.
$this->assertRequestPathWithParamsHasXPath('', array(), $xpath_for_loadtime);
*/
// Just loads the html string of the homeview.
// Do whatever tests you need on this string.
// Complete assert list: http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html
echo($this->loadHTMLString('', array()));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment