2 declare(strict_types = 1);
27 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
40 $fixture = $this->getAccessibleMock(Backend::class, [
'dummy'], [],
'',
false);
42 $dataMapFactory = $this->createMock(DataMapFactory::class);
44 $dataMap = $this->createMock(DataMap::class);
46 $columnMap = $this->createMock(ColumnMap::class);
48 $storageBackend = $this->createMock(BackendInterface::class);
50 $domainObject = $this->createMock(DomainObjectInterface::class);
53 'identifier' =>
'myTable:myField',
57 'identifier' =>
'myTable:myField',
62 ->expects($this->once())
63 ->method(
'getRelationTableMatchFields')
64 ->will($this->returnValue($mmMatchFields));
66 ->expects($this->any())
67 ->method(
'getChildSortByFieldName')
68 ->will($this->returnValue(
''));
70 ->expects($this->any())
71 ->method(
'getColumnMap')
72 ->will($this->returnValue($columnMap));
74 ->expects($this->any())
75 ->method(
'buildDataMap')
76 ->will($this->returnValue($dataMap));
78 ->expects($this->once())
80 ->with(
null, $expectedRow,
true);
82 $fixture->_set(
'dataMapFactory', $dataMapFactory);
83 $fixture->_set(
'storageBackend', $storageBackend);
84 $fixture->_call(
'insertRelationInRelationtable', $domainObject, $domainObject,
'');
92 $fakeUuid =
'fakeUuid';
93 $configurationManager = $this->createMock(ConfigurationManagerInterface::class);
94 $session = $this->getMockBuilder(
'stdClass')
95 ->setMethods([
'getIdentifierByObject'])
96 ->disableOriginalConstructor()
98 $object = new \stdClass();
100 $referenceIndexProphecy = $this->prophesize(ReferenceIndex::class);
101 GeneralUtility::addInstance(ReferenceIndex::class, $referenceIndexProphecy->reveal());
103 $session->expects($this->once())->method(
'getIdentifierByObject')->with($object)->will($this->returnValue($fakeUuid));
106 $backend = $this->getAccessibleMock(Backend::class, [
'dummy'], [$configurationManager]);
107 $backend->_set(
'session', $session);
109 $this->assertEquals($backend->getIdentifierByObject($object), $fakeUuid);
117 $fakeUuid =
'fakeUuid';
118 $configurationManager = $this->createMock(ConfigurationManagerInterface::class);
119 $parentObject = new \stdClass();
120 $proxy = $this->getMockBuilder(LazyLoadingProxy::class)
121 ->setMethods([
'_loadRealInstance'])
122 ->disableOriginalConstructor()
123 ->disableProxyingToOriginalMethods()
125 $session = $this->getMockBuilder(
'stdClass')
126 ->setMethods([
'getIdentifierByObject'])
127 ->disableOriginalConstructor()
129 $object = new \stdClass();
131 $referenceIndexProphecy = $this->prophesize(ReferenceIndex::class);
132 GeneralUtility::addInstance(ReferenceIndex::class, $referenceIndexProphecy->reveal());
134 $proxy->expects($this->once())->method(
'_loadRealInstance')->will($this->returnValue($object));
135 $session->expects($this->once())->method(
'getIdentifierByObject')->with($object)->will($this->returnValue($fakeUuid));
138 $backend = $this->getAccessibleMock(Backend::class, [
'dummy'], [$configurationManager]);
139 $backend->_set(
'session', $session);
141 $this->assertEquals($backend->getIdentifierByObject($proxy), $fakeUuid);