Passed
Push — master ( 82bace...290ab0 )
by Aimeos
02:57
created

StandardTest::testGetBodyHtmlException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 13
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), 2019
6
 */
7
8
9
namespace Aimeos\Client\Html\Basket\Bulk;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
{
14
	private $object;
15
	private $context;
16
17
18
	protected function setUp()
19
	{
20
		$this->context = \TestHelperHtml::getContext();
21
22
		$this->object = new \Aimeos\Client\Html\Basket\Bulk\Standard( $this->context );
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\Basket\Bulk\Standard::class )
43
			->setConstructorArgs( array( $this->context, [] ) )
44
			->setMethods( array( 'addData' ) )
45
			->getMock();
46
47
		$object->expects( $this->once() )->method( 'addData' )
48
			->will( $this->throwException( new \RuntimeException() ) );
49
50
		$object->setView( \TestHelperHtml::getView() );
51
52
		$this->assertEquals( null, $object->getHeader() );
53
	}
54
55
56
	public function testGetBody()
57
	{
58
		$this->assertContains( '<section class="aimeos basket-bulk"', $this->object->getBody() );
59
	}
60
61
62
	public function testGetBodyHtmlException()
63
	{
64
		$object = $this->getMockBuilder( \Aimeos\Client\Html\Basket\Bulk\Standard::class )
65
			->setConstructorArgs( array( $this->context, [] ) )
66
			->setMethods( array( 'addData' ) )
67
			->getMock();
68
69
		$object->expects( $this->once() )->method( 'addData' )
70
			->will( $this->throwException( new \Aimeos\Client\Html\Exception( 'test exception' ) ) );
71
72
		$object->setView( \TestHelperHtml::getView() );
73
74
		$this->assertContains( 'test exception', $object->getBody() );
75
	}
76
77
78
	public function testGetBodyFrontendException()
79
	{
80
		$object = $this->getMockBuilder( \Aimeos\Client\Html\Basket\Bulk\Standard::class )
81
			->setConstructorArgs( array( $this->context, [] ) )
82
			->setMethods( array( 'addData' ) )
83
			->getMock();
84
85
		$object->expects( $this->once() )->method( 'addData' )
86
			->will( $this->throwException( new \Aimeos\Controller\Frontend\Exception( 'test exception' ) ) );
87
88
		$object->setView( \TestHelperHtml::getView() );
89
90
		$this->assertContains( 'test exception', $object->getBody() );
91
	}
92
93
94
	public function testGetBodyMShopException()
95
	{
96
		$object = $this->getMockBuilder( \Aimeos\Client\Html\Basket\Bulk\Standard::class )
97
			->setConstructorArgs( array( $this->context, [] ) )
98
			->setMethods( array( 'addData' ) )
99
			->getMock();
100
101
		$object->expects( $this->once() )->method( 'addData' )
102
			->will( $this->throwException( new \Aimeos\MShop\Exception( 'test exception' ) ) );
103
104
		$object->setView( \TestHelperHtml::getView() );
105
106
		$this->assertContains( 'test exception', $object->getBody() );
107
	}
108
109
110
	public function testGetSubClientInvalid()
111
	{
112
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
113
		$this->object->getSubClient( 'invalid', 'invalid' );
114
	}
115
116
117
	public function testGetSubClientInvalidName()
118
	{
119
		$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' );
120
		$this->object->getSubClient( '$$$', '$$$' );
121
	}
122
}
123