Completed
Push — master ( dd223a...70a284 )
by Aimeos
01:50
created

StandardTest::testGet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 0
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( 2, $result['meta']['total'] );
45
		$this->assertInternalType( 'array', $result['data'] );
46
		$this->assertEquals( 'category.include', $result['data'][0]['id'] );
47
		$this->assertEquals( 'category.exclude', $result['data'][1]['id'] );
48
49
		$this->assertArrayNotHasKey( 'errors', $result );
50
	}
51
}