1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2025 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Base\View\Helper\Url; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Test class for \Aimeos\Base\View\Helper\Url\Symfony. |
14
|
|
|
*/ |
15
|
|
|
class SymfonyTest extends \PHPUnit\Framework\TestCase |
16
|
|
|
{ |
17
|
|
|
private $object; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Sets up the fixture, for example, opens a network connection. |
22
|
|
|
* This method is called before a test is executed. |
23
|
|
|
* |
24
|
|
|
* @access protected |
25
|
|
|
*/ |
26
|
|
|
protected function setUp() : void |
27
|
|
|
{ |
28
|
|
|
if( !class_exists( '\Symfony\Component\Routing\Router' ) ) { |
29
|
|
|
$this->markTestSkipped( 'Symfony\Component\Routing\Router is not available' ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
$view = new \Aimeos\Base\View\Standard(); |
33
|
|
|
|
34
|
|
|
$loc = new \Symfony\Component\Config\FileLocator( array( __DIR__ . DIRECTORY_SEPARATOR . '_testfiles' ) ); |
35
|
|
|
$loader = new \Symfony\Component\Routing\Loader\PhpFileLoader( $loc ); |
36
|
|
|
$router = new \Symfony\Component\Routing\Router( $loader, 'routing.php' ); |
37
|
|
|
|
38
|
|
|
$this->object = new \Aimeos\Base\View\Helper\Url\Symfony( $view, $router, array( 'site' => 'unittest' ) ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Tears down the fixture, for example, closes a network connection. |
44
|
|
|
* This method is called after a test is executed. |
45
|
|
|
* |
46
|
|
|
* @access protected |
47
|
|
|
*/ |
48
|
|
|
protected function tearDown() : void |
49
|
|
|
{ |
50
|
|
|
$this->object = null; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
public function testTransform() |
55
|
|
|
{ |
56
|
|
|
$this->assertEquals( '/unittest/lists', $this->object->transform( 'catalog_list' ) ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
public function testTransformArrays() |
61
|
|
|
{ |
62
|
|
|
$this->assertEquals( '/unittest/lists?test%5B0%5D=a&test%5B1%5D=b', $this->object->transform( 'catalog_list', null, null, array( 'test' => array( 'a', 'b' ) ) ) ); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
public function testTransformTrailing() |
67
|
|
|
{ |
68
|
|
|
$this->assertEquals( '/unittest/lists?trailing=a_b', $this->object->transform( 'catalog_list', null, null, [], array( 'a', 'b' ) ) ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
public function testTransformAbsolute() |
73
|
|
|
{ |
74
|
|
|
$options = array( 'absoluteUri' => true ); |
75
|
|
|
$result = $this->object->transform( 'catalog_list', null, null, [], [], $options ); |
76
|
|
|
$this->assertEquals( 'http://localhost/unittest/lists', $result ); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|