StandardTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testGet() 0 22 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2025
6
 */
7
8
9
namespace Aimeos\Admin\JsonAdm\Coupon\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() : void
20
	{
21
		$this->context = \TestHelper::context();
22
		$this->view = $this->context->view();
23
24
		$this->object = new \Aimeos\Admin\JsonAdm\Coupon\Config\Standard( $this->context, 'coupon/config' );
25
		$this->object->setAimeos( \TestHelper::getAimeos() );
26
		$this->object->setView( $this->view );
27
	}
28
29
30
	public function testGet()
31
	{
32
		$params = array(
33
			'id' => 'None,Required,Basket',
34
		);
35
		$helper = new \Aimeos\Base\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( 4, $result['meta']['total'] );
45
		$this->assertIsArray( $result['data'] );
46
		$this->assertEquals( 'required.productcode', $result['data'][0]['id'] );
47
		$this->assertEquals( 'required.only', $result['data'][1]['id'] );
48
		$this->assertEquals( 'basket.total-value-min', $result['data'][2]['id'] );
49
		$this->assertEquals( 'basket.total-value-max', $result['data'][3]['id'] );
50
51
		$this->assertArrayNotHasKey( 'errors', $result );
52
	}
53
}
54