StandardTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2025
6
 */
7
8
9
namespace Aimeos\Base\View\Helper\Value;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
16
17
	protected function setUp() : void
18
	{
19
		$view = new \Aimeos\Base\View\Standard();
20
		$view->list = ['a' => 1, 'b' => 2, 'c' => 2];
0 ignored issues
show
Bug Best Practice introduced by
The property list does not exist on Aimeos\Base\View\Standard. Since you implemented __set, consider adding a @property annotation.
Loading history...
21
22
		$this->object = new \Aimeos\Base\View\Helper\Value\Standard( $view );
23
	}
24
25
26
	protected function tearDown() : void
27
	{
28
		$this->object = null;
29
	}
30
31
32
	public function testTransform()
33
	{
34
		$params = array( 'key' => 'test', 'list' => array( 'test' => array( 'key' => 'value' ) ) );
35
36
		$this->assertEquals( 'test', $this->object->transform( $params, 'key', 'none' ) );
37
		$this->assertEquals( 'value', $this->object->transform( $params, '/list/test/key', 'none' ) );
38
		$this->assertEquals( 'none', $this->object->transform( $params, 'missing', 'none' ) );
39
	}
40
41
42
	public function testTransformNoDefault()
43
	{
44
		$params = array( 'key' => 'test', 'list' => array( 'test' => array( 'key' => 'value' ) ) );
45
46
		$this->assertEquals( 'test', $this->object->transform( $params, 'key' ) );
47
		$this->assertEquals( 'value', $this->object->transform( $params, '/list/test/key' ) );
48
		$this->assertEquals( null, $this->object->transform( $params, 'missing' ) );
49
	}
50
51
52
	public function testTransformString()
53
	{
54
		$this->assertEquals( 1, $this->object->transform( 'list', 'a', 'none' ) );
55
		$this->assertEquals( 'none', $this->object->transform( 'list', 'd', 'none' ) );
56
	}
57
}
58