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

LaravelTest   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 143
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 55
c 1
b 0
f 0
dl 0
loc 143
rs 10
wmc 15

14 Methods

Rating   Name   Duplication   Size   Complexity  
A testAttach() 0 7 1
A setUp() 0 14 2
A tearDown() 0 3 1
A testSend() 0 12 1
A testTo() 0 6 1
A testFrom() 0 6 1
A testBcc() 0 6 1
A testHtml() 0 6 1
A testSender() 0 6 1
A testCc() 0 6 1
A testText() 0 6 1
A testEmbed() 0 6 1
A testReplyTo() 0 6 1
A testSubject() 0 7 1
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