[FEATURE] Add Contexts for storing data access modes
[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 use TYPO3\CMS\Core\Context\Context;
18
19 /**
20 * Test case
21 */
22 class PageRepositoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
23 {
24 /**
25 * @var \TYPO3\CMS\Frontend\Page\PageRepository|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
26 */
27 protected $pageSelectObject;
28
29 protected $defaultTcaForPages = [
30 'ctrl' => [
31 'label' => 'title',
32 'tstamp' => 'tstamp',
33 'sortby' => 'sorting',
34 'type' => 'doktype',
35 'versioningWS' => true,
36 'origUid' => 't3_origuid',
37 'delete' => 'deleted',
38 'enablecolumns' => [
39 'disabled' => 'hidden',
40 'starttime' => 'starttime',
41 'endtime' => 'endtime',
42 'fe_group' => 'fe_group'
43 ],
44 ],
45 'columns' => []
46 ];
47
48 /**
49 * Sets up this testcase
50 */
51 protected function setUp()
52 {
53 $this->pageSelectObject = $this->getAccessibleMock(\TYPO3\CMS\Frontend\Page\PageRepository::class, ['getMultipleGroupsWhereClause'], [], '', false);
54 $this->pageSelectObject->_set('context', new Context());
55 $this->pageSelectObject->expects($this->any())->method('getMultipleGroupsWhereClause')->will($this->returnValue(' AND 1=1'));
56 }
57
58 ///////////////////////////////
59 // Tests concerning getExtURL
60 ///////////////////////////////
61 /**
62 * @test
63 */
64 public function getExtUrlForDokType3UsesTheSameValue()
65 {
66 $this->assertEquals('http://www.example.com', $this->pageSelectObject->getExtURL([
67 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
68 'url' => 'http://www.example.com'
69 ]));
70 }
71
72 /**
73 * @test
74 */
75 public function getExtUrlForDokType3PrependsSiteUrl()
76 {
77 $this->assertEquals(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'hello/world/', $this->pageSelectObject->getExtURL([
78 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
79 'url' => 'hello/world/'
80 ]));
81 }
82
83 /**
84 * @test
85 */
86 public function getExtUrlForDokType3AssumesAbsoluteUrl()
87 {
88 $this->assertEquals('/hello/world/', $this->pageSelectObject->getExtURL([
89 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
90 'url' => '/hello/world/'
91 ]));
92 }
93
94 /**
95 * @test
96 */
97 public function getExtUrlForDokType3UsesEmailAsSameValue()
98 {
99 $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
100 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
101 'url' => 'mailto:mail@typo3-test.com'
102 ]));
103 }
104
105 /**
106 * @test
107 */
108 public function getExtUrlForDokType3UsesValidEmailWithoutProtocolAsEmail()
109 {
110 $this->assertEquals('mailto:mail@typo3-test.com', $this->pageSelectObject->getExtURL([
111 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_LINK,
112 'url' => 'mail@typo3-test.com'
113 ]));
114 }
115 }