Completed
Push — master ( d9c87d...d2fca1 )
by Aimeos
06:49
created

StandardTest::testGetBodyFrontendException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Aimeos\Client\Html\Account\History;
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 $object;
14
	private $context;
15
16
17
	protected function setUp()
18
	{
19
		$this->context = \TestHelperHtml::getContext();
20
21
		$paths = \TestHelperHtml::getHtmlTemplatePaths();
22
		$this->object = new \Aimeos\Client\Html\Account\History\Standard( $this->context, $paths );
23
		$this->object->setView( \TestHelperHtml::getView() );
24
	}
25
26
27
	protected function tearDown()
28
	{
29
		unset( $this->object );
30
	}
31
32
33
	public function testGetHeader()
34
	{
35
		$output = $this->object->getHeader();
36
		$this->assertNotNull( $output );
37
	}
38
39
40
	public function testGetHeaderException()
41
	{
42
		$object = $this->getMockBuilder( '\Aimeos\Client\Html\Account\History\Standard' )
43
			->setConstructorArgs( array( $this->context, array() ) )
44
			->setMethods( array( 'setViewParams' ) )
45
			->getMock();
46
47
		$object->expects( $this->once() )->method( 'setViewParams' )
48
			->will( $this->throwException( new \Exception() ) );
49
50
		$object->setView( \TestHelperHtml::getView() );
51
52
		$this->assertEquals( null, $object->getHeader() );
53
	}
54
55
56
	public function testGetBody()
57
	{
58
		$output = $this->object->getBody();
59
		$this->assertStringStartsWith( '<section class="aimeos account-history">', $output );
60
	}
61
62
63
	public function testGetBodyHtmlException()
64
	{
65
		$object = $this->getMockBuilder( '\Aimeos\Client\Html\Account\History\Standard' )
66
			->setConstructorArgs( array( $this->context, array() ) )
67
			->setMethods( array( 'setViewParams' ) )
68
			->getMock();
69
70
		$object->expects( $this->once() )->method( 'setViewParams' )
71
			->will( $this->throwException( new \Aimeos\Client\Html\Exception( 'test exception' ) ) );
72
73
		$object->setView( \TestHelperHtml::getView() );
74
75
		$this->assertContains( 'test exception', $object->getBody() );
76
	}
77
78
79
	public function testGetBodyFrontendException()
80
	{
81
		$object = $this->getMockBuilder( '\Aimeos\Client\Html\Account\History\Standard' )
82
			->setConstructorArgs( array( $this->context, array() ) )
83
			->setMethods( array( 'setViewParams' ) )
84
			->getMock();
85
86
		$object->expects( $this->once() )->method( 'setViewParams' )
87
			->will( $this->throwException( new \Aimeos\Controller\Frontend\Exception( 'test exception' ) ) );
88
89
		$object->setView( \TestHelperHtml::getView() );
90
91
		$this->assertContains( 'test exception', $object->getBody() );
92
	}
93
94
95
	public function testGetBodyMShopException()
96
	{
97
		$object = $this->getMockBuilder( '\Aimeos\Client\Html\Account\History\Standard' )
98
			->setConstructorArgs( array( $this->context, array() ) )
99
			->setMethods( array( 'setViewParams' ) )
100
			->getMock();
101
102
		$object->expects( $this->once() )->method( 'setViewParams' )
103
			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
104
105
		$object->setView( \TestHelperHtml::getView() );
106
107
		$this->assertContains( 'test exception', $object->getBody() );
108
	}
109
110
111
	public function testGetBodyException()
112
	{
113
		$object = $this->getMockBuilder( '\Aimeos\Client\Html\Account\History\Standard' )
114
			->setConstructorArgs( array( $this->context, array() ) )
115
			->setMethods( array( 'setViewParams' ) )
116
			->getMock();
117
118
		$object->expects( $this->once() )->method( 'setViewParams' )
119
			->will( $this->throwException( new \Exception() ) );
120
121
		$object->setView( \TestHelperHtml::getView() );
122
123
		$this->assertContains( 'A non-recoverable error occured', $object->getBody() );
124
	}
125
126
127
	public function testGetSubClient()
128
	{
129
		$client = $this->object->getSubClient( 'lists', 'Standard' );
130
		$this->assertInstanceOf( '\\Aimeos\\Client\\HTML\\Iface', $client );
131
	}
132
133
134
	public function testGetSubClientInvalid()
135
	{
136
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
137
		$this->object->getSubClient( 'invalid', 'invalid' );
138
	}
139
140
141
	public function testGetSubClientInvalidName()
142
	{
143
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
144
		$this->object->getSubClient( '$$$', '$$$' );
145
	}
146
147
148
	public function testProcess()
149
	{
150
		$this->object->process();
151
	}
152
}