Skip to content

Commit 8bb6907

Browse files
author
Jiri Travnicek
committed
CSSInlinerTest added
1 parent 5d68248 commit 8bb6907

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

tests/CSSInlinerTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Tests;
4+
use Northys\CSSInliner\CSSInliner;
5+
6+
/**
7+
* Class CSSInlinerTest
8+
*
9+
* @package Tests
10+
*/
11+
class CSSInlinerTest extends \PHPUnit_Framework_TestCase
12+
{
13+
14+
/**
15+
* Test Component
16+
*/
17+
public function testComponent()
18+
{
19+
$inliner = new CSSInliner;
20+
$inliner->addCSS(__DIR__ . '/test.css');
21+
$output = $inliner->render(file_get_contents('test.html'), true);
22+
$expected = <<<EXPECTED
23+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
24+
<html><body><h1 style="color: #27ae60; font-size: 200px; margin: 10px 50px 80px 30px;">Hello, world!</h1>
25+
<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>
26+
<a href="http://Facebook.com" class="facebook" style="color: #2c3e50;color: #8e44ad; margin: 300px;">Facebook</a>
27+
<a href="http://Outlook.com" id="outlook" style="color: #2c3e50;color: #2980b9; position: absolute; top: 30px; left: 500px; padding: 50px;">Outlook</a></body></html>
28+
29+
EXPECTED;
30+
$this->assertSame($expected, $output);
31+
}
32+
33+
}

tests/test.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
h1{color:#27ae60;font-size:200px;margin:10px 50px 80px 30px;}
2+
a{color:#2c3e50;}
3+
a#outlook{color:#2980b9;position:absolute;top:30px;left:500px;padding:50px;}
4+
a.facebook{color:#8e44ad;margin:300px;}
5+
a.google{color:#c0392b;font-weight:700;font-family:Verdana, 'Open Sans';font-size:30px;}

tests/test.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<h1>Hello, world!</h1>
2+
<a href="http://google.com" class="google">Google</a>
3+
<a href="http://Facebook.com" class="facebook">Facebook</a>
4+
<a href="http://Outlook.com" id="outlook">Outlook</a>

0 commit comments

Comments
 (0)