‪TYPO3CMS  ‪main
DemandTest.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 
20 use PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
26 final class ‪DemandTest extends UnitTestCase
27 {
29  {
30  return [
31  [
32  [1, '', '', [], '', '', []],
33  ['integrity_status' => ‪RedirectConflict::NO_CONFLICT],
34  ],
35  [
36  [2, '', '', ['host'], '', '', []],
37  ['source_host' => 'host', 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
38  ],
39  [
40  [3, '', '', [], 'path', '', []],
41  ['source_path' => 'path', 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
42  ],
43  [
44  [4, '', '', [], '', 'target', []],
45  ['target' => 'target', 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
46  ],
47  [
48  [5, '', '', [], '', '', [301]],
49  ['target_statuscode' => 301, 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
50  ],
51  [
52  [6, '', '', ['host'], '', 'target'],
53  ['source_host' => 'host', 'target' => 'target', 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
54  ],
55  [
56  [7, '', '', [], 'path', '', [302]],
57  ['source_path' => 'path', 'target_statuscode' => 302, 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
58  ],
59  [
60  [8, '', '', ['host'], 'path', 'target', [307]],
61  ['source_path' => 'path', 'source_host' => 'host', 'target' => 'target', 'target_statuscode' => 307, 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
62  ],
63  [
64  [9, '', '', [], '', '', [], 100],
65  ['max_hits' => 100, 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
66  ],
67  [
68  [10, '', '', [], '', '', [], 0, null, 1],
69  ['creation_type' => 1, 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
70  ],
71  [
72  [11, '', '', [], '', '', [], 0, null, -1, 1],
73  ['protected' => 1, 'integrity_status' => ‪RedirectConflict::NO_CONFLICT],
74  ],
75  [
76  [12, '', '', [], '', '', [], 0, null, null, null, 'self_reference'],
77  ['integrity_status' => ‪RedirectConflict::SELF_REFERENCE],
78  ],
79  ];
80  }
81 
82  #[DataProvider('getParametersRespectsDemandStateStateDataProvider')]
83  #[Test]
84  public function ‪getParametersRespectsDemandState(array $input, array $expected): void
85  {
86  self::assertEquals($expected, (new ‪Demand(...$input))->getParameters());
87  }
88 }
‪TYPO3\CMS\Redirects\Repository\Demand
Definition: Demand.php:29
‪TYPO3\CMS\Redirects\Utility\RedirectConflict
Definition: RedirectConflict.php:24
‪TYPO3\CMS\Redirects\Tests\Unit\Repository
Definition: DemandTest.php:18
‪TYPO3\CMS\Redirects\Tests\Unit\Repository\DemandTest\getParametersRespectsDemandState
‪getParametersRespectsDemandState(array $input, array $expected)
Definition: DemandTest.php:84
‪TYPO3\CMS\Redirects\Utility\RedirectConflict\NO_CONFLICT
‪const NO_CONFLICT
Definition: RedirectConflict.php:25
‪TYPO3\CMS\Redirects\Tests\Unit\Repository\DemandTest\getParametersRespectsDemandStateStateDataProvider
‪static getParametersRespectsDemandStateStateDataProvider()
Definition: DemandTest.php:28
‪TYPO3\CMS\Redirects\Tests\Unit\Repository\DemandTest
Definition: DemandTest.php:27
‪TYPO3\CMS\Redirects\Utility\RedirectConflict\SELF_REFERENCE
‪const SELF_REFERENCE
Definition: RedirectConflict.php:26