Completed
Push — master ( 17a913...e4ae37 )
by Aimeos
03:08
created

Typo3Test::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 16
rs 9.8666
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2020
6
 */
7
8
namespace Aimeos\MW\View\Engine;
9
10
11
require_once __DIR__ . DIRECTORY_SEPARATOR . 'T3Object';
12
require_once __DIR__ . DIRECTORY_SEPARATOR . 'T3View';
13
require_once __DIR__ . DIRECTORY_SEPARATOR . 'T3Configuration';
14
15
16
class Typo3Test extends \PHPUnit\Framework\TestCase
17
{
18
	public function testRender()
19
	{
20
		$mock = $this->getMockBuilder( '\TYPO3\CMS\Extbase\Object\ObjectManagerInterface' )
21
			->setMethods( array( 'get' ) )
22
			->disableOriginalConstructor()
23
			->getMock();
24
25
		$config = $this->getMockBuilder( '\TYPO3\CMS\Extbase\Configuration\ConfigurationManager' )
26
			->setMethods( array( 'getConfiguration' ) )
27
			->disableOriginalConstructor()
28
			->getMock();
29
30
		$view = $this->getMockBuilder( 'TYPO3\\CMS\\Fluid\\View\\T3View' )
31
			->setMethods( array( 'assign', 'assignMultiple', 'render', 'setTemplatePathAndFilename', 'setPartialRootPaths', 'setLayoutRootPaths' ) )
32
			->disableOriginalConstructor()
33
			->getMock();
34
35
		$conf = ['view' => ['partialRootPaths' => '', 'layoutRootPaths' => '']];
36
		$config->expects( $this->once() )->method( 'getConfiguration' )->will( $this->returnValue( $conf ) );
37
		$mock->expects( $this->exactly( 2 ) )->method( 'get' )->will( $this->onConsecutiveCalls( $config, $view ) );
38
39
		$view->expects( $this->once() )->method( 'setTemplatePathAndFilename' );
40
		$view->expects( $this->once() )->method( 'assignMultiple' );
41
		$view->expects( $this->once() )->method( 'assign' );
42
		$view->expects( $this->once() )->method( 'setPartialRootPaths' );
43
		$view->expects( $this->once() )->method( 'setLayoutRootPaths' );
44
		$view->expects( $this->once() )->method( 'render' )->will( $this->returnValue( 'test' ) );
45
46
		$v = new \Aimeos\MW\View\Standard( [] );
47
		$object = new \Aimeos\MW\View\Engine\Typo3( $mock );
48
49
		$this->assertEquals( 'test', $object->render( $v, 'filepath', array( 'key' => 'value' ) ) );
50
	}
51
}
52