/** * @test * @return void */ public function generateUuidGeneratesUuidAndRegistersProxyAsNewObject() { $className = 'Class' . md5(uniqid(mt_rand(), TRUE)); eval('class ' . $className . ' implements \\TYPO3\\Flow\\Persistence\\Aspect\\PersistenceMagicInterface { public $Persistence_Object_Identifier = NULL; }'); $object = new $className(); $this->mockJoinPoint->expects($this->atLeastOnce())->method('getProxy')->will($this->returnValue($object)); $this->mockPersistenceManager->expects($this->atLeastOnce())->method('registerNewObject')->with($object); $this->persistenceMagicAspect->generateUuid($this->mockJoinPoint); $this->assertEquals(36, strlen($object->Persistence_Object_Identifier)); }
/** * @test * @todo adjust when AfterInvocationInterceptor is used again */ public function enforcePolicyDoesNotInvokeInterceptorIfAuthorizationChecksAreDisabled() { $this->mockAdviceChain->expects($this->once())->method('proceed')->with($this->mockJoinPoint); $this->mockJoinPoint->expects($this->once())->method('getAdviceChain')->will($this->returnValue($this->mockAdviceChain)); $this->mockSecurityContext->expects($this->atLeastOnce())->method('areAuthorizationChecksDisabled')->will($this->returnValue(true)); $this->mockPolicyEnforcementInterceptor->expects($this->never())->method('invoke'); $this->policyEnforcementAspect->enforcePolicy($this->mockJoinPoint); }
/** * @test */ public function generateValueHashUsesTimestampOfDateTime() { $date = new \DateTime(); $methodArguments = array('foo' => new \DateTime()); $className = 'Class' . md5(uniqid(mt_rand(), TRUE)); eval('class ' . $className . ' { }'); $object = new $className(); $this->mockJoinPoint->expects($this->atLeastOnce())->method('getProxy')->will($this->returnValue($object)); $this->mockJoinPoint->expects($this->atLeastOnce())->method('getMethodArguments')->will($this->returnValue($methodArguments)); $this->persistenceMagicAspect->generateValueHash($this->mockJoinPoint); $this->assertEquals(sha1($className . $date->getTimestamp()), $object->Persistence_Object_Identifier); }