示例#1
0
 /**
  * @test
  */
 public function objectCanBeUnregisteredAsReconstituted()
 {
     $persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
     $entity = $this->getMock('TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity');
     $persistenceSession->registerReconstitutedEntity($entity);
     $persistenceSession->unregisterReconstitutedEntity($entity);
     $reconstitutedObjects = $persistenceSession->getReconstitutedEntities();
     $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
 }
示例#2
0
 /**
  * Test if mapObjectToClassProperty method returns objects
  * that are already registered in the persistence session
  * without query it from the persistence layer
  *
  * @test
  */
 public function mapObjectToClassPropertyReturnsExistingObjectWithoutCallingFetchRelated()
 {
     $columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap('columnName', 'propertyName');
     $columnMap->setTypeOfRelation(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap::RELATION_HAS_ONE);
     $dataMap = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMap', array('getColumnMap'), array(), '', FALSE);
     $className = $this->getUniqueId('Class1');
     $classNameWithNS = __NAMESPACE__ . '\\' . $className;
     eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity { public $relationProperty; }');
     $object = new $classNameWithNS();
     $classSchema1 = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array($classNameWithNS));
     $classSchema1->_set('typeHandlingService', new \TYPO3\CMS\Extbase\Service\TypeHandlingService());
     $className2 = $this->getUniqueId('Class2');
     $className2WithNS = __NAMESPACE__ . '\\' . $className2;
     eval('namespace ' . __NAMESPACE__ . '; class ' . $className2 . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity { }');
     $child = new $className2WithNS();
     $classSchema2 = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array($className2WithNS));
     $classSchema2->_set('typeHandlingService', new \TYPO3\CMS\Extbase\Service\TypeHandlingService());
     $classSchema1->addProperty('relationProperty', $className2WithNS);
     $identifier = 1;
     $session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
     $session->registerObject($child, $identifier);
     $mockReflectionService = $this->getMock('\\TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array('getClassSchema'), array(), '', FALSE);
     $mockReflectionService->expects($this->any())->method('getClassSchema')->will($this->returnValue($classSchema1));
     $dataMap->expects($this->any())->method('getColumnMap')->will($this->returnValue($columnMap));
     $dataMapper = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapper', array('getDataMap', 'getNonEmptyRelationValue'));
     $dataMapper->_set('reflectionService', $mockReflectionService);
     $dataMapper->_set('persistenceSession', $session);
     $dataMapper->expects($this->any())->method('getDataMap')->will($this->returnValue($dataMap));
     $dataMapper->expects($this->never())->method('getNonEmptyRelationValue');
     $result = $dataMapper->_call('mapObjectToClassProperty', $object, 'relationProperty', $identifier);
     $this->assertEquals($child, $result);
 }