[BUGFIX] Reuse entities of overridden classes in persistence session
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Functional / Persistence / ImplementationClassNameTest.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Extbase\Tests\Functional;
4
5 use TYPO3\CMS\Core\Utility\GeneralUtility;
6 use TYPO3\CMS\Extbase\Object\ObjectManager;
7
8 /**
9 * Class TYPO3\CMS\Extbase\Tests\Functional\ImplementationClassNameTest
10 */
11 class ImplementationClassNameTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
12 {
13 /**
14 * @var array
15 */
16 protected $testExtensionsToLoad = [
17 'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a',
18 'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b',
19 ];
20
21 /**
22 * @var array
23 */
24 protected $coreExtensionsToLoad = ['extbase', 'fluid'];
25
26 /**
27 * @var ObjectManager
28 */
29 private $objectManager;
30
31 public function setUp(): void
32 {
33 parent::setUp();
34
35 $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
36
37 $this->importCSVDataSet(GeneralUtility::getFileAbsFileName(
38 'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/tx_a_domain_model_a.csv'
39 ));
40 }
41
42 /**
43 * @test
44 */
45 public function testARepositoryObjectsAreTakenFromSession(): void
46 {
47 $aRepository = $this->objectManager->get(\ExtbaseTeam\A\Domain\Model\ARepository::class);
48 $a1 = $aRepository->findByUid(1);
49 $a2 = $aRepository->findByUid(1);
50
51 $this->assertSame($a1, $a2);
52 }
53
54 /**
55 * @test
56 */
57 public function testBRepositoryObjectsAreTakenFromSession(): void
58 {
59 $bRepository = $this->objectManager->get(\ExtbaseTeam\B\Domain\Model\BRepository::class);
60 $b1 = $bRepository->findByUid(1);
61 $b2 = $bRepository->findByUid(1);
62
63 $this->assertSame($b1, $b2);
64 }
65 }