TYPO3 CMS  TYPO3_7-6
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 
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(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 
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 
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 }