27 $fixture = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', array(
'dummy'), array(),
'', FALSE);
29 $dataMapper = $this->getMock(
'TYPO3\\CMS\Extbase\\Persistence\\Generic\\Mapper\\DataMapper');
31 $dataMap = $this->getMock(
'TYPO3\\CMS\Extbase\\Persistence\\Generic\\Mapper\\DataMap', array(), array(),
'', FALSE);
33 $columnMap = $this->getMock(
'TYPO3\\CMS\Extbase\\Persistence\\Generic\\Mapper\\ColumnMap', array(), array(),
'', FALSE);
35 $storageBackend = $this->getMock(
'TYPO3\\CMS\Extbase\\Persistence\\Generic\\Storage\\BackendInterface');
37 $domainObject = $this->getMock(
'TYPO3\\CMS\Extbase\\DomainObject\\DomainObjectInterface');
39 $mmMatchFields = array(
40 'identifier' =>
'myTable:myField',
44 'identifier' =>
'myTable:myField',
49 ->expects($this->once())
50 ->method(
'getRelationTableMatchFields')
51 ->will($this->returnValue($mmMatchFields));
53 ->expects($this->any())
54 ->method(
'getChildSortByFieldName')
55 ->will($this->returnValue(
''));
57 ->expects($this->any())
58 ->method(
'getColumnMap')
59 ->will($this->returnValue($columnMap));
61 ->expects($this->any())
62 ->method(
'getDataMap')
63 ->will($this->returnValue($dataMap));
65 ->expects($this->once())
67 ->with(NULL, $expectedRow, TRUE);
69 $fixture->_set(
'dataMapper', $dataMapper);
70 $fixture->_set(
'storageBackend', $storageBackend);
71 $fixture->_call(
'insertRelationInRelationtable', $domainObject, $domainObject,
'');
78 $fixture = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', array(
'dummy'), array(),
'', FALSE);
79 $columnMap = new \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap(
'column_name',
'propertyName');
80 $columnMap->setDateTimeStorageFormat(
'datetime');
81 $datetimeAsString =
'2013-04-15 09:30:00';
82 $input = new \DateTime($datetimeAsString);
83 $this->assertEquals(
'2013-04-15 09:30:00', $fixture->_call(
'getPlainValue', $input, $columnMap));
84 $columnMap->setDateTimeStorageFormat(
'date');
85 $this->assertEquals(
'2013-04-15', $fixture->_call(
'getPlainValue', $input, $columnMap));
91 public function getIdentifierByObjectReturnsIdentifierForNonlazyObject() {
92 $fakeUuid =
'fakeUuid';
93 $configurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
94 $session = $this->getMock(
'stdClass', array(
'getIdentifierByObject'), array(),
'', FALSE);
95 $object = new \stdClass();
97 $session->expects($this->once())->method(
'getIdentifierByObject')->with($object)->will($this->returnValue($fakeUuid));
100 $backend = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', array(
'dummy'), array($configurationManager));
101 $backend->_set(
'session', $session);
103 $this->assertEquals(
$backend->getIdentifierByObject($object), $fakeUuid);
109 public function getIdentifierByObjectReturnsIdentifierForLazyObject() {
110 $fakeUuid =
'fakeUuid';
111 $configurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
112 $parentObject = new \stdClass();
113 $proxy = $this->getMock(
'TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy', array(
'_loadRealInstance'), array($parentObject,
'y',
'z'),
'', FALSE);
114 $session = $this->getMock(
'stdClass', array(
'getIdentifierByObject'), array(),
'', FALSE);
115 $object = new \stdClass();
117 $proxy->expects($this->once())->method(
'_loadRealInstance')->will($this->returnValue($object));
118 $session->expects($this->once())->method(
'getIdentifierByObject')->with($object)->will($this->returnValue($fakeUuid));
121 $backend = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', array(
'dummy'), array($configurationManager));
122 $backend->_set(
'session', $session);
124 $this->assertEquals(
$backend->getIdentifierByObject($proxy), $fakeUuid);
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
insertRelationInRelationtableSetsMmMatchFieldsInRow()
getPlainValueReturnsCorrectDateTimeFormat()