TYPO3 CMS  TYPO3_6-2
PageRendererTest.php
Go to the documentation of this file.
1 <?php
3 
17 
24 
28  public function renderMethodCallsResetInAnyCase() {
29  $pageRenderer = $this->getMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('reset', 'prepareRendering', 'renderJavaScriptAndCss', 'getPreparedMarkerArray', 'getTemplateForPart'));
30  $pageRenderer->expects($this->exactly(3))->method('reset');
31 
32  $pageRenderer->render(PageRenderer::PART_COMPLETE);
33  $pageRenderer->render(PageRenderer::PART_HEADER);
34  $pageRenderer->render(PageRenderer::PART_FOOTER);
35  }
36 
41  public function includingNotAvailableLocalJqueryVersionThrowsException() {
43  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
44  $subject->_set('availableLocalJqueryVersions', array('1.1.1'));
45  $subject->loadJquery('2.2.2');
46  }
47 
52  public function includingJqueryWithNonAlphnumericNamespaceThrowsException() {
54  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
55  $subject->loadJquery(NULL, NULL, '12sd.12fsd');
56  $subject->render();
57  }
58 
62  public function addBodyContentAddsContent() {
64  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
65  $expectedReturnValue = 'ABCDE';
66  $subject->addBodyContent('A');
67  $subject->addBodyContent('B');
68  $subject->addBodyContent('C');
69  $subject->addBodyContent('D');
70  $subject->addBodyContent('E');
71  $out = $subject->getBodyContent();
72  $this->assertEquals($expectedReturnValue, $out);
73  }
74 
78  public function addInlineLanguageLabelFileSetsInlineLanguageLabelFiles() {
80  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
81  $fileReference = $this->getUniqueId('file_');
82  $selectionPrefix = $this->getUniqueId('prefix_');
83  $stripFromSelectionName = $this->getUniqueId('strip_');
84  $errorMode = 0;
85 
86  $expectedInlineLanguageLabelFile = array(
87  'fileRef' => $fileReference,
88  'selectionPrefix' => $selectionPrefix,
89  'stripFromSelectionName' => $stripFromSelectionName,
90  'errorMode' => $errorMode
91  );
92 
93  $subject->addInlineLanguageLabelFile($fileReference, $selectionPrefix, $stripFromSelectionName, $errorMode);
94  $actualResult = $subject->getInlineLanguageLabelFiles();
95 
96  $this->assertSame($expectedInlineLanguageLabelFile, array_pop($actualResult));
97  }
98 
102  public function addInlineLanguageLabelFileSetsTwoDifferentInlineLanguageLabelFiles() {
104  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
105  $fileReference1 = $this->getUniqueId('file1_');
106  $selectionPrefix1 = $this->getUniqueId('prefix1_');
107  $stripFromSelectionName1 = $this->getUniqueId('strip1_');
108  $errorMode1 = 0;
109  $expectedInlineLanguageLabelFile1 = array(
110  'fileRef' => $fileReference1,
111  'selectionPrefix' => $selectionPrefix1,
112  'stripFromSelectionName' => $stripFromSelectionName1,
113  'errorMode' => $errorMode1
114  );
115  $fileReference2 = $this->getUniqueId('file2_');
116  $selectionPrefix2 = $this->getUniqueId('prefix2_');
117  $stripFromSelectionName2 = $this->getUniqueId('strip2_');
118  $errorMode2 = 0;
119  $expectedInlineLanguageLabelFile2 = array(
120  'fileRef' => $fileReference2,
121  'selectionPrefix' => $selectionPrefix2,
122  'stripFromSelectionName' => $stripFromSelectionName2,
123  'errorMode' => $errorMode2
124  );
125 
126  $subject->addInlineLanguageLabelFile($fileReference1, $selectionPrefix1, $stripFromSelectionName1, $errorMode1);
127  $subject->addInlineLanguageLabelFile($fileReference2, $selectionPrefix2, $stripFromSelectionName2, $errorMode2);
128  $actualResult = $subject->getInlineLanguageLabelFiles();
129 
130  $this->assertSame($expectedInlineLanguageLabelFile2, array_pop($actualResult));
131  $this->assertSame($expectedInlineLanguageLabelFile1, array_pop($actualResult));
132  }
133 
137  public function addInlineLanguageLabelFileDoesNotSetSameLanguageFileTwice() {
139  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
140  $fileReference = $this->getUniqueId('file2_');
141  $selectionPrefix = $this->getUniqueId('prefix2_');
142  $stripFromSelectionName = $this->getUniqueId('strip2_');
143  $errorMode = 0;
144 
145  $subject->addInlineLanguageLabelFile($fileReference, $selectionPrefix, $stripFromSelectionName, $errorMode);
146  $subject->addInlineLanguageLabelFile($fileReference, $selectionPrefix, $stripFromSelectionName, $errorMode);
147  $this->assertSame(1, count($subject->getInlineLanguageLabelFiles()));
148  }
149 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)