[TASK] Add more fixers for php-cs-fixer
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Functional / Persistence / OperatorTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Functional\Persistence;
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\Utility\GeneralUtility;
18 use TYPO3\CMS\Extbase\Persistence\QueryInterface;
19
20 class OperatorTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase
21 {
22 /**
23 * @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository
24 */
25 protected $blogRepository;
26
27 /**
28 * @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository
29 */
30 protected $postRepository;
31
32 /**
33 * @var array
34 */
35 protected $testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
36
37 /**
38 * @var array
39 */
40 protected $coreExtensionsToLoad = ['extbase', 'fluid'];
41
42 /**
43 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
44 */
45 protected $objectManager;
46
47 /**
48 * Sets up this test suite.
49 */
50 protected function setUp()
51 {
52 parent::setUp();
53
54 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
55 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml');
56 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml');
57 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml');
58 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml');
59
60 $this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
61 $this->blogRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository::class);
62 $this->postRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
63 }
64
65 /**
66 * @test
67 */
68 public function equalsNullIsResolvedCorrectly()
69 {
70 $query = $this->postRepository->createQuery();
71
72 $query->matching(
73 $query->equals('title', null)
74 );
75
76 $this->assertSame(0, $query->count());
77 }
78
79 /**
80 * @test
81 */
82 public function equalsCorrectlyHandlesCaseSensivity()
83 {
84 $query = $this->postRepository->createQuery();
85
86 $query->matching(
87 $query->equals('title', 'PoSt1', false)
88 );
89
90 $this->assertSame(2, $query->count());
91 }
92
93 /**
94 * @test
95 */
96 public function betweenSetsBoundariesCorrectly()
97 {
98 $query = $this->postRepository->createQuery();
99 $query->setOrderings(['uid' => QueryInterface::ORDER_ASCENDING]);
100
101 $query->matching(
102 $query->between('uid', 3, 5)
103 );
104
105 $result = array_map(
106 function ($row) {
107 return $row['uid'];
108 },
109 $query->execute(true)
110 );
111 $this->assertEquals([3, 4, 5], $result);
112 }
113 }