Skip to content

Commit

Permalink
[TASK] Make SessionTest notice free
Browse files Browse the repository at this point in the history
Resolves: #84430
Releases: master
Change-Id: Ib1eec062d20483f8f9f7afa49fa938beed4d5943
Reviewed-on: https://review.typo3.org/56300
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
lsascha authored and lolli42 committed Mar 17, 2018
1 parent 06a538a commit aad48b0
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions typo3/sysext/extbase/Tests/Unit/Persistence/Generic/SessionTest.php
@@ -1,4 +1,5 @@
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic;

/*
Expand All @@ -13,20 +14,20 @@
*
* The TYPO3 project - inspiring people to share!
*/
class SessionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
{
/**
* Subject is not notice free, disable E_NOTICES
*/
protected static $suppressNotices = true;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\Generic\Session;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class SessionTest extends UnitTestCase
{
/**
* @test
*/
public function objectRegisteredWithRegisterReconstitutedEntityCanBeRetrievedWithGetReconstitutedEntities()
{
$someObject = new \ArrayObject([]);
$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$session = new Session();
$session->registerReconstitutedEntity($someObject, ['identifier' => 'fakeUuid']);

$ReconstitutedEntities = $session->getReconstitutedEntities();
Expand All @@ -39,7 +40,7 @@ public function objectRegisteredWithRegisterReconstitutedEntityCanBeRetrievedWit
public function unregisterReconstitutedEntityRemovesObjectFromSession()
{
$someObject = new \ArrayObject([]);
$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$session = new Session();
$session->registerObject($someObject, 'fakeUuid');
$session->registerReconstitutedEntity($someObject, ['identifier' => 'fakeUuid']);
$session->unregisterReconstitutedEntity($someObject);
Expand All @@ -55,7 +56,7 @@ public function hasObjectReturnsTrueForRegisteredObject()
{
$object1 = new \stdClass();
$object2 = new \stdClass();
$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$session = new Session();
$session->registerObject($object1, 12345);

$this->assertTrue($session->hasObject($object1), 'Session claims it does not have registered object.');
Expand All @@ -67,7 +68,7 @@ public function hasObjectReturnsTrueForRegisteredObject()
*/
public function hasIdentifierReturnsTrueForRegisteredObject()
{
$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$session = new Session();
$session->registerObject(new \stdClass(), 12345);

$this->assertTrue($session->hasIdentifier('12345', 'stdClass'), 'Session claims it does not have registered object.');
Expand All @@ -80,7 +81,7 @@ public function hasIdentifierReturnsTrueForRegisteredObject()
public function getIdentifierByObjectReturnsRegisteredUUIDForObject()
{
$object = new \stdClass();
$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$session = new Session();
$session->registerObject($object, 12345);

$this->assertEquals($session->getIdentifierByObject($object), 12345, 'Did not get UUID registered for object.');
Expand All @@ -92,7 +93,7 @@ public function getIdentifierByObjectReturnsRegisteredUUIDForObject()
public function getObjectByIdentifierReturnsRegisteredObjectForUUID()
{
$object = new \stdClass();
$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$session = new Session();
$session->registerObject($object, 12345);

$this->assertSame($session->getObjectByIdentifier('12345', 'stdClass'), $object, 'Did not get object registered for UUID.');
Expand All @@ -105,7 +106,7 @@ public function unregisterObjectRemovesRegisteredObject()
{
$object1 = new \stdClass();
$object2 = new \stdClass();
$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$session = new Session();
$session->registerObject($object1, 12345);
$session->registerObject($object2, 67890);

Expand All @@ -127,7 +128,7 @@ public function unregisterObjectRemovesRegisteredObject()
*/
public function newSessionIsEmpty()
{
$persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$persistenceSession = new Session();
$reconstitutedObjects = $persistenceSession->getReconstitutedEntities();
$this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
}
Expand All @@ -137,9 +138,9 @@ public function newSessionIsEmpty()
*/
public function objectCanBeRegisteredAsReconstituted()
{
$persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$entity = $this->createMock(\TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class);
$persistenceSession->registerReconstitutedEntity($entity);
$persistenceSession = new Session();
$entity = $this->createMock(AbstractEntity::class);
$persistenceSession->registerReconstitutedEntity($entity, ['identifier' => 'fakeUuid']);
$reconstitutedObjects = $persistenceSession->getReconstitutedEntities();
$this->assertTrue($reconstitutedObjects->contains($entity), 'The object was not registered as reconstituted.');
}
Expand All @@ -149,9 +150,9 @@ public function objectCanBeRegisteredAsReconstituted()
*/
public function objectCanBeUnregisteredAsReconstituted()
{
$persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
$entity = $this->createMock(\TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class);
$persistenceSession->registerReconstitutedEntity($entity);
$persistenceSession = new Session();
$entity = $this->createMock(AbstractEntity::class);
$persistenceSession->registerReconstitutedEntity($entity, ['identifier' => 'fakeUuid']);
$persistenceSession->unregisterReconstitutedEntity($entity);
$reconstitutedObjects = $persistenceSession->getReconstitutedEntities();
$this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
Expand Down

0 comments on commit aad48b0

Please sign in to comment.