[BUGFIX] Reuse entities of overridden classes in persistence session 59/58959/10
authorMarkus Klösges <mkloesges@gmx.de>
Tue, 27 Nov 2018 09:41:05 +0000 (10:41 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 19:46:43 +0000 (20:46 +0100)
When saving and retrieving object from the persistence session,
implementation class names set via \TYPO3\CMS\Extbase\Object\Container
are now respected by storing and retrieving them with that overridden
class name.

Resolves: #77617
Releases: master, 9.5
Change-Id: I887cb164328afe789dc274c92c8f8774b2098a40
Reviewed-on: https://review.typo3.org/58959
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
21 files changed:
typo3/sysext/extbase/Classes/Persistence/Generic/Session.php
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Classes/Domain/Model/A.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Classes/Domain/Repository/ARepository.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Configuration/TCA/tx_a_domain_model_a.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_emconf.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_localconf.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_tables.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_tables.sql [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Classes/Domain/Model/B.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Classes/Domain/Repository/BRepository.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Configuration/TCA/Overrides/tx_a_domain_model_a.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_emconf.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_localconf.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_tables.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_tables.sql [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_typoscript_setup.typoscript [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/tx_a_domain_model_a.csv [new file with mode: 0644]
typo3/sysext/extbase/Tests/Functional/Persistence/ImplementationClassNameTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Mapper/DataMapperTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/PersistenceManagerTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/SessionTest.php

index 421bef1..0779b31 100644 (file)
@@ -23,6 +23,11 @@ use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
 class Session implements \TYPO3\CMS\Core\SingletonInterface
 {
     /**
+     * @var \TYPO3\CMS\Extbase\Object\Container\Container
+     */
+    protected $objectContainer;
+
+    /**
      * Reconstituted objects
      *
      * @var ObjectStorage
@@ -42,8 +47,9 @@ class Session implements \TYPO3\CMS\Core\SingletonInterface
     /**
      * Constructs a new Session
      */
-    public function __construct()
+    public function __construct(\TYPO3\CMS\Extbase\Object\Container\Container $container)
     {
+        $this->objectContainer = $container;
         $this->reconstitutedEntities = new ObjectStorage();
         $this->objectMap = new ObjectStorage();
     }
@@ -128,7 +134,7 @@ class Session implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function hasIdentifier($identifier, $className)
     {
-        return isset($this->identifierMap[strtolower($className)][$identifier]);
+        return isset($this->identifierMap[$this->getClassIdentifier($className)][$identifier]);
     }
 
     /**
@@ -140,7 +146,7 @@ class Session implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getObjectByIdentifier($identifier, $className)
     {
-        return $this->identifierMap[strtolower($className)][$identifier];
+        return $this->identifierMap[$this->getClassIdentifier($className)][$identifier];
     }
 
     /**
@@ -168,7 +174,7 @@ class Session implements \TYPO3\CMS\Core\SingletonInterface
     public function registerObject($object, $identifier)
     {
         $this->objectMap[$object] = $identifier;
-        $this->identifierMap[strtolower(get_class($object))][$identifier] = $object;
+        $this->identifierMap[$this->getClassIdentifier(get_class($object))][$identifier] = $object;
     }
 
     /**
@@ -178,7 +184,7 @@ class Session implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function unregisterObject($object)
     {
-        unset($this->identifierMap[strtolower(get_class($object))][$this->objectMap[$object]]);
+        unset($this->identifierMap[$this->getClassIdentifier(get_class($object))][$this->objectMap[$object]]);
         $this->objectMap->detach($object);
     }
 
@@ -192,4 +198,16 @@ class Session implements \TYPO3\CMS\Core\SingletonInterface
         $this->objectMap = new ObjectStorage();
         $this->reconstitutedEntities = new ObjectStorage();
     }
+
+    /**
+     * Objects are stored in the cache with their implementation class name
+     * to allow reusing instances of different classes that point to the same implementation
+     *
+     * @param string $className
+     * @return string a unique class identifier respecting configured implementation class names
+     */
+    protected function getClassIdentifier($className): string
+    {
+        return strtolower($this->objectContainer->getImplementationClassName($className));
+    }
 }
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Classes/Domain/Model/A.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Classes/Domain/Model/A.php
new file mode 100644 (file)
index 0000000..84d98cc
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+declare(strict_types = 1);
+
+namespace ExtbaseTeam\A\Domain\Model;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Class ExtbaseTeam\A\Domain\Model\A
+ */
+class A extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
+{
+    /**
+     * @var string
+     */
+    protected $a;
+
+    /**
+     * @return string
+     */
+    public function getA(): string
+    {
+        return $this->a;
+    }
+
+    /**
+     * @param string $a
+     */
+    public function setA(string $a): void
+    {
+        $this->a = $a;
+    }
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Classes/Domain/Repository/ARepository.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Classes/Domain/Repository/ARepository.php
new file mode 100644 (file)
index 0000000..dcb4217
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+declare(strict_types = 1);
+
+namespace ExtbaseTeam\A\Domain\Model;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Extbase\Persistence\Repository;
+
+/**
+ * Class ExtbaseTeam\A\Domain\Model\ARepository
+ */
+class ARepository extends Repository
+{
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Configuration/TCA/tx_a_domain_model_a.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/Configuration/TCA/tx_a_domain_model_a.php
new file mode 100644 (file)
index 0000000..ff16f41
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+return [
+    'ctrl' => [
+        'label' => 'uid',
+        'title' => 'A',
+        'tstamp' => 'tstamp',
+        'crdate' => 'crdate',
+    ],
+    'interface' => [
+        'showRecordFieldList' => 'title'
+    ],
+    'columns' => [
+        'a' => [
+            'label' => 'a',
+            'config' => [
+                'type' => 'input',
+                'size' => 25,
+                'max' => 255,
+            ]
+        ],
+    ],
+    'types' => [
+        '1' => ['showitem' => '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,a']
+    ],
+];
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_emconf.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_emconf.php
new file mode 100644 (file)
index 0000000..bdd1dfe
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+$EM_CONF[$_EXTKEY] = [
+    'title' => '',
+    'description' => '',
+    'category' => 'example',
+    'author' => '',
+    'author_company' => '',
+    'author_email' => '',
+    'state' => 'stable',
+    'uploadfolder' => 0,
+    'createDirs' => '',
+    'clearCacheOnLoad' => 1,
+    'version' => '10.0.0',
+    'constraints' => [
+        'depends' => [
+            'typo3' => '10.0.0',
+        ],
+        'conflicts' => [],
+        'suggests' => [],
+    ],
+];
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_localconf.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_localconf.php
new file mode 100644 (file)
index 0000000..1d514a6
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+defined('TYPO3_MODE') or die();
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_tables.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_tables.php
new file mode 100644 (file)
index 0000000..1d514a6
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+defined('TYPO3_MODE') or die();
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_tables.sql b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a/ext_tables.sql
new file mode 100644 (file)
index 0000000..e2a2cf1
--- /dev/null
@@ -0,0 +1,14 @@
+--
+-- Table structure for table 'tx_a_domain_model_a'
+--
+CREATE TABLE tx_a_domain_model_a (
+       uid int(11) NOT NULL auto_increment,
+       pid int(11) DEFAULT '0' NOT NULL,
+       tstamp int(11) DEFAULT '0' NOT NULL,
+       crdate int(11) DEFAULT '0' NOT NULL,
+
+       a varchar(255) DEFAULT '' NOT NULL,
+
+       PRIMARY KEY (uid),
+       KEY parent (pid)
+);
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Classes/Domain/Model/B.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Classes/Domain/Model/B.php
new file mode 100644 (file)
index 0000000..131dbb8
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+declare(strict_types = 1);
+
+namespace ExtbaseTeam\B\Domain\Model;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Class ExtbaseTeam\B\Domain\Model\B
+ */
+class B extends \ExtbaseTeam\A\Domain\Model\A
+{
+    /**
+     * @var string
+     */
+    protected $b;
+
+    /**
+     * @return string
+     */
+    public function getB(): string
+    {
+        return $this->b;
+    }
+
+    /**
+     * @param string $b
+     */
+    public function setB(string $b): void
+    {
+        $this->b = $b;
+    }
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Classes/Domain/Repository/BRepository.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Classes/Domain/Repository/BRepository.php
new file mode 100644 (file)
index 0000000..0b60d2d
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+declare(strict_types = 1);
+
+namespace ExtbaseTeam\B\Domain\Model;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Extbase\Persistence\Repository;
+
+/**
+ * Class ExtbaseTeam\B\Domain\Model\BRepository
+ */
+class BRepository extends Repository
+{
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Configuration/TCA/Overrides/tx_a_domain_model_a.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/Configuration/TCA/Overrides/tx_a_domain_model_a.php
new file mode 100644 (file)
index 0000000..cbea169
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
+    'tx_a_domain_model_a',
+    [
+        'b' => [
+            'label' => 'b',
+            'config' => [
+                'type' => 'input',
+                'size' => 25,
+                'max' => 255,
+            ]
+        ],
+    ]
+);
+
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_a_domain_model_a', 'b');
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_emconf.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_emconf.php
new file mode 100644 (file)
index 0000000..bdd1dfe
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+$EM_CONF[$_EXTKEY] = [
+    'title' => '',
+    'description' => '',
+    'category' => 'example',
+    'author' => '',
+    'author_company' => '',
+    'author_email' => '',
+    'state' => 'stable',
+    'uploadfolder' => 0,
+    'createDirs' => '',
+    'clearCacheOnLoad' => 1,
+    'version' => '10.0.0',
+    'constraints' => [
+        'depends' => [
+            'typo3' => '10.0.0',
+        ],
+        'conflicts' => [],
+        'suggests' => [],
+    ],
+];
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_localconf.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_localconf.php
new file mode 100644 (file)
index 0000000..aaa0e91
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+defined('TYPO3_MODE') or die();
+
+\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
+    ->registerImplementation(
+    \ExtbaseTeam\A\Domain\Model\A::class,
+    \ExtbaseTeam\B\Domain\Model\B::class
+);
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_tables.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_tables.php
new file mode 100644 (file)
index 0000000..1d514a6
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+defined('TYPO3_MODE') or die();
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_tables.sql b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_tables.sql
new file mode 100644 (file)
index 0000000..1b10220
--- /dev/null
@@ -0,0 +1,6 @@
+--
+-- Table structure for table 'tx_a_domain_model_a'
+--
+CREATE TABLE tx_a_domain_model_a (
+       b varchar(255) DEFAULT '' NOT NULL
+);
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_typoscript_setup.typoscript b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/ext_typoscript_setup.typoscript
new file mode 100644 (file)
index 0000000..3ae18dd
--- /dev/null
@@ -0,0 +1,9 @@
+config.tx_extbase.persistence {
+  classes {
+    ExtbaseTeam\B\Domain\Model\B {
+      mapping {
+        tableName = tx_a_domain_model_a
+      }
+    }
+  }
+}
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/tx_a_domain_model_a.csv b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/tx_a_domain_model_a.csv
new file mode 100644 (file)
index 0000000..10e7e9e
--- /dev/null
@@ -0,0 +1,3 @@
+"tx_a_domain_model_a",,,,,,
+,"uid", "pid", "tstamp", "crdate", "a", "b"
+,1, 0, 1546178428, 1546178428,  "A", "B"
diff --git a/typo3/sysext/extbase/Tests/Functional/Persistence/ImplementationClassNameTest.php b/typo3/sysext/extbase/Tests/Functional/Persistence/ImplementationClassNameTest.php
new file mode 100644 (file)
index 0000000..232f452
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+declare(strict_types = 1);
+namespace TYPO3\CMS\Extbase\Tests\Functional;
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+
+/**
+ * Class TYPO3\CMS\Extbase\Tests\Functional\ImplementationClassNameTest
+ */
+class ImplementationClassNameTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
+{
+    /**
+     * @var array
+     */
+    protected $testExtensionsToLoad = [
+        'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/a',
+        'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b',
+    ];
+
+    /**
+     * @var array
+     */
+    protected $coreExtensionsToLoad = ['extbase', 'fluid'];
+
+    /**
+     * @var ObjectManager
+     */
+    private $objectManager;
+
+    public function setUp(): void
+    {
+        parent::setUp();
+
+        $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
+
+        $this->importCSVDataSet(GeneralUtility::getFileAbsFileName(
+            'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/class_overriding/b/tx_a_domain_model_a.csv'
+        ));
+    }
+
+    /**
+    * @test
+    */
+    public function testARepositoryObjectsAreTakenFromSession(): void
+    {
+        $aRepository = $this->objectManager->get(\ExtbaseTeam\A\Domain\Model\ARepository::class);
+        $a1 = $aRepository->findByUid(1);
+        $a2 = $aRepository->findByUid(1);
+
+        $this->assertSame($a1, $a2);
+    }
+
+    /**
+    * @test
+    */
+    public function testBRepositoryObjectsAreTakenFromSession(): void
+    {
+        $bRepository = $this->objectManager->get(\ExtbaseTeam\B\Domain\Model\BRepository::class);
+        $b1 = $bRepository->findByUid(1);
+        $b2 = $bRepository->findByUid(1);
+
+        $this->assertSame($b1, $b2);
+    }
+}
index 6464742..1079952 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper;
  */
 
 use TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface;
+use TYPO3\CMS\Extbase\Object\Container\Container;
 use TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnexpectedTypeException;
 use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap;
 use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper;
@@ -248,7 +249,7 @@ class DataMapperTest extends UnitTestCase
         $classSchema1 = new ClassSchema(Fixture\DummyParentEntity::class);
         $identifier = 1;
 
-        $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
+        $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session(new Container());
         $session->registerObject($child, $identifier);
 
         $mockReflectionService = $this->getMockBuilder(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class)
index 3aa26b2..7954678 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic;
  */
 
 use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
+use TYPO3\CMS\Extbase\Object\Container\Container;
 use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
 use TYPO3\CMS\Extbase\Persistence\Generic\Backend;
 use TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface;
@@ -288,7 +289,7 @@ class PersistenceManagerTest extends UnitTestCase
             PersistenceManager::class,
             ['dummy']
         );
-        $session = new Session();
+        $session = new Session(new Container());
         $changedEntities = new ObjectStorage();
         $entity1 = new $classNameWithNamespace();
         /** @var RepositoryInterface|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $repository */
index e9d2afe..1fa5881 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic;
  */
 
 use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
+use TYPO3\CMS\Extbase\Object\Container\Container;
 use TYPO3\CMS\Extbase\Persistence\Generic\Session;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -27,7 +28,7 @@ class SessionTest extends UnitTestCase
     public function objectRegisteredWithRegisterReconstitutedEntityCanBeRetrievedWithGetReconstitutedEntities()
     {
         $someObject = new \ArrayObject([]);
-        $session = new Session();
+        $session = new Session(new Container());
         $session->registerReconstitutedEntity($someObject);
 
         $ReconstitutedEntities = $session->getReconstitutedEntities();
@@ -40,7 +41,7 @@ class SessionTest extends UnitTestCase
     public function unregisterReconstitutedEntityRemovesObjectFromSession()
     {
         $someObject = new \ArrayObject([]);
-        $session = new Session();
+        $session = new Session(new Container());
         $session->registerObject($someObject, 'fakeUuid');
         $session->registerReconstitutedEntity($someObject);
         $session->unregisterReconstitutedEntity($someObject);
@@ -56,7 +57,7 @@ class SessionTest extends UnitTestCase
     {
         $object1 = new \stdClass();
         $object2 = new \stdClass();
-        $session = new Session();
+        $session = new Session(new Container());
         $session->registerObject($object1, 12345);
 
         $this->assertTrue($session->hasObject($object1), 'Session claims it does not have registered object.');
@@ -68,7 +69,7 @@ class SessionTest extends UnitTestCase
      */
     public function hasIdentifierReturnsTrueForRegisteredObject()
     {
-        $session = new Session();
+        $session = new Session(new Container());
         $session->registerObject(new \stdClass(), 12345);
 
         $this->assertTrue($session->hasIdentifier('12345', 'stdClass'), 'Session claims it does not have registered object.');
@@ -81,7 +82,7 @@ class SessionTest extends UnitTestCase
     public function getIdentifierByObjectReturnsRegisteredUUIDForObject()
     {
         $object = new \stdClass();
-        $session = new Session();
+        $session = new Session(new Container());
         $session->registerObject($object, 12345);
 
         $this->assertEquals($session->getIdentifierByObject($object), 12345, 'Did not get UUID registered for object.');
@@ -93,7 +94,7 @@ class SessionTest extends UnitTestCase
     public function getObjectByIdentifierReturnsRegisteredObjectForUUID()
     {
         $object = new \stdClass();
-        $session = new Session();
+        $session = new Session(new Container());
         $session->registerObject($object, 12345);
 
         $this->assertSame($session->getObjectByIdentifier('12345', 'stdClass'), $object, 'Did not get object registered for UUID.');
@@ -106,7 +107,7 @@ class SessionTest extends UnitTestCase
     {
         $object1 = new \stdClass();
         $object2 = new \stdClass();
-        $session = new Session();
+        $session = new Session(new Container());
         $session->registerObject($object1, 12345);
         $session->registerObject($object2, 67890);
 
@@ -128,7 +129,7 @@ class SessionTest extends UnitTestCase
      */
     public function newSessionIsEmpty()
     {
-        $persistenceSession = new Session();
+        $persistenceSession = new Session(new Container());
         $reconstitutedObjects = $persistenceSession->getReconstitutedEntities();
         $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
     }
@@ -138,7 +139,7 @@ class SessionTest extends UnitTestCase
      */
     public function objectCanBeRegisteredAsReconstituted()
     {
-        $persistenceSession = new Session();
+        $persistenceSession = new Session(new Container());
         $entity = $this->createMock(AbstractEntity::class);
         $persistenceSession->registerReconstitutedEntity($entity);
         $reconstitutedObjects = $persistenceSession->getReconstitutedEntities();
@@ -150,7 +151,7 @@ class SessionTest extends UnitTestCase
      */
     public function objectCanBeUnregisteredAsReconstituted()
     {
-        $persistenceSession = new Session();
+        $persistenceSession = new Session(new Container());
         $entity = $this->createMock(AbstractEntity::class);
         $persistenceSession->registerReconstitutedEntity($entity);
         $persistenceSession->unregisterReconstitutedEntity($entity);