Skip to content

Commit

Permalink
HTML 5 format tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Roelof Roos committed Mar 6, 2020
1 parent 14a9ce8 commit 0ca8a5d
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/FormatTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Eduardokum\LaravelMailAutoEmbed\Tests;

use Eduardokum\LaravelMailAutoEmbed\Listeners\SwiftEmbedImages;
use Eduardokum\LaravelMailAutoEmbed\Tests\Traits\InteractsWithSwift;

/**
* Tests some scenarios, like HTML5 mails and mail with "invalid" HTML that mail clients
* like
*/
class FormatTest extends TestCase
{
use InteractsWithSwift;
private const HANDLE_CONFIG = [
'enabled' => true,
'method' => 'attachment'
];

/**
* @test
*/
public function testValidHtml5Message()
{
$message = $this->handleBeforeSendPerformedEvent('formats/html5-valid.html', self::HANDLE_CONFIG);

$this->assertEmailImageTags([
'url' => 'cid:',
'entity' => 'cid:',
], $message->getBody());
}

/**
* @test
*/
public function testUserGeneratedHtml5Message()
{
$message = $this->handleBeforeSendPerformedEvent('formats/html5-user-generated.html', self::HANDLE_CONFIG);

$this->assertEmailImageTags([
'url' => 'cid:',
'entity' => 'cid:',
], $message->getBody());
}
}
72 changes: 72 additions & 0 deletions tests/lib/formats/html5-user-generated.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
</head>

<body>
<main>
<article>
<h1>Lorem Ipsum</h1>

<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla, dolorum assumenda aliquam blanditiis,
necessitatibus mollitia delectus sapiente amet earum minima qui non deserunt quidem, doloremque
architecto voluptatem eveniet illo aperiam.
</p>

<p>
<!-- Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/colgroup -->
<table>
<caption>Superheros and sidekicks</caption>
<colgroup>
<col>
<col span="2" class="batman">
<col span="2" class="flash">
</colgroup>
<tr>
<td> </td>
<th scope="col">Batman</th>
<th scope="col">Robin</th>
<th scope="col">The Flash</th>
<th scope="col">Kid Flash</th>
</tr>
<tr>
<th scope="row">Skill</th>
<td>Smarts</td>
<td>Dex, acrobat</td>
<td>Super speed</td>
<td>Super speed</td>
</tr>
</table>
</p>

<p>
<figure>
<!-- url --><img src="http://localhost/test.png" />
<caption>Lorem ipsum</caption>
</figure>
</p>
</article>

<aside>
<header>
<h1>Lorem Ipsum</h1>
</header>

<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore cum, blanditiis a minima aspernatur
corporis pariatur, perferendis explicabo consectetur tenetur iste, fuga possimus corrupti dolorem
laudantium sapiente sunt error autem.
</p>

<figure>
<!-- entity --><img src="embed:Eduardokum\LaravelMailAutoEmbed\Tests\fixtures\PictureEntity:1" />
<caption>Lorem Ipsum</caption>
</figure>
</aside>
</main>
</body>

</html>
45 changes: 45 additions & 0 deletions tests/lib/formats/html5-valid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
</head>

<body>
<main>
<article>
<h1>Lorem Ipsum</h1>

<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nulla, dolorum assumenda aliquam blanditiis,
necessitatibus mollitia delectus sapiente amet earum minima qui non deserunt quidem, doloremque
architecto voluptatem eveniet illo aperiam.
</p>


<figure>
<!-- url --><img src="http://localhost/test.png" />
<caption>Lorem ipsum</caption>
</figure>
</article>

<aside>
<header>
<h1>Lorem Ipsum</h1>
</header>

<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore cum, blanditiis a minima aspernatur
corporis pariatur, perferendis explicabo consectetur tenetur iste, fuga possimus corrupti dolorem
laudantium sapiente sunt error autem.
</p>

<figure>
<!-- entity --><img src="embed:Eduardokum\LaravelMailAutoEmbed\Tests\fixtures\PictureEntity:1" />
<caption>Lorem Ipsum</caption>
</figure>
</aside>
</main>
</body>

</html>

0 comments on commit 0ca8a5d

Please sign in to comment.