SlimTest::testTransformAbsolute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2020
6
 */
7
8
9
namespace Aimeos\MW\View\Helper\Url;
10
11
12
class SlimTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $router;
16
17
18
	protected function setUp() : void
19
	{
20
		if( !class_exists( 'Slim\Router', false ) ) {
21
			$this->markTestSkipped( '\Slim\Router is not available' );
22
		}
23
24
		$view = new \Aimeos\MW\View\Standard();
25
		$this->router = new \Aimeos\Slim\Router();
26
		$this->object = new \Aimeos\MW\View\Helper\Url\Slim( $view, $this->router, array( 'site' => 'default' ) );
27
	}
28
29
30
	protected function tearDown() : void
31
	{
32
		unset( $this->object, $this->router );
33
	}
34
35
36
	public function testTransform()
37
	{
38
		$this->router->map( array( 'GET' ), 'shop/{site}', null )->setName( 'route' );
39
		$result = $this->object->transform( 'route', 'catalog', 'lists', array( 'key' => 'value' ) );
40
41
		$this->assertEquals( 'shop/default?key=value', $result );
42
	}
43
44
45
	public function testTransformAbsolute()
46
	{
47
		$config = array( 'absoluteUri' => true );
48
49
		$this->router->setBasePath( 'https://localhost/' );
50
		$this->router->map( array( 'GET' ), 'shop/{site}', null )->setName( 'route' );
51
52
		$result = $this->object->transform( 'route', 'catalog', 'lists', array( 'key' => 'value' ), [], $config );
53
54
		$this->assertEquals( 'https://localhost/shop/default?key=value', $result );
55
	}
56
}
57