TYPO3 CMS  TYPO3_6-2
ClassSchemaTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNamespacedClasses() {
26  $className = $this->getUniqueId('BazFixture');
27  eval ('
28  namespace Foo\\Bar\\Domain\\Model;
29  class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
30  ');
31  eval ('
32  namespace Foo\\Bar\\Domain\\Repository;
33  class ' . $className . 'Repository {}
34  ');
35 
37  $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
38  $mockClassSchema = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array('Foo\\Bar\\Domain\\Model\\' . $className));
39  $mockClassSchema->_set('typeHandlingService', $this->getMock('TYPO3\\CMS\\Extbase\\Service\\TypeHandlingService'));
40  $objectManager->expects($this->once())->method('get')->will($this->returnValue($mockClassSchema));
41 
43  $service = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService', array('dummy'));
44  $service->_set('objectManager', $objectManager);
45  $classSchema = $service->getClassSchema('Foo\\Bar\\Domain\\Model\\' . $className);
46  $this->assertTrue($classSchema->isAggregateRoot());
47  }
48 
52  public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNotNamespacedClasses() {
53  $className = $this->getUniqueId('BazFixture');
54  eval ('
55  class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
56  ');
57  eval ('
58  class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
59  ');
60 
62  $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
63  $mockClassSchema = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Reflection\\ClassSchema', array('dummy'), array('Foo_Bar_Domain_Model_' . $className));
64  $mockClassSchema->_set('typeHandlingService', $this->getMock('TYPO3\\CMS\\Extbase\\Service\\TypeHandlingService'));
65  $objectManager->expects($this->once())->method('get')->will($this->returnValue($mockClassSchema));
66 
67  $service = $this->getAccessibleMock('TYPO3\CMS\Extbase\Reflection\ReflectionService', array('dummy'));
68  $service->_set('objectManager', $objectManager);
69  $classSchema = $service->getClassSchema('Foo_Bar_Domain_Model_' . $className);
70  $this->assertTrue($classSchema->isAggregateRoot());
71  }
72 
73 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)