forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMailMessageTest.php
More file actions
executable file
·34 lines (30 loc) · 1.44 KB
/
MailMessageTest.php
File metadata and controls
executable file
·34 lines (30 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
use Mockery as m;
class MailMessageTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
m::close();
}
public function testBasicAttachment()
{
$swift = m::mock('StdClass');
$message = $this->getMock('Illuminate\Mail\Message', ['createAttachmentFromPath'], [$swift]);
$attachment = m::mock('StdClass');
$message->expects($this->once())->method('createAttachmentFromPath')->with($this->equalTo('foo.jpg'))->will($this->returnValue($attachment));
$swift->shouldReceive('attach')->once()->with($attachment);
$attachment->shouldReceive('setContentType')->once()->with('image/jpeg');
$attachment->shouldReceive('setFilename')->once()->with('bar.jpg');
$message->attach('foo.jpg', ['mime' => 'image/jpeg', 'as' => 'bar.jpg']);
}
public function testDataAttachment()
{
$swift = m::mock('StdClass');
$message = $this->getMock('Illuminate\Mail\Message', ['createAttachmentFromData'], [$swift]);
$attachment = m::mock('StdClass');
$message->expects($this->once())->method('createAttachmentFromData')->with($this->equalTo('foo'), $this->equalTo('name'))->will($this->returnValue($attachment));
$swift->shouldReceive('attach')->once()->with($attachment);
$attachment->shouldReceive('setContentType')->once()->with('image/jpeg');
$message->attachData('foo', 'name', ['mime' => 'image/jpeg']);
}
}