|
1
|
|
|
<?php |
|
2
|
|
|
namespace Gilbertsoft\Lib\Tests\Functional; |
|
3
|
|
|
|
|
4
|
|
|
/*************************************************************** |
|
5
|
|
|
* Copyright notice |
|
6
|
|
|
* |
|
7
|
|
|
* (c) 2014 Helmut Hummel <[email protected]> |
|
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
|
|
|
* A copy is found in the text file GPL.txt and important notices to the license |
|
19
|
|
|
* from the author is found in LICENSE.txt distributed with these scripts. |
|
20
|
|
|
* |
|
21
|
|
|
* |
|
22
|
|
|
* This script is distributed in the hope that it will be useful, |
|
23
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25
|
|
|
* GNU General Public License for more details. |
|
26
|
|
|
* |
|
27
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
|
28
|
|
|
***************************************************************/ |
|
29
|
|
|
|
|
30
|
|
|
use Nimut\TestingFramework\Http\Response; |
|
31
|
|
|
use Nimut\TestingFramework\TestCase\FunctionalTestCase; |
|
32
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Class RenderingTest |
|
36
|
|
|
*/ |
|
37
|
|
|
class RenderingTest extends FunctionalTestCase |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $testExtensionsToLoad = array('typo3conf/ext/gslib'); |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var array |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $coreExtensionsToLoad = array('fluid'); |
|
48
|
|
|
|
|
49
|
|
|
public function setUp() |
|
50
|
|
|
{ |
|
51
|
|
|
parent::setUp(); |
|
52
|
|
|
$this->importDataSet(__DIR__ . '/Fixtures/Database/pages.xml'); |
|
53
|
|
|
$this->setUpFrontendRootPage(1, array('EXT:gslib/Tests/Functional/Fixtures/Frontend/Basic.ts')); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @test |
|
58
|
|
|
*/ |
|
59
|
|
|
public function emailViewHelperWorksWithSpamProtection() |
|
60
|
|
|
{ |
|
61
|
|
|
$requestArguments = array('id' => '1'); |
|
62
|
|
|
$expectedContent = '<a href="javascript:linkTo_UnCryptMailto(\'ocknvq,varq5Bikndgtvuqhv0qti\');">typo3(AT)gilbertsoft(DOT)org</a>'; |
|
63
|
|
|
$this->assertSame($expectedContent, $this->fetchFrontendResponse($requestArguments)->getContent()); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
/* *************** |
|
69
|
|
|
* Utility methods |
|
70
|
|
|
* ***************/ |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param array $requestArguments |
|
76
|
|
|
* @param bool $failOnFailure |
|
77
|
|
|
* @return Response |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function fetchFrontendResponse(array $requestArguments, $failOnFailure = true) |
|
80
|
|
|
{ |
|
81
|
|
|
if (!empty($requestArguments['url'])) { |
|
82
|
|
|
$requestUrl = '/' . ltrim($requestArguments['url'], '/'); |
|
83
|
|
|
} else { |
|
84
|
|
|
$requestUrl = '/?' . GeneralUtility::implodeArrayForUrl('', $requestArguments); |
|
85
|
|
|
} |
|
86
|
|
|
if (property_exists($this, 'instancePath')) { |
|
87
|
|
|
$instancePath = $this->instancePath; |
|
88
|
|
|
} else { |
|
89
|
|
|
$instancePath = $this->getInstancePath(); |
|
90
|
|
|
} |
|
91
|
|
|
$arguments = array( |
|
92
|
|
|
'documentRoot' => $instancePath, |
|
93
|
|
|
'requestUrl' => 'http://localhost' . $requestUrl, |
|
94
|
|
|
); |
|
95
|
|
|
|
|
96
|
|
|
$template = new \Text_Template('ntf://Frontend/Request.tpl'); |
|
97
|
|
|
$template->setVar( |
|
98
|
|
|
array( |
|
99
|
|
|
'arguments' => var_export($arguments, true), |
|
100
|
|
|
'originalRoot' => ORIGINAL_ROOT, |
|
101
|
|
|
'ntfRoot' => __DIR__ . '/../../.Build/vendor/nimut/testing-framework/', |
|
102
|
|
|
) |
|
103
|
|
|
); |
|
104
|
|
|
|
|
105
|
|
|
$php = \PHPUnit_Util_PHP::factory(); |
|
106
|
|
|
$response = $php->runJob($template->render()); |
|
107
|
|
|
$result = json_decode($response['stdout'], true); |
|
108
|
|
|
|
|
109
|
|
|
if ($result === null) { |
|
110
|
|
|
$this->fail('Frontend Response is empty.' . LF . 'Error: ' . LF . $response['stderr']); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
if ($failOnFailure && $result['status'] === Response::STATUS_Failure) { |
|
114
|
|
|
$this->fail('Frontend Response has failure:' . LF . $result['error']); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
$response = new Response($result['status'], $result['content'], $result['error']); |
|
118
|
|
|
return $response; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|