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

StandardTest::testGetBodyException()   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\Catalog\Count;
4
5
6
/**
7
 * @copyright Metaways Infosystems GmbH, 2014
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 $context;
14
	private $object;
15
16
17
	protected function setUp()
18
	{
19
		$paths = \TestHelperHtml::getHtmlTemplatePaths();
20
		$this->context = \TestHelperHtml::getContext();
21
22
		$this->object = new \Aimeos\Client\Html\Catalog\Count\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\Catalog\Count\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
60
		$this->assertContains( 'var categoryCounts', $output );
61
	}
62
63
64
	public function testGetBodyException()
65
	{
66
		$object = $this->getMockBuilder( '\Aimeos\Client\Html\Catalog\Count\Standard' )
67
			->setConstructorArgs( array( $this->context, array() ) )
68
			->setMethods( array( 'setViewParams' ) )
69
			->getMock();
70
71
		$object->expects( $this->once() )->method( 'setViewParams' )
72
			->will( $this->throwException( new \Exception() ) );
73
74
		$object->setView( \TestHelperHtml::getView() );
75
76
		$this->assertEquals( null, $object->getBody() );
77
	}
78
79
80
	public function testGetSubClient()
81
	{
82
		$client = $this->object->getSubClient( 'tree', 'Standard' );
83
		$this->assertInstanceOf( '\\Aimeos\\Client\\HTML\\Iface', $client );
84
	}
85
86
87
	public function testGetSubClientInvalid()
88
	{
89
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
90
		$this->object->getSubClient( 'invalid', 'invalid' );
91
	}
92
93
94
	public function testGetSubClientInvalidName()
95
	{
96
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
97
		$this->object->getSubClient( '$$$', '$$$' );
98
	}
99
100
}
101