‪TYPO3CMS  9.5
OperatorTest.php
Go to the documentation of this file.
1 <?php
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 
19 
20 class ‪OperatorTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
21 {
25  protected ‪$blogRepository;
26 
30  protected ‪$postRepository;
31 
35  protected ‪$testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
36 
40  protected ‪$coreExtensionsToLoad = ['extbase', 'fluid'];
41 
45  protected ‪$objectManager;
46 
50  protected function ‪setUp()
51  {
52  parent::setUp();
53 
54  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/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 
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 
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 
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 }
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Persistence\QueryInterface
Definition: QueryInterface.php:26
‪TYPO3
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\equalsNullIsResolvedCorrectly
‪equalsNullIsResolvedCorrectly()
Definition: OperatorTest.php:63
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\equalsCorrectlyHandlesCaseSensitivity
‪equalsCorrectlyHandlesCaseSensitivity()
Definition: OperatorTest.php:77
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest
Definition: OperatorTest.php:21
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$postRepository
‪ExtbaseTeam BlogExample Domain Repository PostRepository $postRepository
Definition: OperatorTest.php:28
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\betweenSetsBoundariesCorrectly
‪betweenSetsBoundariesCorrectly()
Definition: OperatorTest.php:91
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$objectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
Definition: OperatorTest.php:40
‪TYPO3\CMS\Extbase\Persistence\QueryInterface\ORDER_ASCENDING
‪const ORDER_ASCENDING
Definition: QueryInterface.php:95
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence
Definition: AddTest.php:2
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: OperatorTest.php:32
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$blogRepository
‪ExtbaseTeam BlogExample Domain Repository BlogRepository $blogRepository
Definition: OperatorTest.php:24
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\setUp
‪setUp()
Definition: OperatorTest.php:45
‪ExtbaseTeam
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Tests\Functional\Persistence\OperatorTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: OperatorTest.php:36