forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMailMessageTest.php
executable file
·37 lines (29 loc) · 1.35 KB
/
MailMessageTest.php
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
35
36
37
<?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', array('createAttachmentFromPath'), array($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', array('mime' => 'image/jpeg', 'as' => 'bar.jpg'));
}
public function testDataAttachment()
{
$swift = m::mock('StdClass');
$message = $this->getMock('Illuminate\Mail\Message', array('createAttachmentFromData'), array($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', array('mime' => 'image/jpeg'));
}
}