Completed
Push — master ( dd6d00...52e4ba )
by Aimeos
03:58
created

StandardTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 3
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2020
6
 */
7
8
9
namespace Aimeos\Client\Html\Email\Payment\Pdf;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private static $orderItem;
15
	private static $orderBaseItem;
16
	private $object;
17
	private $context;
18
	private $emailMock;
19
20
21
	public static function setUpBeforeClass() : void
22
	{
23
		$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperHtml::getContext() );
24
		$orderBaseManager = $manager->getSubManager( 'base' );
25
26
		$search = $manager->createSearch();
27
		$search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) );
28
29
		if( ( self::$orderItem = $manager->searchItems( $search )->first() ) === null ) {
30
			throw new \RuntimeException( 'No order found' );
31
		}
32
33
		self::$orderBaseItem = $orderBaseManager->load( self::$orderItem->getBaseId() );
34
	}
35
36
37
	protected function setUp() : void
38
	{
39
		$this->context = \TestHelperHtml::getContext();
40
		$this->emailMock = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\Message\\None' )->getMock();
41
42
		$view = \TestHelperHtml::getView( 'unittest', $this->context->getConfig() );
43
		$view->extOrderItem = self::$orderItem;
44
		$view->extOrderBaseItem = self::$orderBaseItem;
45
		$view->addHelper( 'mail', new \Aimeos\MW\View\Helper\Mail\Standard( $view, $this->emailMock ) );
46
47
		$this->object = new \Aimeos\Client\Html\Email\Payment\Pdf\Standard( $this->context );
48
		$this->object->setView( $view );
49
	}
50
51
52
	protected function tearDown() : void
53
	{
54
		unset( $this->object );
55
	}
56
57
58
	public function testGetBody()
59
	{
60
		$this->emailMock->expects( $this->once() )->method( 'addAttachment' );
61
62
		$this->object->setView( $this->object->addData( $this->object->getView() ) );
63
		$this->object->getBody();
64
	}
65
66
67
	public function testGetSubClientInvalid()
68
	{
69
		$this->expectException( '\\Aimeos\\Client\\Html\\Exception' );
70
		$this->object->getSubClient( 'invalid', 'invalid' );
71
	}
72
73
74
	public function testGetSubClientInvalidName()
75
	{
76
		$this->expectException( '\\Aimeos\\Client\\Html\\Exception' );
77
		$this->object->getSubClient( '$$$', '$$$' );
78
	}
79
}
80