[TASK] Disable a series of functional tests with mssql
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Functional / Persistence / QueryParserTest.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
19 class QueryParserTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
20 {
21
22 /**
23 * @var array
24 */
25 protected $testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
26
27 /**
28 * @var array
29 */
30 protected $coreExtensionsToLoad = ['extbase', 'fluid'];
31
32 /**
33 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface The object manager
34 */
35 protected $objectManager;
36
37 /**
38 * @var \ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository
39 */
40 protected $blogRepository;
41
42 /**
43 * Sets up this test suite.
44 */
45 protected function setUp()
46 {
47 parent::setUp();
48
49 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/categories.xml');
50 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags.xml');
51 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/blogs.xml');
52 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/tags-mm.xml');
53 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/persons.xml');
54 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/posts.xml');
55 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/post-tag-mm.xml');
56 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/category-mm.xml');
57 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/fe_users.xml');
58 $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/fe_groups.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 }
63
64 /**
65 * @test
66 * @group not-mssql
67 */
68 public function queryWithMultipleRelationsToIdenticalTablesReturnsExpectedResultForOrQuery()
69 {
70 /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
71 $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
72 $query = $postRepository->createQuery();
73 $query->matching(
74 $query->logicalAnd(
75 $query->equals('blog', 3),
76 $query->logicalOr(
77 $query->equals('tags.name', 'Tag12'),
78 $query->equals('author.tags.name', 'TagForAuthor1')
79 )
80 )
81 );
82
83 $result = $query->execute()->toArray();
84 $this->assertEquals(3, count($result));
85 }
86
87 /**
88 * Test ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY
89 *
90 * @test
91 * @group not-mssql
92 */
93 public function queryWithRelationHasAndBelongsToManyReturnsExpectedResult()
94 {
95 /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
96 $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
97 $query = $postRepository->createQuery();
98 $query->matching(
99 $query->equals('tags.name', 'Tag12')
100 );
101 $result = $query->execute()->toArray();
102 $this->assertEquals(2, count($result));
103 }
104
105 /**
106 * Test ColumnMap::RELATION_HAS_MANY
107 *
108 * @test
109 * @group not-mssql
110 */
111 public function queryWithRelationHasManyWithoutParentKeyFieldNameReturnsExpectedResult()
112 {
113 /** @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $frontendUserRepository */
114 $frontendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
115 $query = $frontendUserRepository->createQuery();
116 $query->matching(
117 $query->equals('usergroup.title', 'Group A')
118 );
119
120 $result = $query->execute()->toArray();
121 $this->assertCount(2, $result);
122 }
123
124 /**
125 * Test ColumnMap::RELATION_HAS_ONE, ColumnMap::ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY
126 *
127 * @test
128 * @group not-mssql
129 */
130 public function queryWithRelationHasOneAndHasAndBelongsToManyWithoutParentKeyFieldNameReturnsExpectedResult()
131 {
132 /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
133 $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
134 $query = $postRepository->createQuery();
135 $query->matching(
136 $query->equals('author.firstname', 'Author')
137 );
138 $result = $query->execute()->toArray();
139 $this->assertCount(2, $result);
140 }
141
142 /**
143 * @test
144 * @group not-mssql
145 */
146 public function orReturnsExpectedResult()
147 {
148 /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
149 $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
150 $query = $postRepository->createQuery();
151 $query->matching(
152 $query->logicalOr(
153 $query->equals('tags.name', 'Tag12'),
154 $query->equals('tags.name', 'Tag11')
155 )
156 );
157 $result = $query->execute()->toArray();
158 $this->assertCount(2, $result);
159 }
160
161 /**
162 * @test
163 * @group not-mssql
164 */
165 public function queryWithMultipleRelationsToIdenticalTablesReturnsExpectedResultForAndQuery()
166 {
167 /** @var \ExtbaseTeam\BlogExample\Domain\Repository\PostRepository $postRepository */
168 $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
169 $query = $postRepository->createQuery();
170 $query->matching(
171 $query->logicalAnd(
172 $query->equals('blog', 3),
173 $query->equals('tags.name', 'Tag12'),
174 $query->equals('author.tags.name', 'TagForAuthor1')
175 )
176 );
177 $result = $query->execute()->toArray();
178 $this->assertCount(1, $result);
179 }
180
181 /**
182 * @test
183 * @group not-mssql
184 */
185 public function queryWithFindInSetReturnsExpectedResult()
186 {
187 /** @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository $frontendUserRepository */
188 $frontendUserRepository = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
189 $query = $frontendUserRepository->createQuery();
190
191 $result = $query->matching($query->contains('usergroup', 1))
192 ->execute();
193 $this->assertCount(2, $result);
194 }
195
196 /**
197 * @test
198 */
199 public function queryForPostWithCategoriesReturnsPostWithCategories()
200 {
201 $postRepository = $this->objectManager->get('ExtbaseTeam\\BlogExample\\Domain\\Repository\\PostRepository');
202 $query = $postRepository->createQuery();
203 $post = $query->matching($query->equals('uid', 1))->execute()->current();
204 $this->assertCount(3, $post->getCategories());
205 }
206 }