Passed
Push — master ( 72d47d...8357d2 )
by Aimeos
13:03 queued 05:09
created

SwiftTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2014-2022
6
 */
7
8
9
namespace Aimeos\Base\Mail;
10
11
12
class SwiftTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $mock;
16
17
18
	protected function setUp() : void
19
	{
20
		if( class_exists( '\Swift_Message' ) === false ) {
21
			$this->markTestSkipped( 'Class Swift_Message not found' );
22
		}
23
24
		$transport = new \Swift_Transport_NullTransport( new \Swift_Events_SimpleEventDispatcher() );
25
26
		$this->mock = $this->getMockBuilder( 'Swift_Mailer' )->setConstructorArgs( array( $transport ) )->getMock();
27
		$this->object = new \Aimeos\Base\Mail\Swift( $this->mock );
28
	}
29
30
31
	protected function tearDown() : void
32
	{
33
		unset( $this->object, $this->mock );
34
	}
35
36
37
	public function testClosure()
38
	{
39
		$mock = $this->mock;
40
		$object = new \Aimeos\Base\Mail\Swift( function() use ( $mock ) { return $mock; } );
41
42
		$this->assertInstanceOf( '\\Aimeos\\Base\\Mail\\Swift', $object );
43
	}
44
45
46
	public function testCreate()
47
	{
48
		$result = $this->object->create( 'ISO-8859-1' );
49
		$this->assertInstanceOf( '\\Aimeos\\Base\\Mail\\Message\\Iface', $result );
50
	}
51
52
53
	public function testSend()
54
	{
55
		$this->mock->expects( $this->once() )->method( 'send' );
56
57
		$this->object->send( $this->object->create() );
58
	}
59
60
61
	public function testClone()
62
	{
63
		$result = clone $this->object;
64
		$this->assertInstanceOf( '\\Aimeos\\Base\\Mail\\Iface', $result );
65
	}
66
}
67