Skip to content

Commit 3b5b80d

Browse files
authored
Merge pull request #16 from OpenBuildings/css-inliner-upgrade
Upgrade tijsverkoyen/css-to-inline-styles to 2.0
2 parents 6b3121c + bbca57f commit 3b5b80d

File tree

6 files changed

+25
-44
lines changed

6 files changed

+25
-44
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ env:
1818

1919
matrix:
2020
fast_finish: true
21+
allow_failures:
22+
- php: hhvm
2123
exclude:
2224
- php: hhvm
2325
env: DEPS=lowest

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require" : {
1313
"php": ">=5.4",
1414
"swiftmailer/swiftmailer": "^5.1",
15-
"tijsverkoyen/css-to-inline-styles": "^1.5"
15+
"tijsverkoyen/css-to-inline-styles": "^2.0"
1616
},
1717
"require-dev" : {
1818
"phpunit/phpunit": "^4.0|^5.0",

composer.lock

Lines changed: 11 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/CssInlinerPlugin.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function __construct(CssToInlineStyles $converter = null)
2828
$this->converter = $converter;
2929
} else {
3030
$this->converter = new CssToInlineStyles();
31-
$this->converter->setUseInlineStylesBlock(true);
3231
}
3332
}
3433

@@ -40,18 +39,12 @@ public function beforeSendPerformed(Swift_Events_SendEvent $event)
4039
$message = $event->getMessage();
4140

4241
if ($message->getContentType() === 'text/html') {
43-
$this->converter->setCSS('');
44-
$this->converter->setHTML($message->getBody());
45-
46-
$message->setBody($this->converter->convert());
42+
$message->setBody($this->converter->convert($message->getBody()));
4743
}
4844

4945
foreach ($message->getChildren() as $part) {
5046
if (strpos($part->getContentType(), 'text/html') === 0) {
51-
$this->converter->setCSS('');
52-
$this->converter->setHTML($part->getBody());
53-
54-
$part->setBody($this->converter->convert());
47+
$part->setBody($this->converter->convert($part->getBody()));
5548
}
5649
}
5750
}

tests/fixtures/emailConverted.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2-
<html><head><style>
2+
<html>
3+
<head>
4+
<style><![CDATA[
35
.block {
46
width: 100px;
57
height: 20px;
68
}
79
div.block ul li.small {
810
margin: 10px;
911
}
10-
</style></head><body>
11-
<div class="block" style="height: 20px; width: 100px;">
12+
]]></style>
13+
</head>
14+
<body>
15+
<div class="block" style="width: 100px; height: 20px;">
1216
text
1317

1418
<ul><li>
@@ -18,4 +22,5 @@
1822
Small list
1923
</li>
2024
</ul></div>
21-
</body></html>
25+
</body>
26+
</html>

tests/src/CssInlinerPluginTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,6 @@ public function testHtmlPart()
8787
$this->assertEquals($this->emailConverted, $children[0]->getBody());
8888
}
8989

90-
/**
91-
* @covers ::__construct
92-
*/
93-
public function testDefaultConverterUsesInlineStylesBlock()
94-
{
95-
$plugin = new CssInlinerPlugin();
96-
97-
$converter = PHPUnit_Framework_Assert::readAttribute($plugin, 'converter');
98-
99-
$this->assertTrue(
100-
PHPUnit_Framework_Assert::readAttribute(
101-
$converter,
102-
'useInlineStylesBlock'
103-
),
104-
'setUseInlineStylesBlock() should be called on default $converter'
105-
);
106-
}
107-
10890
/**
10991
* @covers ::__construct
11092
* @covers ::beforeSendPerformed

0 commit comments

Comments
 (0)