Completed
Push — master ( b4d1c4...5b98ac )
by Aimeos
05:50
created

StandardTest::testGetSubClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Aimeos\Client\Html\Email\Payment\Html\Summary;
4
5
6
/**
7
 * @copyright Metaways Infosystems GmbH, 2013
8
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
9
 * @copyright Aimeos (aimeos.org), 2015
10
 */
11
class StandardTest extends \PHPUnit_Framework_TestCase
12
{
13
	private static $orderItem;
14
	private static $orderBaseItem;
15
	private $object;
16
	private $context;
17
	private $emailMock;
18
19
20
	public static function setUpBeforeClass()
21
	{
22
		$orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager( \TestHelperHtml::getContext() );
23
		$orderBaseManager = $orderManager->getSubManager( 'base' );
24
25
		$search = $orderManager->createSearch();
26
		$search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) );
27
		$result = $orderManager->searchItems( $search );
28
29
		if( ( self::$orderItem = reset( $result ) ) === false ) {
30
			throw new \Exception( 'No order found' );
31
		}
32
33
		self::$orderBaseItem = $orderBaseManager->load( self::$orderItem->getBaseId() );
34
	}
35
36
37
	/**
38
	 * Sets up the fixture, for example, opens a network connection.
39
	 * This method is called before a test is executed.
40
	 *
41
	 * @access protected
42
	 */
43
	protected function setUp()
44
	{
45
		$this->context = \TestHelperHtml::getContext();
46
		$this->emailMock = $this->getMock( '\\Aimeos\\MW\\Mail\\Message\\None' );
47
48
		$paths = \TestHelperHtml::getHtmlTemplatePaths();
49
		$this->object = new \Aimeos\Client\Html\Email\Payment\Html\Summary\Standard( $this->context, $paths );
50
51
		$view = \TestHelperHtml::getView();
52
		$view->extOrderItem = self::$orderItem;
53
		$view->extOrderBaseItem = self::$orderBaseItem;
54
		$view->addHelper( 'mail', new \Aimeos\MW\View\Helper\Mail\Standard( $view, $this->emailMock ) );
55
56
		$this->object->setView( $view );
57
	}
58
59
60
	/**
61
	 * Tears down the fixture, for example, closes a network connection.
62
	 * This method is called after a test is executed.
63
	 *
64
	 * @access protected
65
	 */
66
	protected function tearDown()
67
	{
68
		unset( $this->object );
69
	}
70
71
72
	public function testGetHeader()
73
	{
74
		$output = $this->object->getHeader();
75
		$this->assertNotNull( $output );
76
	}
77
78
79
	public function testGetBody()
80
	{
81
		$output = $this->object->getBody();
82
83
		$this->assertStringStartsWith( '<div class="common-summary content-block">', $output );
84
		$this->assertContains( '<div class="common-summary-address container">', $output );
85
		$this->assertContains( '<div class="common-summary-service container">', $output );
86
		$this->assertContains( '<div class="common-summary-coupon container">', $output );
87
		$this->assertContains( '<div class="common-summary-detail container">', $output );
88
	}
89
90
91
	public function testGetSubClient()
92
	{
93
		$client = $this->object->getSubClient( 'detail' );
94
		$this->assertInstanceOf( '\Aimeos\Client\Html\Iface', $client );
95
	}
96
97
98
	public function testGetSubClientInvalid()
99
	{
100
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
101
		$this->object->getSubClient( 'invalid', 'invalid' );
102
	}
103
104
105
	public function testGetSubClientInvalidName()
106
	{
107
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
108
		$this->object->getSubClient( '$$$', '$$$' );
109
	}
110
111
112
	public function testProcess()
113
	{
114
		$this->object->process();
115
	}
116
}
117