Completed
Push — master ( e9b4e1...6865ff )
by Aimeos
03:59
created

BaseTest::testGetClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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