[BUGFIX] Exception with EXT:sys_note is installed
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / TypoScript / TemplateServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\TypoScript;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase for \TYPO3\CMS\Core\TypoScript\TemplateService
29 *
30 * @author Christian Kuhn <lolli@schwarzbu.ch>
31 */
32 class TemplateServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
33
34 /**
35 * Enable backup of global and system variables
36 *
37 * @var boolean
38 */
39 protected $backupGlobals = TRUE;
40
41 /**
42 * @var \TYPO3\CMS\Core\TypoScript\TemplateService
43 */
44 protected $templateService;
45
46 /**
47 * Sets up this test case.
48 *
49 * @return void
50 */
51 protected function setUp() {
52 $this->templateService = new \TYPO3\CMS\Core\TypoScript\TemplateService();
53 }
54
55 /**
56 * Tears down this test case.
57 *
58 * @return void
59 */
60 protected function tearDown() {
61 unset($this->templateService);
62 }
63
64 /**
65 * @test
66 */
67 public function versionOlCallsVersionOlOfPageSelectClassWithGivenRow() {
68 $row = array('foo');
69 $GLOBALS['TSFE'] = new \stdClass();
70 $sysPageMock = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
71 $sysPageMock->expects($this->once())->method('versionOL')->with('sys_template', $row);
72 $GLOBALS['TSFE']->sys_page = $sysPageMock;
73 $this->templateService->versionOL($row);
74 }
75
76 /**
77 * @test
78 */
79 public function extensionStaticFilesAreNotProcessedIfNotExplicitlyRequested() {
80 $identifier = uniqid('test');
81 $GLOBALS['TYPO3_LOADED_EXT'] = array(
82 $identifier => array(
83 'ext_typoscript_setup.txt' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
84 'core', 'Tests/Unit/TypoScript/Fixtures/ext_typoscript_setup.txt'
85 ),
86 ),
87 );
88
89 $this->templateService->runThroughTemplates(array(), 0);
90 $this->assertFalse(
91 in_array('test.Core.TypoScript = 1', $this->templateService->config)
92 );
93 }
94
95 /**
96 * @test
97 */
98 public function extensionStaticsAreProcessedIfExplicitlyRequested() {
99 $identifier = uniqid('test');
100 $GLOBALS['TYPO3_LOADED_EXT'] = array(
101 $identifier => array(
102 'ext_typoscript_setup.txt' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
103 'core', 'Tests/Unit/TypoScript/Fixtures/ext_typoscript_setup.txt'
104 ),
105 ),
106 );
107
108 $this->templateService->setProcessExtensionStatics(TRUE);
109 $this->templateService->runThroughTemplates(array(), 0);
110 $this->assertTrue(
111 in_array('test.Core.TypoScript = 1', $this->templateService->config)
112 );
113 }
114
115 }
116
117 ?>