BaseTest::testGetClient()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
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), 2015-2025
6
 */
7
8
9
namespace Aimeos\Admin\JsonAdm\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->createMock( '\Aimeos\Admin\JsonAdm\Standard' );
30
31
		$this->object = new \Aimeos\Admin\JsonAdm\Common\Decorator\Example( $this->stub, $context, '' );
32
	}
33
34
35
	protected function tearDown() : void
36
	{
37
		unset( $this->object, $this->stub, $this->view );
38
	}
39
40
41
	public function testDelete()
42
	{
43
		$this->stub->expects( $this->once() )->method( 'delete' )->willReturnArgument( 1 );
44
		$response = $this->view->response();
45
46
		$this->assertSame( $response, $this->object->delete( $this->view->request(), $response ) );
47
	}
48
49
50
	public function testGet()
51
	{
52
		$this->stub->expects( $this->once() )->method( 'get' )->willReturnArgument( 1 );
53
		$response = $this->view->response();
54
55
		$this->assertSame( $response, $this->object->get( $this->view->request(), $response ) );
56
	}
57
58
59
	public function testPatch()
60
	{
61
		$this->stub->expects( $this->once() )->method( 'patch' )->willReturnArgument( 1 );
62
		$response = $this->view->response();
63
64
		$this->assertSame( $response, $this->object->patch( $this->view->request(), $response ) );
65
	}
66
67
68
	public function testPost()
69
	{
70
		$this->stub->expects( $this->once() )->method( 'post' )->willReturnArgument( 1 );
71
		$response = $this->view->response();
72
73
		$this->assertSame( $response, $this->object->post( $this->view->request(), $response ) );
74
	}
75
76
77
	public function testPut()
78
	{
79
		$this->stub->expects( $this->once() )->method( 'put' )->willReturnArgument( 1 );
80
		$response = $this->view->response();
81
82
		$this->assertSame( $response, $this->object->put( $this->view->request(), $response ) );
83
	}
84
85
86
	public function testOptions()
87
	{
88
		$this->stub->expects( $this->once() )->method( 'options' )->willReturnArgument( 1 );
89
		$response = $this->view->response();
90
91
		$this->assertSame( $response, $this->object->options( $this->view->request(), $response ) );
92
	}
93
94
95
	public function testGetClient()
96
	{
97
		$result = $this->access( 'getClient' )->invokeArgs( $this->object, [] );
98
		$this->assertSame( $this->stub, $result );
99
	}
100
101
102
	protected function access( $name )
103
	{
104
		$class = new \ReflectionClass( \Aimeos\Admin\JsonAdm\Common\Decorator\Base::class );
105
		$method = $class->getMethod( $name );
106
		$method->setAccessible( true );
107
108
		return $method;
109
	}
110
}
111