Passed
Pull Request — master (#123)
by
unknown
04:14
created

MetadataWrapVariableViewHelperTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderingContextCallsGetVariableProviderAdd() 0 26 1
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Tests\Unit\ViewHelpers;
14
15
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
16
use TYPO3\CMS\Fluid\View\StandaloneView;
17
18
/**
19
 * @covers MetadataWrapVariableViewHelper
20
 */
21
class MetadataWrapVariableViewHelperTest extends FunctionalTestCase
22
{
23
    /**
24
     * @var bool Speed up this test case, it needs no database
25
     */
26
    protected $initializeDatabase = false;
27
28
    /**
29
     * @test
30
     */
31
    public function renderingContextCallsGetVariableProviderAdd(): void
32
    {
33
        $view = new StandaloneView();
34
35
        $view->assign(
36
            'configObject',
37
            [ 'wrap' => 'all.wrap = <article class="shlb-metadata-text-item metadata-title">|</article>
38
                 key.wrap = <label>|</label>
39
                 value.required = 1
40
                 value.wrap = <li>|</li>'
41
            ]
42
        );
43
        $view->setTemplateSource(
44
            '<html xmlns:kitodo="http://typo3.org/ns/Kitodo/Dlf/ViewHelpers">
45
                {configObject.wrap -> kitodo:metadataWrapVariable(name: \'metadataWrap\')}
46
            </html>'
47
        );
48
        $view->render();
49
50
        self::assertEquals(
51
            [
52
                'key' => ['wrap' => '<label>|</label>'],
53
                'value' => ['required' => 1, 'wrap' => '<li>|</li>'],
54
                'all' => ['wrap' => '<article class="shlb-metadata-text-item metadata-title">|</article>']
55
            ],
56
            $view->getRenderingContext()->getVariableProvider()->get('metadataWrap')
57
        );
58
    }
59
}
60