‪TYPO3CMS  ‪main
PlainDataResolverTest.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;
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 final class ‪PlainDataResolverTest extends FunctionalTestCase
26 {
35  public static function ‪sortingDataProvider(): array
36  {
37  return [
38  'sorting' => [
39  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
40  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
41  ['sorting'],
42  ],
43  'sorting asc' => [
44  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
45  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
46  ['sorting asc'],
47  ],
48  'sorting desc' => [
49  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
50  [9, 6, 7, 8, 5, 4, 3, 10, 2, 1],
51  ['sorting desc'],
52  ],
53  'sorting ASC' => [
54  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
55  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
56  ['sorting ASC'],
57  ],
58  'sorting DESC' => [
59  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
60  [9, 6, 7, 8, 5, 4, 3, 10, 2, 1],
61  ['sorting DESC'],
62  ],
63  'sorting ASC title' => [
64  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
65  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
66  ['sorting ASC', 'title'],
67  ],
68  'sorting ASC title asc' => [
69  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
70  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
71  ['sorting ASC', 'title asc'],
72  ],
73  'sorting ASC title desc' => [
74  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
75  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
76  ['sorting ASC', 'title desc'],
77  ],
78  'sorting ASC title ASC' => [
79  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
80  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
81  ['sorting ASC', 'title ASC'],
82  ],
83  'sorting ASC title DESC' => [
84  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
85  [1, 2, 10, 3, 4, 5, 8, 7, 6, 9],
86  ['sorting ASC', 'title DESC'],
87  ],
88  'title sorting ASC' => [
89  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
90  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
91  ['title', 'sorting ASC'],
92  ],
93  'title asc sorting ASC' => [
94  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
95  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
96  ['title asc', 'sorting ASC'],
97  ],
98  'title desc sorting ASC' => [
99  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
100  [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
101  ['title desc', 'sorting ASC'],
102  ],
103  'title ASC sorting ASC' => [
104  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
105  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
106  ['title ASC', 'sorting ASC'],
107  ],
108  'title DESC sorting ASC' => [
109  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
110  [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
111  ['title DESC', 'sorting ASC'],
112  ],
113  ];
114  }
115 
116  #[DataProvider('sortingDataProvider')]
117  #[Test]
118  public function ‪processSortingReturnsExpectedSequenceOfUids(array $input, array $expected, array $sortings): void
119  {
120  $this->importCSVDataSet(__DIR__ . '/DataSet/Pages.csv');
121  $subject = new ‪PlainDataResolver('pages', [], $sortings);
122  self::assertSame($expected, $subject->processSorting($input));
123  }
124 }
‪TYPO3\CMS\Core\DataHandling\PlainDataResolver
Definition: PlainDataResolver.php:34
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataResolving\PlainDataResolverTest\sortingDataProvider
‪static sortingDataProvider()
Definition: PlainDataResolverTest.php:35
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataResolving\PlainDataResolverTest
Definition: PlainDataResolverTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataResolving\PlainDataResolverTest\processSortingReturnsExpectedSequenceOfUids
‪processSortingReturnsExpectedSequenceOfUids(array $input, array $expected, array $sortings)
Definition: PlainDataResolverTest.php:118
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataResolving
Definition: PlainDataResolverTest.php:18