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