Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions tests/fixtures/emailConverted.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head><style>
<head>
<style>
.block {
width: 100px;
height: 20px;
}
div.block ul li.small {
margin: 10px;
}
</style></head>
<body>
</style>
</head>
<body>
<div class="block" style="width: 100px; height: 20px;">
text

<ul>
<li>
<li>
Big list
</li>
<li class="small" style="margin: 10px;">
Small list
</li>
</ul>
</div>
</div>
</body>
</html>
19 changes: 17 additions & 2 deletions tests/src/CssInlinerPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testHtmlBody()

$this->mailer->send($message);

$this->assertEquals($this->emailConverted, $message->getBody());
$this->assertStringEqualsStringWithoutIndentation($this->emailConverted, $message->getBody());
}

/**
Expand All @@ -83,7 +83,7 @@ public function testHtmlPart()

$children = $message->getChildren();

$this->assertEquals($this->emailConverted, $children[0]->getBody());
$this->assertStringEqualsStringWithoutIndentation($this->emailConverted, $children[0]->getBody());
}

/**
Expand Down Expand Up @@ -113,4 +113,19 @@ public function testInjectedConverterIsUsedInsteadOfDefault()
$mailer->registerPlugin(new CssInlinerPlugin($converterStub));
$mailer->send($message);
}

/**
* This assert is an ugly hack aiming to fix an indent issue when using libxml < 2.9.5.
*
* @param string $expected
* @param string $actual
* @param string $message
*/
private function assertStringEqualsStringWithoutIndentation($expected, $actual, $message = '')
{
$expected = preg_replace('/^[[:space:]]+|\n/m', '', $expected);
$actual = preg_replace('/^[[:space:]]+|\n/m', '', $actual);

$this->assertEquals($expected, $actual, $message);
}
}