Guest User

Untitled

a guest
May 4th, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. how to test HEAD section contains link to CSS file in conditional comments
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <title></title>
  6. <link href="/css/blueprint/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
  7. <!--[if lt IE 8]> <link href="/css/blueprint/ie.css" media="screen, projection" rel="stylesheet" type="text/css" /><![endif]-->
  8.  
  9. <?php
  10. class BlueprintTest extends Zend_Test_PHPUnit_ControllerTestCase
  11. {
  12. public function setUp()
  13. {
  14. $this->bootstrap = new Zend_Application(APPLICATION_ENV,
  15. APPLICATION_PATH . '/configs/application.ini');
  16. parent::setUp();
  17. }
  18.  
  19. /**
  20. * this test FAILS
  21. */
  22. public function testBlueprintMSIEScreenCssIncluded()
  23. {
  24. $this->dispatch('/');
  25. $xpath = '/html/head/link'
  26. . '[@rel="stylesheet"]'
  27. . '[@href="/css/blueprint/ie.css"]'
  28. . '[@type="text/css"]'
  29. . '[@media="screen, projection"]';
  30. $this->assertXpathCount($xpath, 1);
  31. }
  32.  
  33. /**
  34. * this test passes, but i do not like the way it is done:
  35. */
  36. public function testBlueprintMSIECssIncludedUsingUglyLongGeneratedRegex()
  37. {
  38. $this->dispatch('/');
  39. $p = array(
  40. 'rels*=s*"stylesheet"',
  41. 'hrefs*=s*"/css/blueprint/ie.css"',
  42. 'types*=s*"text/css"',
  43. 'medias*=s*"screen, projection"'
  44. );
  45. $tmp = array();
  46. foreach($p as $a) {
  47. foreach($p as $b) {
  48. if($b == $a) continue;
  49. foreach($p as $c) {
  50. if($c == $a || $c == $b) continue;
  51. foreach($p as $d) {
  52. if($d == $a || $d == $b || $d == $c) continue;
  53. $tmp[] = "($as+$bs+$cs+$d)";
  54. }
  55. }
  56. }
  57. }
  58.  
  59. $pattern = '#<!--[if lt IE 8]>[sn]*'
  60. . '<links+' . implode("|", $tmp) . 's*[/]*>[sn]*'
  61. . '<![endif]-->#im';
  62. $this->assertQueryContentRegex('html head', $pattern);
  63. }
Advertisement
Add Comment
Please, Sign In to add comment