Skip to content

Commit 45138b2

Browse files
authored
Merge pull request #22 from OpenBuildings/fix-tests
Fix tests on libxml < 2.9.5
2 parents c7f933e + 4ba771b commit 45138b2

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

tests/fixtures/emailConverted.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
22
<html>
3-
<head><style>
3+
<head>
4+
<style>
45
.block {
56
width: 100px;
67
height: 20px;
78
}
89
div.block ul li.small {
910
margin: 10px;
1011
}
11-
</style></head>
12-
<body>
12+
</style>
13+
</head>
14+
<body>
1315
<div class="block" style="width: 100px; height: 20px;">
1416
text
1517

1618
<ul>
17-
<li>
19+
<li>
1820
Big list
1921
</li>
2022
<li class="small" style="margin: 10px;">
2123
Small list
2224
</li>
2325
</ul>
24-
</div>
26+
</div>
2527
</body>
2628
</html>

tests/src/CssInlinerPluginTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testHtmlBody()
6666

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

69-
$this->assertEquals($this->emailConverted, $message->getBody());
69+
$this->assertStringEqualsStringWithoutIndentation($this->emailConverted, $message->getBody());
7070
}
7171

7272
/**
@@ -83,7 +83,7 @@ public function testHtmlPart()
8383

8484
$children = $message->getChildren();
8585

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

8989
/**
@@ -113,4 +113,19 @@ public function testInjectedConverterIsUsedInsteadOfDefault()
113113
$mailer->registerPlugin(new CssInlinerPlugin($converterStub));
114114
$mailer->send($message);
115115
}
116+
117+
/**
118+
* This assert is an ugly hack aiming to fix an indent issue when using libxml < 2.9.5.
119+
*
120+
* @param string $expected
121+
* @param string $actual
122+
* @param string $message
123+
*/
124+
private function assertStringEqualsStringWithoutIndentation($expected, $actual, $message = '')
125+
{
126+
$expected = preg_replace('/^[[:space:]]+|\n/m', '', $expected);
127+
$actual = preg_replace('/^[[:space:]]+|\n/m', '', $actual);
128+
129+
$this->assertEquals($expected, $actual, $message);
130+
}
116131
}

0 commit comments

Comments
 (0)