InlineCssLibTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. App::uses('InlineCssLib', 'Tools.Lib');
  3. App::uses('MyCakeTestCase', 'Tools.TestSuite');
  4. class InlineCssLibTest extends MyCakeTestCase {
  5. public function setUp() {
  6. //Configure::write('InlineCss.engine', 'cssToInline');
  7. $this->InlineCss = new InlineCssLib();
  8. parent::setUp();
  9. }
  10. public function testProcess() {
  11. $res = $this->InlineCss->process($this->testHtml);
  12. $this->debug($this->testHtml);
  13. $this->debug($res);
  14. }
  15. public function testProcessPlainPiece() {
  16. $html = 'blabla
  17. <style>
  18. div#container { margin: 1em auto; }
  19. h1 { font-weight: bold; font-size: 2em; }
  20. p { margin-bottom: 1em; font-family: sans-serif; text-align: justify; }
  21. p.small { font-size: 70%; }
  22. </style>
  23. <div id="container">
  24. <h1>Sample Page Title</h1>
  25. <p>Bacon ipsum dolor sit amet in cow elit, in t-bone qui meatloaf corned beef aute ullamco minim. Consequat swine short ribs pastrami jerky.</p>
  26. <p class="small">Some small note!</p>
  27. </div>
  28. bla';
  29. $res = $this->InlineCss->process($html);
  30. $this->debug($html);
  31. $this->debug($res);
  32. }
  33. public $testHtml = '<!doctype html>
  34. <html lang="en">
  35. <head>
  36. <style>
  37. body { font: 11px/20px Georgia, "Times New Roman", Times, serif; }
  38. div#container { margin: 1em auto; }
  39. h1 { font-weight: bold; font-size: 2em; }
  40. p { margin-bottom: 1em; font-family: sans-serif; text-align: justify; }
  41. p.small { font-size: 70%; }
  42. </style>
  43. <title>Example</title>
  44. </head>
  45. <body>
  46. <div id="container">
  47. <h1>Sample Page Title</h1>
  48. <p>Bacon ipsum dolor sit amet in cow elit, in t-bone qui meatloaf corned beef aute ullamco minim. Consequat swine short ribs pastrami jerky.</p>
  49. <p class="small">Some small note!</p>
  50. </div>
  51. </body>
  52. </html>';
  53. }