‪TYPO3CMS  10.4
OperatorTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
23 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 class ‪OperatorTest extends FunctionalTestCase
26 {
30  protected ‪$blogRepository;
31 
35  protected ‪$postRepository;
36 
40  protected ‪$testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
41 
45  protected ‪$coreExtensionsToLoad = ['extbase', 'fluid'];
46 
50  protected ‪$objectManager;
51 
55  protected function ‪setUp(): void
56  {
57  parent::setUp();
58 
59  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
60  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml');
61  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml');
62  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml');
63  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml');
64 
65  $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
66  $this->blogRepository = $this->objectManager->get(BlogRepository::class);
67  $this->postRepository = $this->objectManager->get(PostRepository::class);
68  }
69 
73  public function ‪equalsNullIsResolvedCorrectly()
74  {
75  $query = $this->postRepository->createQuery();
76 
77  $query->matching(
78  $query->equals('title', null)
79  );
80 
81  self::assertSame(0, $query->count());
82  }
83 
88  {
89  $query = $this->postRepository->createQuery();
90 
91  $query->matching(
92  $query->equals('title', 'PoSt1', false)
93  );
94 
95  self::assertSame(2, $query->count());
96  }
97 
101  public function ‪betweenSetsBoundariesCorrectly()
102  {
103  $query = $this->postRepository->createQuery();
104  $query->setOrderings(['uid' => ‪QueryInterface::ORDER_ASCENDING]);
105 
106  $query->matching(
107  $query->between('uid', 3, 5)
108  );
109 
110  $result = array_map(
111  function ($row) {
112  return $row['uid'];
113  },
114  $query->execute(true)
115  );
116  self::assertEquals([3, 4, 5], $result);
117  }
118 }
‪ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository
Definition: BlogRepository.php:25
‪TYPO3\CMS\Extbase\Persistence\QueryInterface
Definition: QueryInterface.php:29
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\equalsNullIsResolvedCorrectly
‪equalsNullIsResolvedCorrectly()
Definition: OperatorTest.php:68
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\equalsCorrectlyHandlesCaseSensitivity
‪equalsCorrectlyHandlesCaseSensitivity()
Definition: OperatorTest.php:82
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest
Definition: OperatorTest.php:26
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$postRepository
‪ExtbaseTeam BlogExample Domain Repository PostRepository $postRepository
Definition: OperatorTest.php:33
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\betweenSetsBoundariesCorrectly
‪betweenSetsBoundariesCorrectly()
Definition: OperatorTest.php:96
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$objectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
Definition: OperatorTest.php:45
‪TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_ASCENDING
‪const ORDER_ASCENDING
Definition: QueryInterface.php:98
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence
Definition: AddTest.php:16
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: OperatorTest.php:37
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$blogRepository
‪ExtbaseTeam BlogExample Domain Repository BlogRepository $blogRepository
Definition: OperatorTest.php:29
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\setUp
‪setUp()
Definition: OperatorTest.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪ExtbaseTeam\BlogExample\Domain\Repository\PostRepository
Definition: PostRepository.php:30
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: OperatorTest.php:41