Completed
Push — master ( 5d21ce...a446d4 )
by Aimeos
05:10
created

StandardTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 44
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
B testGet() 0 26 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017
6
 */
7
8
9
namespace Aimeos\Admin\JsonAdm\Service\Config;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $context;
15
	private $object;
16
	private $view;
17
18
19
	protected function setUp()
20
	{
21
		$templatePaths = \TestHelperJadm::getJsonadmPaths();
22
		$this->context = \TestHelperJadm::getContext();
23
		$this->view = $this->context->getView();
24
25
		$this->object = new \Aimeos\Admin\JsonAdm\Service\Config\Standard( $this->context, $this->view, $templatePaths, 'service/config' );
26
	}
27
28
29
	public function testGet()
30
	{
31
		$params = array(
32
			'id' => 'DirectDebit,Category',
33
			'type' => 'payment',
34
		);
35
		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
36
		$this->view->addHelper( 'param', $helper );
37
38
		$response = $this->object->get( $this->view->request(), $this->view->response() );
39
		$result = json_decode( (string) $response->getBody(), true );
40
41
		$this->assertEquals( 200, $response->getStatusCode() );
42
		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
43
44
		$this->assertEquals( 6, $result['meta']['total'] );
45
		$this->assertInternalType( 'array', $result['data'] );
46
		$this->assertEquals( 'payment.url-success', $result['data'][0]['id'] );
47
		$this->assertEquals( 'payment.url-failure', $result['data'][1]['id'] );
48
		$this->assertEquals( 'payment.url-cancel', $result['data'][2]['id'] );
49
		$this->assertEquals( 'payment.url-update', $result['data'][3]['id'] );
50
		$this->assertEquals( 'category.include', $result['data'][4]['id'] );
51
		$this->assertEquals( 'category.exclude', $result['data'][5]['id'] );
52
53
		$this->assertArrayNotHasKey( 'errors', $result );
54
	}
55
}