‪TYPO3CMS  9.5
QueryGeneratorTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪QueryGeneratorTest extends UnitTestCase
26 {
31  {
32  return [
33  'multidimensional array input' => [
34  [
35  'foo' => [
36  'bar' => 1,
37  'baz' => [
38  'jane' => 1,
39  'john' => 'doe',
40  ],
41  'fae' => 1,
42  ],
43  'don' => [
44  'dan' => 1,
45  'jim' => [
46  'jon' => 1,
47  'jin' => 'joh',
48  ],
49  ],
50  'one' => [
51  'two' => 1,
52  'three' => [
53  'four' => 1,
54  'five' => 'six',
55  ],
56  ]
57  ],
58  [
59  0 => 'foo',
60  1 => 'bar',
61  ],
62  ],
63  'array with multiple entries input' => [
64  [
65  'foo' => 1,
66  'bar' => 2,
67  'baz' => 3,
68  'don' => 4,
69  ],
70  [
71  0 => 'foo',
72  ],
73  ],
74  'array with one entry input' => [
75  [
76  'foo' => 'bar',
77  ],
78  [
79  0 => 'foo',
80  ],
81  ],
82  'empty array input' => [
83  [],
84  [
85  0 => null,
86  ],
87  ],
88  'empty multidimensional array input' => [
89  [[[[]]], [[]], [[]]],
90  [
91  0 => 0,
92  1 => 0,
93  2 => 0,
94  3 => null,
95  ],
96  ],
97  'null input' => [
98  null,
99  [],
100  ],
101  'string input' => [
102  'foo bar',
103  [],
104  ],
105  'numeric input' => [
106  3.14,
107  [],
108  ],
109  ];
110  }
111 
118  public function ‪getSubscriptReturnsExpectedValues($input, array $expectedArray): void
119  {
120  $subject = new ‪QueryGenerator();
121  $this->assertSame($expectedArray, $subject->getSubscript($input));
122  }
123 }
‪TYPO3\CMS\Core\Tests\Unit\Database\QueryGeneratorTest\getSubscriptReturnsExpectedValuesDataProvider
‪array getSubscriptReturnsExpectedValuesDataProvider()
Definition: QueryGeneratorTest.php:30
‪TYPO3\CMS\Core\Database\QueryGenerator
Definition: QueryGenerator.php:33
‪TYPO3\CMS\Core\Tests\Unit\Database
Definition: ConnectionPoolTest.php:3
‪TYPO3\CMS\Core\Tests\Unit\Database\QueryGeneratorTest\getSubscriptReturnsExpectedValues
‪getSubscriptReturnsExpectedValues($input, array $expectedArray)
Definition: QueryGeneratorTest.php:118
‪TYPO3\CMS\Core\Tests\Unit\Database\QueryGeneratorTest
Definition: QueryGeneratorTest.php:26