Completed
Push — master ( af70c5...172542 )
by Aimeos
02:11
created

StandardTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
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\Plugin\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\Plugin\Config\Standard( $this->context, $this->view, $templatePaths, 'plugin/config' );
26
	}
27
28
29
	public function testGet()
30
	{
31
		$params = array(
32
			'id' => 'Autofill,Log',
33
		);
34
		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params );
35
		$this->view->addHelper( 'param', $helper );
36
37
		$response = $this->object->get( $this->view->request(), $this->view->response() );
38
		$result = json_decode( (string) $response->getBody(), true );
39
40
		$this->assertEquals( 200, $response->getStatusCode() );
41
		$this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) );
42
43
		$this->assertEquals( 8, $result['meta']['total'] );
44
		$this->assertInternalType( 'array', $result['data'] );
45
		$this->assertEquals( 'autofill.address', $result['data'][0]['id'] );
46
		$this->assertEquals( 'autofill.delivery', $result['data'][1]['id'] );
47
		$this->assertEquals( 'autofill.deliverycode', $result['data'][2]['id'] );
48
		$this->assertEquals( 'autofill.payment', $result['data'][3]['id'] );
49
		$this->assertEquals( 'autofill.paymentcode', $result['data'][4]['id'] );
50
		$this->assertEquals( 'autofill.useorder', $result['data'][5]['id'] );
51
		$this->assertEquals( 'autofill.orderaddress', $result['data'][6]['id'] );
52
		$this->assertEquals( 'autofill.orderservice', $result['data'][7]['id'] );
53
54
		$this->assertArrayNotHasKey( 'errors', $result );
55
	}
56
}