TYPO3 CMS  TYPO3_7-6
AbstractTagBasedViewHelperTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 {
22  protected $viewHelper;
23 
24  protected function setUp()
25  {
26  $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper::class, ['dummy'], [], '', false);
27  }
28 
33  {
34  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, ['reset'], [], '', false);
35  $mockTagBuilder->expects($this->once())->method('reset');
36  $this->viewHelper->_set('tag', $mockTagBuilder);
37 
38  $this->viewHelper->initialize();
39  }
40 
45  {
46  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, ['addAttribute'], [], '', false);
47  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('foo', 'bar');
48  $this->viewHelper->_set('tag', $mockTagBuilder);
49 
50  $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', false);
51  $arguments = ['foo' => 'bar'];
52  $this->viewHelper->setArguments($arguments);
53  $this->viewHelper->initialize();
54  }
55 
60  {
61  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, ['addAttribute'], [], '', false);
62  $mockTagBuilder->expects($this->once())->method('addAttribute')->with('foo', 'bar');
63  $this->viewHelper->_set('tag', $mockTagBuilder);
64 
65  $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', false);
66  $arguments = ['additionalAttributes' => ['foo' => 'bar']];
67  $this->viewHelper->setArguments($arguments);
68  $this->viewHelper->initialize();
69  }
70 
75  {
76  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, ['addAttribute'], [], '', false);
77  $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('data-foo', 'bar');
78  $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('data-baz', 'foos');
79  $this->viewHelper->_set('tag', $mockTagBuilder);
80 
81  $arguments = ['data' => ['foo' => 'bar', 'baz' => 'foos']];
82  $this->viewHelper->setArguments($arguments);
83  $this->viewHelper->initializeArguments();
84  $this->viewHelper->initialize();
85  }
86 
91  {
92  $mockTagBuilder = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder::class, ['addAttribute'], [], '', false);
93  $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('class', 'classAttribute');
94  $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('dir', 'dirAttribute');
95  $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('id', 'idAttribute');
96  $mockTagBuilder->expects($this->at(3))->method('addAttribute')->with('lang', 'langAttribute');
97  $mockTagBuilder->expects($this->at(4))->method('addAttribute')->with('style', 'styleAttribute');
98  $mockTagBuilder->expects($this->at(5))->method('addAttribute')->with('title', 'titleAttribute');
99  $mockTagBuilder->expects($this->at(6))->method('addAttribute')->with('accesskey', 'accesskeyAttribute');
100  $mockTagBuilder->expects($this->at(7))->method('addAttribute')->with('tabindex', 'tabindexAttribute');
101  $this->viewHelper->_set('tag', $mockTagBuilder);
102 
103  $arguments = [
104  'class' => 'classAttribute',
105  'dir' => 'dirAttribute',
106  'id' => 'idAttribute',
107  'lang' => 'langAttribute',
108  'style' => 'styleAttribute',
109  'title' => 'titleAttribute',
110  'accesskey' => 'accesskeyAttribute',
111  'tabindex' => 'tabindexAttribute'
112  ];
113  $this->viewHelper->_call('registerUniversalTagAttributes');
114  $this->viewHelper->setArguments($arguments);
115  $this->viewHelper->initializeArguments();
116  $this->viewHelper->initialize();
117  }
118 
123  {
124  $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper::class, ['registerArgument'], [], '', false);
125  $this->viewHelper->expects($this->once())->method('registerArgument')->with('foo', 'string', 'Description', false, 'defaultValue');
126  $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', false, 'defaultValue');
127  }
128 
133  {
134  $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper::class, ['registerArgument'], [], '', false);
135  $this->viewHelper->expects($this->once())->method('registerArgument')->with('foo', 'string', 'Description', false, null);
136  $this->viewHelper->_call('registerTagAttribute', 'foo', 'string', 'Description', false);
137  }
138 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)