Passed
Push — master ( ba1f55...7c0b62 )
by Aimeos
03:42
created

ExampleTest   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 30
c 1
b 0
f 0
dl 0
loc 98
rs 10
wmc 13

13 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetView() 0 3 1
A testSetView() 0 6 1
A testModifyHeader() 0 3 1
A testGetSubClient() 0 3 1
A testCall() 0 4 1
A testModifyBody() 0 3 1
A testInit() 0 3 1
A testBody() 0 4 1
A testHeader() 0 4 1
A setUp() 0 12 1
A tearDown() 0 3 1
A testSetObject() 0 3 1
A testResponse() 0 3 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2014
6
 * @copyright Aimeos (aimeos.org), 2015-2021
7
 */
8
9
10
namespace Aimeos\Client\Html\Common\Decorator;
11
12
13
class ExampleTest extends \PHPUnit\Framework\TestCase
14
{
15
	private $client;
16
	private $object;
17
	private $context;
18
	private $view;
19
20
21
	protected function setUp() : void
22
	{
23
		$this->view = \TestHelperHtml::view();
24
		$this->context = \TestHelperHtml::getContext();
25
26
		$this->client = $this->getMockBuilder( '\\Aimeos\\Client\\Html\\Catalog\\Filter\\Standard' )
27
			->setMethods( array( 'header', 'body', 'testMethod' ) )
28
			->setConstructorArgs( array( $this->context, [] ) )
29
			->getMock();
30
31
		$this->object = new \Aimeos\Client\Html\Common\Decorator\Example( $this->client, $this->context, [] );
0 ignored issues
show
Unused Code introduced by
The call to Aimeos\Client\Html\Commo...\Example::__construct() has too many arguments starting with array(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
		$this->object = /** @scrutinizer ignore-call */ new \Aimeos\Client\Html\Common\Decorator\Example( $this->client, $this->context, [] );

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
32
		$this->object->setView( $this->view );
33
	}
34
35
36
	protected function tearDown() : void
37
	{
38
		unset( $this->object, $this->context, $this->view );
39
	}
40
41
42
	public function testCall()
43
	{
44
		$this->client->expects( $this->once() )->method( 'testMethod' ) ->will( $this->returnValue( true ) );
45
		$this->assertTrue( $this->object->testMethod() );
46
	}
47
48
49
	public function testGetSubClient()
50
	{
51
		$this->assertInstanceOf( '\\Aimeos\\Client\\Html\\Iface', $this->object->getSubClient( 'tree' ) );
52
	}
53
54
55
	public function testHeader()
56
	{
57
		$this->client->expects( $this->once() )->method( 'header' )->will( $this->returnValue( 'header' ) );
58
		$this->assertEquals( 'header', $this->object->header() );
59
	}
60
61
62
	public function testBody()
63
	{
64
		$this->client->expects( $this->once() )->method( 'body' )->will( $this->returnValue( 'body' ) );
65
		$this->assertEquals( 'body', $this->object->body() );
66
	}
67
68
69
	public function testGetView()
70
	{
71
		$this->assertInstanceOf( '\\Aimeos\\MW\\View\\Iface', $this->view );
72
	}
73
74
75
	public function testSetView()
76
	{
77
		$this->view = new \Aimeos\MW\View\Standard();
78
		$this->object->setView( $this->view );
79
80
		$this->assertSame( $this->view, $this->view );
81
	}
82
83
84
	public function testModifyBody()
85
	{
86
		$this->assertEquals( 'test', $this->object->modifyBody( 'test', 1 ) );
87
	}
88
89
90
	public function testModifyHeader()
91
	{
92
		$this->assertEquals( 'test', $this->object->modifyHeader( 'test', 1 ) );
93
	}
94
95
96
	public function testInit()
97
	{
98
		$this->object->init();
99
	}
100
101
102
	public function testResponse()
103
	{
104
		$this->assertInstanceOf( '\Psr\Http\Message\ResponseInterface', $this->object->response() );
105
	}
106
107
108
	public function testSetObject()
109
	{
110
		$this->assertInstanceOf( \Aimeos\Client\Html\Iface::class, $this->object->setObject( $this->object ) );
111
	}
112
113
}
114