
Untitled
By: a guest on
May 4th, 2012 | syntax:
None | size: 1.89 KB | hits: 11 | expires: Never
how to test HEAD section contains link to CSS file in conditional comments
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="/css/blueprint/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
<!--[if lt IE 8]> <link href="/css/blueprint/ie.css" media="screen, projection" rel="stylesheet" type="text/css" /><![endif]-->
<?php
class BlueprintTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = new Zend_Application(APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini');
parent::setUp();
}
/**
* this test FAILS
*/
public function testBlueprintMSIEScreenCssIncluded()
{
$this->dispatch('/');
$xpath = '/html/head/link'
. '[@rel="stylesheet"]'
. '[@href="/css/blueprint/ie.css"]'
. '[@type="text/css"]'
. '[@media="screen, projection"]';
$this->assertXpathCount($xpath, 1);
}
/**
* this test passes, but i do not like the way it is done:
*/
public function testBlueprintMSIECssIncludedUsingUglyLongGeneratedRegex()
{
$this->dispatch('/');
$p = array(
'rels*=s*"stylesheet"',
'hrefs*=s*"/css/blueprint/ie.css"',
'types*=s*"text/css"',
'medias*=s*"screen, projection"'
);
$tmp = array();
foreach($p as $a) {
foreach($p as $b) {
if($b == $a) continue;
foreach($p as $c) {
if($c == $a || $c == $b) continue;
foreach($p as $d) {
if($d == $a || $d == $b || $d == $c) continue;
$tmp[] = "($as+$bs+$cs+$d)";
}
}
}
}
$pattern = '#<!--[if lt IE 8]>[sn]*'
. '<links+' . implode("|", $tmp) . 's*[/]*>[sn]*'
. '<![endif]-->#im';
$this->assertQueryContentRegex('html head', $pattern);
}