Completed
Push — master ( 4be27a...24b753 )
by Aimeos
03:01 queued 03:01
created

LaravelTest::testBcc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2022
6
 */
7
8
9
namespace Aimeos\Base\Mail\Message;
10
11
12
class LaravelTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $mock;
16
	private $stub;
17
18
19
	protected function setUp() : void
20
	{
21
		if( !class_exists( 'Illuminate\Mail\Mailer' ) ) {
22
			$this->markTestSkipped( 'Class Illuminate\\Mail\\Mailer not found' );
23
		}
24
25
		$this->mock = $this->getMockBuilder( \Illuminate\Mail\Mailer::class )
26
			->disableOriginalConstructor()
27
			->getMock();
28
29
		$this->stub = $this->getMockBuilder( \Symfony\Component\Mime\Email::class )
30
			->getMock();
31
32
		$this->object = new \Aimeos\Base\Mail\Message\Laravel( $this->mock, $this->stub, 'UTF-8' );
33
	}
34
35
36
	protected function tearDown() : void
37
	{
38
		unset( $this->object, $this->mock, $this->stub );
39
	}
40
41
42
	public function testFrom()
43
	{
44
		$this->stub->expects( $this->once() )->method( 'from' );
45
46
		$result = $this->object->from( 'a@b', 'test' );
47
		$this->assertSame( $this->object, $result );
48
	}
49
50
51
	public function testTo()
52
	{
53
		$this->stub->expects( $this->once() )->method( 'to' );
54
55
		$result = $this->object->to( 'a@b', 'test' );
56
		$this->assertSame( $this->object, $result );
57
	}
58
59
60
	public function testCc()
61
	{
62
		$this->stub->expects( $this->once() )->method( 'cc' );
63
64
		$result = $this->object->cc( 'a@b', 'test' );
65
		$this->assertSame( $this->object, $result );
66
	}
67
68
69
	public function testBcc()
70
	{
71
		$this->stub->expects( $this->once() )->method( 'bcc' );
72
73
		$result = $this->object->bcc( 'a@b', 'test' );
74
		$this->assertSame( $this->object, $result );
75
	}
76
77
78
	public function testReplyTo()
79
	{
80
		$this->stub->expects( $this->once() )->method( 'replyTo' );
81
82
		$result = $this->object->replyTo( 'a@b', 'test' );
83
		$this->assertSame( $this->object, $result );
84
	}
85
86
87
	public function testSend()
88
	{
89
		$transport = $this->getMockBuilder( '\Symfony\Component\Mailer\Transport\TransportInterface' )
90
			->disableOriginalConstructor()
91
			->getMock();
92
93
		$transport->expects( $this->once() )->method( 'send' );
94
95
		$this->mock->expects( $this->once() )->method( 'getSymfonyTransport' )
96
			->will( $this->returnValue( $transport ) );
97
98
		$this->assertSame( $this->object, $this->object->send() );
99
	}
100
101
102
	public function testSender()
103
	{
104
		$this->stub->expects( $this->once() )->method( 'sender' );
105
106
		$result = $this->object->sender( 'a@b', 'test' );
107
		$this->assertSame( $this->object, $result );
108
	}
109
110
111
	public function testSubject()
112
	{
113
		$this->stub->expects( $this->once() )->method( 'subject' )
114
			->with( $this->stringContains( 'test' ) );
115
116
		$result = $this->object->subject( 'test' );
117
		$this->assertSame( $this->object, $result );
118
	}
119
120
121
	public function testText()
122
	{
123
		$this->stub->expects( $this->once() )->method( 'text' )
124
			->with( $this->stringContains( 'test' ) );
125
126
		$this->assertSame( $this->object, $this->object->text( 'test' ) );
127
	}
128
129
130
	public function testHtml()
131
	{
132
		$this->stub->expects( $this->once() )->method( 'html' )
133
			->with( $this->stringContains( 'test' ) );
134
135
		$this->assertSame( $this->object, $this->object->html( 'test' ) );
136
	}
137
138
139
	public function testAttach()
140
	{
141
		$this->stub->expects( $this->once() )->method( 'attach' )
142
			->with( $this->stringContains( 'test' ) );
143
144
		$result = $this->object->attach( 'test' );
145
		$this->assertSame( $this->object, $result );
146
	}
147
148
149
	public function testEmbed()
150
	{
151
		$this->stub->expects( $this->once() )->method( 'embed' )
152
			->with( $this->stringContains( 'test' ) );
153
154
		$this->assertIsString( $this->object->embed( 'test' ) );
155
	}
156
}
157