Skip to content

Commit

Permalink
CSSInlinerTest added
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Travnicek committed Sep 28, 2015
1 parent 5d68248 commit 8bb6907
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/CSSInlinerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Tests;
use Northys\CSSInliner\CSSInliner;

/**
* Class CSSInlinerTest
*
* @package Tests
*/
class CSSInlinerTest extends \PHPUnit_Framework_TestCase
{

/**
* Test Component
*/
public function testComponent()
{
$inliner = new CSSInliner;
$inliner->addCSS(__DIR__ . '/test.css');
$output = $inliner->render(file_get_contents('test.html'), true);
$expected = <<<EXPECTED
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><h1 style="color: #27ae60; font-size: 200px; margin: 10px 50px 80px 30px;">Hello, world!</h1>
<a href="http://google.com" class="google" style='color: #2c3e50;color: #c0392b; font-weight: 700; font-family: Verdana,"Open Sans"; font-size: 30px;'>Google</a>
<a href="http://Facebook.com" class="facebook" style="color: #2c3e50;color: #8e44ad; margin: 300px;">Facebook</a>
<a href="http://Outlook.com" id="outlook" style="color: #2c3e50;color: #2980b9; position: absolute; top: 30px; left: 500px; padding: 50px;">Outlook</a></body></html>
EXPECTED;
$this->assertSame($expected, $output);
}

}
5 changes: 5 additions & 0 deletions tests/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
h1{color:#27ae60;font-size:200px;margin:10px 50px 80px 30px;}
a{color:#2c3e50;}
a#outlook{color:#2980b9;position:absolute;top:30px;left:500px;padding:50px;}
a.facebook{color:#8e44ad;margin:300px;}
a.google{color:#c0392b;font-weight:700;font-family:Verdana, 'Open Sans';font-size:30px;}
4 changes: 4 additions & 0 deletions tests/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>Hello, world!</h1>
<a href="http://google.com" class="google">Google</a>
<a href="http://Facebook.com" class="facebook">Facebook</a>
<a href="http://Outlook.com" id="outlook">Outlook</a>

0 comments on commit 8bb6907

Please sign in to comment.