/** * Sets up this test case * */ public function setUp() { $this->mockObjectManager = $this->getMock('TYPO3\\FLOW3\\Object\\ObjectManagerInterface'); $this->mockObjectManager->expects($this->any())->method('create')->will($this->returnCallback(array($this, 'objectManagerCallBack'))); $this->route = $this->getAccessibleMock('TYPO3\\FLOW3\\Mvc\\Routing\\Route', array('dummy')); $this->route->_set('objectManager', $this->mockObjectManager); $this->mockRouter = $this->getMock('TYPO3\\FLOW3\\Mvc\\Routing\\RouterInterface'); $this->mockRouter->expects($this->any())->method('getControllerObjectName')->will($this->returnValue('SomeControllerObjectName')); $this->route->injectRouter($this->mockRouter); $this->mockPersistenceManager = $this->getMock('TYPO3\\FLOW3\\Persistence\\PersistenceManagerInterface'); $this->mockPersistenceManager->expects($this->any())->method('convertObjectsToIdentityArrays')->will($this->returnCallback(function ($array) { return $array; })); $this->route->injectPersistenceManager($this->mockPersistenceManager); }
/** * @test */ public function createPathSegmentForObjectReturnsTheCleanedUpObjectIdentifierIfUriPatternIsEmpty() { $identityRoutePart = $this->getAccessibleMock('TYPO3\\FLOW3\\Mvc\\Routing\\IdentityRoutePart', array('dummy')); $identityRoutePart->_set('persistenceManager', $this->mockPersistenceManager); $identityRoutePart->setUriPattern(''); $object = new \stdClass(); $this->mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($object)->will($this->returnValue('Objäct--Identifüer/---')); $actualResult = $identityRoutePart->_call('createPathSegmentForObject', $object); $this->assertSame('Objaect-Identifueer', $actualResult); }
/** * @test */ public function cacheResolveCallSkipsCacheIfRouteValuesContainObjectsThatCantBeConvertedToHashes() { $mockObject = new \stdClass(); $routeValues = array('b' => 'route values', 'someObject' => $mockObject); $this->mockJoinPoint->expects($this->once())->method('getMethodArgument')->with('routeValues')->will($this->returnValue($routeValues)); $this->mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($mockObject)->will($this->returnValue(NULL)); $matchingUri = 'uncached/matching/uri'; $this->mockAdviceChain->expects($this->once())->method('proceed')->with($this->mockJoinPoint)->will($this->returnValue($matchingUri)); $this->mockResolveCache->expects($this->never())->method('has'); $this->mockResolveCache->expects($this->never())->method('set'); $this->routerCachingAspect->cacheResolveCall($this->mockJoinPoint); }
/** * @test */ public function convertFromReturnsNullIfSpecifiedResourcePointerCantBeFound() { $source = array('error' => \UPLOAD_ERR_NO_FILE, 'submittedFile' => array('filename' => 'SomeFilename', 'resourcePointer' => 'someNonExistingResourcePointer')); $this->mockPersistenceManager->expects($this->once())->method('getObjectByIdentifier')->with('someNonExistingResourcePointer', 'TYPO3\\FLOW3\\Resource\\ResourcePointer')->will($this->returnValue(NULL)); $this->assertNull($this->resourceTypeConverter->convertFrom($source, 'TYPO3\\FLOW3\\Resource\\Resource')); }
/** * @test */ public function resolveValueReturnsFalseIfTheValueToBeResolvedIsAnObjectWithAnIdentifierThatIsNoString() { $object = new \stdClass(); $this->mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($object)->will($this->returnValue(array('foo', 'bar'))); $this->assertFalse($this->dynamicRoutPart->_call('resolveValue', $object)); }