[!!!][TASK] Drop "documentation" extension
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Unit / Page / PageRepositoryTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\Page;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Test case
19 */
20 class PageRepositoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
22 /**
23 * @var \TYPO3\CMS\Frontend\Page\PageRepository|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
24 */
25 protected $pageSelectObject;
26
27 protected $defaultTcaForPages = [
28 'ctrl' => [
29 'label' => 'title',
30 'tstamp' => 'tstamp',
31 'sortby' => 'sorting',
32 'type' => 'doktype',
33 'versioningWS' => true,
34 'origUid' => 't3_origuid',
35 'delete' => 'deleted',
36 'enablecolumns' => [
37 'disabled' => 'hidden',
38 'starttime' => 'starttime',
39 'endtime' => 'endtime',
40 'fe_group' => 'fe_group'
41 ],
42 ],
43 'columns' => []
44 ];
45
46 /**
47 * Sets up this testcase
48 */
49 protected function setUp()
50 {
51 $this->pageSelectObject = $this->getAccessibleMock(\TYPO3\CMS\Frontend\Page\PageRepository::class, ['getMultipleGroupsWhereClause']);
52 $this->pageSelectObject->expects($this->any())->method('getMultipleGroupsWhereClause')->will($this->returnValue(' AND 1=1'));
53 }
54
55 ///////////////////////////////
56 // Tests concerning getExtURL
57 ///////////////////////////////
58 /**
59 * @test
60 */
61 public function getExtUrlForDokType3UsesTheSameValue()
62 {
63 $this->assertEquals('http://www.example.com', $this->pageSelectObject->getExtURL([
64 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
65 'url' => 'http://www.example.com'
66 ]));
67 }
68
69 /**
70 * @test
71 */
72 public function getExtUrlForDokType3PrependsSiteUrl()
73 {
74 $this->assertEquals(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'hello/world/', $this->pageSelectObject->getExtURL([
75 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
76 'url' => 'hello/world/'
77 ]));
78 }
79
80 /**
81 * @test
82 */
83 public function getExtUrlForDokType3AssumesAbsoluteUrl()
84 {
85 $this->assertEquals('/hello/world/', $this->pageSelectObject->getExtURL([
86 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
87 'url' => '/hello/world/'
88 ]));
89 }
90
91 /**
92 * @test
93 */
94 public function getExtUrlForDokType3UsesEmailAsSameValue()
95 {
96 $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
97 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
98 'url' => 'mailto:mail@typo3-test.com'
99 ]));
100 }
101
102 /**
103 * @test
104 */
105 public function getExtUrlForDokType3UsesValidEmailWithoutProtocolAsEmail()
106 {
107 $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
108 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
109 'url' => 'mail@typo3-test.com'
110 ]));
111 }
112 }