2 declare(strict_types = 1);
18 use PHPUnit\Framework\MockObject\MockObject;
34 protected $testExtensionsToLoad = [
'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
59 protected function setUp()
63 $this->importCSVDataSet(ORIGINAL_ROOT .
'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/translatedBlogExampleData.csv');
66 $this->objectManager = GeneralUtility::makeInstance(\
TYPO3\CMS\
Extbase\Object\ObjectManager::class);
68 'features' => [
'consistentTranslationOverlayHandling' => 1],
72 'TYPO3\CMS\Extbase\Domain\Model\Category' => [
73 'mapping' => [
'tableName' =>
'sys_category']
78 $configurationManager = $this->objectManager->get(\
TYPO3\CMS\
Extbase\Configuration\ConfigurationManagerInterface::class);
79 $configurationManager->setConfiguration($configuration);
80 $this->postRepository = $this->objectManager->get(\
ExtbaseTeam\BlogExample\Domain\Repository\PostRepository::class);
81 $this->persistenceManager = $this->objectManager->get(PersistenceManager::class);
90 $environmentServiceMock = $this->createMock(EnvironmentService::class);
91 $environmentServiceMock
92 ->expects($this->atLeast(1))
93 ->method(
'isEnvironmentInFrontendMode')
95 GeneralUtility::setSingletonInstance(EnvironmentService::class, $environmentServiceMock);
97 $context = GeneralUtility::makeInstance(Context::class);
101 $frontendControllerMock = $this->createMock(\
TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
102 $frontendControllerMock->sys_page = $pageRepositoryFixture;
103 $GLOBALS[
'TSFE'] = $frontendControllerMock;
119 $context = GeneralUtility::makeInstance(Context::class);
122 $post2 = $this->postRepository->findByUid(2);
124 $this->assertEquals([
'Post 2', 2, 2,
'Blog 1', 1, 1,
'John', 1, 1], [
127 $post2->_getProperty(
'_localizedUid'),
128 $post2->getBlog()->getTitle(),
129 $post2->getBlog()->getUid(),
130 $post2->getBlog()->_getProperty(
'_localizedUid'),
131 $post2->getAuthor()->getFirstname(),
132 $post2->getAuthor()->getUid(),
133 $post2->getAuthor()->_getProperty(
'_localizedUid')
137 $this->persistenceManager->clearState();
140 $post2translated = $this->postRepository->findByUid(11);
141 $this->assertEquals([
'Post 2 - DK', 2, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
142 $post2translated->getTitle(),
143 $post2translated->getUid(),
144 $post2translated->_getProperty(
'_localizedUid'),
145 $post2translated->getBlog()->getTitle(),
146 $post2translated->getBlog()->getUid(),
147 $post2translated->getBlog()->_getProperty(
'_localizedUid'),
148 $post2translated->getAuthor()->getFirstname(),
149 $post2translated->getAuthor()->getUid(),
150 $post2translated->getAuthor()->_getProperty(
'_localizedUid')
161 $context = GeneralUtility::makeInstance(Context::class);
164 $post2 = $this->postRepository->findByUid(2);
165 $this->assertEquals([
'Post 2', 2, 2,
'Blog 1', 1, 1,
'John', 1, 1], [
168 $post2->_getProperty(
'_localizedUid'),
169 $post2->getBlog()->getTitle(),
170 $post2->getBlog()->getUid(),
171 $post2->getBlog()->_getProperty(
'_localizedUid'),
172 $post2->getAuthor()->getFirstname(),
173 $post2->getAuthor()->getUid(),
174 $post2->getAuthor()->_getProperty(
'_localizedUid')
178 $this->persistenceManager->clearState();
180 $post2translated = $this->postRepository->findByUid(11);
181 $this->assertEquals([
'Post 2 - DK', 2, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
182 $post2translated->getTitle(),
183 $post2translated->getUid(),
184 $post2translated->_getProperty(
'_localizedUid'),
185 $post2translated->getBlog()->getTitle(),
186 $post2translated->getBlog()->getUid(),
187 $post2translated->getBlog()->_getProperty(
'_localizedUid'),
188 $post2translated->getAuthor()->getFirstname(),
189 $post2translated->getAuthor()->getUid(),
190 $post2translated->getAuthor()->_getProperty(
'_localizedUid')
201 $context = GeneralUtility::makeInstance(Context::class);
204 $post2 = $this->postRepository->findByUid(2);
205 $this->assertEquals([
'Post 2 - DK', 2, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
208 $post2->_getProperty(
'_localizedUid'),
209 $post2->getBlog()->getTitle(),
210 $post2->getBlog()->getUid(),
211 $post2->getBlog()->_getProperty(
'_localizedUid'),
212 $post2->getAuthor()->getFirstname(),
213 $post2->getAuthor()->getUid(),
214 $post2->getAuthor()->_getProperty(
'_localizedUid')
218 $this->persistenceManager->clearState();
219 $post2translated = $this->postRepository->findByUid(11);
220 $this->assertEquals([
'Post 2 - DK', 2, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
221 $post2translated->getTitle(),
222 $post2translated->getUid(),
223 $post2translated->_getProperty(
'_localizedUid'),
224 $post2translated->getBlog()->getTitle(),
225 $post2translated->getBlog()->getUid(),
226 $post2translated->getBlog()->_getProperty(
'_localizedUid'),
227 $post2translated->getAuthor()->getFirstname(),
228 $post2translated->getAuthor()->getUid(),
229 $post2translated->getAuthor()->_getProperty(
'_localizedUid')
240 $context = GeneralUtility::makeInstance(Context::class);
243 $post2 = $this->postRepository->findByUid(2);
244 $this->assertEquals([
'Post 2 - DK', 2, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
247 $post2->_getProperty(
'_localizedUid'),
248 $post2->getBlog()->getTitle(),
249 $post2->getBlog()->getUid(),
250 $post2->getBlog()->_getProperty(
'_localizedUid'),
251 $post2->getAuthor()->getFirstname(),
252 $post2->getAuthor()->getUid(),
253 $post2->getAuthor()->_getProperty(
'_localizedUid')
257 $this->persistenceManager->clearState();
259 $post2translated = $this->postRepository->findByUid(11);
260 $this->assertEquals([
'Post 2 - DK', 2, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
261 $post2translated->getTitle(),
262 $post2translated->getUid(),
263 $post2translated->_getProperty(
'_localizedUid'),
264 $post2translated->getBlog()->getTitle(),
265 $post2translated->getBlog()->getUid(),
266 $post2translated->getBlog()->_getProperty(
'_localizedUid'),
267 $post2translated->getAuthor()->getFirstname(),
268 $post2translated->getAuthor()->getUid(),
269 $post2translated->getAuthor()->_getProperty(
'_localizedUid')
285 $query = $this->postRepository->createQuery();
286 $querySettings = $query->getQuerySettings();
287 $querySettings->setLanguageUid(0);
288 $querySettings->setLanguageOverlayMode(
true);
289 $query->matching($query->equals(
'uid', 2));
290 $post2 = $query->execute()->getFirst();
293 $this->assertEquals([
'Post 2', 2, 2,
'Blog 1', 1, 1,
'John', 1, 1], [
296 $post2->_getProperty(
'_localizedUid'),
297 $post2->getBlog()->getTitle(),
298 $post2->getBlog()->getUid(),
299 $post2->getBlog()->_getProperty(
'_localizedUid'),
300 $post2->getAuthor()->getFirstname(),
301 $post2->getAuthor()->getUid(),
302 $post2->getAuthor()->_getProperty(
'_localizedUid')
306 $this->persistenceManager->clearState();
308 $query = $this->postRepository->createQuery();
309 $querySettings = $query->getQuerySettings();
310 $querySettings->setLanguageUid(0);
311 $querySettings->setLanguageOverlayMode(
true);
312 $query->matching($query->equals(
'uid', 11));
313 $post2 = $query->execute()->getFirst();
316 $this->assertNull($post2);
319 $this->persistenceManager->clearState();
321 $query = $this->postRepository->createQuery();
322 $querySettings = $query->getQuerySettings();
323 $querySettings->setLanguageUid(1);
324 $querySettings->setLanguageOverlayMode(
true);
325 $query->matching($query->equals(
'uid', 2));
326 $post2 = $query->execute()->getFirst();
328 $this->assertNull($post2);
331 $this->persistenceManager->clearState();
333 $query = $this->postRepository->createQuery();
334 $querySettings = $query->getQuerySettings();
335 $querySettings->setLanguageUid(1);
336 $querySettings->setLanguageOverlayMode(
true);
337 $query->matching($query->equals(
'uid', 11));
338 $post2 = $query->execute()->getFirst();
340 $this->assertEquals([
'Post 2 - DK', 2, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
343 $post2->_getProperty(
'_localizedUid'),
344 $post2->getBlog()->getTitle(),
345 $post2->getBlog()->getUid(),
346 $post2->getBlog()->_getProperty(
'_localizedUid'),
347 $post2->getAuthor()->getFirstname(),
348 $post2->getAuthor()->getUid(),
349 $post2->getAuthor()->_getProperty(
'_localizedUid')
364 $query = $this->postRepository->createQuery();
365 $querySettings = $query->getQuerySettings();
366 $querySettings->setLanguageUid(0);
367 $querySettings->setLanguageOverlayMode(
false);
368 $query->matching($query->equals(
'uid', 2));
369 $post2 = $query->execute()->getFirst();
371 $this->assertEquals([
'Post 2', 2, 2,
'Blog 1', 1, 1,
'John', 1, 1], [
374 $post2->_getProperty(
'_localizedUid'),
375 $post2->getBlog()->getTitle(),
376 $post2->getBlog()->getUid(),
377 $post2->getBlog()->_getProperty(
'_localizedUid'),
378 $post2->getAuthor()->getFirstname(),
379 $post2->getAuthor()->getUid(),
380 $post2->getAuthor()->_getProperty(
'_localizedUid')
384 $this->persistenceManager->clearState();
386 $query = $this->postRepository->createQuery();
387 $querySettings = $query->getQuerySettings();
388 $querySettings->setLanguageUid(0);
389 $querySettings->setLanguageOverlayMode(
false);
390 $query->matching($query->equals(
'uid', 11));
391 $post2 = $query->execute()->getFirst();
394 $this->assertNull($post2);
397 $this->persistenceManager->clearState();
399 $query = $this->postRepository->createQuery();
400 $querySettings = $query->getQuerySettings();
401 $querySettings->setLanguageUid(1);
402 $querySettings->setLanguageOverlayMode(
false);
403 $query->matching($query->equals(
'uid', 2));
404 $post2 = $query->execute()->getFirst();
406 $this->assertNull($post2);
409 $this->persistenceManager->clearState();
411 $query = $this->postRepository->createQuery();
412 $querySettings = $query->getQuerySettings();
413 $querySettings->setLanguageUid(1);
414 $querySettings->setLanguageOverlayMode(
false);
415 $query->matching($query->equals(
'uid', 11));
416 $post2 = $query->execute()->getFirst();
418 $this->assertEquals([
'Post 2 - DK', 11, 11,
'Blog 1 DK', 1, 2,
'Translated John', 1, 2], [
421 $post2->_getProperty(
'_localizedUid'),
422 $post2->getBlog()->getTitle(),
423 $post2->getBlog()->getUid(),
424 $post2->getBlog()->_getProperty(
'_localizedUid'),
425 $post2->getAuthor()->getFirstname(),
426 $post2->getAuthor()->getUid(),
427 $post2->getAuthor()->_getProperty(
'_localizedUid')
438 '_localizedUid' => 4,
439 'content' =>
'A - content',
440 'blog.title' =>
'Blog 1',
442 'blog._localizedUid' => 1,
443 'author.firstname' =>
'John',
445 'author._localizedUid' => 1,
446 'secondAuthor.firstname' =>
'John',
447 'secondAuthor.uid' => 1,
448 'secondAuthor._localizedUid' => 1,
454 '_localizedUid' => 2,
455 'content' =>
'B - content',
456 'blog.title' =>
'Blog 1',
458 'blog._localizedUid' => 1,
459 'author.firstname' =>
'John',
461 'author._localizedUid' => 1,
462 'secondAuthor.firstname' =>
'John',
463 'secondAuthor.uid' => 1,
464 'secondAuthor._localizedUid' => 1,
465 'tags.0.name' =>
'Tag2',
467 'tags.0._localizedUid' => 2,
468 'tags.1.name' =>
'Tag3',
470 'tags.1._localizedUid' => 3,
471 'tags.2.name' =>
'Tag4',
473 'tags.2._localizedUid' => 4,
478 '_localizedUid' => 7,
479 'content' =>
'C - content',
480 'blog.title' =>
'Blog 1',
482 'blog._localizedUid' => 1,
483 'author.firstname' =>
'John',
485 'author._localizedUid' => 1,
486 'secondAuthor.firstname' =>
'John',
487 'secondAuthor.uid' => 1,
488 'secondAuthor._localizedUid' => 1,
494 '_localizedUid' => 6,
495 'content' =>
'F - content',
496 'blog.title' =>
'Blog 1',
498 'blog._localizedUid' => 1,
499 'author.firstname' =>
'John',
501 'author._localizedUid' => 1,
502 'secondAuthor.firstname' =>
'John',
503 'secondAuthor.uid' => 1,
504 'secondAuthor._localizedUid' => 1,
508 'title' =>
'Post 1 - not translated',
510 '_localizedUid' => 1,
511 'content' =>
'G - content',
512 'blog.title' =>
'Blog 1',
514 'blog._localizedUid' => 1,
515 'author.firstname' =>
'John',
517 'author._localizedUid' => 1,
518 'secondAuthor.firstname' =>
'Never translate me henry',
519 'secondAuthor.uid' => 3,
520 'secondAuthor._localizedUid' => 3,
521 'tags.0.name' =>
'Tag1',
523 'tags.0._localizedUid' => 1,
524 'tags.1.name' =>
'Tag2',
526 'tags.1._localizedUid' => 2,
527 'tags.2.name' =>
'Tag3',
529 'tags.2._localizedUid' => 3,
536 'expected' => $lang0Expected
541 'expected' => $lang0Expected
548 'title' =>
'Post 5 - DK',
550 '_localizedUid' => 13,
551 'content' =>
'A - content',
552 'blog.title' =>
'Blog 1 DK',
554 'blog._localizedUid' => 2,
555 'author.firstname' =>
'Translated John',
557 'author._localizedUid' => 2,
558 'secondAuthor.firstname' =>
'Translated John',
559 'secondAuthor.uid' => 1,
560 'secondAuthor._localizedUid' => 2,
564 'title' =>
'Post 2 - DK',
566 '_localizedUid' => 11,
567 'content' =>
'C - content',
568 'blog.title' =>
'Blog 1 DK',
570 'blog._localizedUid' => 2,
571 'author.firstname' =>
'Translated John',
573 'author._localizedUid' => 2,
574 'secondAuthor.firstname' =>
'Translated John',
575 'secondAuthor.uid' => 1,
576 'secondAuthor._localizedUid' => 2,
577 'tags.0.name' =>
'Tag 3 DK',
579 'tags.0._localizedUid' => 18,
580 'tags.1.name' =>
'Tag4',
582 'tags.1._localizedUid' => 4,
583 'tags.2.name' =>
'Tag5',
585 'tags.2._localizedUid' => 5,
586 'tags.3.name' =>
'Tag 6 DK',
588 'tags.3._localizedUid' => 19,
589 'tags.4.name' =>
'Tag7',
591 'tags.4._localizedUid' => 7,
596 '_localizedUid' => 6,
597 'content' =>
'F - content',
598 'blog.title' =>
'Blog 1 DK',
600 'blog._localizedUid' => 2,
601 'author.firstname' =>
'Translated John',
603 'author._localizedUid' => 2,
604 'secondAuthor.firstname' =>
'Translated John',
605 'secondAuthor.uid' => 1,
606 'secondAuthor._localizedUid' => 2,
610 'title' =>
'Post 1 - not translated',
612 '_localizedUid' => 1,
613 'content' =>
'G - content',
614 'blog.title' =>
'Blog 1 DK',
616 'blog._localizedUid' => 2,
617 'author.firstname' =>
'Translated John',
619 'author._localizedUid' => 2,
620 'secondAuthor.firstname' =>
'Never translate me henry',
621 'secondAuthor.uid' => 3,
622 'secondAuthor._localizedUid' => 3,
623 'tags.0.name' =>
'Tag 1 DK',
625 'tags.0._localizedUid' => 16,
626 'tags.1.name' =>
'Tag 2 DK',
628 'tags.1._localizedUid' => 17,
629 'tags.2.name' =>
'Tag 3 DK',
631 'tags.2._localizedUid' => 18,
637 '_localizedUid' => 3,
638 'content' =>
'I - content',
639 'blog.title' =>
'Blog 1 DK',
641 'blog._localizedUid' => 2,
642 'author.firstname' =>
'Translated John',
644 'author._localizedUid' => 2,
645 'secondAuthor.firstname' =>
'Translated John',
646 'secondAuthor.uid' => 1,
647 'secondAuthor._localizedUid' => 2,
654 'overlay' =>
'hideNonTranslated',
659 'title' =>
'Post 5 - DK',
661 '_localizedUid' => 13,
662 'content' =>
'A - content',
663 'blog.title' =>
'Blog 1 DK',
665 'blog._localizedUid' => 2,
666 'author.firstname' =>
'Translated John',
668 'author._localizedUid' => 2,
669 'secondAuthor.firstname' =>
'Translated John',
670 'secondAuthor.uid' => 1,
671 'secondAuthor._localizedUid' => 2,
675 'title' =>
'Post 2 - DK',
677 '_localizedUid' => 11,
678 'content' =>
'C - content',
679 'blog.title' =>
'Blog 1 DK',
681 'blog._localizedUid' => 2,
682 'author.firstname' =>
'Translated John',
684 'author._localizedUid' => 2,
685 'secondAuthor.firstname' =>
'Translated John',
686 'secondAuthor.uid' => 1,
687 'secondAuthor._localizedUid' => 2,
688 'tags.0.name' =>
'Tag 3 DK',
690 'tags.0._localizedUid' => 18,
691 'tags.1.name' =>
'Tag4',
693 'tags.1._localizedUid' => 4,
694 'tags.2.name' =>
'Tag5',
696 'tags.2._localizedUid' => 5,
697 'tags.3.name' =>
'Tag 6 DK',
699 'tags.3._localizedUid' => 19,
700 'tags.4.name' =>
'Tag7',
702 'tags.4._localizedUid' => 7,
705 'title' =>
'Post 7 - DK',
707 '_localizedUid' => 14,
708 'content' =>
'S - content',
709 'blog.title' =>
'Blog 1 DK',
711 'blog._localizedUid' => 2,
712 'author.firstname' =>
'Translated John',
714 'author._localizedUid' => 2,
715 'secondAuthor.firstname' =>
'Translated John',
716 'secondAuthor.uid' => 1,
717 'secondAuthor._localizedUid' => 2,
721 'title' =>
'Post 4 - DK',
723 '_localizedUid' => 12,
724 'content' =>
'U - content',
725 'blog.title' =>
'Blog 1 DK',
727 'blog._localizedUid' => 2,
728 'author.firstname' =>
'Translated John',
730 'author._localizedUid' => 2,
731 'secondAuthor.firstname' =>
'Translated John',
732 'secondAuthor.uid' => 1,
733 'secondAuthor._localizedUid' => 2,
743 'title' =>
'Post 5 - DK',
745 '_localizedUid' => 13,
746 'content' =>
'A - content',
747 'blog.title' =>
'Blog 1 DK',
749 'blog._localizedUid' => 2,
750 'author.firstname' =>
'Translated John',
752 'author._localizedUid' => 2,
753 'secondAuthor.firstname' =>
'Translated John',
754 'secondAuthor.uid' => 1,
755 'secondAuthor._localizedUid' => 2,
759 'title' =>
'Post DK only',
761 '_localizedUid' => 15,
762 'content' =>
'B - content',
763 'blog.title' =>
'Blog 1 DK',
765 'blog._localizedUid' => 2,
766 'author.firstname' =>
'Translated John',
768 'author._localizedUid' => 2,
769 'secondAuthor.firstname' =>
'Translated John',
770 'secondAuthor.uid' => 1,
771 'secondAuthor._localizedUid' => 2,
775 'title' =>
'Post 2 - DK',
777 '_localizedUid' => 11,
778 'content' =>
'C - content',
779 'blog.title' =>
'Blog 1 DK',
781 'blog._localizedUid' => 2,
782 'author.firstname' =>
'Translated John',
784 'author._localizedUid' => 2,
785 'secondAuthor.firstname' =>
'Translated John',
786 'secondAuthor.uid' => 1,
787 'secondAuthor._localizedUid' => 2,
788 'tags.0.name' =>
'Tag 3 DK',
790 'tags.0._localizedUid' => 18,
791 'tags.1.name' =>
'Tag4',
793 'tags.1._localizedUid' => 4,
794 'tags.2.name' =>
'Tag5',
796 'tags.2._localizedUid' => 5,
797 'tags.3.name' =>
'Tag 6 DK',
799 'tags.3._localizedUid' => 19,
800 'tags.4.name' =>
'Tag7',
802 'tags.4._localizedUid' => 7,
805 'title' =>
'Post 7 - DK',
807 '_localizedUid' => 14,
808 'content' =>
'S - content',
809 'blog.title' =>
'Blog 1 DK',
811 'blog._localizedUid' => 2,
812 'author.firstname' =>
'Translated John',
814 'author._localizedUid' => 2,
815 'secondAuthor.firstname' =>
'Translated John',
816 'secondAuthor.uid' => 1,
817 'secondAuthor._localizedUid' => 2,
821 'title' =>
'Post 4 - DK',
823 '_localizedUid' => 12,
824 'content' =>
'U - content',
825 'blog.title' =>
'Blog 1 DK',
827 'blog._localizedUid' => 2,
828 'author.firstname' =>
'Translated John',
830 'author._localizedUid' => 2,
831 'secondAuthor.firstname' =>
'Translated John',
832 'secondAuthor.uid' => 1,
833 'secondAuthor._localizedUid' => 2,
855 $query = $this->postRepository->createQuery();
856 $querySettings = $query->getQuerySettings();
857 $querySettings->setLanguageUid($languageUid);
858 $querySettings->setLanguageOverlayMode($overlay);
860 $query->setOrderings([
865 $query->setOffset(0);
866 $posts = $query->execute()->toArray();
868 $this->assertCount(count($expected), $posts);
878 '_localizedUid' => 5,
879 'content' =>
'Z - content',
880 'blog.title' =>
'Blog 1',
882 'blog._localizedUid' => 1,
883 'author.firstname' =>
'John',
885 'author._localizedUid' => 1,
886 'secondAuthor.firstname' =>
'John',
887 'secondAuthor.uid' => 1,
888 'secondAuthor._localizedUid' => 1,
893 '_localizedUid' => 6,
894 'content' =>
'F - content',
895 'blog.title' =>
'Blog 1',
897 'blog._localizedUid' => 1,
898 'author.firstname' =>
'John',
900 'author._localizedUid' => 1,
901 'secondAuthor.firstname' =>
'John',
902 'secondAuthor.uid' => 1,
903 'secondAuthor._localizedUid' => 1,
912 'expected' => $lang0Expected
916 'overlay' =>
'hideNonTranslated',
917 'expected' => $lang0Expected
922 'expected' => $lang0Expected
931 '_localizedUid' => 6,
932 'content' =>
'F - content',
933 'blog.title' =>
'Blog 1 DK',
935 'blog._localizedUid' => 2,
936 'author.firstname' =>
'Translated John',
938 'author._localizedUid' => 2,
939 'secondAuthor.firstname' =>
'Translated John',
940 'secondAuthor.uid' => 1,
941 'secondAuthor._localizedUid' => 2,
944 'title' =>
'Post 5 - DK',
946 '_localizedUid' => 13,
947 'content' =>
'A - content',
948 'blog.title' =>
'Blog 1 DK',
950 'blog._localizedUid' => 2,
951 'author.firstname' =>
'Translated John',
953 'author._localizedUid' => 2,
954 'secondAuthor.firstname' =>
'Translated John',
955 'secondAuthor.uid' => 1,
956 'secondAuthor._localizedUid' => 2,
962 'overlay' =>
'hideNonTranslated',
965 'title' =>
'Post 5 - DK',
967 '_localizedUid' => 13,
968 'content' =>
'A - content',
969 'blog.title' =>
'Blog 1 DK',
971 'blog._localizedUid' => 2,
972 'author.firstname' =>
'Translated John',
974 'author._localizedUid' => 2,
975 'secondAuthor.firstname' =>
'Translated John',
976 'secondAuthor.uid' => 1,
977 'secondAuthor._localizedUid' => 2,
986 'title' =>
'Post 5 - DK',
988 '_localizedUid' => 13,
989 'content' =>
'A - content',
990 'blog.title' =>
'Blog 1 DK',
992 'blog._localizedUid' => 2,
993 'author.firstname' =>
'Translated John',
995 'author._localizedUid' => 2,
996 'secondAuthor.firstname' =>
'Translated John',
997 'secondAuthor.uid' => 1,
998 'secondAuthor._localizedUid' => 2,
1001 'title' =>
'Post DK only',
1003 '_localizedUid' => 15,
1004 'content' =>
'B - content',
1005 'blog.title' =>
'Blog 1 DK',
1007 'blog._localizedUid' => 2,
1008 'author.firstname' =>
'Translated John',
1010 'author._localizedUid' => 2,
1011 'secondAuthor.firstname' =>
'Translated John',
1012 'secondAuthor.uid' => 1,
1013 'secondAuthor._localizedUid' => 2,
1036 $query = $this->postRepository->createQuery();
1037 $querySettings = $query->getQuerySettings();
1038 $querySettings->setLanguageUid($languageUid);
1039 $querySettings->setLanguageOverlayMode($overlay);
1043 $query->like(
'title',
'Post 5%'),
1044 $query->like(
'title',
'Post 6%'),
1045 $query->like(
'title',
'Post DK only')
1049 $posts = $query->execute()->toArray();
1051 $this->assertCount(count($expected), $posts);
1059 'title' =>
'Blog 1',
1061 '_localizedUid' => 1,
1064 'title' =>
'Blog 1',
1066 '_localizedUid' => 1,
1071 'title' =>
'Blog 1',
1073 '_localizedUid' => 1,
1076 'title' =>
'Blog 1 DK',
1078 '_localizedUid' => 2,
1086 'expected' => $lang0Expected
1092 'expected' => $lang0Expected
1098 'expected' => $mixed
1104 'expected' => $mixed
1112 'title' =>
'Blog 1 DK',
1114 '_localizedUid' => 2,
1117 'title' =>
'Blog 1 DK',
1119 '_localizedUid' => 2,
1129 'title' =>
'Blog 1 DK',
1131 '_localizedUid' => 2,
1134 'title' =>
'Blog 1 DK',
1136 '_localizedUid' => 2,
1144 'expected' => $mixed
1150 'expected' => $mixed
1172 $context = GeneralUtility::makeInstance(Context::class);
1173 $context->setAspect(
'language',
new LanguageAspect($languageUid, $languageUid, $overlay));
1175 $blogRepository = $this->objectManager->get(\
ExtbaseTeam\BlogExample\Domain\Repository\BlogRepository::class);
1176 $query = $blogRepository->createQuery();
1177 $querySettings = $query->getQuerySettings();
1178 $querySettings->setLanguageMode($languageMode);
1179 $querySettings->setRespectSysLanguage(
false);
1182 $posts = $query->execute()->toArray();
1184 $this->assertCount(count($expected), $posts);
1197 foreach ($objects as $key => $post) {
1199 $propertiesToCheck = array_keys($expected[$key]);
1200 foreach ($propertiesToCheck as $propertyPath) {
1203 $actual[] = $actualPost;
1204 $this->assertEquals($expected[$key], $actual[$key],
'Assertion of the $expected[' . $key .
'] failed');
1206 $this->assertEquals($expected, $actual);
1220 $propertyPathSegments = explode(
'.', $propertyPath);
1222 foreach ($propertyPathSegments as $pathSegment) {
1224 if ($subject instanceof \SplObjectStorage || $subject instanceof ObjectStorage) {
1225 $subject = iterator_to_array(clone $subject,
false);
1228 }
catch (\
TYPO3\CMS\
Extbase\Reflection\Exception\PropertyNotAccessibleException $error) {