[TASK] Removes extra empty lines
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Tests / Unit / RecordList / AbstractDatabaseRecordListTest.php
1 <?php
2 namespace TYPO3\CMS\Recordlist\Tests\Unit\RecordList;
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\Tests\UnitTestCase;
18 use TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList;
19
20 /**
21 * Test case
22 */
23 class AbstractDatabaseRecordListTest extends UnitTestCase
24 {
25 /**
26 * @test
27 * @dataProvider setTableDisplayOrderConvertsStringsDataProvider
28 * @param array $input
29 * @param array $expected
30 */
31 public function setTableDisplayOrderConvertsStringInput(array $input, array $expected)
32 {
33 /** @var AbstractDatabaseRecordList|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
34 $subject = $this->getAccessibleMock(AbstractDatabaseRecordList::class, ['dummy']);
35 $subject->setTableDisplayOrder($input);
36 $this->assertSame($expected, $subject->_get('tableDisplayOrder'));
37 }
38
39 /**
40 * @return array
41 */
42 public function setTableDisplayOrderConvertsStringsDataProvider()
43 {
44 return [
45 'no information at all' => [
46 [],
47 []
48 ],
49 'string in before' => [
50 [
51 'tableA' => [
52 'before' => 'tableB, tableC'
53 ]
54 ],
55 [
56 'tableA' => [
57 'before' => ['tableB', 'tableC']
58 ]
59 ]
60 ],
61 'array is preserved in before' => [
62 [
63 'tableA' => [
64 'before' => ['tableB', 'tableC']
65 ]
66 ],
67 [
68 'tableA' => [
69 'before' => ['tableB', 'tableC']
70 ]
71 ]
72 ],
73 'array is preserved in before, after is modified' => [
74 [
75 'tableA' => [
76 'before' => ['tableB', 'tableC'],
77 'after' => 'tableD'
78 ]
79 ],
80 [
81 'tableA' => [
82 'before' => ['tableB', 'tableC'],
83 'after' => ['tableD']
84 ]
85 ]
86 ],
87 ];
88 }
89
90 /**
91 * @test
92 * @expectedException \UnexpectedValueException
93 * @expectedExceptionCode 1436195934
94 */
95 public function setTableDisplayOrderThrowsExceptionOnInvalidAfter()
96 {
97 $test = [
98 'table' => [ 'after' => new \stdClass ]
99 ];
100 $subject = new AbstractDatabaseRecordList();
101 $subject->setTableDisplayOrder($test);
102 }
103
104 /**
105 * @test
106 * @expectedException \UnexpectedValueException
107 * @expectedExceptionCode 1436195933
108 */
109 public function setTableDisplayOrderThrowsExceptionOnInvalidBefore()
110 {
111 $test = [
112 'table' => [ 'before' => new \stdClass ]
113 ];
114 $subject = new AbstractDatabaseRecordList();
115 $subject->setTableDisplayOrder($test);
116 }
117 }