BaseTest   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 35
dl 0
loc 94
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A access() 0 7 1
A testPut() 0 6 1
A testGetClient() 0 4 1
A testOptions() 0 6 1
A testPatch() 0 6 1
A testDelete() 0 6 1
A testPost() 0 6 1
A testGet() 0 6 1
A setUp() 0 10 1
A tearDown() 0 3 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2025
6
 */
7
8
9
namespace Aimeos\Client\JsonApi\Common\Decorator;
10
11
12
class Example extends Base
13
{
14
}
15
16
17
class BaseTest extends \PHPUnit\Framework\TestCase
18
{
19
	private $object;
20
	private $stub;
21
	private $view;
22
23
24
	protected function setUp() : void
25
	{
26
		$context = \TestHelper::context();
27
		$this->view = $context->view();
28
29
		$this->stub = $this->getMockBuilder( \Aimeos\Client\JsonApi\Standard::class )
30
			->setConstructorArgs( [$context, 'attribute'] )
31
			->getMock();
32
33
		$this->object = new \Aimeos\Client\JsonApi\Common\Decorator\Example( $this->stub, $context, '' );
34
	}
35
36
37
	protected function tearDown() : void
38
	{
39
		unset( $this->object, $this->stub, $this->view );
40
	}
41
42
43
	public function testDelete()
44
	{
45
		$this->stub->expects( $this->once() )->method( 'delete' )->willReturnArgument( 1 );
46
		$response = $this->view->response();
47
48
		$this->assertSame( $response, $this->object->delete( $this->view->request(), $response ) );
49
	}
50
51
52
	public function testGet()
53
	{
54
		$this->stub->expects( $this->once() )->method( 'get' )->willReturnArgument( 1 );
55
		$response = $this->view->response();
56
57
		$this->assertSame( $response, $this->object->get( $this->view->request(), $response ) );
58
	}
59
60
61
	public function testPatch()
62
	{
63
		$this->stub->expects( $this->once() )->method( 'patch' )->willReturnArgument( 1 );
64
		$response = $this->view->response();
65
66
		$this->assertSame( $response, $this->object->patch( $this->view->request(), $response ) );
67
	}
68
69
70
	public function testPost()
71
	{
72
		$this->stub->expects( $this->once() )->method( 'post' )->willReturnArgument( 1 );
73
		$response = $this->view->response();
74
75
		$this->assertSame( $response, $this->object->post( $this->view->request(), $response ) );
76
	}
77
78
79
	public function testPut()
80
	{
81
		$this->stub->expects( $this->once() )->method( 'put' )->willReturnArgument( 1 );
82
		$response = $this->view->response();
83
84
		$this->assertSame( $response, $this->object->put( $this->view->request(), $response ) );
85
	}
86
87
88
	public function testOptions()
89
	{
90
		$this->stub->expects( $this->once() )->method( 'options' )->willReturnArgument( 1 );
91
		$response = $this->view->response();
92
93
		$this->assertSame( $response, $this->object->options( $this->view->request(), $response ) );
94
	}
95
96
97
	public function testGetClient()
98
	{
99
		$result = $this->access( 'getClient' )->invokeArgs( $this->object, [] );
100
		$this->assertSame( $this->stub, $result );
101
	}
102
103
104
	protected function access( $name )
105
	{
106
		$class = new \ReflectionClass( \Aimeos\Client\JsonApi\Common\Decorator\Base::class );
107
		$method = $class->getMethod( $name );
108
		$method->setAccessible( true );
109
110
		return $method;
111
	}
112
}
113