Completed
Push — 2016.04 ( 690368...e61816 )
by Aimeos
04:37
created

Typo3Test::testTransformBackend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2014
7
 */
8
9
10
namespace Aimeos\MW\View\Helper\Url;
11
12
13
require_once __DIR__ . DIRECTORY_SEPARATOR . 'UriBuilder';
14
15
16
/**
17
 * Test class for \Aimeos\MW\View\Helper\Url\Typo3.
18
 */
19
class Typo3Test extends \PHPUnit_Framework_TestCase
20
{
21
	private $view;
22
23
24
	/**
25
	 * Sets up the fixture, for example, opens a network connection.
26
	 * This method is called before a test is executed.
27
	 *
28
	 * @access protected
29
	 */
30
	protected function setUp()
31
	{
32
		$this->view = new \Aimeos\MW\View\Standard();
33
	}
34
35
36
	/**
37
	 * Tears down the fixture, for example, closes a network connection.
38
	 * This method is called after a test is executed.
39
	 *
40
	 * @access protected
41
	 */
42
	protected function tearDown()
43
	{
44
		unset( $this->view );
45
	}
46
47
48
	public function testTransform()
49
	{
50
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
51
			->setMethods( array( 'buildFrontendUri') )->getMock();
52
53
		$mock->expects( $this->once() )->method( 'buildFrontendUri' );
54
55
		$fixed = array( 'site' => 'unittest' );
56
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, $fixed );
57
58
		$this->assertEquals( '', $object->transform() );
59
	}
60
61
62
	public function testTransformAbsolute()
63
	{
64
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
65
			->setMethods( array( 'setCreateAbsoluteUri') )->getMock();
66
67
		$mock->expects( $this->once() )->method( 'setCreateAbsoluteUri' )
68
			->with( $this->equalTo( true ) )->will( $this->returnValue( $mock ) );
69
70
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array() );
71
72
		$config = array( 'absoluteUri' => 1 );
73
		$this->assertEquals( '', $object->transform( null, null, null, array(), array(), $config ) );
74
	}
75
76
77
	public function testTransformNocache()
78
	{
79
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
80
			->setMethods( array( 'setNoCache') )->getMock();
81
82
		$mock->expects( $this->once() )->method( 'setNoCache' )
83
			->with( $this->equalTo( true ) )->will( $this->returnValue( $mock ) );
84
85
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array() );
86
87
		$config = array( 'nocache' => 1 );
88
		$this->assertEquals( '', $object->transform( null, null, null, array(), array(), $config ) );
89
	}
90
91
92
	public function testTransformChash()
93
	{
94
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
95
			->setMethods( array( 'setUseCacheHash') )->getMock();
96
97
		$mock->expects( $this->once() )->method( 'setUseCacheHash' )
98
			->with( $this->equalTo( true ) )->will( $this->returnValue( $mock ) );
99
100
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array() );
101
102
		$config = array( 'chash' => 1 );
103
		$this->assertEquals( '', $object->transform( null, null, null, array(), array(), $config ) );
104
	}
105
106
107
	public function testTransformType()
108
	{
109
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
110
			->setMethods( array( 'setTargetPageType') )->getMock();
111
112
		$mock->expects( $this->once() )->method( 'setTargetPageType' )
113
			->with( $this->equalTo( 123 ) )->will( $this->returnValue( $mock ) );
114
115
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array() );
116
117
		$config = array( 'type' => 123 );
118
		$this->assertEquals( '', $object->transform( null, null, null, array(), array(), $config ) );
119
	}
120
121
122
	public function testTransformFormat()
123
	{
124
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
125
			->setMethods( array( 'setFormat') )->getMock();
126
127
		$mock->expects( $this->once() )->method( 'setFormat' )
128
			->with( $this->equalTo( 'xml' ) )->will( $this->returnValue( $mock ) );
129
130
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array() );
131
132
		$config = array( 'format' => 'xml' );
133
		$this->assertEquals( '', $object->transform( null, null, null, array(), array(), $config ) );
134
	}
135
136
137
	public function testTransformEID()
138
	{
139
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
140
			->setMethods( array( 'setArguments') )->getMock();
141
142
		$param = array( 'eID' => 123, 'ai' => array( 'controller' => null, 'action' => null ) );
143
144
		$mock->expects( $this->once() )->method( 'setArguments' )
145
			->with( $this->equalTo( $param ) )->will( $this->returnValue( $mock ) );
146
147
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array() );
148
149
		$config = array( 'eID' => 123 );
150
		$this->assertEquals( '', $object->transform( null, null, null, array(), array(), $config ) );
151
	}
152
153
154
	public function testTransformBackend()
155
	{
156
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
157
		->setMethods( array( 'buildBackendUri') )->getMock();
158
159
		$mock->expects( $this->once() )->method( 'buildBackendUri' );
160
161
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array( 'site' => 'unittest' ) );
162
163
		$params = array( 'test' => 'my/value' );
164
		$this->assertEquals( '', $object->transform( null, null, null, $params, array(), array( 'BE' => 1 ) ) );
165
	}
166
167
168
	public function testTransformParams()
169
	{
170
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
171
			->setMethods( array( 'buildFrontendUri') )->getMock();
172
173
		$mock->expects( $this->once() )->method( 'buildFrontendUri' );
174
175
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array( 'site' => 'unittest' ) );
176
177
		$params = array( 'test' => 'my/value' );
178
		$this->assertEquals( '', $object->transform( null, null, null, $params ) );
179
	}
180
181
182
	public function testTransformNoNamespace()
183
	{
184
		$mock = $this->getMockBuilder( 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder' )
185
			->setMethods( array( 'buildFrontendUri', 'getArgumentPrefix' ) )->getMock();
186
187
		$mock->expects( $this->once() )->method( 'buildFrontendUri' );
188
		$mock->expects( $this->once() )->method( 'getArgumentPrefix' )->will( $this->returnValue( 'ai' ) );
189
190
		$object = new \Aimeos\MW\View\Helper\Url\Typo3( $this->view, $mock, array( 'site' => 'unittest' ) );
191
192
		$params = array( 'test' => 'my/value' );
193
		$config = array( 'namespace' => false );
194
		$this->assertEquals( '', $object->transform( null, null, null, $params, array(), $config ) );
195
	}
196
}
197