‪TYPO3CMS  11.5
SourceHostTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
23 class ‪SourceHostTest extends UnitTestCase
24 {
29  {
30  return [
31  // Valid formats
32  'www.domain.com' => ['www.domain.com', 'www.domain.com'],
33  'domain.com' => ['domain.com', 'domain.com'],
34  '127.0.0.1' => ['127.0.0.1', '127.0.0.1'],
35  '2001:0db8:85a3:08d3::0370:7344' => ['2001:0db8:85a3:08d3::0370:7344', '2001:0db8:85a3:08d3::0370:7344'],
36  'http://127.0.0.1' => ['http://127.0.0.1', '127.0.0.1'],
37  'http://www.domain.com' => ['http://www.domain.com', 'www.domain.com'],
38  'https://www.domain.com' => ['https://www.domain.com', 'www.domain.com'],
39  'http://www.domain.com/subfolder/index.php?id=123&foo=bar' => [
40  'http://www.domain.com/subfolder/index.php?id=123&foo=bar',
41  'www.domain.com',
42  ],
43  'https://www.domain.com/subfolder/index.php?id=123&foo=bar' => [
44  'https://www.domain.com/subfolder/index.php?id=123&foo=bar',
45  'www.domain.com',
46  ],
47  'http://www.domain.com/subfolder/' => ['http://www.domain.com/subfolder/', 'www.domain.com'],
48  'https://www.domain.com/subfolder/' => ['https://www.domain.com/subfolder/', 'www.domain.com'],
49  'http://[2001:0db8:85a3:08d3::0370:7344]/' => [
50  'http://[2001:0db8:85a3:08d3::0370:7344]/',
51  '2001:0db8:85a3:08d3::0370:7344',
52  ],
53  'www.domain.com/subfolder/' => ['www.domain.com/subfolder/', 'www.domain.com'],
54  'domain.com/subfolder/' => ['domain.com/subfolder/', 'domain.com'],
55  'www.domain.com/subfolder/index.php?id=123&foo=bar' => [
56  'www.domain.com/subfolder/index.php?id=123&foo=bar',
57  'www.domain.com',
58  ],
59  'domain.com/subfolder/index.php?id=123&foo=bar' => [
60  'domain.com/subfolder/index.php?id=123&foo=bar',
61  'domain.com',
62  ],
63  // special case, * means all domains
64  '*' => ['*', '*'],
65 
66  // Invalid formats
67  'mailto:foo@typo3.org' => ['mailto:foo@typo3.org', ''],
68  'mailto:foo@typo3.org?subject=bar' => ['mailto:foo@typo3.org?subject=bar', ''],
69  ];
70  }
71 
78  public function ‪evaluateFieldValueWorksWithDifferentInputs(string $input, string $expected): void
79  {
80  $subject = new ‪SourceHost();
81  self::assertSame($expected, $subject->evaluateFieldValue($input));
82  }
83 }
‪TYPO3\CMS\Redirects\Evaluation\SourceHost
Definition: SourceHost.php:30
‪TYPO3\CMS\Redirects\Tests\Unit\Evaluation\SourceHostTest\evaluateFieldValueWorksWithDifferentInputs
‪evaluateFieldValueWorksWithDifferentInputs(string $input, string $expected)
Definition: SourceHostTest.php:78
‪TYPO3\CMS\Redirects\Tests\Unit\Evaluation\SourceHostTest\evaluateFieldValueWorksWithDifferentInputsDataProvider
‪array evaluateFieldValueWorksWithDifferentInputsDataProvider()
Definition: SourceHostTest.php:28
‪TYPO3\CMS\Redirects\Tests\Unit\Evaluation
Definition: SourceHostTest.php:18
‪TYPO3\CMS\Redirects\Tests\Unit\Evaluation\SourceHostTest
Definition: SourceHostTest.php:24